Tsp-Net Instrument Commands: Tsp-Enabled Device Control; Example: Using Tspnet Commands - Keithley 2450 Reference Manual

Interactive sourcemeter instrument
Table of Contents

Advertisement

Model 2450 Interactive SourceMeter® Instrument Reference Manual

TSP-Net instrument commands: TSP-enabled device control

The following instrument commands provide TSP-enabled device control:
tspnet.tsp.abort()
tspnet.tsp.abortonconnect
tspnet.tsp.rbtablecopy()
tspnet.tsp.runscript()

Example: Using tspnet commands

function telnetConnect(ipAddress, userName, password)
-- Connect through Telnet to a computer.
id = tspnet.connect(ipAddress, 23, "")
-- Read the title and login prompt from the computer.
print(string.format("from computer--> (%s)", tspnet.read(id, "%n")))
print(string.format("from computer--> (%s)", tspnet.read(id, "%s")))
-- Send the login name.
tspnet.write(id, userName .. "\r\n")
-- Read the login echo and password prompt from the computer.
print(string.format("from computer--> (%s)", tspnet.read(id, "%s")))
-- Send the password information.
tspnet.write(id, password .. "\r\n")
-- Read the telnet banner from the computer.
print(string.format("from computer--> (%s)", tspnet.read(id, "%n")))
print(string.format("from computer--> (%s)", tspnet.read(id, "%n")))
print(string.format("from computer--> (%s)", tspnet.read(id, "%n")))
print(string.format("from computer--> (%s)", tspnet.read(id, "%n")))
end
function test_tspnet ()
tspnet.reset()
-- Connect to a computer using Telnet.
telnetConnect("192.0.2.1", "my_username", "my_password")
-- Read the prompt back from the computer.
print(string.format("from computer--> (%s)", tspnet.read(id, "%n")))
-- Change directory and read the prompt back from the computer.
tspnet.write(id, "cd c:\\\r\n")
print(string.format("from computer--> (%s)", tspnet.read(id, "%s")))
-- Make a directory and read the prompt back from the computer.
tspnet.write(id, "mkdir TEST_TSP\r\n")
print(string.format("from computer--> (%s)", tspnet.read(id, "%s")))
-- Change to the newly created directory.
tspnet.write(id, "cd c:\\TEST_TSP\r\n")
print(string.format("from computer--> (%s)", tspnet.read(id, "%s")))
-- if you have data print it to the file.
-- 11.2 is an example of data collected.
cmd = "echo " .. string.format("%g", 11.2) .. " >> datafile.dat\r\n"
tspnet.write(id, cmd)
print(string.format("from computer--> (%s)", tspnet.read(id, "%s")))
tspnet.disconnect(id)
end
test_tspnet()
2450-901-01 Rev. B/September 2013
(on page 8-245)
(on page 8-245)
(on page 8-246)
(on page 8-247)
Section 3: Functions and features
3-133

Advertisement

Table of Contents
loading

Table of Contents