LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

visa serial read hex

I am using labVIEW 7, and cannot figure out how to configure VISA read to output HEX instead of ASCII. I am able to read from the serial port, however I am having to do a conversion from ascii to hex. I was unable to find a direct conversion from ASCII to hex so several steps are used. Can someone tell me if it is possible to read hex directly from a serial port, or if there is a good way to convert from ascii to hex?

Thanks for your help,

Jesse
0 Kudos
Message 1 of 4
(4,737 Views)
Hi Jesse,

This is a little subtle but bear with me.

When you read from the serial port and get a string, you ARE READING HEX!

I am guessing what you really want is an array of bytes that you can act on directly.

Wether it is an array of bytes or a string the data is the same. What is different is the representation.

The "type cast" (found on the advanced >>> data manipulation pallette) will let you change the represenation of your data.

You wire the data you want to change the representation of to the left input and a "type" into the top input. The "type" just tells LV what representation you want.

So...

drop a "type cast" on your diagram and wire the string to the left input. Wire a byte array to the top, and you are now free to work with t
he bytes using any number system you want (including HEX).

I hope this help,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 4
(4,737 Views)
There are also "String to Byte Array" and "Byte Array to String" functions that do this.

Type Cast can also be used if you have 16- or 32-bit data. Just wire in an array of i16's or i32's to the type input.

Brian
0 Kudos
Message 3 of 4
(4,737 Views)
0jd wrote in news:50650000000800000078DD0000-
1079395200000@exchange.ni.com:

> I am using labVIEW 7, and cannot figure out how to configure VISA read
> to output HEX instead of ASCII. I am able to read from the serial
> port, however I am having to do a conversion from ascii to hex. I was
> unable to find a direct conversion from ASCII to hex so several steps
> are used. Can someone tell me if it is possible to read hex directly
> from a serial port, or if there is a good way to convert from ascii to
> hex?

Could you use the "String to byte array" function?

Function palette->Numeric->Conversion
or (same function)
Function palette->String->String/Array/Path Conversion

--
Rolf
0 Kudos
Message 4 of 4
(4,737 Views)