LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Checksum (4 characters)

Solved!
Go to solution

Hello everyone,

I have a serial device with a message-based communication, where it's used 4-characters checksum at the end of message (command).

 

For example command: "START " (space is included at the end),

in ASCII: "83 84 65 82 84 32",

so the sum is: "430",

this decimal in hexadecimal (4-characters) is: "01AE",

and the desired message is: "START 01AE".

 

So I tryed this with String To Byte Array and Add Array Elements, but result is only "AE" and I didn't find any solution for fix it.

 

Thanks in advance for your help.

 

0 Kudos
Message 1 of 9
(4,565 Views)

Hi,

Convert your decimal number to an array of bytes, then use the "Byte array to string" function.

Regards

 

 

Message 2 of 9
(4,557 Views)

You should cast the byte numbers to a 16bit number before adding them.

Message 3 of 9
(4,556 Views)

checksum.png

 

convert to U16 , sum, split number, add to array    and finally convert to string and send to VISA 🙂

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 4 of 9
(4,542 Views)

Meanwhile, I came to this solution.

 

progress.png

 

As with your solution, I still get: "START  ®" But we are close. Smiley Wink

The correct output should be this string: "START 01AE". Any idea how to prevent conversion checksum from HEX to ASCII at Concatenate Strings?

0 Kudos
Message 5 of 9
(4,524 Views)
Solution
Accepted by topic author Neolker

Using the format into string 🙂

 

 

 

checksum2.png

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 6 of 9
(4,518 Views)

Great, you are really fast. Thanks a lot! Smiley Happy Last think is Use minimum field width (for checksum part) with 4 characters pad with zeros on left.

0 Kudos
Message 7 of 9
(4,509 Views)

You have been to fast 😉 I had edited my solution

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 8 of 9
(4,506 Views)

Thank you again, this completely solve my problem. Have a nice day.

 

Greeatings from Czech Republic,

Martin Wolker

0 Kudos
Message 9 of 9
(4,498 Views)