예제 #1
0
        public static int Compute16BitHeader(int type, int p0, int p1, int p2, int p3, CRC16 crcCalculator)
        {
            var crc = Compute16BitHeaderAsArray(type, p0, p1, p2, p3, crcCalculator);

            return(BitConverter.ToUInt16(crc, 0));
        }
예제 #2
0
        public static byte[] Compute16BitHeaderAsArray(int type, int p0, int p1, int p2, int p3, CRC16 crcCalculator)
        {
            var b = new byte[5];

            b[0] = Convert.ToByte(type);
            b[1] = Convert.ToByte(p0);
            b[2] = Convert.ToByte(p1);
            b[3] = Convert.ToByte(p2);
            b[4] = Convert.ToByte(p3);

            var crc = crcCalculator.ComputeHash(b).Reverse().ToArray();

            // Seems like 16 bit headers need no encoding ¯\_(ツ)_/¯
            ////var encodedCRC = ZDLEEncoder.EscapeControlCharacters(crc);

            return(crc);
        }