Digital Output
The digitalout library provides an interface for controlling digital outputs.
The digitalout library is available for:
- ENP-RL6 (6 hardware ports),
- ENP-RL6 M2 (6 hardware ports),
- Virtual UCM using Generic IO interface,
- Virtual UCM on Welotec Arrakis Mk3/Mk4 with DIO module installed (4 hardware ports).
digitalout.new
-- @param connection_uri string Connection URI to the digitalout device
-- @return object|nil, string|nil
function digitalout.new(connection_string)
end
Creates a new digital output client. The connection URI should specify the desired digital output device.
Example
local client, err = digitalout.new("port://do-1")
if err ~= nil then
enapter.log("Failed to create digitalout device: "..err, "error")
end
Constants
digitalout.LOW— logial low state.digitalout.HIGH— logical high state.
client Object
client:set_state
-- @param state digitalout.HIGH|digitalout.LOW
-- @return string|nil
function client:set_state(state)
end
Sets the state of the digital output. The state is digitalin.LOW when the output is open, or digitalin.HIGH when the output is closed.
On success, the function returns nil. On failure, it returns an error message string.
client:get_state
-- @return digitalout.HIGH|digitalout.LOW, string|nil
function client:get_state()
end
Returns the current state of the digital output. The state is digitalin.LOW when the output is open, or digitalin.HIGH when the output is closed.
On success, the function returns an output state and nil. On failure, it returns an nil and an error message string.
Example
local power = digitalout.new(config.read("my_do_conn_str"))
local err = power:set_state(digitalout.HIGH)
if err ~= nil then
enapter.log("Failed to set digitalout state " .. err, "error", true)
end
local state, err = power:get_state()
if err ~= nil then
enapter.log("Failed to get digitalout state " .. err, "error", true)
else
enapter.log("digitalout state " .. tostring(state) .. err)
end