LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial communication without string

hi,

    i am using basic serial write read example from labview examples. i want to communicate the device with hex format commands and i need to write hex commands into the device. The write visa is looking like it will take only string format but i need to communicate only with hex numbers. i dont want to make any string to write. Is there any way to write hex commands into device without string format.

0 Kudos
Message 1 of 13
(3,908 Views)

Hi shjukheter,

 

there is no way to use VISA-Write without using string data. So you have to convert your hex numbers into string - and you will find a lot of threads on that very topic!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(3,906 Views)
0 Kudos
Message 3 of 13
(3,904 Views)

Hi smercurio,

 

GerdW wrote: "There is no way ... without string data"

smercurio wrote: "There's a way"

 

Ehm - what is the pink line in your snippet?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 13
(3,897 Views)

 


@GerdW wrote:

Hi smercurio,

 

GerdW wrote: "There is no way ... without string data"

smercurio wrote: "There's a way"

 

Ehm - what is the pink line in your snippet?


 

The forums editor does not allow you to post a reply without having some text, so I just put in some dummy text in there temporarily which I would delete when going back to edit the post to insert the image. Oddly enough, the forums editor allows you to remove the message body on an edit.

 

My message wasn't intended to indicate that you could wire a non-string to VISA Write. Rather, to show what to do. Sorry for the confusion.

0 Kudos
Message 5 of 13
(3,886 Views)

Yes, in the same way while reading the data also we should read only strings. Is that right?, So, only string communication is possible in labview. However really confused with these stuff because pink color indicates a string data in labview but my instructor is asking for hex coomunication. I dont want to send string to the device. is it possible in labview.

0 Kudos
Message 6 of 13
(3,880 Views)

Hi shjukheter,

 

yes, it is possible and was shown some message before...

 

You have to convert from/to string when using VISA-Write/Read. Keep in mind: a string is just a bunch of bytes using ASCII representation (atleast in current LabVIEW versions)! You can even switch to hex (or slash) display to show non-printable chars...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 13
(3,876 Views)

suppose, if i want to write a command which is in hex, then i will change the poperties in hex then proceed by writing the command to device. In another case the device will send only hex, so that time i will change proerties to hex and then i will read the data back.

Is that correct?...what is wrong with string communication compared with hex number communication? does it take much space than normal hex communication?

0 Kudos
Message 8 of 13
(3,859 Views)

Hi shjukheter,

 

you have to define what you understand by "hex"! That's why I wrote: "you will find a lot of threads on that topic"!

 

smercurio showed a way on how to convert hex numbers to a string, for backconversion you will find a similar function in the same palette.

When you are talking about hex string you have to define their format before we can suggest a specific conversion if any is needed...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 13
(3,855 Views)

There is no difference between "hex communication" and string. You're getting too fixated on the terms. All you're doing is sending a stream of bytes. That's all the serial driver cares about. All strings are composed of characters, and each character has a numeric value. The value can be written in decimal notation, hex, octal, binary, or cuneiform. It doesn't matter, so stop being fixated on this. Instead of an array of numeric values you could just as well have a string constant, and set its display format to "hex". This allows you to enter "hex values" directly in the string. It's six of one and half a dozen of another. If you use numeric arrays like the example I showed you then you just need to use the Byte Array to String, and for the VISA Read you'd use String to Byte Array if you wanted to have the return value as a numeric array.

0 Kudos
Message 10 of 13
(3,853 Views)