View Source Arb (arb v0.11.0)

A NIF for controlling the ABACOM CH341A relay board.

Summary

Types

The relays are labeled from 1 to 8 according to the data sheet.

Functions

Activates the relays that correspond to the given a list of IDs. An empty list deactivates all relays.

Returns the ids of active relays.

Resets the relay board.

Types

@type relay_id() :: 1..8

The relays are labeled from 1 to 8 according to the data sheet.

Functions

Link to this function

activate(ids, opts \\ [])

View Source
@spec activate([relay_id()], Keyword.t()) :: :ok | {:error, Arb.Error.t()}

Activates the relays that correspond to the given a list of IDs. An empty list deactivates all relays.

Options

  • :port (non_neg_integer/0) - The USB port to be used. Only necessary if multiple relay boards are connected.

  • :verify (boolean/0) - Configures whether the activation should be verified. The default value is true.

Examples

iex> Arb.activate([1, 4, 7])
:ok
@spec get_active(Keyword.t()) :: {:ok, [relay_id()]} | {:error, Arb.Error.t()}

Returns the ids of active relays.

Options

  • :port (non_neg_integer/0) - The USB port to be used. Only necessary if multiple relay boards are connected.

Examples

iex> Arb.get_active()
{:ok, [1, 3, 6]}
@spec reset(Keyword.t()) :: {:ok, [relay_id()]} | {:error, Arb.Error.t()}

Resets the relay board.

If, under some circumstances relay board operations fail due to a USB error e.g. {:error, {:usb, "Input/Output Error"}}, this function may resolve the issue by resetting the relay board. The effect is similar to replugging the device.

Note: Previously activated relays stay active.

Options

  • :port (non_neg_integer/0) - The USB port to be used. Only necessary if multiple relay boards are connected.

Examples

iex> Arb.reset()
:ok