Author Topic: Possible Checksum Calculation  (Read 1758 times)

0 Members and 1 Guest are viewing this topic.

Offline Chet T16Topic starter

  • Frequent Contributor
  • **
  • Posts: 537
  • Country: ie
    • Retro-Renault
Possible Checksum Calculation
« on: October 25, 2017, 11:27:38 am »
Hi guys,

I'm going nuts here trying to figure out how the last byte in a packet is being calculated, the final column in the below hex value table.

I have the rest of the values figured out.

A4AAC001E800FFFF4265
A4ABC001E800FFFF4264
A4ACC001E800FFFF4160
A4B7C001E800FFFF4278
A4B8C001E800FFFF4570
A4B9C001E800FFFF4571
A4BAC001E804FFFF4A79
A4BBC001E802FFFF487C
A4BCC001E801FFFF4B7B
A4BDC001E802FFFF4C7E
A4BEC001E804FFFF4E79
A4BFC001E804FFFF4670
A4C0C001E804FFFF89C0
A4C1C001E804FFFF89C1
A4C2C001E802FFFF4805
A4C3C001E802FFFF87CB
A4C4C001E802FFFF87CC
A4C5C001E800FFFF420A
A4C6C001E800FFFF82C9
A4C7C301E800FFFF82CB
A4C8C001E800FFFF82C7
A4C9C001E800FFFF82C6
A4CAC001E800FFFF4205
A4CBC001E800FFFF82C4
A4CCC001E800FFFF82C3
A4CDC001E800FFFF4101
A4CEC001E800FFFF4506
A467C001E802FFFF4CA4
A467C001E800FFFF41BC
A468C001E800FFFF41A4

Byte two is a sequential number and when all the others stay the same the "checksum" generally decreases by 1, which may tell me something! I've been trying all sorts of things like addition and bit flipping but not getting anywhere.

Pointers very much appreciated.
Chet
Paid Electron Wrestler
 

Offline HKJ

  • Super Contributor
  • ***
  • Posts: 3042
  • Country: dk
    • Tests
Re: Possible Checksum Calculation
« Reply #1 on: October 25, 2017, 12:02:06 pm »
Have you tried XOR
 

Offline stmdude

  • Frequent Contributor
  • **
  • Posts: 479
  • Country: se
Re: Possible Checksum Calculation
« Reply #2 on: October 25, 2017, 12:07:26 pm »
 

Offline WillHuang

  • Contributor
  • Posts: 47
Re: Possible Checksum Calculation
« Reply #3 on: October 25, 2017, 02:07:57 pm »
The checksum is calculated as follows:

Checksum = 0xFF

For each byte in packet excluding the last byte:
Checksum ^= byte

Finally, checksum ^= 0xFF.

This should yield the last byte in the column
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2161
  • Country: us
Re: Possible Checksum Calculation
« Reply #4 on: October 25, 2017, 02:11:57 pm »
It's two's complement.  Add the bytes, XOR the least significant byte of the sum with 0xFF, then add 1.
 

Offline hlavac

  • Frequent Contributor
  • **
  • Posts: 536
  • Country: cz
Re: Possible Checksum Calculation
« Reply #5 on: October 25, 2017, 03:33:36 pm »
it seems to be simple xor of the bytes. if you xor them all you get 00.
to calculate, xor all the bytes except the checksum and put the result in checksum
Good enough is the enemy of the best.
 

Offline Chet T16Topic starter

  • Frequent Contributor
  • **
  • Posts: 537
  • Country: ie
    • Retro-Renault
Re: Possible Checksum Calculation
« Reply #6 on: October 25, 2017, 05:43:45 pm »
You guys are good, I knew someone would know..just not what seems to be everyone except me  ;D

It is indeed an XOR, I ran some code to check incoming packets and they all matched.

Thanks!
Chet
Paid Electron Wrestler
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf