Agilent Technologies N5183A Portable Generator User Manual


 
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 115
Programming Examples
LAN Programming Interface Examples
* Simpler UNIX version, using file I/O. recv() version works too.
* This demonstrates how to use file I/O on sockets, in UNIX.
***********************************************************************/
FILE * instFile;
instFile = fdopen(sock, "r+");
if (instFile == NULL)
{
fprintf(stderr, "Unable to create FILE * structure : %s\n",
strerror(errno));
exit(2);
}
return fgets(result, maxLength, instFile);
#endif
}
/***************************************************************************
*
> $Function: queryInstrument$
*
* $Description: send a SCPI command to the instrument, return a response.$
*
* $Parameters: $
* (FILE *) . . . . . . . . . file pointer associated with TCP/IP socket.
* (const char *command) . . SCPI command string.
* (char *result) . . . . . . where to put the result.
* (size_t) maxLength . . . . maximum size of result array in bytes.
*
* $Return: (long) . . . . . . . The number of bytes in result buffer.
*
* $Errors: returns 0 if anything goes wrong. $
*
***************************************************************************/
long queryInstrument(SOCKET sock,
const char *command, char *result, size_t maxLength)
{
long ch;
char tmp_buf[8];
long resultBytes = 0;
int command_err;
int count;