FrankBoesing / FastCRC

Fast CRC library for PC and ARDUINO
MIT License
149 stars 50 forks source link

Results does not match? #13

Closed luckwaski closed 7 years ago

luckwaski commented 7 years ago

Hello, I've got a little stuck with this library.

I have a buffer of:

00 01 01 33 01 00 00 e9 41 20 59 ad

to CRC but I'm having hard time getting proper results. Lets get [3] element from the array 0x33 which is 51. While this:

Serial.println( CRC16.ccitt("51", 2), HEX );

gave me correct result of 0xC11D i cant for the love of God make it out of my buffer. I've tried casting all the types back and forth - with whole bunch of different results but never the correct one: 0xC11D. Could you please advice?

Thank you

FrankBoesing commented 7 years ago

I think, you are confusing some things.. "51" is a string with two chars (two Bytes - in decimal 53, 49) - this string is not in your Array. So, to get 0xC11D, your buffer should be :

uint8_t buf[] = {53, 49};
Serial.println( CRC16.ccitt(buf, 2), HEX );

But please understand, this is not the place to discuss programming problems.. its meant for issues / bugs in the library. Please ask in the forum: http://forum.pjrc.com

Frank.