Skip to main content

Digital OutputHardware UCMVirtual UCM

The digitalout library provides an interface for controlling digital outputs.

The digitalout library is available for:

digitalout.new

-- @param connection_uri string Connection URI
-- @return object|nil, string|nil
function digitalout.new(connection_uri)
end

Creates a new digital output client. The connection URI should specify the desired digital output device.

Use port schema to access hardware ports. On Virtual UCM you may also use gio schema for Generic IO.

On failure, it returns nil and an error message string.

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 — low state of output.
  • digitalout.HIGH — high state of output.

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 digitalout.LOW when the output is open, or digitalout.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 digitalout.LOW when the output is open, or digitalout.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 err = client:set_state(digitalout.HIGH)
if err ~= nil then
enapter.log("Failed to set digitalout state " .. err, "error")
end
local state, err = power:get_state()
if err ~= nil then
enapter.log("Failed to get digitalout state " .. err, "error")
else
enapter.log("digitalout state " .. tostring(state) .. err)
end

All Rights Reserved © 2025 Enapter AG.