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 165
Image 165
Manual background

Programming Examples

Using C Programming Over Socket LAN

if (instSock == INVALID_SOCKET) { fprintf(stderr, "Unable to open socket.\n"); return 1;

}

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

if (strlen(command) > 0)

{

/********************************************************/ /* if the command has a ’?’ in it, use queryInstrument. */

/* otherwise, simply send the command.*/ /********************************************************/ if ( isQuery(command) )

{

long bufBytes;

bufBytes = queryInstrument(instSock, command, charBuf, INPUT_BUF_SIZE);

if (!quiet)

{

fwrite(charBuf, bufBytes, 1, stdout); fwrite("\n", 1, 1, stdout) ; fflush(stdout);

}

}

else

{

commandInstrument(instSock, command);

}

}

else

{

/* read a line from <stdin> */ while ( gets(charBuf) != NULL )

{

if ( !strlen(charBuf) ) continue ;

Chapter 3

165

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