API Reference modbuv v#0.1.0

Copy Markdown View Source

Modules

CRC16/MODBUS calculation.

Modbus PDU encoding and decoding. A PDU is <<fc, body::binary>>; slave/unit ids, CRC, and MBAP live in the transport layers.

Server/Slave function-code registry: maps a numeric function code to the direction, data width, address region, and (for writes) single/multi layout.

IEEE754 float helper. :be keeps the first register as the high word; :le swaps the two words.

Pure functions over the Server/Slave DB: %{slave_id => %{{region, address} => value}}.

Agent that holds the Server/Slave DB.

Modbus RTU ADU framing: <<slave, pdu, crc::little-16>>.

Circuits.UART framer for Modbus RTU slave traffic. It accumulates bytes, derives the expected length from the fc_map, validates CRC, and resyncs byte-by-byte when a candidate is invalid.

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.

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

Modbus TCP ADU framing: MBAP header plus the Codec PDU.

Modbus TCP client. In passive mode request/2 followed by confirmation/1 returns the result synchronously; in active mode responses are sent to d_pid as {:modbuv_tcp, frame, result}.

Modbus TCP server: listens on a port, serves each connection from the shared DB, and optionally notifies the owner of parsed requests.

Telemetry instrumentation for Modbuv.Tcp.Client and Modbuv.Rtu.Master requests.