8-2 CRC GENERATION
The function takes two arguments:
unsigned char puchMsg; /* A pointer to the message buffer */
unsigned short usDataLen; /* The quantity of bytes in the message buffer */
The function returns the CRC as a type unsigned short.
CRC Generation Function
unsigned short CRC16 (puchMsg, usDataLen)
unsigned char *puchMsg; /* message to calculate CRC upon */
unsigned short usDataLen; /* quantity of bytes in message */
{
unsigned char uchCRCHi = 0xFF; /* high CRC byte initialized */
unsigned char uchCRCLo = 0xFF; /* low CRC byte initialized */
unsigned uIndex; /* will index into CRC lookup */
while( usDataLen--) /* pass through message buffer */
{
uIndex = uchCRCHi ^ *+; /* calculate the CRC */
uchCRCHi = uchCRCLo ^ auchCRCHi[ uIndex};
uchCRCLo = auchCRCLo[ uIndex];
}
return( uchCRCHi << 8 | uchCRCLo);
}
Содержание DS Series
Страница 5: ...1 2 INTRODUCTION END OF INTRODUCTION SECTION ...
Страница 8: ...HARDWARE INTERFACE 2 3 Figure 2 3 Figure 2 2 Figure 2 1 ...
Страница 13: ...2 8 HARDWARE INTERFACE END OF HARDWARE INTERFACE ...
Страница 19: ...3 6 MODBUS RTV PROTOCAL DESCRIPTION END OF MODBUS RTU PROTOCAL DESCRIPTION ...
Страница 23: ...5 2 MODBUS FUNCTION FORMATS END OF MODBUS FUNCTION FORMATS ...
Страница 29: ...6 6 PHOENIX AC DRIVE FUNCTION FORMATS END OF PHOENIX AC DRIVE FUNCTION FORMATS ...
Страница 31: ...7 2 EXCEPTION RESPONSE END OF EXCEPTION RESPONSE ...
Страница 37: ...9 2 PARAMETER CONVERSION END OF PARAMETER CONVERSION ...
Страница 43: ...A 6 APPENDIX BASIC TCP IP DESCRIPTION THIS PAGE INTENTIONALLY LEFT BLANK ...