I need help identifying the checksum algorithm in the following packets please.

So, packets format is:

sd ?? dd dd dd ??

where

s = start nibble

d = data (binary coded decimal)

? = unknown – possibly checksum

Here are five packets (number being transmitted in brackets) and the actual packet sent on the wire in hex on the right.

(1112694): f1 f7 11 26 94 74

(5432432): f5 7c 43 24 32 a2

(6430116): f6 dc 43 01 16 48

(3254817): f3 d8 25 48 17 e9

(0042863): f0 ce 04 28 63 b2

I've tried XOR and summing but they dont seem to work. The packets are transmitted using UART.

any help appreciated!

## Best Answer

Take your first data row:

(1112694): f1 f7 11 26 94 74

Make a byte stream of hex numbers as:

0x94

0x26

0x11

0xF1

Run those bytes in that order through a CRC-CCITT (XModem) CRC algorithm to arrive at a CRC of 0xF774. The high byte of the CRC goes to the second position of the message and the low byte of the CRC goes to the last position of the message.

This same technique works for each of the messages in your sample. I used the online calculator to show the result as here:

The polynomial function for the CRC-CCITT algorithm is as follows:

I leave it to you to look up and find source code for the CRC-CCITT algorithm and understand the specific nuances of using that code in the old XModem methodology. The 0x1021 polynomial is well known and I have used it for years in my projects for everything from communications protocols to check codes on data sets stored in serial EEPROMs and FRAM chips. The usage nuances come into play as to whether the CRC fields of the packet are preset to something like 0x0000 or 0xFFFF and whether those preset fields are also passed through the CRC calculator to arrive at a result. Note that there is a plethora of information online.