02-22-2011 08:55 AM
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.
02-22-2011 09:01 AM
02-22-2011 09:02 AM - edited 02-22-2011 09:03 AM
02-22-2011 09:05 AM
02-22-2011 09:10 AM
@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.
02-22-2011 09:15 AM
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.
02-22-2011 09:17 AM - edited 02-22-2011 09:17 AM
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...
02-22-2011 09:34 AM
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?
02-22-2011 09:38 AM
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...
02-22-2011 09:41 AM
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.