Reputation: 13
I am using this code from this question: CRC8 Embedded Implementation
this code is based on this site:
I know that the value of 0xAA79 is 0x61, and I'm also getting that result.
my question is how exactly do how I add two results of two crc-8 calculation. for instance if I would like to get the crc-8 result of "0xAA79AA79", then the above website gives me the result of 0xc0, but when I'm just adding the result of 0xAA79 twice I get 0xc2. what I'm doing wrong?
Upvotes: 0
Views: 796
Reputation: 28941
Using binary math (+ means xor, % means modulo, no carries on multiplies or borrows on divide), the CRC is really calculating:
aa79aa7900%131 = c0
This can be split up into two parts, and added (xor)
aa79000000%131 = a1
aa7900%131 = 61
a1+61 = c0
The operations can be split up into components modulo 131
1000000%131 = 46
100%31 = 31
(aa79*46)%131 = a1
(aa79*31)%131 = 61
a1+61 = c0
Upvotes: 2
Reputation: 112607
A CRC is not a checksum. You cannot add two CRCs arithmetically and expect that to be related in any way to the CRC of the combined sequence.
It is possible however to combine CRCs. crcany will generate code, for any CRC definition, that does exactly that.
Upvotes: 2