Example: Using Tspnet Commands - Keithley 3700A Series Reference Manual

System switch/multimeter
Hide thumbs Also See for 3700A Series:
Table of Contents

Advertisement

Section 10: Instrument programming

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()
10-68
Series 3700A System Switch/Multimeter Reference Manual
3700AS-901-01 Rev. D/June 2018

Advertisement

Table of Contents
loading

Table of Contents