# `AVModbus.Server.RTU`
[🔗](https://github.com/piyopiyoex/avmodbus/blob/v0.1.0/lib/avmodbus/server/rtu.ex#L1)

serial transport 上で動作する Modbus RTU server process です。

1 本の UART を所有し、fragmented request の再構築、line noise の除去、unit filtering、
no-response の broadcast write を処理し、request semantics は `AVModbus.Server` に委譲します。

`start_link/2` は configured AtomVM UART を開き、`:serial` option で instance ごとに設定を上書きできます。
`start_link/4` は open 済み transport handle を受け取り、UART を application 側で管理する場合や
host-side tests に利用できます。

# `option`

```elixir
@type option() ::
  {:mode, :rtu | :ascii}
  | {:units, [1..247]}
  | {:echo, boolean()}
  | {:silence, pos_integer()}
  | {:gap, non_neg_integer()}
  | {:serial, keyword()}
  | {:handler_timeout, pos_integer() | :infinity}
  | {:backoff, {pos_integer(), pos_integer()}}
  | {:authorize, AVModbus.Server.authorize() | nil}
  | {:identification, AVModbus.Server.Identification.objects() | nil}
  | {:name, atom()}
```

# `server`

```elixir
@type server() :: pid() | atom()
```

# `start_link`

```elixir
@spec start_link(AVModbus.Server.handler(), [option()]) ::
  {:ok, pid()} | {:error, term()}
```

configured UART を開き、`handler` 用の RTU server を起動します。

# `start_link`

```elixir
@spec start_link(module(), term(), AVModbus.Server.handler(), [option()]) ::
  {:ok, pid()} | {:error, term()}
```

open 済み transport handle 上で RTU server を起動します。

# `status`

```elixir
@spec status(server()) :: :connected | {:disconnected, term()}
```

`:connected` または reopen 中の最新 transport error を返します。

# `stop`

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

server を停止し、自身で open した UART を close します。

---

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