From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.


Showing results for 
Search instead for 
Did you mean: 

Read in Binary form in VISA read function

Dear All,
I have connected my Device to the serial Port. and data read from the buffer is stored in text format. I want to view the data in binary format .
Actually, i have performed the same function in Visual Basic. there also if i view the data in text format, it shows some junk values. but if i view the data in binary, it shows the actual data coming from the instrument .
I dont know how to modify the VISA read function. can any one pls tell me how can i read the data in binary format?

0 Kudos
Message 1 of 13

Hi Ritesh,

what do you mean. If you read your data it should be in binary format. Where is the difference between binary and text for you?


0 Kudos
Message 2 of 13
You need to typecast the string to your appropriate data. For instance, if you want to see it as individual bytes then you can use the String to Byte Array function. If your data consists of something larger, like 16-bit integers, then use the TypeCast function.

Message Edited by smercurio_fc on 08-12-2008 10:45 AM
0 Kudos
Message 3 of 13

Boom!, Baby.  That solved my issue too.Smiley Wink




0 Kudos
Message 4 of 13

Oops!  No it didn't.


Lab VIEW 2012 (if that makes a dif)


I'm using the VISA Read function to take ADC readings in from a microcontroller.  The VISA Read function outputs the data as a string.  Easy to convert the string to U8, either with the conversion function or type cast function, and works great except for a tiny corner case when the ADC reading is zero.  The VISA Read function treats the 8-bit zero reading as a null character and strips it out.


Apparently, since this is done by the VISA Read function as it's building the string, type casting and or converting the output string from the VISA Read function doesn't "bring the zeros back".


I've tried setting the VISA property "Discard NUL Characters" to false, and that didn't seem to help.


My current work around is just to never have the micro send a zero ADC reading. 


Anyway, I'm a Lab VIEW noob, so while this isn't essential to my project, I remain curious about how to send Lab VIEW serial data that isn't automatically considered characters, thrown into a string with all the zeros stripped out.


0 Kudos
Message 5 of 13

@Who_Knew wrote:

Oops!  No it didn't.



.  The VISA Read function treats the 8-bit zero reading as a null character and strips it out.


No.  VISA Read does not strip out null characters.  There is a property node you can set for the com port that can cause null values to be stripped out.  So if you have set that somewhere, it could do it.  But the default value for that property is false.

0 Kudos
Message 6 of 13

Thanks for letting me know I'm wrong about this.  Since what I'm experiencing is different from what you claim, perhaps you could provide an example showing how it doesn't remove nulls?  Then, not only would I know I had it wrong, I'd see how to do it right too.  Thanks!


0 Kudos
Message 7 of 13

Here is how you can see what the current setting is.  Then how to set it so it doesn't discard nulls.


0 Kudos
Message 8 of 13

Awesome.  I went through the properties and found that one.  Set it to false, but it didn't seem to help.  I'll try it again.  At least I can report back what difference it makes if any.  Thanks.


0 Kudos
Message 9 of 13

You may want to check if your microcontroller is handling it properly.  Try using another serial program to see what it is doing with Null characters.  (Usually we'd suggest Hyperterminal to check on the operation of a serial port, but it isn't going to be able to show you a non-printable character like a Null character.  So look for another terminal program that can show you what comes in as Hex.)

0 Kudos
Message 10 of 13