This has been bugging me for a while. I have a piece of hardware that I want to control from a MCU that currently works over a simple serial connection from a piece of software (that wont work in win10!). In order for me to really do this I need to figure out how the checksum works so that I don't have to manually store tons of data when it could easily be calculated on the fly.
Data is sent as blocks of 8 bytes, the last two are checksum. If I alter those the hardware does not respond, if I alter the other 6 bytes the hardware does also not respond and in both cases an 8bit corrupt data counter is increased by 1.
So here is an example of valid data:
01 00 20 01 01 01 7b 38
01 00 20 02 02 02 1b 04
01 00 20 03 03 03 3b 10
01 00 20 04 04 04 db 7c
01 00 20 05 05 05 fb 68
01 00 20 06 06 06 9b 54
01 00 20 07 07 07 bb 40
01 00 20 08 08 08 6a be
01 00 20 09 09 09 4a aa
01 00 20 0a 0a 0a 2a 96
01 00 20 0b 0b 0b 0a 82
01 00 20 0c 0c 0c ea ee
01 00 20 0d 0d 0d ca fa
01 00 20 0e 0e 0e aa c6
01 00 20 0f 0f 0f 8a d2
Somehow the last two bytes are calculated from the first 6. I would have thought it cannot be *that* complicated as the hardware is based on a 16f871 PIC. I have tried some CRC ideas but basically, I'm looking for any ideas that may help me! I have also tried looking for patterns in binary (nothing obvious). Thing is this isn't my strong point hence I post here in the hope that someone with more experience may help me.
Strange...it looks like bit 3 of byte 4 somehow gets xored with bit 1 or byte 5...
This is my code with the test vectors slightly munged by XORing with 00 00 00 00 01 00 for the last eight... I get the right checksums, but can't explain why...
01 00 20 01 01 01 => 7b 38 should be 7b 38, error 00 00
01 00 20 02 02 02 => 1b 04 should be 1b 04, error 00 00
01 00 20 03 03 03 => 3b 10 should be 3b 10, error 00 00
01 00 20 04 04 04 => db 7c should be db 7c, error 00 00
01 00 20 05 05 05 => fb 68 should be fb 68, error 00 00
01 00 20 06 06 06 => 9b 54 should be 9b 54, error 00 00
01 00 20 07 07 07 => bb 40 should be bb 40, error 00 00
01 00 20 08 09 08 => 6a be should be 6a be, error 00 00
01 00 20 09 08 09 => 4a aa should be 4a aa, error 00 00
01 00 20 0a 0b 0a => 2a 96 should be 2a 96, error 00 00
01 00 20 0b 0a 0b => 0a 82 should be 0a 82, error 00 00
01 00 20 0c 0d 0c => ea ee should be ea ee, error 00 00
01 00 20 0d 0c 0d => ca fa should be ca fa, error 00 00
01 00 20 0e 0f 0e => aa c6 should be aa c6, error 00 00
01 00 20 0f 0e 0f => 8a d2 should be 8a d2, error 00 00