2023-08-01 11:27:01 -04:00
|
|
|
//
|
|
|
|
// FILE: CRC16_test.ino
|
|
|
|
// AUTHOR: Rob Tillaart
|
|
|
|
// PURPOSE: demo
|
|
|
|
// DATE: 2021-01-20
|
|
|
|
// (c) : MIT
|
|
|
|
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
#include "CRC16.h"
|
|
|
|
#include "CRC.h"
|
|
|
|
|
|
|
|
char str[24] = "123456789";
|
|
|
|
|
|
|
|
CRC16 crc;
|
|
|
|
|
2021-12-14 14:22:40 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.println(__FILE__);
|
|
|
|
|
2022-01-28 08:56:11 -05:00
|
|
|
// Serial.println("Verified with - http://zorc.breitbandkatze.de/crc.html \n");
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
test();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-12-14 14:22:40 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
void test()
|
|
|
|
{
|
2023-07-13 05:08:10 -04:00
|
|
|
Serial.println(calcCRC16((uint8_t *) str, 9), HEX);
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
crc.add((uint8_t*)str, 9);
|
2023-07-13 05:08:10 -04:00
|
|
|
Serial.println(crc.calc(), HEX);
|
2021-01-29 06:31:58 -05:00
|
|
|
|
|
|
|
crc.restart();
|
|
|
|
for (int i = 0; i < 9; i++)
|
|
|
|
{
|
|
|
|
crc.add(str[i]);
|
|
|
|
}
|
2023-07-13 05:08:10 -04:00
|
|
|
Serial.println(crc.calc(), HEX);
|
2021-01-29 06:31:58 -05:00
|
|
|
Serial.println(crc.count());
|
|
|
|
}
|
2023-08-01 11:27:01 -04:00
|
|
|
|
|
|
|
|
|
|
|
// -- END OF FILE --
|
|
|
|
|