Instrument Control (GPIB, Serial, VISA, IVI)

Showing results for 
Search instead for 
Did you mean: 

I can't read ascii characters from 1 to 31

I am doing a software able to read on a serial port.
I have a problem reading ascii characters from 1 to 31. In fact, I can't read them with VISA Read. The program return each time a ? instead of the value.
0 Kudos
Message 1 of 9
Please post more specifics. Can you recieve other ASCII charcters? The first 32 chars are control charcters (like CR which is 13 or LF which is 10) so they don't have any visual representation, which is why you're getting a ?. Use the String to Byte array VI to convert the character into the ascii number and this way you can see if you are getting the chars.

Try to take over the world!
0 Kudos
Message 2 of 9
Yes, I can read others characters but I can't read ascii characters from 1 to 31.
I gonna try what you advise. Do you have some examples concerning the use of String to Byte.
I am sorry for my english I am french.
Thanks a lot for your help.
Message 3 of 9
The ASCII standard represents each character with a byte, so it can represent 256 different characters. The string to Byte Array VI (which can be found in the String\Array\Path Conversion subpalette in the String palette) translates the string to a 1D U8 (that's a byte) array, where each element is one character. For instance, if you wire the string "ABC" into it, you'll get the array [65,66,67]. Create a for loop that will run 256 times and wire i out of the loop. Wire the resulting 1D array into the Byte Array to String VI and you'll get the entire ASCII table in one string. Also, search google for "ASCII table" for more data on this.

Try to take over the world!
0 Kudos
Message 4 of 9
I tried what you recommand to me but I have always the same problem. I tested the Visa Interface and it seems not to be adapted to receive the non printable characters. Do you have an idea about which object I can use to realize my software.
hanks very much in advance
0 Kudos
Message 5 of 9

You need to convert your ASCII characters into ASCII characters. You will find example here.

Hope this help
Ingénieur d'applications
National Instruments France
0 Kudos
Message 6 of 9
Thanks you for your reply. My problem is just after the VISA Read. In fact, it gives me a ? instead of the right value in the read buffer. That's why I can't convert the string into hexa. It is useless because it converts the ? character into his hexa code. I think that the real problem is the VISA Read because it gives a string buffer and the character sent is an unprintable character so it returns a ? because it doesn't know how to return an unprintable character.
Do you have some idea ?
0 Kudos
Message 7 of 9
There is nothing wrong with VISA Read. The read buffer contains the exact characters received. You should be able to convert it to hex or "\" codes by following the instructions in the app note. If you have the read buffer connected to a string indicator, right click the indicator and select either Hex or "\" Codes Display. If you don't have an indicator, do not use a regular probe. You would need to create a custom probe to view the buffer correctly.
0 Kudos
Message 8 of 9
Thanks you very much. You were right. It works correctly now.
0 Kudos
Message 9 of 9