User`s guide
Programming with VISA 3
Agilent VISA User’s Guide 53
You can manually flush the read and write buffers using the
viFlush function. Flushing the read buffer also includes
reading all pending response data from a device. If the
device is still sending data, the flush process will continue to
read data from the device until it receives an END indicator
from the device.
Sample: Sending and Receiving Formatted I/O
This C sample program shows sending and receiving
formatted I/O. The sample opens a session with a GPIB
device and sends a comma operator to send a
comma- separated list. This sample program is intended to
show specific VISA functionality and does not include error
trapping. Error trapping, however, is good programming
practice and is recommended in your VISA applications. See
“Trapping Errors” in this chapter for more information.
This sample program is installed on your system in the
ProgrammingSamples subdirectory. See the IO Libraries
Suite Online Help for locations of sample programs on your
operating system.
/*formatio.c
This example program makes a multimeter
measurement with a comma-separated list passed
with formatted I/O and prints the results. You
may need to change the device address. */
#include <visa.h>
#include <stdio.h>
void main () {
ViSession defaultRM, vi;
double res;
double list [2] = {1,0.001};
/* Open session to GPIB device at address 22*/
viOpenDefaultRM(&efaultRM);
viOpen(defaultRM, "GPIB0::22::INSTR",
VI_NULL,VI_NULL, &vi);