Example #1
0
        private void Init()
        {
            var cl  = Packet.GetPacketClass(packet.Project, packet.Class);
            var cmd = Packet.GetPacketCommand(packet.Project, packet.Class, packet.Command);

            lblProject.Text = string.Format("Project: {0}", packet.Project);
            lblClass.Text   = string.Format("Class: {0}", cl);
            lblCommand.Text = string.Format("Command: {0} ({1})", cmd, packet.Command);
            lblLen.Text     = string.Format("Length: {0}", packet.Data.Length);

            var ms   = new MemoryStream(packet.Data);
            var prov = new Be.Windows.Forms.DynamicFileByteProvider(ms);

            hxData.ByteProvider = prov;
        }
Example #2
0
        private void AddFrameToList(Frame f)
        {
            var a = new Action(() =>
            {
                var i = new ListViewItem(f.Time.ToString("0.###"));
                i.SubItems.Add(f.Direction.ToString());
                i.SubItems.Add(f.Type.ToString());

                if (f.Type == FrameType.ACK)
                {
                    i.ForeColor = Color.Purple;
                }
                else if (f.Direction == Frame.FrameDirection.ToDrone)
                {
                    i.ForeColor = Color.Blue;
                }
                else if (f.Direction == Frame.FrameDirection.ToController)
                {
                    i.ForeColor = Color.Black;
                }

                if (f.Id == 0)
                {
                    i.SubItems.Add("PING");
                    i.ForeColor = Color.Orange;
                }
                else if (f.Id == 1)
                {
                    i.SubItems.Add("PONG");
                    i.ForeColor = Color.DarkGreen;
                }
                else
                {
                    i.SubItems.Add(f.Id.ToString());
                }

                i.SubItems.Add(f.Seq.ToString());
                i.SubItems.Add(f.Data.Length.ToString());
                if (f.Id >= 2 && (f.Type == FrameType.DATA_W_ACK ||
                                  f.Type == FrameType.DATA_LL ||
                                  f.Type == FrameType.DATA))
                {
                    var proj = (PacketType)f.Data[0];
                    var c    = Packet.GetPacketClass(proj, f.Data[1]);

                    ushort command = 0;
                    command        = f.Data[2];
                    command       |= (ushort)(f.Data[3] << 8);

                    var cmd = Packet.GetPacketCommand(proj, f.Data[1], command);
                    i.SubItems.Add(proj.ToString());
                    i.SubItems.Add(c);
                    i.SubItems.Add(cmd);
                }
                i.Tag = f;
                lstPackets.Items.Add(i);
            });

            if (lstPackets.InvokeRequired)
            {
                lstPackets.Invoke(a);
            }
            else
            {
                a();
            }
        }