예제 #1
0
        private void Menu_CopyBytes(object sender, Avalonia.Interactivity.RoutedEventArgs e)
        {
            if (seletedItem == null)
            {
                return;
            }
            var fullData = seletedItem.Packet.Data;

            var fullText = new StringBuilder();

            foreach (var p in PvPacket.Split(fullData))
            {
                if (fullText.Length != 0)
                {
                    fullText.Append("\n\n");
                }

                var data = p.Data;

                fullText.Append("var data=new byte[]{");
                int pos = 0;
                foreach (var b in data)
                {
                    if (pos != 0)
                    {
                        fullText.Append(", ");
                    }
                    fullText.Append($"0x{b:X2}");
                    pos++;
                }
                fullText.Append("};\n");
            }
            Application.Current.Clipboard.SetTextAsync(fullText.ToString());
        }
예제 #2
0
        private void Item_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
        {
            if (seletedItem != null)
            {
                seletedItem.Selected = false;
            }
            seletedItem = (PacketListItem)sender;
            detailContainer.Children.Clear();
            if (seletedItem.Packet.Data[0] == 0xCA) // Pv Packet
            {
                foreach (var pvPacket in PvPacket.Split(seletedItem.Packet.Data))
                {
                    detailContainer.Children.Add(new PvDetails
                    {
                        Source      = seletedItem.Packet.Source,
                        Destination = seletedItem.Packet.Destination,
                        Command     = $"0x{(int)pvPacket.Command:X2} {pvPacket.Command.ToString()}",
                        Flags       = pvPacket.Flag.ToString(),
                        PayloadSize = pvPacket.Data.Length - 8
                    });
                    detailContainer.Children.Add(new HexViewer {
                        Data = pvPacket.Data
                    });
                }
            }
            else
            {
                detailContainer.Children.Add(new HexViewer {
                    Data = seletedItem.Packet.Data
                });
            }

            seletedItem.Selected = true;
        }
 public void Add(PCapPacket packet)
 {
     lock (searchLock)
     {
         foreach (var p in PvPacket.Split(packet.Data))
         {
             var channel = p.ReadString(45);
             searches.Add(new Search
             {
                 Time    = packet.TimeStampSeconds + "." + packet.TimeStampMicroseconds,
                 Channel = channel,
                 From    = packet.Source
             });
         }
     }
     ShowStats();
 }
예제 #4
0
        private void Menu_Copy(object sender, Avalonia.Interactivity.RoutedEventArgs e)
        {
            if (seletedItem == null)
            {
                return;
            }
            var fullData = seletedItem.Packet.Data;

            var fullText = new StringBuilder();

            foreach (var p in PvPacket.Split(fullData))
            {
                if (fullText.Length != 0)
                {
                    fullText.Append("\n\n");
                }

                var data = p.Data;

                var hex       = new StringBuilder();
                var chars     = new StringBuilder();
                var posString = new StringBuilder();

                int nbInRow = 0;
                int pos     = 0;
                foreach (var b in data)
                {
                    if (nbInRow == 0)
                    {
                        posString.Append($"{pos:X4}");
                    }
                    else
                    {
                        hex.Append(' ');
                    }
                    if (nbInRow == 8)
                    {
                        hex.Append(" ");
                        chars.Append(" ");
                    }
                    if ((b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || (b >= '1' && b <= '0') || ",;:+\"*%&/()=?^~[]{}§-_".Contains((char)b))
                    {
                        chars.Append((char)b);
                    }
                    else
                    {
                        chars.Append('.');
                    }
                    hex.Append($"{b:X2}");
                    nbInRow++;
                    pos++;
                    if (nbInRow >= 16)
                    {
                        nbInRow = 0;
                        fullText.Append(posString.ToString());
                        fullText.Append("    ");
                        fullText.Append(hex.ToString());
                        fullText.Append("  ");
                        fullText.Append(chars.ToString());
                        fullText.Append("\n");

                        posString.Clear();
                        hex.Clear();
                        chars.Clear();
                    }
                }

                if (posString.ToString().Length > 0)
                {
                    fullText.Append(posString.ToString());
                    fullText.Append("    ");
                    fullText.Append(hex.ToString());
                    fullText.Append(new string(' ', 48 - hex.ToString().Length));
                    fullText.Append("  ");
                    fullText.Append(chars.ToString());
                    fullText.Append("\n");
                }
            }
            Application.Current.Clipboard.SetTextAsync(fullText.ToString());
        }
예제 #5
0
 public ushort ReadUInt16(int offset)
 {
     return(PvPacket.ReadUInt16(Data, IsBigEndian, offset));
 }
예제 #6
0
 public uint ReadUInt32(int offset)
 {
     return(PvPacket.ReadUInt32(Data, IsBigEndian, offset));
 }