Skip to main content

Module encode

Module encode 

Source
Expand description

Request frame encoders — one free function per Modbus function code.

Each function accepts user-supplied parameters plus the transaction id assigned by the task, builds the corresponding PDU via mbus_core helpers, and wraps it into a complete ADU frame ready to hand to AsyncTransport::send.

§Conventions

  • All functions return Result<Vec<u8, MAX_ADU_FRAME_LEN>, MbusError>.
  • txn_id is always the task-assigned identifier; callers never pick it.
  • unit is the UnitIdOrSlaveAddr already validated before this point.
  • Broadcast reads are rejected at the client_core layer; no guards here.

Functions§

encode_request
Encodes a ClientRequest into a complete ADU frame using the given txn_id.