Skip to main content

Frame Check Sequence

Message with Appended Frame Check Sequence

DATA
CRC16

Verification of successful reception of a message is ensured via a CRC16 frame check sequence (FCS). The FCS is appended to the message data as shown in the table above, and is generated using the IBM BISYNC CRC16 algorithm, with a generator polynomial of x16+x15+x2+1. C code for a compatible implementation of the algorithm is:

unsigned short int crc16(unsigned char *d, int n) {
unsigned short int crc=0;
int i, bit;
  for (i = 0; i < n; i++) {
crc ^= d[i];
    for (bit = 0; bit < 8; bit++)
crc = crc & 1 ? (crc >> 1) ^ 0xa001 : crc >> 1;
}
return crc;
}

The 16 bit CRC code is stored in big endian format. When decoding received data, if the received CRC16 does not match the computed CRC16 for the data (up to, but not including the 16 bit FCS), then the entire message is considered to be in error and should be discarded.

For example, if the input message is "hello", then the resulting sequence would be:

68 65 6c 6c 6f 34 d2

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.