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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

checksum calculation

Solved!
Go to solution

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~

0 Kudos
Message 1 of 5
(2,990 Views)

Hi Wanglm,

 

 Please find the attached VI with proper comments inside.

 

Regards,

SrikrishnaNF

Regards,
Srikrishna


0 Kudos
Message 2 of 5
(2,988 Views)
Solution
Accepted by wanglm

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.

0 Kudos
Message 3 of 5
(2,977 Views)

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.

 

0 Kudos
Message 4 of 5
(2,973 Views)

Smiley HappyThanks a lot!

 

I get a wrong message from the manufacturer, checksum should contain the final byte ox88. 

 

Now the calculation is clear.

0 Kudos
Message 5 of 5
(2,970 Views)