Modbuv.Rtu.Slave (modbuv v0.1.0)

Copy Markdown View Source

Modbus RTU slave. The UART runs with Modbuv.Rtu.Framer in active mode; complete frames are decoded, applied to the shared DB, and answered.

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns the raw DB map currently held by the slave's shared model.

Sends raw bytes directly over the UART without any framing or encoding. Useful for injecting pre-built RTU frames or test data.

Applies a frame tuple to the slave's local DB, similar to Tcp.Server.update/2. Validates the frame against the fc_map and returns the result.

Starts the RTU slave GenServer. params must include :tty and :model, and may include :active, :timeout, :uart_opts, and :fc_map.

Returns the current internal state struct of the RTU slave.

Stops the RTU slave GenServer process.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_db(pid)

@spec get_db(pid()) :: map()

Returns the raw DB map currently held by the slave's shared model.

raw_write(pid, data)

@spec raw_write(pid(), binary()) :: :ok

Sends raw bytes directly over the UART without any framing or encoding. Useful for injecting pre-built RTU frames or test data.

request(pid, frame)

@spec request(pid(), tuple()) :: term()

Applies a frame tuple to the slave's local DB, similar to Tcp.Server.update/2. Validates the frame against the fc_map and returns the result.

start_link(params, gen_opts \\ [])

@spec start_link(keyword(), keyword()) :: {:ok, pid()} | {:error, term()}

Starts the RTU slave GenServer. params must include :tty and :model, and may include :active, :timeout, :uart_opts, and :fc_map.

state(pid)

@spec state(pid()) :: %Modbuv.Rtu.Slave{
  fc_map: term(),
  model_pid: term(),
  parent_pid: term(),
  status: term(),
  tty: term(),
  uart_opts: term(),
  uart_pid: term()
}

Returns the current internal state struct of the RTU slave.

stop(pid)

@spec stop(pid()) :: :ok

Stops the RTU slave GenServer process.