Hello and thanks in advance,
Background: I have to communicate with a device for which I have to write a 10-bit CRC with initial value 0000010000 (0x10) and poly:
x10 + x7 + x3 + x2 + x + 1 --> 0x08F
Problem: If I look for the CRC algorithm using the messages I receive and "CRC RevEng":
reveng -w 10 -i 10 -s 010000FF0300005A 00F87F000000033D 00000000000003E3 0000FFFFFFFF012D
I get the actual algorithm:
width=10 poly=0x08f init=0x010 refin=false refout=false xorout=0x000 check=0x06c residue=0x000 name=(none)
BUT, if I reverse the operation, and use the CRC algorithm parameters to calculate the CRC, I do not get the CRCs I entered in the first place (0x005A, 0x033D, 0x03E3, 0x012D).
reveng -w 10 -i 10 -p 08f -c 010000FF0300 00F87F000000 000000000000 0000FFFFFFFF
00fc
0316
0331
007a
What am I missing?
Thank you,
The input length in bits is no longer a multiple of 8 after chopping off the 10-bit CRC at the end, so the input character width cannot be set to 8. It cannot be set to 4 either to specify the input as nybbles, so the only sensible alternative is to set the input character width to 1 (-a 1
) and specify the input in binary. The output width can be set to 4 (-A 4
) to show the CRC in hexadecimal for convenience.
$ reveng -w 10 -i 10 -p 8f -a 1 -A 4 -c 000000010000000000000000111111110000001100000000000000
05a
If you really wanted to go to the effort, you could specify the 54 input bits in octal since it is a multiple of 3 (input width -a 3
), here with the output width set to 4 (-A 4
):
$ reveng -w 10 -i 10 -p 8f -a 3 -A 4 -c 002000007760140000
05a
It is also possible to check the original hexadecimal strings including the CRC on the end produce a CRC of 0:
$ reveng -w 10 -i 10 -p 8f -c 010000FF0300005A 00F87F000000033D 00000000000003E3 0000FFFFFFFF012D
0000
0000
0000
0000