03-04-2010 08:05 AM - edited 03-04-2010 08:09 AM
Hi,
I'm developing a program which would read serial port, capture packets, extract payload, convert the data in the payload and display. Now, everything until the last steps working fine. The problem is with the converting a byte array to number. In the serial communication, packets carry 16-bit unsigned integers (which basically means 2 bytes in the payload). Now the problem is how to convert these two bytes to an unsigned 16-bit integer in LabView. If I just try to convert the byte array using U16 converter, it outputs a 1-D array of unsigned 16-bit integers while I need only one. Is there any way to do this?
As an example, if I have two bytes 0x02 and 0x8C, and try to convert these to an unsigned 16-bit integer using U16 converter, it outputs an array [2, 140] while I need it to be converted to just 652.
Solved! Go to Solution.
03-04-2010 08:22 AM
have you tried the "Scan From String" opeartor in the String palette?
See the help on that node to see if it may help.
Ben
03-04-2010 08:26 AM
03-04-2010 08:27 AM
Also, on the Numeric >>> Data manipulation
palette you will find "Join Numbers" that will combine two byte into a U16.
Ben
03-04-2010 08:29 AM
Azzimuth wrote:
How would that help? That works with strings while I need byte array...
THat would help with the string coming from the serial port. If can be expanded and used to format multiple fields from a string.
Ben
03-04-2010 08:34 AM
Ben wrote:
Azzimuth wrote:
How would that help? That works with strings while I need byte array...
THat would help with the string coming from the serial port. If can be expanded and used to format multiple fields from a string.
Ben
Well that part is done and working fine. The only thing I need now is byte array to number conversion
03-04-2010 08:37 AM
use index array to pull out the two bytes (it can be expanded by dragging the bottm down to get two outputs).
Wire those two bytes to teh join and you are ready to go.
THere are other ways but I'll leave others to mention.
Ben
03-04-2010 08:44 AM
03-04-2010 08:47 AM