Usage of NI I/O trace to monitor the SCPI traffic
The NI I/O Trace is a communication tracing tool by National Instruments which is delivered along with e.g. NI MAX. It can be started out of NI MAX and used either in combination with NI MAX or to monitor any network trafic.
Start NI I/O Trace out of NI Max
In the NI Max main menu click on Tools -> NI I/O Trace
Start capture in NI I/O Trace
In the NI I/O Trace main menu click on Tools -> Start capture
Try out NI I/O Trace using NI Max
Send a request using NI Max and verify the corresponding tracing in NI I/O Trace
Try out NI I/O Trace using a Python script with PyVisa
Send a request using a Python script and verify the corresponding tracing in NI I/O Trace. See also the Phython SCPI examples
Preconditions
Before running the examples start the SCPI server, verify and adapt the IP-address and the port number in the python code. The connection to the SCPI server can be verified using NI MAX.
The PyVISA package must be added to the used Python projects. The currently used version ist the 1.11.3.
# use pyvisa or similar package
import pyvisa # required library for Visa communication -- the PyVISA package must be added to the Python project
# adapt IP address and SCPI port according to your needs
SCPI_server_IP = '172.22.44.29'
SCPI_Port = '5025'
VISA_resource_name = 'TCPIP::' + SCPI_server_IP + '::' + SCPI_Port + '::SOCKET'
print('Trying to connect to VISA resource: ' + VISA_resource_name)
visaSession = pyvisa.ResourceManager().open_resource(VISA_resource_name)
visaSession.read_termination = '\n'
print('SCPI client connected to SCPI server: ' + visaSession.query("*IDN?"))