User's Manual

29.05.2007 Page 46 of 59
ASR500 Reader Operation
5.10 CRC Calculation
The 8 Bit CRC will be calculated with the CCITT-CRC-8 Polygon x
8
+x
4
+x
3
+x
2
+1 with all Bytes
including STX without the Checksum itself. An ESCAPE before the checksum has to be calcu-
lated as well.
A frame from the ASR500 to the Host always has a DLE in front of a CRC.
5.10.1 CRC-Algorithm
CRC-Algorithm
char CalcCRC8 (char CRC, char byte)
{
unsigned char count;
for (count = 0; count < 8; ++count)
{
if (((CRC & 0x01) ^ (byte & 0x01)) != 0)
{
CRC ^= 0x70;
CRC >>= 1;
CRC |= 0x80;
}
else
{
CRC >>= 1;
CRC &= 0x7F;
}
byte >>= 1;
}
return (CRC);
}