LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Checksum calculation

Solved!
Go to solution

Hello,

 

 

I am writing some data to a LCD display via serial port through LabVIEW. This requires calculation of chksum. The method to calculate checksum is mentioned in the manual of Display as

 

"CHKSUM: Checksum byte; this byte is calculated by taking each byte and XOR’ing all bytes in the 

message from (and including) the COMMAND byte to the last parameter byte. Then, the result is appended
to the end to yield the checksum byte."

 

A typical string such as 070F000007 should generate a checksum of 09.

 

Based on the method of calculation, I converted the string to a byte array and then XORed each bytes. I am not clear enough what it meant by result id appended to yield the checksum byte, but I found that sending 070F00000709 form the terminal writes correct data to the display, so I assume that XORing as above should yield the checksum. However, I dont get the correct result. I appreciate, if anyone could suggest how I can get it correct.

 

Many thanks in advance

 

Zach

0 Kudos
Message 1 of 3
(14,101 Views)
Solution
Accepted by topic author zacharia01

A couple of things are not clear.

 

Above you are talking about a string of 070F000007, but in the VI, the data is a string of 010F000007. However, you are using a plain string of these formatted characters (10 bytes) and I suspect that you should set the text constant to hex display (5 bytes). Once you do this, the checksum is 9 as expected.

 

 

Download All
Message 2 of 3
(14,085 Views)

Altenbach,

 

Sorry for confusion, the data should be 010F0000007 instead of "07..". Thank you very much for the solution! It works...

0 Kudos
Message 3 of 3
(14,051 Views)