Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide 117
Programming Examples
LAN Programming Interface Examples
int main(int argc, char* argv[])
{
INST id; // Device session id
int opcResponse; // Variable for
response flag
char instrumentName[] = "xxxxx"; // Put your instrument's
hostname here
char instNameBuf[256];// Variable to hold instrument name
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);
Summary of Contents for X-Series
Page 4: ...4 ...
Page 10: ...10 Contents ...