Projector Control
APPENDIX 1: CRC CALCULATION ALGORITHM
The following ‘C’ code can be used to calculate the
calculation is performed with the CRC bytes of the packet header initialized to zero.
//Using two 256 byte lookup tables, quickly calculate a
//Params:
//pcData : Pointer to data to calculate CRC on.
//nCount : Number of data bytes.
//Return:
WORD CalculateCRC16 (BYTE *pcData, int nCount)
{
BYTE cCRCHi = 0xFF; // high byte of CRC initialized BYTE cCRCLo = 0xFF; // low byte of CRC initialized BYTE cIndex; // will index into CRC lookup table while
{
cIndex = cCRCHi ^ *pcData++; // calculate the CRC
cCRCHi = cCRCLo ^ cCRCHiArray[cIndex]; cCRCLo = cCRCLoArray[cIndex];
}
return (cCRCHi << 8) + cCRCLo;
}
Page 10 | Version 1. |