Polynomials CRC

Hi All,

I hope I have posted this in the right place.

I have been working on a project that reads RF data from a sensor. This has worked really well but I am stuck on one bit that I am hoping someone on here can explain.

The data sent from the sensor has an 8-bit CRC at the end. Since this is a specialised sensor that is not really for the purpose I am using it for, there is no documentation on how the CRC is formed etc, I have had to work out the data structure myself by reverse engineering it.

After a few hours of trying to find out how the CRC is formed by trying every formula I know of, I eventually found a program on the web called CRC RevEng.

I gave this program quite a few samples of the data, and it did come back with a result but the result it gives is complete gibberish to me as it’s all about polynomials which I know absolutely nothing about and a search on the web just shows degree level maths and huge formulas which mean absolutely nothing to me and certainly nothing that I can code a program from.

This is the output of the RevEng output.

width=8 poly=0x2f init=0xdf refin=false refout=false xorout=0x00 check=0x93 residue=0x00 name=(none)

I have no idea what it is telling me but I do know it solved the CRC because if I go in to one of the samples and just change anything, it comes back with no models found.

I am not sure what the info above is telling me. The data is 8 bytes long with the last byte being the CRC. The sensor is a TPMS sensor that I am using for a different purpose. I have completely decoded the data from it and the only byte I cannot decode is the final byte (the CRC).

Here is one sample of the data:

DC A5 8D 00 60 15 04 C6

Many thanks in advanced for any help and advice you can give me.

If you read up on CRC algorithms, the meaning of those parameters will be explained, which will in turn allow you to write code to do the calculation.

There exist web sites that will create C code for you, given the parameters.

If you don’t want to learn the material, post on the Gigs and Collaborations section of the forum, and be prepared to pay for the help.

To get started, though, take a look at a typical 8-bit CRC calculation:

#include <stdio.h>
#include <stdlib.h>

// CRC8 version 1 from code.google.com, rewritten by comparing to version 2
// works for Oregon Scientific Version 2.1 and 3.0 sensors

#define CRC8INIT  0x2b
#define CRC8POLY  0x07

char msglen=8;
char msg[]={0x01,0xD2,0x02,0x78,0x01,0x23,0x04,0x50};  //get 0xAB observe 0xAB
unsigned char crc8 ( char* data_in, char number_of_bytes_to_read ) {
 unsigned char  crc,loop_count,bit_counter;

  crc = CRC8INIT;

  for (loop_count = 0; loop_count < number_of_bytes_to_read; loop_count++)
  {
    crc = crc ^ data_in[loop_count];
    bit_counter = 8;
    do {
        if (( crc & 0x80 ) != 0 ) {
            crc <<= 1;
            crc = crc ^ CRC8POLY;
        }
        else crc <<= 1;
      bit_counter--;
    } while (bit_counter > 0);
  }
  return crc;
}

int main()
{
    unsigned char crc;
    crc=crc8(msg,msglen);
    printf("\r\n crc %2x",crc);
    return 0;
}

Thank you very much for your help. I managed to get it working. I cannot say I fully understand it but with your code and a lot of research I can validate the CRC.

That is good news, congratulations!

It would be great if you would post your code, in case others have a similar problem, or your specific sensor.