LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I/O Assistant Query and Parse problem.

Hi,

I am trying to use the I/O assistant with Instrument via the serial port (com1). When I use the query and parse option it only grabs the first line and parses it. For example, my command is "gc", my instrument by nature will echo that back to serial port and when the parse occurs it only receives the "gc" rather then the entire result. Using hyperterminal I get this below. What is important to me is the second line but I only read back gc for some reason with I/O assistant. Any way to parse entire result?

tp:> gc
version: gc.library 1.3.0.0 (2003.11.03)
0 Kudos
Message 1 of 6
(3,781 Views)
In your Query and Parse step you should see a termination character window. As explained in the help window when you move the mouse over the termination character window, this character terminates the read session. The default is \n or a line feed. When your instrument sends two lines, the first line ends with a line feed and the read stops before the second line is read. Set the term character to none to read the entire line. Your instrument probably requires a termination character at the end of the string you're sending so put the termination character in the command line (i.e. gc\n).
0 Kudos
Message 2 of 6
(3,781 Views)
Hi Dennis,

Thanks. I tried that before but there when I execute the command there is no way to tell when there is no more data being received, so it seems. I receive a timeout error on the read.

Timeout expired before operation completed. Visa Status Code : bfff0015

I can verify that the command is actually being executed. I am a newbie at this so bear with me.

Thanks
Scott
0 Kudos
Message 3 of 6
(3,781 Views)
One way you could work around this in the Instrument I/O Assistant is to add a Read step after the Query step. Then the Query will send the command and read up to the first '\n', and the Read will then read what is left in the buffer. This of course, assumes that there will always be two '\n' characters in the response.

-Tommy
0 Kudos
Message 4 of 6
(3,781 Views)
Hi Tommy,

Thanks, I managed to get something going. I guess you have to know exactly what your expecting in order to parse after words. I still leave the termination character on and and do two reads after the command, this seems to work fine.

Thanks for the help,
Scott
0 Kudos
Message 5 of 6
(3,781 Views)
Sorry. Forgot that the I/O Assistant would do this. Tommy's suggestion about using a second read is a good one. You can also try using the regular VISA Reads and Writes. There are several shipping examples and several more on NI Developer Zone.
0 Kudos
Message 6 of 6
(3,781 Views)