2

I'm trying to calculate the check sum of a m-bus data frame. In page 1 of this PDF I'm able to read that the frame's check sum "is calculated from the arithmetical sum of the data mentioned above, without taking carry digits into account". The data I have above are the bytes:

  1. Start
  2. L Field
  3. L Field
  4. Start
  5. C Field
  6. A Field
  7. CI Field
  8. Check sum
  9. Stop

In page 2 we can find that one example of a valid data frame is:

68 03 03 68 53 01 BB 0F 16

In hexadecimal, being 0F the check sum. Unfortunately I must be doing something wrong because I'm not able to reach that value.

Could someone explain how this algorithm, to find the check sum, works?

1 Answer 1

2

just one sample is never sufficient to answer a checksum query you need a bunch of samples to corelate and find patterns

so looking at the linked pdf it seems it is clear enough

skip the start and sum the data and extract the least two bytes

skip     sum     mask 
x,x,x,x | y,y,... 0x000000ff = checksum

so the sample you posted would be

skip         | sum            
68 , 3 ,3 68 | 53 , 01 , bb |  =

checksum

"{0:X2}" -f ((0x53+0x1+0xbb) -band 0x000000ff) = 0x0f seems to match 

running this on other sequnces in the pdf seem to tally

PS C:\> $a = "{0:X2}" -f ((0x53+0xfe+0x51+0x01+0x7a+0x01) -band 0x000000ff) ; $a
1E 
PS C:\> $a = "{0:X2}" -f ((0x73+0x01+0x51+0x01+0x7A+0x02 ) -band 0x000000ff) ; $a
42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.