Skip to main content

Module request

Module request 

Source
Expand description

Modbus request PDUs. Wrap them in a Frame to give them a unit ID and CRC.

use async_modbus::zerocopy::IntoBytes;

let pdu = WriteHolding::new().with_register(0x10BC).with_value(12345);
let frame = Frame::new(0x01, pdu);
assert_eq!(frame.as_bytes(), hex!("01 06 10 BC 30 39 98 FC"));

Structsยง

ReadCoils
ReadCoils PDU (function code 0x01).
ReadDiscreteInputs
ReadDiscreteInputs PDU (function code 0x02).
ReadHoldings
ReadHoldings PDU (function code 0x03).
ReadInputs
ReadInputs PDU (function code 0x04).
WriteHolding
WriteHolding PDU (function code 0x06).
WriteHoldings
WriteHoldings PDU (function code 0x10).