Technical data

32 N9320A Programmer’s Guide
4 Programming Example
Example Program
This example program queries a USB device for an
identification string and prints the results. Note that you
must change the address if something other than the default
USB address value is required.
/*idn.c - program filename */
#include "visa.h"
#include <stdio.h>
void main ()
{
/*Open session to USB device */
viOpenDefaultRM(&defaultRM);
viPrintf
viScanf
These are the VTL formatted I/O functions that are patterned after
those used in the C programming language. The viPrintf call
sends the SCPI commands to the analyzer. The viPrintf call can
also be used to query the analyzer. The viScanf call is then used
to read the results.
viWrite This function synchronously sends the data pointed to by buf to
the device specified by vi. Only one synchronous write operation
van occur at any one time.
viWrite(vi, buf, count, &retCount)
viRead This function synchronously reads raw data from the session
specified by the vi parameter and stores the result in location
where buf is pointing. Only one synchronous read operation can
occur at any one time.
viRead(vi, buf, count, &retCount)
viClose This function must be used to close each session. When you close
a device session, all data structures that had been allocated for the
session will be set free. If you close the default resource manager
session, all sessions opened using that resource manager session
will be closed.
viClose(vi);
viClose(defaultRM)