From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-12-2014 10:58 PM
example:(hexadecimal format)
7e 09 68 00 00 00 00 00 77 88
7e 09 69 00 00 00 00 00 78 88
7e 09 02 00 00 00 00 00 11 88
7e 09 10 00 00 00 00 00 1f 88
7e 09 01 00 00 00 00 00 10 88
7e 09 -- header
68 00 -- command type
00 00 00 00 -- data
77 (blue text) -- checksum (sum of the 8 bytes before it)
88 -- end
These are some data packet send to an instrument via a COM port.
I've tried some methods but can't get the right checksum in the example. Please give me a hand!
Thanks~
Solved! Go to Solution.
05-12-2014 11:12 PM
05-12-2014 11:31 PM - edited 05-12-2014 11:35 PM
Srikrishna,
I don't think your message is what the original poster is looking for. All you are doing is extracting the checksum from the string of messages, which is actually pretty trivial and can be done more easily than what you have posted.
I'd be willing to bet they are actually asking how to CALCULATE the checksum based on the previous bytes.
That can't be answered with the limited information since there are many different checksum calculation schemes out there.
WangIM, you need to read the communication manual for the instrument. It should tell you how to calculate the checksum.
Though strangely enough, with the limited sample you provided, if you add up all the bytes except for the checksum, (i.e. the first 8 bytes, plus the final byte of x88) you get the same value as the checksum byte. This is done if all the bytes are stored in a U8 array and the array elements are summed.
05-12-2014 11:36 PM
Hi SrikrishnaNF:
Thanks!
I'm afraid I haven’t make it clear.
I want a command, but don't know how to calculate the checksum.
for example: 7e 09 01 00 ff 00 ff 00 ?? 88, I need to get the ?? first. That's my problem.
05-12-2014 11:45 PM
RavensFanThanks a lot!
I get a wrong message from the manufacturer, checksum should contain the final byte ox88.
Now the calculation is clear.