S820E Microwave Site Master™ Programming Manual : General Information : Sending SCPI Commands
 
Sending SCPI Commands
SCPI commands can be sent to the instrument through any Virtual Instrument Software Architecture (VISA) controller. VISA is a commonly used API in the Test and Measurement industry for communicating with instruments from a PC. The physical connection between the PC and the instrument is USB or Ethernet. NI-VISA is the National Instruments implementation of the VISA I/O standard. Information and downloads are available at: http://www.ni.com/visa/
The following example describes the verification that a VISA controller can interact with the instrument. The images shown and the instructions for your instrument and software may differ from the examples.
USB Connectivity
1. On the PC, run NI Measurement & Automation Explorer or VISA Interactive Control and double-click on the TMC Class instrument.
Figure 1-4. NI Measurement & Automation Explorer
2. Verify that the USB Settings list the correct Manufacturer, Model, and Serial Number, as shown in the example below.
NI VISA Interactive Control USB Configurations / Settings Tab.
3. Select the Input/Output Basic I/O tab and execute the default *IDN? Query. If the PC is connected to the instrument the command returns the following information from the Buffer: manufacturer name (“Anritsu”), model number/options, serial number, and firmware package number, as shown in the example below.
NI VISA Interactive Control USB Basic I/O Tab.
Ethernet Connectivity
1. On the PC, run NI Measurement & Automation Explorer or VISA Interactive Control and create a new LAN Resource under Network Devices. Add the TCP/IP resource using a Manual Entry of Raw Socket, as shown in the example below.
NI VISA Interactive Control LAN resource addition using Raw Socket.
2. Enter the IP address that the instrument has acquired (go to System, Status, Connectivity Info). Enter the port number as 9001, as shown in the example below.
NI VISA Interactive Control LAN resource settings of IP address and port number.
NI VISA Interactive Control LAN resource validated.
3. Select the Configuration I/O settings tab and verify that the Termination Methods are set as shown in the example below.
NI VISA Interactive Control LAN resource I/O Termination Method Settings
4. Select the Input/Output Basic I/O tab and execute the default *IDN? Query. If the PC is connected to the instrument the command returns the following information from the Buffer: manufacturer name (“Anritsu”), model number/options, serial number, and firmware package number, as shown in the example below.
NI VISA Interactive Control USB Basic I/O Tab.
 
Note 
When sending SCPI commands over Ethernet, it is required to send a newline termination character at the end of each command. In the example above, a newline character ("\n" in this case, but could be different depending on your programming environment) was used to terminate the *IDN? command.
Note 
When sending query commands over raw socket, the entire buffer must be read before the next query command is sent. Each query result is terminated by a newline to help identify the end of the query response. Query read operations could be broken into multiple reads, if necessary.
Note 
When using raw socket connections, you must close a session before opening a new one or before switching to a new protocol (such as USB). If you try to open a new session or switch protocols without first closing the previously opened session, you may lose communications with the instrument and not be able to reconnect until you reboot the instrument.