Technical data

Programming Examples 3
Agilent N8211A/N8212A Performance Upconverter Synthetic Instrument Module, 250 kHz to 20 / 40 GHz 61
Sockets on UNIX
In UNIX, LAN communication via sockets is very similar to reading or writing a file. The only
difference is the openSocket() routine, which uses a few network library routines to
create the TCP/IP network connection. Once this connection is created, the standard
fread() and fwrite() routines are used for network communication. The following
steps outline the process:
1 Copy the lanio.c and getopt.c files to your home UNIX directory. For example,
/users/mydir/.
2 At the UNIX prompt in your home directory type: cc -Aa -O -o lanio lanio.c
3 At the UNIX prompt in your home directory type: ./lanio xxxxx β€œ*IDN?” where
xxxxx is the hostname for the N8211A/N8212A. Use this same format to output SCPI
commands to the N8211A/N8212A.
The int main1() function will output a sequence of commands in a program format. If
you want to run a program using a sequence of commands then perform the following:
1 Rename the lanio.c int main1() to int main() and the original int main() to
int main1().
2 In the main(), openSocket() function, change the β€œyour hostname here” string to
the hostname of the N8211A/N8212A you want to control.
3 Re-save the lanio.c program.
4 At the UNIX prompt type: cc -Aa -O -o lanio lanio.c
5 At the UNIX prompt type: ./lanio
The program will run and output a sequence of SCPI commands to the N8211A/N8212A.
The UNIX display will show a display similar to the following:
unix machine: /users/mydir
$ ./lanio
ID: Agilent Technologies, E4438C, US70000001, C.02.00
Frequency: +2.5000000000000E+09
Power Level: -5.00000000E+000