#1, BYTE CRC
参考:
/MODBUS******************
-
Name: CRC-16/MODBUS x16+x15+x2+1
-
Width: 16
-
Poly: 0x8005
-
Init: 0xFFFF
-
Refin: True
-
Refout: True
-
Xorout: 0x0000
-
Note:
*****************************************************************************/
WORD CRC_GetModbus16(BYTE * pData, WORD nLength)
{
WORD cRc_16 = 0xFFFF, i;
BYTE temp;
for (i = 0; i < nLength; ++i)
{
temp = (BYTE)(cRc_16 & 0xFF);
cRc_16 = (WORD)((cRc_16 >> 8) ^ crc16tab[(temp ^ pData[i]) & 0xFF]);
}
return cRc_16;
}
#2, WORD CRC