=====
Sub ComputeCRC (val() As Byte) As Byte()
Dim crc As Long
Dim q As Long
Dim c As Byte
For i = 0 To val.Length - 1
c = val(i)
q = Bit.And(Bit.Xor(crc, c), 0xF)
crc = Bit.Xor(Bit.ShiftRight(crc, 4), q * 0x1081)
q = Bit.And(Bit.Xor(crc, Bit.ShiftRight(c, 4)), 0xF)
crc = Bit.Xor(Bit.ShiftRight(crc, 4), q * 0x1081)
Next
Return Array As Byte(Bit.And(crc, 0xFF), Bit.ShiftRight(crc, 8))
End Sub
=====
that code will generate CRC-CCITT (Kermit) from: FC0511 CRC: 2756
then i need to get CRC-CCITT (XModem) from: FC0511 expected CRC: 6BD6
https://www.lammertbies.nl/comm/info/crc-calculation.html
which part of the code should be modified?
many thanks
Sub ComputeCRC (val() As Byte) As Byte()
Dim crc As Long
Dim q As Long
Dim c As Byte
For i = 0 To val.Length - 1
c = val(i)
q = Bit.And(Bit.Xor(crc, c), 0xF)
crc = Bit.Xor(Bit.ShiftRight(crc, 4), q * 0x1081)
q = Bit.And(Bit.Xor(crc, Bit.ShiftRight(c, 4)), 0xF)
crc = Bit.Xor(Bit.ShiftRight(crc, 4), q * 0x1081)
Next
Return Array As Byte(Bit.And(crc, 0xFF), Bit.ShiftRight(crc, 8))
End Sub
=====
that code will generate CRC-CCITT (Kermit) from: FC0511 CRC: 2756
then i need to get CRC-CCITT (XModem) from: FC0511 expected CRC: 6BD6
https://www.lammertbies.nl/comm/info/crc-calculation.html
which part of the code should be modified?
many thanks