public void AppendCRC(int payloadStart = 0) { byte[] msg = ToArray(); ushort crc = RedundancyCheck.CalculateCRC(msg, payloadStart, msg.Length - payloadStart); Append(crc); }
public void AppendLRC(int payloadStart, int payloadLength) { byte[] msg = ToArray(); byte lrc = RedundancyCheck.CalculateLRC(msg, payloadStart, payloadLength); Append(lrc); }
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); }
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); }