4/14/2016
D014465 CR1400 CR1000 CR2300 CR2600 CR3600 CR44X5 CR8000 CR900FD CR6000 CR5000 T500 Client Version ICD
Page 104 of 106
© 2013-2016 The Code Corporation
12393 South Gateway Park Place Suite 600, Draper, UT 84020
(801) 495-2200
FAX (801) 495-0280
13
Appendix: Example CRC14 C Code
The CRC14 required by Host to Reader packets (see Section 7.2) can be calculated using the following
sample C code. This CRC14 consists of two consecutive bytes, each in range [0,127] most significant byte
first. A CRC16 is calculated on each packet byte, over the entire packet, excluding the prefix and the CRC16
itself. Bitwise AND each byte of the CRC16 checksum with 0x7F to generate the two bytes of the CRC14
checksum.
crc_t crc = 0;
<send firstByte>
crc = crc(crc, firstByte, firstByteSize);
<send secondByte>
crc = crc(crc, secondByte, secondByteSize)
<…>
crcHighByte = (crc >> 8) & 0x7f;
crcLowByte = crc & 0x7f;
<send crcHighByte>
<send crcLowByte>
The CRC16 is calculated in Appendix: Example CRC16 C Code above.