This function is wiithin file
C:\Arduino\libraries\util\crc16.h
on windows.
There are other files in Arduino-land that have the same function names but use a traditional bit-shift for loop and probably a different polynomial.
The author of the code above did not state the initial CRC value (0 or FFFF are common), nor the polynomial. CCITT in common use has several variants.
Perhaps that function is in the library "core.a"? The CRC16 code is not recompiled each build by my review of the build verbose logs.
My issue is that an AVR or Teensy 3 must exchange messages with a PC/MAC/Linux that tries to have the same CRC algorithm and initial value but the PC/MAC/Linux must use Python code for portability - - including Python 2.7 and its serial module for all operating systems.
My Python coded app attempts to duplicate that CRC code. Two instances of my code on two serial ports talks to another copy of itself just fine, of course.
But the packet from an AVR has exactly the same content but a different CRC.
I don't know why the function name has a leading underscore in C.
I've spent a lot of time trying to duplicate the gawd afwul code above in Python (dealing with lack of uint8_t in Python), but I'm also not sure that code is even what the Arduino environment's linker is pulling!
help appreciated. Maybe some way to get the GCC library manager to list core.a and see what file the crc function is in?
And does Teensy 3 use the same?
steve
C:\Arduino\libraries\util\crc16.h
on windows.
Code:
static uint16_t _crc_ccitt_update (uint16_t crc, uint8_t data)
{
data ^= lo8 (crc);
data ^= data << 4;
return ((((uint16_t)data << 8) | hi8 (crc)) ^ (uint8_t)(data >> 4)
^ ((uint16_t)data << 3));
}
There are other files in Arduino-land that have the same function names but use a traditional bit-shift for loop and probably a different polynomial.
The author of the code above did not state the initial CRC value (0 or FFFF are common), nor the polynomial. CCITT in common use has several variants.
Perhaps that function is in the library "core.a"? The CRC16 code is not recompiled each build by my review of the build verbose logs.
My issue is that an AVR or Teensy 3 must exchange messages with a PC/MAC/Linux that tries to have the same CRC algorithm and initial value but the PC/MAC/Linux must use Python code for portability - - including Python 2.7 and its serial module for all operating systems.
My Python coded app attempts to duplicate that CRC code. Two instances of my code on two serial ports talks to another copy of itself just fine, of course.
But the packet from an AVR has exactly the same content but a different CRC.
I don't know why the function name has a leading underscore in C.
I've spent a lot of time trying to duplicate the gawd afwul code above in Python (dealing with lack of uint8_t in Python), but I'm also not sure that code is even what the Arduino environment's linker is pulling!
help appreciated. Maybe some way to get the GCC library manager to list core.a and see what file the crc function is in?
And does Teensy 3 use the same?
steve
Last edited: