79715230

Date: 2025-07-25 20:49:43
Score: 0.5
Natty:
Report link

    Public Shared Function ComputeChecksum(ByVal bytes As Byte()) As UShort
        Dim crc As UShort = &HFFFFUS ' The calculation start with 0xFFFF
        For i As Integer = 0 To bytes.Length - 1
            Dim index As Byte = CByte(((crc) And &HFF) Xor bytes(i))
            crc = CUShort((crc >> 8) Xor table(index))
        Next
        Return crc
    End Function

This appears to work - I tested it against a few MODBUS messages to compare CRCs - But I needed to swap Hi/Lo byte order of the CRC to get it to match the message order  
Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Tim Bowman