BallAerospace / COSMOS

Ball Aerospace COSMOS
https://ballaerospace.github.io/cosmos-website/
Other
360 stars 129 forks source link

CRC16 Calculation error #1769

Closed abdelrahman47 closed 2 years ago

abdelrahman47 commented 2 years ago

With data equals string=("68008002710100007101000000000000FF051D002C32D06203000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")

bytes = ("0x68 0x00 0x80 0x02 0x71 0x01 0x00 0x00 0x71 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0xFF 0x05 0x1D 0x00 0x2C 0x32 0xD0 0x62 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00")

CRC_Protocol gets CRC equals ("BC97") while the correct CRC equals ("AEB2") and the correct CRC was checked by online calculator. the problem is that CRC_Protocol calculates CRC from string while it should calculate it from bytes same as the online calculator.

So how to make CRC_Protocol calculates the CRC from bytes instead of string ???

jmthomas commented 2 years ago

Is your data a STRING type? Perhaps it should be BLOCK.

abdelrahman47 commented 2 years ago

Yes data type is STRING. I made a simple CRC16 implementation inside my custom protocol (CAN Protocol) and the problem is solved. Thanks