private void btnSendPkt_Click(object sender, EventArgs e) { if (_remote_data_endpoint == null) { MessageBox.Show("No EIB Client is connected. cannot sent packets.", "Error", MessageBoxButtons.OK); return; } if (this.tbValue.Text == null || this.tbValue.Text.Length == 0) { MessageBox.Show("No value was provided. you must enter the cEMI frame value to send", "Error", MessageBoxButtons.OK); return; } if (!hex_regex.IsMatch(this.tbValue.Text)) { MessageBox.Show("The cEMI frame value is not valid HEX format.", "Error", MessageBoxButtons.OK); return; } for (int i = 0; i < this.nudNumPkts.Value; ++i) { EIBAddress dst_addr; EIBAddress src_addr = new EIBAddress(this.tbSrcAddress.Text); if (this.checkBox1.Checked) { dst_addr = EIBAddress.GetRandomAddress(); } else { dst_addr = new EIBAddress(this.tbDestAddress.Text); } CemiFrame frame = new CemiFrame(src_addr, dst_addr, StringToByteArray(this.tbValue.Text), cbNeedAck.Checked); byte[] data = null; switch (_mode) { case DEVICE_MODE.MODE_TUNNELING: TunnelRequest req = new TunnelRequest(frame, _send_sequence); data = req.ToByteArray(); break; case DEVICE_MODE.MODE_ROUTING: RoutingIndication roi = new RoutingIndication(frame); data = roi.ToByteArray(); break; } _sock.SendTo(data, _remote_data_endpoint); LogSend(String.Format("Data packet. Dest addr: {0} Value 0x{1}", dst_addr.ToString(), this.tbValue.Text)); System.Threading.Thread.Sleep(10); } }
private void btnSendPkt_Click(object sender, EventArgs e) { if (_remote_data_endpoint == null) { MessageBox.Show("No EIB Client is connected. cannot sent packets.", "Error", MessageBoxButtons.OK); return; } if (this.tbValue.Text == null || this.tbValue.Text.Length == 0) { MessageBox.Show("No value was provided. you must enter the cEMI frame value to send", "Error", MessageBoxButtons.OK); return; } if (!hex_regex.IsMatch(this.tbValue.Text)) { MessageBox.Show("The cEMI frame value is not valid HEX format.", "Error", MessageBoxButtons.OK); return; } for (int i = 0; i < this.nudNumPkts.Value; ++i) { EIBAddress dst_addr; EIBAddress src_addr = new EIBAddress(this.tbSrcAddress.Text); if (this.checkBox1.Checked) dst_addr = EIBAddress.GetRandomAddress(); else dst_addr = new EIBAddress(this.tbDestAddress.Text); CemiFrame frame = new CemiFrame(src_addr, dst_addr, StringToByteArray(this.tbValue.Text), cbNeedAck.Checked); byte[] data = null; switch (_mode) { case DEVICE_MODE.MODE_TUNNELING: TunnelRequest req = new TunnelRequest(frame, _send_sequence); data = req.ToByteArray(); break; case DEVICE_MODE.MODE_ROUTING: RoutingIndication roi = new RoutingIndication(frame); data = roi.ToByteArray(); break; } _sock.SendTo(data, _remote_data_endpoint); LogSend(String.Format("Data packet. Dest addr: {0} Value 0x{1}", dst_addr.ToString(), this.tbValue.Text)); System.Threading.Thread.Sleep(10); } }