Agilent Technologies E4406A VSA manual Programming Examples, Using C Programming Over Socket LAN

Models: E4406A VSA

1 406
Download 406 pages 63.49 Kb
Page 157
Image 157
Manual background

Programming Examples

Using C Programming Over Socket LAN

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

*

>$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;

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

*Send command to analyzer

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

command_err = commandInstrument(sock, command); if (command_err) return COMMAND_ERROR;

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

*Read response from analyzer

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

Chapter 3

157

Page 157
Image 157
Agilent Technologies E4406A VSA manual Programming Examples, Using C Programming Over Socket LAN, Chapter