./pycrc.py --check-hexstring=03414243 --reflect-in=False --xor-in=0xffff
--poly=0x8005 --width=16 --reflect-out=False --xor-out=0
0xb4bc
GOTCHA! [ Reverse-Bits(0xA001)=0x8005 ]
./pycrc.py --reflect-in=False --xor-in=0xffff --poly=0x8005 --width=16
--reflect-out=False --xor-out=0 --generate c --algorithm=table-driven
--table-idx-width 4
/**
* \file stdout
* Functions and types for CRC checks.
*
* Generated on Thu Oct 20 20:13:33 2011,
* by pycrc v0.7.6, http://www.tty1.net/pycrc/
* using the configuration:
* Width = 16
* Poly = 0x8005
* XorIn = 0xffff
* ReflectIn = False
* XorOut = 0x0000
* ReflectOut = False
* Algorithm = table-driven
************************************************************************
*****/
#include "stdout.h"
#include <stdint.h>
#include <stdlib.h>
/**
* Static table used for the table_driven implementation.
************************************************************************
*****/
static const crc_t crc_table[16] = {
0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022
};
/**
* Update the crc value with new data.
*
* \param crc The current crc value.
* \param data Pointer to a buffer of \a data_len bytes.
* \param data_len Number of bytes in the \a data buffer.
* \return The updated crc value.
************************************************************************
*****/
crc_t crc_update(crc_t crc, const unsigned char *data, size_t data_len)
{
unsigned int tbl_idx;
while (data_len--) {
tbl_idx = (crc >> 12) ^ (*data >> 4);
crc = crc_table[tbl_idx & 0x0f] ^ (crc << 4);
tbl_idx = (crc >> 12) ^ (*data >> 0);
crc = crc_table[tbl_idx & 0x0f] ^ (crc << 4);
data++;
}
return crc & 0xffff;
}