LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Serial Read/Write buffer leftovers

LabView 5.1, Windows 2000 - I'm using the instrument driver template to build a VISA driver for a GPS receiver. Using VISA writes & reads gives the unusual behavior of 1) Send Position Command, 2) Receive Position Response, 3) Send Status Command, 4) Recieve (new) Position Response, 5) Send Status Command, 6) Receive Status Response.

Single-stepping with the debugger forces the code to work correctly.

Adding a buffer flush after reading results in no data being available for the next command. Adding a read before the VISA write results in no data being available for the next command. It seems that the VISA Write node fires before the new incoming command string appears at the input terminal.

Anyone have suggestions how
to fix this? Thanks!

David.Huggins@Riverside.net
0 Kudos
Message 1 of 3
(2,561 Views)
It sounds like maybe you have a race condition of some kind. Are you using local variables? You have to be careful with them because the code might read what is in them before they have the data you want in them.

Or you are trying to read back from the instrument before the data is ready. Try putting a small delay inbetween your write and read. Running in debug mode would automatically add delay between the functions. This was the solution to a similar problem that I recently had. Also make sure you termination characters are setup correctly so that VISA knows when it gets to the end of a message.

Hope this helps
Brian
0 Kudos
Message 2 of 3
(2,561 Views)
Thanks Brian, this is my first VISA application and I thought VISA would auto-magically do the right thing for me. I added some "wait for data to appear" loops and got the routines working smoothly.
0 Kudos
Message 3 of 3
(2,561 Views)