-2

I need help calculating the checksum (crc-16:X16+X15+X2+1) for BYTE6 and BYTE7 of this data string. I have read some examples but I have no idea how and where to start. What does the X16, X15 etc means? What should I put in BYTE6 and BYTE7?

Byte0: 0x55

Byte1: 0x80

Byte2: 0x06

Byte3: 0x02

Byte4: 0x00

Byte5: 0x00

Byte6: MSB of the checksum word (CRC-16)

Byte7: LSB of the checksum word (CRC-16)

vitr
  • 6,766
  • 8
  • 30
  • 50
Windwaker
  • 1
  • 2
  • This is an IBM CRC polynom as stated in https://en.wikipedia.org/wiki/Polynomial_representations_of_cyclic_redundancy_checks. Those X16, etc... are X to the power of 16, etc... In which language do you want that done? – Jean-François Fabre Aug 22 '16 at 06:35
  • For now I just want to understand the basic concept of it, however i would use the C language – Windwaker Aug 22 '16 at 06:39
  • a quick lookup on this site could have lead to this: http://stackoverflow.com/questions/23638939/crc-16-ibm-reverse-lookup-in-c – Jean-François Fabre Aug 22 '16 at 06:58

1 Answers1

0

The CRC polynomial (x16+x15+x2+1) is necessary but not sufficient to define the CRC. You can see this list of 16-bit CRCs, in which you can find seven different CRC's that use that particular polynomial (poly=0x8005).

Once you have the full description, you can use my crcany code to generate C code to compute the CRC.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
  • I cloned your project and successfully built it and test, but having trouble figuring out how to use it. I want to obtain a crc16/ibm-sdlc for a few hex bytes of data. Can you show me the process for doing this please? – peinal Jan 19 '22 at 16:54
  • 1
    `% echo -n 123456789 | ./crcany -sdlc`, result: `CRC-16/IBM-SDLC: 0x906e`. Make a file with your binary data. Then: `./crcany -sdlc datafile`. – Mark Adler Jan 19 '22 at 18:01
  • Thanks Mark. That helps a lot. For the data file, does it presume an ascii hex representation? ie "080a18ff40" or would the txt file be "0x08 0x0a 0x18 0xff 0x40"? – peinal Jan 21 '22 at 15:28
  • No. Those actual bytes. The file would be five bytes in length. – Mark Adler Jan 21 '22 at 17:14