beautypg.com

Agilent Technologies N5183A MXG User Manual

Page 135

background image

Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide

125

Programming Examples

LAN Programming Interface Examples

char *charBuf = (char *) malloc(INPUT_BUF_SIZE);

/*********************************************/

/* open a socket connection to the instrument*/

/*********************************************/

#ifdef WINSOCK

if (init_winsock() != 0) {

exit(1);

}

#endif /* WINSOCK */

instSock = openSocket("xxxxxx", SCPI_PORT); /* Put your hostname here */

if (instSock == INVALID_SOCKET) {

fprintf(stderr, "Unable to open socket.\n");

return 1;

}

/* fprintf(stderr, "Socket opened.\n"); */

bufBytes = queryInstrument(instSock, "*IDN?\n", charBuf, INPUT_BUF_SIZE);

printf("ID: %s\n",charBuf);

commandInstrument(instSock, "FREQ 2.5 GHz\n");

printf("\n");

bufBytes = queryInstrument(instSock, "FREQ:CW?\n", charBuf, INPUT_BUF_SIZE);

printf("Frequency: %s\n",charBuf);

commandInstrument(instSock, "POW:AMPL -5 dBm\n");

bufBytes = queryInstrument(instSock, "POW:AMPL?\n", charBuf, INPUT_BUF_SIZE);

printf("Power Level: %s\n",charBuf);

printf("\n");

#ifdef WINSOCK

closesocket(instSock);

close_winsock();

#else

close(instSock);

#endif /* WINSOCK */

return 0;

}

/***************************************************************************

This manual is related to the following products: