Programming instructions

Programming Examples
LAN Programming Examples
Chapter 266
char buf[256]; // Variable for id string
ionerror(I_ERROR_EXIT); // Register SICL error handler
// Open SICL instrument handle using VXI-11 protocol
sprintf(instNameBuf, "lan[%s]:inst0", instrumentName);
id = iopen(instNameBuf); // Open instrument session
itimeout(id, 1000); // Set 1 second timeout for operations
printf("Setting frequency to 1 Ghz...\n");
iprintf(id, "freq 1 GHz\n"); // Set frequency to 1 GHz
printf("Waiting for source to settle...\n");
iprintf(id, "*opc?\n"); // Query for operation complete
iscanf(id, "%d", &opcResponse); // Operation complete flag
if (opcResponse != 1) // If operation fails, prompt user
{
printf("Bad response to ’OPC?’\n");
iclose(id);
exit(1);
}
iprintf(id, "FREQ?\n"); // Query the frequency
iscanf(id, "%t", &buf); // Read the signal generator frequency
printf("\n"); // Print the frequency to the display
printf("Frequency of signal generator is %s\n", buf);
ipromptf(id, "*IDN?\n", "%t", buf);// Query for id string
printf("Instrument ID: %s\n", buf);// Print id string to display
iclose(id); // Close the session
return 0;
}
VXI-11 Programming Using VISA and C
The following program uses the VXI-11 protocol and the VISA library to control the signal
generator. The signal generator is set to a 1 GHz CW frequency and queried for its ID string.
Before running this code, you must set up the interface using the Agilent IO Libraries IO
Config utility.
The following program example is available on the ESG Documentation CD-ROM as
vxivisa.cpp.
//****************************************************************************************
// PROGRAM FILE NAME:vxivisa.cpp
// Sample test program using the VISA libraries and the VXI-11 protocol
//
// NOTE: You must have the Agilent Libraries installed on your computer to run
// this program
//
// PROGRAM DESCRIPTION:This example uses the VXI-11 protocol and VISA to query
// the signal generator for its ID string. The ID string is then printed to the