# `Modbuv.Rtu.Slave`
[🔗](https://github.com/ultra0224/modbuv/blob/v0.1.0/lib/modbuv/rtu/slave.ex#L1)

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

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `get_db`

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

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

# `raw_write`

```elixir
@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`

```elixir
@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`

```elixir
@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`

```elixir
@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`

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

Stops the RTU slave GenServer process.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
