Expand description
A no_std, allocation-free parser and encoder for Modbus RTU, the
serial-line PDU encoding used by industrial PLCs, sensors, and other
field devices.
§Layering
frameparses/encodes the raw address/function-code/data/CRC-16 framing.crcis Modbus RTU’s CRC-16 checksum.messagedecodes/encodes a frame’s data into a typedModbusRequestorModbusResponse, one variant per supported function code.
§No allocation
Nothing in this crate uses alloc.
Re-exports§
pub use error::MbrtuError;pub use frame::Frame;pub use message::ModbusRequest;pub use message::ModbusResponse;
Modules§
- crc
- Modbus RTU’s CRC-16 (poly
0xA001, the reflected form of0x8005, init0xFFFF), computed over the address, function code, and data of a frame. Cross-checked againstpymodbus’s owncompute_CRC. - error
- Error types for every layer of the decode/encode pipeline.
- frame
- Raw Modbus RTU frame parsing and encoding.
- message
- Function-code-dispatched decoding/encoding of a frame’s data into a
typed
ModbusRequestorModbusResponse.
Functions§
- decode_
request - Parses a single frame from
bufand decodes it as a request PDU (see themessagemodule docs on why direction is a caller-supplied fact, not something recoverable from the bytes alone). - decode_
response - Parses a single frame from
bufand decodes it as a response PDU. - encode_
request - Encodes a request PDU into a full frame in
buf, returning the number of bytes written. - encode_
response - Encodes a response PDU into a full frame in
buf, returning the number of bytes written.