I have read about a helpful website with a CRC calculator covered in other posts, which works great, but the code provided in C language does not replicate the capabilities, unfortunately: http://www.zorc.breitbandkatze.de/crc.html
The following configuration is required for CRC16-CCITT (x.25), which is the format I am working with for a sensor and supporting electronic assembly:
- CRC Order: 16
- CRC polynomial: 0x11021 [entered as 1021]
- Initial value: 0xffff [entered as ffff]
- Direct/Indirect: Direct
- Final XOR Value: 0xffff [entered as ffff]
- Reverse Data Bytes: True
- Reverse CRC Result Before Final XOR: True
However, sometimes an incorrect CRC is calculated using the C code, specifically, but comes out correct with the online calculator.
You can find the C code at the following link, but make sure to change the configuration options to match the above: http://www.zorc.breitbandkatze.de/crctester.c
Here is a sample packet placed in the C Code:
const char string[] = { "\x82\x2f\x0a\x40\x00\x00\x7a\x44" };
This returns an incorrect CRC of "0x1e4e".
and in the online calculator: "%82%2f%0a%40%00%00%7a%44"
Which returns the correct CRC of "0xd831".
Also, you will want a packet that works with BOTH the online calculator AND the C Code, which follows.
In the C Code:
const char string[] = { "\x81\x2f\x0b\x4f\xd8\xab\x0d\x42\xed" };
And in the online calculator: "%81%2f%0b%4f%d8%ab%0d%42%ed"
Does anyone know why this is happening, and how the C Code can be corrected to fix this?
Thank you so much for considering to help!