120 Keysight CXG, EXG, and MXG X-Series Signal Generators Programming Guide
Programming Examples
LAN Programming Interface Examples
// Ask for sig gen ID
string
status = viWrite(instr, (ViBuf)"*IDN?\n", 6, &retCount);
// Read the sig gen
response
status = viRead(instr, (ViBuf)buffer, MAX_COUNT, &retCount);
buffer[retCount]= '\0'; // Indicate the end of
the string
printf("Signal Generator ID = "); // Print header for ID
printf(buffer); // Print the ID string
printf("\n"); // Print carriage return
// Flush the read buffer
// Set sig gen power to
-5dbm
status = viWrite(instr, (ViBuf)"POW:AMPL -5dbm\n", 15,
&retCount);
// Query the power level
status = viWrite(instr, (ViBuf)"POW?\n",5,&retCount);
// Read the power level
status = viRead(instr, (ViBuf)buffer, MAX_COUNT, &retCount);
buffer[retCount]= '\0'; // Indicate the end of
the string
printf("Power level = "); // Print header to the
screen
printf(buffer); // Print the queried power
level
printf("\n");
status = viClose(instr); // Close down the system
status = viClose(defaultRM);
return 0;
}
Sockets LAN Programming and C
The program listing shown in
“Queries for Lan Using Sockets” on page 124
consists of two files; lanio.c and getopt.c. The lanio.c file has two main
functions;
int main()
and an
int main1()
.
Содержание X-Series
Страница 4: ...4 ...
Страница 10: ...10 Contents ...