Modbus RTU master. Reads raw UART bytes and frames replies from the request currently in flight. Only one request may be in flight at a time.
Summary
Functions
Returns a specification to start this module under a supervisor.
Closes the UART port. Returns :ok and clears any pending command.
Updates the master's connection parameters (:tty, :active, :timeout, :uart_opts) at runtime, reopening the UART port.
Opens the UART port for the configured TTY device.
Re-reads the UART for the last sent command in passive mode. Returns nil if no command has been sent yet, or :error in active mode.
Packs and sends a Modbus frame over RTU. In passive mode blocks until the slave responds; in active mode returns :ok and delivers the result to parent_pid.
Starts the RTU master GenServer. params must include :tty and may include :active, :timeout, and :uart_opts.
Returns the current internal state struct of the RTU master.
Stops the RTU master GenServer process.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec close(pid()) :: :ok
Closes the UART port. Returns :ok and clears any pending command.
Updates the master's connection parameters (:tty, :active, :timeout, :uart_opts) at runtime, reopening the UART port.
@spec open(pid()) :: :ok
Opens the UART port for the configured TTY device.
Re-reads the UART for the last sent command in passive mode. Returns nil if no command has been sent yet, or :error in active mode.
Packs and sends a Modbus frame over RTU. In passive mode blocks until the slave responds; in active mode returns :ok and delivers the result to parent_pid.
Starts the RTU master GenServer. params must include :tty and may include :active, :timeout, and :uart_opts.
@spec state(pid()) :: %Modbuv.Rtu.Master{ active: term(), cmd: term(), last_cmd: term(), parent_pid: term(), status: term(), timeout: term(), tty: term(), uart_opts: term(), uart_pid: term() }
Returns the current internal state struct of the RTU master.
@spec stop(pid()) :: :ok
Stops the RTU master GenServer process.