Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Hello All,

I have one Binary file. It is in motorola s37 format.
My Job is to read each and every line in a binary file and to verify the check sum in each and every line.
I am giving the sample
example that How to calculate checkSum.

Checksum calculation[edit]
The following example record:

S1137AF00A0A0D0000000000000000000000000061
is decoded to show how the checksum value is calculated as follows:

Add: add each byte 13 + 7A+F0 + 0A+0A+0D+00+00+00+00+00+00+00+00+00+00+00+00+00 = 19E (hex) total.
Mask: keep the least significant byte of the total = 9E (hex).
Complement: compute ones' complement of least significant byte = 61 (hex).

I need to Implement above in C#. Could you please Help me out
Posted
Comments
CPallini 16-Jun-15 8:08am    
It doesn't look a daunting task. What is your doubt about?

1 solution

So do it, S37 (or SREC as it is properly known) isn't complicated: https://en.wikipedia.org/wiki/SREC_(file_format)[^]

All you have to do is:
1) Read each line
2) Strip off the line header bytes ("S0", "S1", etc.)
3) Pull out the in-file checksum, and convert it to a byte
4) Read each pair of hex digits into a byte.
5) Sum all the bytes.
6) Complement the sum.
7) Compare the calculated value with the in=file value you processed earlier.
8) Continue from (2) with the next line.

This isn't complex: but it's your homework, so I'll give you no code!
 
Share this answer
 
Comments
nsirisha 19-Jun-15 7:38am    
Thank you very much
OriginalGriff 19-Jun-15 7:46am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900