I am trying to understand how the CRC library in Arduino IDE works but I think I have encountered a possible error or possibly it is on my end so I am asking this to figure out which is which.
This is the slightly modified example code called CRC_test.ino from the library itself:
//
// FILE: CRC_test.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo
// URL: https://github.com/RobTillaart/CRC
#include "CRC.h"
#include "printHelpers.h" // for the 64 bit...
char str[24] = "123456789";
void setup() {
Serial.begin(115200);
//Serial.println(__FILE__);
//Serial.println("Verified with - https://crccalc.com/ \n");
}
void loop() {
uint8_t *data = (uint8_t *)&str[0];
// use default parameters for calcCRCxx()
Serial.print("TEST:\t");
Serial.println(str);
Serial.print("CRC8:\t");
Serial.println(calcCRC8(data, 9), HEX);
Serial.print("CRC16:\t");
Serial.println(calcCRC16(data, 9), HEX);
Serial.print("CRC32:\t");
Serial.println(calcCRC32(data, 9), HEX);
// Serial.print("*CRC64:\t");
// uint64_t t = calcCRC64(data, 9);
// Serial.println(print64(t, HEX));
Serial.println("\n\nDone...");
delay(5000);
}
// -- END OF FILE --
Serial monitor output is this:
17:01:52.121 -> TEST: 123456789
17:01:52.121 -> CRC8: F4
17:01:52.121 -> CRC16: A829
17:01:52.121 -> CRC32: CBF43926
17:01:52.121 ->
17:01:52.121 ->
17:01:52.121 -> Done...
I don't know if the forum will let me post a picture since i am still a new user but using the link provided in the code I checked for CRC8, CRC16 and CRC32 and as I can see CRC8 checks out with CRC-8/SMBUS and CRC32 checks out with CRC-32/ISO-HDLC but I haven't able to verify CRC16 result printed on the serial monitor with any of the CRC results provided in the calculator.
I have checked with a few other calculators and they seem to be verifying each other so I don't know what went wrong with the code so if anyone can tell me what am I doing wrong, that will be greatly appreciated.