-2

I am trying to interpret an old (20years) electronic device that sends serial data. The messages are HEX format 22 bytes each. 20 bytes are data (I checked that they change according to specific functions) and the last 2 bytes are somekind of checksum.

The following are sample messages.

MESSAGE 1 : 16 16 16 16 02 FE 4E 8F 04 00 00 00 B0 83 7E 7C 7D 7F 7F 7F 7F SUM 75 FC MESSAGE 2 : 16 16 16 16 02 FE 4E 8F 04 00 00 00 B0 12 7E 7C 7D 7F 7F 7F 7F SUM E4 FA MESSAGE 3 : 16 16 16 16 02 FE 4E 8F 04 00 00 00 B0 94 7E 7C 7D 7F 7F 7F 7F SUM 62 FA MESSAGE 4 : 16 16 16 16 02 FE 4E 8F 04 00 00 00 B0 93 7E 7C 7D 7F 7F 7F 7F SUM 65 FC MESSAGE 5 : 16 16 16 16 02 FE 4E 8F 04 00 00 00 B0 92 7E 7C 7D 7F 7F 7F 7F SUM 64 FA MESSAGE 6 : 16 16 16 16 02 FE 4E 8F 04 00 00 00 B0 8C 7E 7C 7D 7F 7F 7F 7F SUM 7A 0A MESSAGE 7 (Special) : 16 16 16 16 02 FE 4E 50 SUM E2 80

I changed only one byte to make it easier to detect the change in the "checksum" , I confirmed that the first byte in the SUM is LRC by XORing the data bytes, but i cannot interpret the second byte and how it is calculated (i have tried CheckSum8 Modulo 256 / CheckSum8 2s Complement and CRC-8).

Note : The serial communication is 8 bit with even parity.

ElectronS
  • 49
  • 6
  • Empirical reverse engineering an archaic unnamed protocol is somewhat out-of-scope for Stack Overflow... – Oliver Charlesworth Jun 19 '17 at 23:38
  • @OliverCharlesworth , i totally understand and i have done most of the work . I am just confused about this last byte and whether this is a standard protocol , is there 16bit LRC ? , or is the next byte VRC . if someone with experience in old devices might just point me out to the protocols used before CRC . or just tell me that this is non-standard staff and i should do ...etc . I donot expect anyone to spend his time doing my hobbist project. thanks in advance – ElectronS Jun 19 '17 at 23:44
  • @OliverCharlesworth by the way , before i posted my question i see that this post didnot get any vote down or closed , and it is similar to mine : https://stackoverflow.com/questions/2650749/find-out-crc-or-checksum-of-rs232-data?rq=1 – ElectronS Jun 19 '17 at 23:47
  • Surely the device has documentation? Or a manufacturer who can be asked? – user207421 Jun 19 '17 at 23:49
  • @EJP , that is an option , but i donot think they care much about a customer how bought a used product they made a long time ago used on Ebay , and surely they wonot appreciate the sniffing around :) – ElectronS Jun 19 '17 at 23:51
  • 1
    You'd be surprised. I deal regularly with a company that supports everything they have ever built since founding in 1936. The answer is probably just some industry standard anyway. Their response will also be a guide as to how much energy you should put into the whole project. If you want help here, you should supply 16 rows, one for every possible value of the varying byte. NB This is not [tag:serialization]. – user207421 Jun 19 '17 at 23:53
  • Tastes have changed a bit on Stack Overflow in the last 7 years ;) – Oliver Charlesworth Jun 20 '17 at 00:01
  • @OliverCharlesworth I don't mind the question, except maybe inasmuch as it smacks of 'request for offsite resource'. But it needs a complete dataset to be soluble by inspection. He also needs to state what if anything he has already ruled out, such as simple sum, CRC-8, etc. – user207421 Jun 20 '17 at 00:04

1 Answers1

1

I think you should take first byte of the "sum" into account when calculating second byte of the "sum". Notice how sum of the changed byte and first byte of the "sum" is same for all lines with the same last byte of the sum. E.g. for lines ending with FC: 83+75=93+65 (in hex). So, it should be something pretty simple, like sum or similar. In fact, from sample lines you provided it looks like last byte in each line is just a sum of all preceding bytes (including first byte of the sum) plus A8 (all modulo 256 of course). Not sure where A8 comes from. Assume it's a sort of non zero seed which is a pretty common thing to do.

Seva
  • 2,388
  • 10
  • 9
  • excellent , i makes a lot of sense and i think you got it right . i will check on other messages to confirm . Then i will mark as solved . thanks :) – ElectronS Jun 23 '17 at 01:41