admin管理员组文章数量:1277406
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,
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,
Share Improve this question asked Feb 25 at 9:56 Eloi SanchezEloi Sanchez 654 bronze badges 1 |1 Answer
Reset to default 5The 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
本文标签: cCRC mismatch using calculation with CRC RevEng resultsStack Overflow
版权声明:本文标题:c - CRC mismatch using calculation with CRC RevEng results - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741214167a2359721.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
init=0x010
? Is that the initial value of the checksum? That's odd in that case, usually it is either all zeroes or all ones. – Lundin Commented Feb 25 at 10:57