LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Handling VISA READ with an empty buffer

I'm using the VIREAD function, but sometimes don't know if there is data present in the buffer. When I run it in the debugger an annoying popup comes up every time to indicate a timeout occured. When I use the serial port mode, I can determine how much data is in the buffer, but when I use any other protocal I don't know how to. How can I call viread so it just returns an empty string if the buffer is empty?
0 Kudos
Message 1 of 4
(3,488 Views)
Not using VISA for serial I/O so I'm not sure about it but... you probably can query the serial port buffer with viGetAttribute (..., VI_ATTR_ASRL_AVAIL_NUM, ...); to check if there's a message to read in.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(3,474 Views)

For my application I'm using Ethernet, but would like to be able to use a protocal indepedent method of determining if the buffer is empty or full.

0 Kudos
Message 3 of 4
(3,463 Views)

Steve,

 

Have you tried handling the error and setting your return value to empty if you get an error? If you do this, make sure to document it extremely well, or if someone ever inherits your code, they may be very confused, when that function does not throw errors. Here is a link to a good site on error handling in ANSI-C: Exceptions in C with Longjmp and Setjmp.

Richard S -- National Instruments -- (former) Applications Engineer -- Data Acquisition with TestStand
0 Kudos
Message 4 of 4
(3,443 Views)