
Programming with VISA
3
Agilent VISA User’s Guide
43
Example: Sending and Receiving Formatted I/O
The following
C sample program demonstrates sending and receiving formatted I/O.
The program opens a session with a GPIB device and sends a comma
operator to send a comma-separated list. This program shows specific
VISA functionality and does not include error trapping.
This example program is installed on your system in the
ProgrammingSamples
subdirectory.
/*formatio.c
This example program makes a dmm 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);
/* Initialize device */
viPrintf(vi, "*RST\n");
/* Set-up device,send comma-separated list */
viPrintf(vi, "CALC:DBM:REF 50\n");
viPrintf(vi, "MEAS:VOLT:AC? %,2f\n", list);
/* Read results */
viScanf(vi, "%lf", &res);
/* Print results */
printf("Measurement Results: %lf\n", res);
/* Close session */
viClose(vi);
viClose(defaultRM);
}
Summary of Contents for E2094S
Page 6: ...6 Agilent VISA User s Guide ...
Page 116: ...116 Agilent VISA User s Guide 4 Programming via GPIB and VXI ...
Page 126: ...126 Agilent VISA User s Guide 5 Programming via LAN ...
Page 143: ...Glossary Agilent VISA User s Guide 143 Windows notification area See notification area ...