Agilent Technologies ES Switch User Manual


 
6-10 LAN Interface Supplement
Controlling the Analyzer via the LAN
Controlling the Analyzer with a C Program
/*
****************************************************************************
* $Header: lanio.c,v 1.5 96/10/04 20:29:32 roger Exp $
* $Revision: 1.5 $
* $Date: 96/10/04 20:29:32 $
*
* $Contributor: LSID, MID $
*
* $Description: Functions to talk to an HP 8711C/12C/13C/14C/30A
* analyzer via TCP/IP. Uses command-line arguments.
*
* A TCP/IP connection to port 5025 is established and
* the resultant file descriptor is used to "talk" to the
* instrument using regular socket I/O mechanisms. $
*
*
*
* 871xC Examples:
*
* Query the center frequency:
* lanio 15.4.43.5 'sens:freq:cent?'
*
* Select Lin Mag format:
* lanio my8711.sr.hp.com 'CALC:FORM MLIN'
*
* Take a sweep, wait for end of sweep, move mkr to peak and query x pos:
* lanio my8711 ':abort;INIT:CONT OFF;:INIT1;*wai; :calc:mark:max; x?'
*
* Query X and Y values of marker 1 and marker 2 (assumes they are on):
* lanio my8711 'calc:mark1:x?;y?; :calc:mark2:x?;y?'
*
* Check for errors (gets one error):
* lanio my8711 'syst:err?'
*
* Send a list of commands from a file, and number them:
* cat scpi_cmds | lanio -n my8711
*
****************************************************************************
*
* This program compiles and runs under
* - HP-UX 9.05 (UNIX), using HP cc or gcc:
* + cc -Aa -O -o lanio lanio.c
* + gcc -Wall -O -o lanio lanio.c
*
* - Windows 95, using Microsoft Visual C++ 4.0 Standard Edition
* - Windows NT 3.51, using Microsoft Visual C++ 4.0
* + Be sure to add WSOCK32.LIB to your list of libraries!
* + Compile both lanio.c and getopt.c
* + Consider re-naming the files to lanio.cpp and getopt.cpp
*
* Considerations:
* - On UNIX systems, file I/O can be used on network sockets.
* This makes programming very convenient, since routines like
* getc(), fgets(), fscanf() and fprintf() can be used. These
* routines typically use the lower level read() and write() calls.
*
* - In the Windows environment, file operations such as read(), write(),
* and close() cannot be assumed to work correctly when applied to
* sockets. Instead, the functions send() and recv() MUST be used.
*/