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
3700AS,04089762,1.6.3d
Using TSP-Net with any ethernet-enabled instrument
Refer to TSP command reference (on page 11-1) for details about the commands presented in this
section.
The Series 3700A LAN port is auto-sensing (Auto-MDIX), so you can use either a LAN crossover
cable or a LAN straight-through cable to connect directly from the Series 3700A to an ethernet device
or to a hub.
To set up communication to a remote ethernet-enabled instrument that is TSP
®
enabled:
1. Send the following command to configure TSP-Net to send an abort command when a
connection to a TSP instrument is established:
tspnet.tsp.abortonconnect = 1
If the scripts are allowed to run, the connection is made, but the remote instrument may be busy.
2. Send the command:
connectionID = tspnet.connect(ipAddress)
Where:
â–ª connectionID is the connection ID that will be used as a handle in all other TSP-Net function calls.
â–ª ipAddress is the IP address, entered as a string, of the remote instrument.
See tspnet.connect() (on page 11-434) for additional detail.