[RESOLVED] crc 16 ccitt 8408
i need a function to calculate the CRC16 from a string, not a byte array
this is the function from the documentation of the device, but its in C
Code:
word reentrant update_crc16 (word oldcrc, byte d)
{
word crc, carry, b;
byte i;
crc = oldcrc;
for (i = 0; i < 8; ++i)
{
b = (d & (0x01 << i))?0x0001:0x0000;
carry = (crc & 0x0001) ^ b;
crc >>= 1;
if(carry)crc ^= 0x8408;
}
return crc;
}
// you must initialize the initial crc with 0x8408
i already have a equivalent function to do bit-shift in VB (<< >>=)
but i dont understand that line :
b = (d & (0x01 << i))?0x0001:0x0000;
and the word "reentrant"