lxi.lua

local args = otii.get_args()
assert(#args < 3, "Too many arguments")
assert(#args == 2, "Provide a IP address to the instrument")
local agilent = args[2]

-- Clear screen
otii.clear()

-- Connecting to instrument
otii.writeln("Connecting to instrument...")
local lxi, errormsg = otii.lxi_connect(agilent)
if lxi == nil then
    error("Cannot connect to instrument: " .. errormsg)
end
otii.writeln("connected")

-- Read value
local value = lxi:read()
otii.writeln(value)

-- Send a command that returns a result
local result = lxi:get("READ?")
otii.writeln(tonumber(result))

-- Send a command that is not expected to return a result
local state = lxi:set("VOLTAGE:RANGE 10")
otii.writeln(state)

-- Disconnect
lxi:disconnect()
generated by LDoc 1.4.6 Last updated 2020-11-13 10:24:46