Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
 public TunnelRequest(Stream s) : base(s)
 {
     _cch   = new CommonConnectionHeader(s);
     _frame = new CemiFrame(s);
 }
Esempio n. 3
0
 public TunnelRequest(CemiFrame frame, byte sequence) : base(EIBMessages.EIB_MC_TUNNEL_REQUEST)
 {
     _frame        = frame;
     _cch          = new CommonConnectionHeader(sequence);
     total_length += (ushort)(_cch.length + _frame.Length);
 }
Esempio n. 4
0
 public RoutingIndication(CemiFrame frame)
     : base(EIBMessages.EIB_MC_ROUTING_INDICATION)
 {
     _frame        = frame;
     total_length += (ushort)_frame.Length;
 }
Esempio n. 5
0
 public RoutingIndication(Stream s)
     : base(s)
 {
     _frame = new CemiFrame(s);
 }
Esempio n. 6
0
        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);
            }
        }
Esempio n. 7
0
 public RoutingIndication(CemiFrame frame)
     : base(EIBMessages.EIB_MC_ROUTING_INDICATION)
 {
     _frame = frame;
     total_length += (ushort)_frame.Length;
 }
Esempio n. 8
0
 public RoutingIndication(Stream s)
     : base(s)
 {
     _frame = new CemiFrame(s);
 }
Esempio n. 9
0
 public TunnelRequest(Stream s)
     : base(s)
 {
     _cch = new CommonConnectionHeader(s);
     _frame = new CemiFrame(s);
 }
Esempio n. 10
0
 public TunnelRequest(CemiFrame frame, byte sequence)
     : base(EIBMessages.EIB_MC_TUNNEL_REQUEST)
 {
     _frame = frame;
     _cch = new CommonConnectionHeader(sequence);
     total_length += (ushort)(_cch.length + _frame.Length);
 }