Technical data

Programming Fundamentals 28
Agilent N8201A Performance Downconverter Synthetic Instrument Module, 250 kHz to 26.5 GHz 603
N8201A.Connect("N8201A",5025);
NetworkStream ioStream = N8201A.GetStream();
// Next, send the N8201A the query to obtain the port number assigned to this SCPI
// channel's control port. We must do this every time we create a new TcpClient to
// the N8201A.
Byte[] sendBytes = Encoding.UTF8.GetBytes ("SYST:COMM:LAN:SCPI:SOCK:CONT?\n");
ioStream.Write (sendBytes, 0, sendBytes.Length);
byte[] reply = new byte[80];
ioStream.Read(reply,0,80);
string returndata = Encoding.UTF8.GetString(reply);
int port = Convert.ToInt32(returndata);
// We now have the port number and can send the N8201A a device clear. As an example,
// we put the N8201A into single sweep and start a 100 second sweep. Next we sleep for
// five seconds and then send the device clear. One the front panel of the N8201A, you
// will notice that the 100 second sweep starts and then, five seconds later,
// restarts again. The restart is the result of the device clear we sent.
byte[] cmd = Encoding.UTF8.GetBytes("INIT:CONT OFF;:SWE:TIME 100;:INIT:IMM\n");
ioStream.Write(cmd,0,cmd.Length);
// sleep so the device clear become obvious
Thread.Sleep(5000);
string host = "N8201A"; // once again replace N8201A with your hostname
doDcas(host,port); // now do the device clear