arb v0.2.2 Arb View Source

A NIF for controlling the ABACOM CH341A relay board.

Link to this section Summary

Functions

Given a list of ids turns on the corresponding relays. An empty list turns off all relays

Returns the ids of active relays

Resets the relay board

Link to this section Functions

Link to this function activate(ids, opts \\ []) View Source
activate([integer()], Arb.Native.Options.t()) :: :ok | {:error, atom()}

Given a list of ids turns on the corresponding relays. An empty list turns off all relays.

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

Options

The accepted options are:

  • :verify – configures whether the activation should be verfied (default: true)
  • :port – configures which USB port to use. Only necessary if multiple relay boards are connected (default: nil)

Examples

iex> Arb.activate([1, 4, 7])
:ok
Link to this function get_active(port \\ nil) View Source
get_active(integer()) :: {:ok, [integer()]} | {:error, atom()}

Returns the ids of active relays.

Examples

iex> Arb.get_active()
{:ok, [1, 3, 6]}
Link to this function reset(port \\ nil) View Source
reset(integer()) :: {:ok, [integer()]} | {:error, atom()}

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 reseting the relay board. The effect is similar to replugging the device.

Note: Previously activated relays stay active.

Examples

iex> Arb.reset()
:ok