You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried getting crc for hex string 08000001 using crc16.ChecksumIBM. But instead of 84C3 it is giving me 3226. This is my code: data := []byte("08000001") checksum := crc16.ChecksumIBM(data) fmt.Println("\n checksum:", checksum)
The text was updated successfully, but these errors were encountered:
johnwick03
changed the title
crc16 modbus is giving wrong result
crc16 modbus giving wrong result
Dec 6, 2018
Replace with checksum := ^crc16.ChecksumIBM(data)
Modbus checksum should be calculated without XOR out. Take a look at Modbus test in this repository.
But still you will not get 0x84C3, because you're building CRC of chars array.
d := []byte("08000001")
c := ^crc16.ChecksumIBM(d)
fmt.Printf("checksum:%X\n", c) // checksum:F365
d = []byte{0x08, 0x00, 0x00, 0x01}
c = ^crc16.ChecksumIBM(d)
fmt.Printf("checksum:%X\n", c) // checksum:84C3
s := "08000001"
d, err = hex.DecodeString(s)
c = ^crc16.ChecksumIBM(d)
fmt.Printf("checksum:%X\n", c) // checksum:84C3
I tried getting crc for hex string 08000001 using crc16.ChecksumIBM. But instead of 84C3 it is giving me 3226. This is my code:
data := []byte("08000001")
checksum := crc16.ChecksumIBM(data)
fmt.Println("\n checksum:", checksum)
The text was updated successfully, but these errors were encountered: