Agilent Technologies 8714ET Switch User Manual


 
6-20 LAN Interface Supplement
Controlling the Analyzer via the LAN
Controlling the Analyzer with a C Program
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 ;
if ( *charBuf == '#' || *charBuf == '!' )
continue ;
strcat(charBuf, "\n");
if (!quiet)
{
if (number)
{
char num[10];
sprintf(num,"%d: ",number);
fwrite(num, strlen(num), 1, stdout);
}
fwrite(charBuf, strlen(charBuf), 1, stdout) ;
fflush(stdout);
}
if ( isQuery(charBuf) )
{
long bufBytes;
/* Put the query response into the same buffer as the
* command string appended after the null terminator.
*/