High Voltage SourceMeter Instrument Reference Manual Section 9: TSP-Link and TSP-
2470-901-01 Rev. A / May 2019 9-15
To communicate to a remote ethernet device from the 2470:
1. Connect to the remote device using one of the above procedures. If the 2470 cannot make
a
c
onnection to the remote device, it generates a timeout event. Use tspnet.timeout to set t
he
t
imeout value. The default timeout value is 20 s.
2. Use tspnet.write() or tspnet.execute() to send strings to a remote device. If you use:
ï‚§ tspnet.write(): Strings are sent to the device exactly as indicated, and you must supply
any needed termination characters.
ï‚§ tspnet.execute(): The 2470 appends termination characters to all strings that are sent.
Use tspnet.termination() to specify the termination character.
3. To retrieve responses from the remote instrument, use tspnet.read(). The 2470 suspends
operation until the remote device responds or a timeout event is generated. To check if data is
available from the remote instrument, use tspnet.readavailable().
4. Disconnect from the remote device using the tspnet.disconnect() function. Terminate all
remote connections using tspnet.reset().
Example script
The following example demonstrates how to connect to a remote device that is not TSP
®
enabled,
and send and receive data from this device:
-- Set tspnet timeout to 5 s.
tspnet.timeout = 5
-- Establish connection to another device with IP address 192.168.1.51
-- at port 1394.
id_instr = tspnet.connect("192.168.1.51", 1394, "*rst\r\n")
-- Print the device ID from connect string.
print("ID is: ", id_instr)
-- Set the termination character to CRLF. You must do this
-- for each connection after the connection has been made.
tspnet.termination(id_instr, tspnet.TERM_CRLF)
-- Send the command string to the connected device.
tspnet.write(id_instr, "login admin\r\n")
-- Read the data available, then print it.
tspnet.write(id_instr, "*idn?\r\n")
print("instrument write/read returns: ", tspnet.read(id_instr))
-- Disconnect all existing TSP-Net sessions.
tspnet.reset()
This example produces a return such as:
ID is: 1
instrument write/read returns: SUCCESS: Logged in
instrument write/read returns: KEITHLEY INSTRUMENTS,MODEL 2470,04089762,1.6.3d