ExDlt645.Transport behaviour (ex_dlt645 v0.1.0)

Copy Markdown View Source

Behaviour for DL/T 645 communication transport layers.

Decouples ExDlt645.Master and ExDlt645.Slave from hardware serial drivers, allowing seamless switching between real serial ports (Circuits.UART), in-memory virtual buses (ExDlt645.Transport.Virtual), and TCP connections (ExDlt645.Transport.Tcp).

Summary

Callbacks

Closes the transport connection.

Reconfigures the transport.

Flushes input/output buffers in the transport.

Opens the transport connection for the given target / tty.

Reads data from the transport with a timeout.

Starts the transport process.

Stops the transport process.

Writes raw binary data over the transport.

Functions

Resolves the transport module based on options and target identifier.

Checks if options or identifier represent a TCP connection.

Checks if the identifier represents a virtual in-memory bus.

Types

opts()

@type opts() :: keyword()

transport_ref()

@type transport_ref() :: pid() | term()

tty()

@type tty() :: String.t() | atom() | term()

Callbacks

close(transport_ref)

@callback close(transport_ref()) :: :ok | {:error, term()}

Closes the transport connection.

configure(transport_ref, opts)

@callback configure(transport_ref(), opts()) :: :ok | {:error, term()}

Reconfigures the transport.

flush(transport_ref, arg2)

@callback flush(transport_ref(), :receive | :transmit | :both) :: :ok | {:error, term()}

Flushes input/output buffers in the transport.

open(transport_ref, tty, opts)

@callback open(transport_ref(), tty(), opts()) :: :ok | {:error, term()}

Opens the transport connection for the given target / tty.

read(transport_ref, timeout)

@callback read(transport_ref(), timeout()) ::
  {:ok, binary()}
  | {:ok, {:partial, binary()}}
  | {:ok, {:error, term(), term()}}
  | {:error, term()}

Reads data from the transport with a timeout.

start_link(opts)

@callback start_link(opts()) :: {:ok, transport_ref()} | {:error, term()}

Starts the transport process.

stop(transport_ref)

@callback stop(transport_ref()) :: :ok

Stops the transport process.

write(transport_ref, binary)

@callback write(transport_ref(), binary()) :: :ok | {:error, term()}

Writes raw binary data over the transport.

Functions

resolve_transport(params, tty)

@spec resolve_transport(keyword(), tty()) :: module()

Resolves the transport module based on options and target identifier.

tcp_target?(arg1, params)

@spec tcp_target?(term(), keyword()) :: boolean()

Checks if options or identifier represent a TCP connection.

virtual_tty?(arg1)

@spec virtual_tty?(term()) :: boolean()

Checks if the identifier represents a virtual in-memory bus.