Skip to main content

Module modbus

Module modbus 

Source
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§

PamojaModbusFrame
An opaque handle to a parsed Modbus RTU frame with a verified CRC.
PamojaRegisters
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.