Using Socket To Send Commands - Keysight N9320B Programmer's Manual

Spectrum analyzer
Hide thumbs Also See for N9320B:
Table of Contents

Advertisement

Getting Started
Remotely Operating Your N9320B

Using Socket to Send Commands

8
N9320B implements a socket Applications Programming Interface
(API) compatible with Berkeley sockets, Winsock, and other
standard sockets APIs. You can use sockets to control N9320B by
sending SCPI commands to a socket connection. You can program
by only the socket function or the VISA function. Both the VISA
assistant and the IO libraries suite is available for remote control.
Please refer to the following C# programming example to use the
socket calss function.
private IPAddress serveraddrSA; //define the tcp
server
public TcpClient clientSA;
client
/*initiate the server and client and create the
connection*/
private void InitialSA(string ip, int port)
{
serveraddrSA = IPAddress.Parse(ip);
clientSA = new TcpClient();
clientSA.Connect(serveraddrSA, port);
}
/*send the SCPI to instrument, MUST add end flag
at the end of the command*/
private void SendSA(string cmd)
{
string endchar = "\n" ;
clientSA.Client.Send(System.Text.Encoding.Default.Get
Bytes(cmd+endchar));
}
/*send the read SCPI to instrument, MUST add end flag
at the end of the command, and then return the
result*/
private string ReadSA(string cmd)
{
int bytes = 0;
Byte[] RecvBytes = new Byte[8192];
string endchar = "\n";
SendSA(cmd+endchar);
bytes = clientSA.Client.Receive(RecvBytes,
RecvBytes.Length, 0);
//define the tcp

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents