# `AVModbus.ASCII`
[🔗](https://github.com/piyopiyoex/avmodbus/blob/v0.1.0/lib/avmodbus/ascii.ex#L1)

Modbus ASCII の framing、LRC validation、stream extraction を提供します。

binary の各 byte を 2 文字の hexadecimal で表し、`:` から CR + delimiter までを
1 frame として扱います。Change ASCII Input Delimiter 用に custom delimiter も指定できます。

# `decode`

```elixir
@spec decode(binary()) ::
  {:ok, 0..247, binary()} | {:error, :invalid_lrc | :invalid_frame}
```

完全な Modbus ASCII frame を decode し、LRC を検証します。

# `encode`

```elixir
@spec encode(0..247, binary(), byte()) :: {:ok, binary()} | {:error, term()}
```

unit id と PDU を完全な Modbus ASCII frame に encode します。

# `lrc`

```elixir
@spec lrc(binary()) :: byte()
```

`data` の Modbus LRC (Longitudinal Redundancy Check) を返します。

# `split`

```elixir
@spec split(binary(), byte()) :: {:ok, binary(), binary()} | {:skip, binary()} | :more
```

stream buffer の先頭から 1 frame を取り出します。

`{:ok, frame, rest}`、`:more`、`{:skip, rest}` のいずれかを返します。
incomplete frame 内で新しい `:` を検出した場合は、そこから次の frame として再同期します。

---

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