Models 707B and 708B Switching Matrix Reference Manual
Section 6: Instrument programming
707B-901-01 Rev. A / August 2010
6-57
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:
-- Disconnect all existing TSP-Net connections.
tspnet.reset()
-- Set tspnet timeout to 5 seconds.
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 termination character to CRLF. You must do this
-- on a per connection basis after connection has been made.
tspnet.termination(id_instr, tspnet.TERM_CRLF)
-- Send the command string to the connected device
tspnet.write(id_instr, "*idn?" .. "\r\n")
-- Read the data available, then prints it.
print("instrument write/read returns:: , tspnet.read(id_instr))
-- Disconnect all existing TSP-Net sessions.
tspnet.reset()