Technical data
Programming Fundamentals 28
Agilent N8201A Performance Downconverter Synthetic Instrument Module, 250 kHz to 26.5 GHz 619
/*Initialize device */
viPrintf (vi, "*RST\n");
/*Send an *IDN? string to the device */
printf (vi, "*IDN?\n");
/*Read results */
viScanf (vi, "%t", &buf);
/*Print results */
printf ("Instrument identification string: %s\n",
buf);
/* Close sessions */
viClose (vi);
viClose (defaultRM);
}
Including the VISA Declarations File
For C and C++ programs, you must include the visa.h header file at the beginning of
every file that contains VTL function calls:
#include "visa.h"
This header file contains the VISA function prototypes and the definitions for all VISA
constants and error codes. The visa.h header file includes the visatype.h header file.
The visatype.h header file defines most of the VISA types. The VISA types are used
throughout VTL to specify data types used in the functions. For example, the
viOpenDefaultRM function requires a pointer to a parameter of type ViSession. If you
find ViSession in the visatype.h header file, you will find that ViSession is
eventually typed as an unsigned long.
Opening a Session
A session is a channel of communication. Sessions must first be opened on the default
resource manager, and then for each device you will be using. The following is a summary
of sessions that can be opened:
• A resource manager session is used to initialize the VISA system. It is a parent session
that knows about all the opened sessions. A resource manager session must be opened
before any other session can be opened.
• A device session is used to communicate with a device on an interface. A device
session must be opened for each device you will be using. When you use a device
session you can communicate without worrying about the type of interface to which it is
connected. This insulation makes applications more robust and portable across
interfaces. Typically a device is an instrument, but could be a computer, a plotter, or a
printer.