示例#1
0
        public string LogVerbose(NxEspHeader Parent, short Seq)
        {
            var sb = new StringBuilder();

            sb.Append(Parent.ToHex(Seq));
            sb.Append(": ");
            sb.Append(Parent.ToHex(Size));
            sb.Append(" \"");
            sb.Append(Desc);
            sb.Append("\" ");
            sb.Append(Parent.ToHex(Convert.ToByte(0)));

            return(sb.ToString());
        }
示例#2
0
        public List <byte> Serialize(NxEspHeader Parent)
        {
            // Don't use BitConverter to serialise numerics because we always want little-endian
            var bs = new List <byte>();

            bs.Add(Convert.ToByte(Size % 256));
            bs.Add(Convert.ToByte(Size / 256));
            string offset  = Offset.ToString("X2").PadLeft(8, '0');
            string percent = Percent.ToString();

            Desc = (offset + " (" + percent + "%)").PadRight(15);
            bs.AddRange(ASCIIEncoding.ASCII.GetBytes(Desc));
            bs.Add(0); // Null termination
            if (Parent.HeaderBlockSize <= 0)
            {
                Parent.HeaderBlockSize = Convert.ToByte(bs.Count);
            }
            else if (Parent.HeaderBlockSize != bs.Count)
            {
                throw new Exception("Header blocks cannot be different sizes.");
            }
            return(bs); // Should be always 18 bytes
        }