Expand description
The C ABI for Modbus RTU framing.
These functions wrap [pamoja_modbus] for callers that reach the SDK through
the flat C boundary. Each request builder produces a complete RTU frame, CRC
included, ready to put on an RS485 line: the PDU and the frame around it are
one step here rather than two, because a caller crossing this boundary has no
use for a PDU on its own.
A received frame goes the other way through pamoja_modbus_frame_parse,
which validates the CRC before anything else can be read from it. The values a
device returned then come out as typed series, registers as uint16 and coils
as one byte per bit, rather than as bytes the caller would have to unpack.
Structs§
- Pamoja
Modbus Frame - An opaque handle to a parsed Modbus RTU frame with a verified CRC.
- Pamoja
Registers - An opaque handle to the 16-bit registers a device returned.
Functions§
- pamoja_
modbus_ ⚠crc16 - Computes the CRC-16/MODBUS that every RTU frame ends with.
- pamoja_
modbus_ ⚠frame_ address - Returns the unit address a frame is addressed to or came from.
- pamoja_
modbus_ ⚠frame_ coils - Reads the coils or discrete inputs out of a read-bits response.
- pamoja_
modbus_ ⚠frame_ exception - Returns the exception code a device reported.
- pamoja_
modbus_ ⚠frame_ free - Releases a parsed frame handle.
- pamoja_
modbus_ ⚠frame_ function - Returns a frame’s function code.
- pamoja_
modbus_ ⚠frame_ parse - Parses a received RTU frame, verifying its CRC.
- pamoja_
modbus_ ⚠frame_ pdu - Returns a pointer to a frame’s PDU: the function code and its data, without the address or the CRC.
- pamoja_
modbus_ ⚠frame_ pdu_ len - Returns the length in bytes of a frame’s PDU.
- pamoja_
modbus_ ⚠frame_ registers - Reads the 16-bit registers out of a read-registers response.
- pamoja_
modbus_ ⚠raw - Builds a request frame from a raw function code and data.
- pamoja_
modbus_ ⚠read_ coils - Builds a read-coils request frame (function
0x01). - pamoja_
modbus_ ⚠read_ discrete_ inputs - Builds a read-discrete-inputs request frame (function
0x02). - pamoja_
modbus_ ⚠read_ holding_ registers - Builds a read-holding-registers request frame (function
0x03). - pamoja_
modbus_ ⚠read_ holding_ registers_ reply - Builds the reply a device sends to a read-holding-registers request.
- pamoja_
modbus_ ⚠read_ input_ registers - Builds a read-input-registers request frame (function
0x04). - pamoja_
modbus_ ⚠read_ input_ registers_ reply - Builds the reply a device sends to a read-input-registers request.
- pamoja_
modbus_ ⚠write_ multiple_ coils - Builds a write-multiple-coils request frame (function
0x0F). - pamoja_
modbus_ ⚠write_ multiple_ registers - Builds a write-multiple-registers request frame (function
0x10). - pamoja_
modbus_ ⚠write_ single_ coil - Builds a write-single-coil request frame (function
0x05). - pamoja_
modbus_ ⚠write_ single_ register - Builds a write-single-register request frame (function
0x06). - pamoja_
registers_ ⚠data - Returns a pointer to the registers a device returned.
- pamoja_
registers_ ⚠free - Releases a register series.
- pamoja_
registers_ ⚠len - Returns how many registers a device returned.