unsigned short crc_16_rec (char *pucData, unsigned short ucLen) { unsigned int i; unsigned char ucBit, ucCarry; unsigned short usPoly = 0x8408;//reversed 0x1021 unsigned short usCRC = 0; for (i = 0; i < ucLen; i++) { usCRC ^= pucData[i]; for (ucBit = 0; ucBit < 8; ucBit++) { ucCarry = usCRC & 1; usCRC >>= 1; if (ucCarry) { usCRC ^= usPoly; } } } return usCRC; }