05-27-2013 05:33 AM - edited 05-27-2013 05:33 AM
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.
Solved! Go to Solution.
05-27-2013 05:39 AM
Hi,
Convert your decimal number to an array of bytes, then use the "Byte array to string" function.
Regards
05-27-2013 05:40 AM
You should cast the byte numbers to a 16bit number before adding them.
05-27-2013 05:56 AM
convert to U16 , sum, split number, add to array and finally convert to string and send to VISA 🙂
05-27-2013 06:26 AM - edited 05-27-2013 06:27 AM
Meanwhile, I came to this solution.
As with your solution, I still get: "START ®" But we are close.
The correct output should be this string: "START 01AE". Any idea how to prevent conversion checksum from HEX to ASCII at Concatenate Strings?
05-27-2013 06:34 AM - edited 05-27-2013 06:40 AM
Using the format into string 🙂
05-27-2013 06:44 AM - edited 05-27-2013 06:44 AM
Great, you are really fast. Thanks a lot! Last think is Use minimum field width (for checksum part) with 4 characters pad with zeros on left.
05-27-2013 06:46 AM
You have been to fast 😉 I had edited my solution
05-27-2013 06:52 AM
Thank you again, this completely solve my problem. Have a nice day.
Greeatings from Czech Republic,
Martin Wolker