コード例 #1
0
        public void AppendCRC(int payloadStart = 0)
        {
            byte[] msg = ToArray();
            ushort crc = RedundancyCheck.CalculateCRC(msg, payloadStart, msg.Length - payloadStart);

            Append(crc);
        }
コード例 #2
0
        public void AppendLRC(int payloadStart, int payloadLength)
        {
            byte[] msg = ToArray();
            byte   lrc = RedundancyCheck.CalculateLRC(msg, payloadStart, payloadLength);

            Append(lrc);
        }
コード例 #3
0
        public bool ValidateLRC(int payloadStart = 0)
        {
            var  msg           = _bytes.ToArray();
            byte calculatedLRC = RedundancyCheck.CalculateLRC(msg, payloadStart, msg.Length - payloadStart - 1);
            byte readLRC       = ReadByte(msg.Length - payloadStart - 1);

            return(calculatedLRC == readLRC);
        }
コード例 #4
0
        public bool ValidateCRC(int payloadStart, int payloadLength)
        {
            var    msg           = _bytes.ToArray();
            ushort calculatedCRC = RedundancyCheck.CalculateCRC(msg, payloadStart, payloadLength);
            ushort readCRC       = ReadUShort(payloadStart + payloadLength - 2);

            return(calculatedCRC == readCRC);
        }