pub trait RegisterResponse {
// Required methods
fn read_multiple_input_registers_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
registers: &Registers,
);
fn read_single_input_register_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
address: u16,
value: u16,
);
fn read_multiple_holding_registers_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
registers: &Registers,
);
fn write_single_register_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
address: u16,
value: u16,
);
fn write_multiple_registers_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
starting_address: u16,
quantity: u16,
);
fn read_write_multiple_registers_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
registers: &Registers,
);
fn read_single_register_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
address: u16,
value: u16,
);
fn read_single_holding_register_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
address: u16,
value: u16,
);
fn mask_write_register_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
);
}Expand description
Defines callbacks for handling responses to Modbus register-related requests.
Implementors of this trait can process the data received from a Modbus server and update their application state accordingly. Each method corresponds to a specific Modbus register operation response.
§Callback Mapping
- FC 0x03:
read_multiple_holding_registers_response,read_single_holding_register_response - FC 0x04:
read_multiple_input_registers_response,read_single_input_register_response - FC 0x06:
write_single_register_response - FC 0x10:
write_multiple_registers_response - FC 0x16:
mask_write_register_response - FC 0x17:
read_write_multiple_registers_response
§Data Semantics
- Register values are 16-bit words (
u16) already decoded from Modbus big-endian byte pairs. - Address and quantity values are echoed/validated values corresponding to the original request.
Required Methods§
Sourcefn read_multiple_input_registers_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
registers: &Registers,
)
fn read_multiple_input_registers_response( &mut self, txn_id: u16, unit_id_slave_addr: UnitIdOrSlaveAddr, registers: &Registers, )
Handles a response for a Read Input Registers (FC 0x04) request.
§Parameters
txn_id: Transaction ID of the original request. While Modbus Serial (RTU/ASCII) does not natively use transaction IDs, the stack preserves the ID provided in the request and returns it here to allow for asynchronous tracking.unit_id_slave_addr: The unit ID of the device that responded.unit_id: if transport is tcpslave_addr: if transport is serial
registers: ARegistersstruct containing the values of the read input registers.
Sourcefn read_single_input_register_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
address: u16,
value: u16,
)
fn read_single_input_register_response( &mut self, txn_id: u16, unit_id_slave_addr: UnitIdOrSlaveAddr, address: u16, value: u16, )
Handles a response for a Read Single Input Register (FC 0x04) request.
§Parameters
txn_id: Transaction ID of the original request. While Modbus Serial (RTU/ASCII) does not natively use transaction IDs, the stack preserves the ID provided in the request and returns it here to allow for asynchronous tracking.unit_id_slave_addr: The unit ID of the device that responded.unit_id: if transport is tcpslave_addr: if transport is serial
address: The address of the register that was read.value: The value of the read register.
Sourcefn read_multiple_holding_registers_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
registers: &Registers,
)
fn read_multiple_holding_registers_response( &mut self, txn_id: u16, unit_id_slave_addr: UnitIdOrSlaveAddr, registers: &Registers, )
Handles a response for a Read Holding Registers (FC 0x03) request.
§Parameters
txn_id: Transaction ID of the original request. While Modbus Serial (RTU/ASCII) does not natively use transaction IDs, the stack preserves the ID provided in the request and returns it here to allow for asynchronous tracking.unit_id_slave_addr: The unit ID of the device that responded.unit_id: if transport is tcpslave_addr: if transport is serial
registers: ARegistersstruct containing the values of the read holding registers.
Sourcefn write_single_register_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
address: u16,
value: u16,
)
fn write_single_register_response( &mut self, txn_id: u16, unit_id_slave_addr: UnitIdOrSlaveAddr, address: u16, value: u16, )
Handles a response for a Write Single Register (FC 0x06) request, confirming a successful write.
§Parameters
txn_id: Transaction ID of the original request. While Modbus Serial (RTU/ASCII) does not natively use transaction IDs, the stack preserves the ID provided in the request and returns it here to allow for asynchronous tracking.unit_id_slave_addr: The unit ID of the device that responded.unit_id: if transport is tcpslave_addr: if transport is serial
address: The address of the register that was written.value: The value that was written to the register.
Sourcefn write_multiple_registers_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
starting_address: u16,
quantity: u16,
)
fn write_multiple_registers_response( &mut self, txn_id: u16, unit_id_slave_addr: UnitIdOrSlaveAddr, starting_address: u16, quantity: u16, )
Handles a response for a Write Multiple Registers (FC 0x10) request, confirming a successful write.
§Parameters
txn_id: Transaction ID of the original request. While Modbus Serial (RTU/ASCII) does not natively use transaction IDs, the stack preserves the ID provided in the request and returns it here to allow for asynchronous tracking.unit_id_slave_addr: The unit ID of the device that responded.unit_id: if transport is tcpslave_addr: if transport is serial
starting_address: The starting address of the registers that were written.quantity: The number of registers that were written.
Sourcefn read_write_multiple_registers_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
registers: &Registers,
)
fn read_write_multiple_registers_response( &mut self, txn_id: u16, unit_id_slave_addr: UnitIdOrSlaveAddr, registers: &Registers, )
Handles a response for a Read/Write Multiple Registers (FC 0x17) request.
§Parameters
txn_id: Transaction ID of the original request. While Modbus Serial (RTU/ASCII) does not natively use transaction IDs, the stack preserves the ID provided in the request and returns it here to allow for asynchronous tracking.unit_id_slave_addr: The unit ID of the device that responded.unit_id: if transport is tcpslave_addr: if transport is serial
registers: ARegistersstruct containing the values of the registers that were read.
Sourcefn read_single_register_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
address: u16,
value: u16,
)
fn read_single_register_response( &mut self, txn_id: u16, unit_id_slave_addr: UnitIdOrSlaveAddr, address: u16, value: u16, )
Handles a response for a single register read request.
This is a convenience callback for when only one register is requested.
§Parameters
txn_id: Transaction ID of the original request. While Modbus Serial (RTU/ASCII) does not natively use transaction IDs, the stack preserves the ID provided in the request and returns it here to allow for asynchronous tracking.unit_id_slave_addr: The unit ID of the device that responded.unit_id: if transport is tcpslave_addr: if transport is serial
address: The address of the register that was read.value: The value of the read register.
Sourcefn read_single_holding_register_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
address: u16,
value: u16,
)
fn read_single_holding_register_response( &mut self, txn_id: u16, unit_id_slave_addr: UnitIdOrSlaveAddr, address: u16, value: u16, )
Handles a response for a single holding register write request.
§Parameters
txn_id: Transaction ID of the original request. While Modbus Serial (RTU/ASCII) does not natively use transaction IDs, the stack preserves the ID provided in the request and returns it here to allow for asynchronous tracking.unit_id_slave_addr: The unit ID of the device that responded.unit_id: if transport is tcpslave_addr: if transport is serial
address: The address of the register that was written.value: The value that was written to the register.
Sourcefn mask_write_register_response(
&mut self,
txn_id: u16,
unit_id_slave_addr: UnitIdOrSlaveAddr,
)
fn mask_write_register_response( &mut self, txn_id: u16, unit_id_slave_addr: UnitIdOrSlaveAddr, )
Handles a response for a Mask Write Register (FC 0x16) request, confirming a successful operation.
§Parameters
txn_id: Transaction ID of the original request. While Modbus Serial (RTU/ASCII) does not natively use transaction IDs, the stack preserves the ID provided in the request and returns it here to allow for asynchronous tracking.unit_id_slave_addr: The unit ID of the device that responded.unit_id: if transport is tcpslave_addr: if transport is serial