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
i already have a equivalent function to do bit-shift in VB (<< >>=)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
but i dont understand that line :
b = (d & (0x01 << i))?0x0001:0x0000;
and the word "reentrant"




Reply With Quote