Agilent Technologies 89400 Series Command Reference Manual page 489

Table of Contents

Advertisement

/****************************************************************************
*
> $Function: commandInstrument$
*
* $Description:
send a SCPI command to the instrument.$
*
* $Parameters:
$
*
(FILE *) . . . . . . . . . file pointer associated with TCP/IP socket.
*
(const char *command)
* $Return:
(char *) . . . . . . . a pointer to the result string.
*
* $Errors:
returns 0 if fprintf fails $
*
****************************************************************************/
int commandInstrument(FILE *file,
{
if (fprintf(file,"%s\n", command) < 0) return 0;
fflush(file);
return 1;
}
int main(int argc, char *argv[])
{
int instrument;
FILE *instFile;
char charBuf[256];
char *command;
char *destination;
if (argc < 3)
{
fprintf(stderr,"Usage: %s <hostname> <command>\n", argv[0]);
return 1;
}
destination = argv[1];
command = argv[2];
/**********************************************/
/* open a socket connection to the instrument */
/**********************************************/
instrument = openSocket(destination, 5025);
if (instrument == -1) return 1;
/*************************************************************/
/* create a FILE * pointer so we can use fprintf and friends */
/*************************************************************/
instFile = fdopen(instrument,"r+");
if (instFile == NULL)
{
fprintf(stderr, "Unable to create FILE * structure : %s\n",
strerror(errno));
return 1;
}
. . SCPI command string.
const char *command)
Appendix B
Sockets Example Program
479

Advertisement

Table of Contents
loading

This manual is also suitable for:

89400-90039

Table of Contents