Expand description
Defines data structures, constants, and protocol logic for interacting with an 8-Channel Multifunction RS485 Module via Modbus RTU, based on the protocol specification document.
This module covers:
- Representing port states (
PortState,PortStates). - Identifying specific ports (
Port) and the Modbus device address (Address). - Defining Modbus register addresses and data values for reading states and controlling ports.
- Encoding and decoding values from/to Modbus register format (
Word). - Error handling for invalid port or address values.
Assumes standard Modbus function codes “Read Holding Registers” (0x03) and “Write Single Register” (0x06) are used externally to interact with the device.
Structs§
- Address
- Represents a validated Modbus device address, used for RTU communication over RS485.
- Error
Address OutOf Range - Error indicating that a provided Modbus device address (
u8) is outside the valid range for assignable addresses, defined byAddress::MINandAddress::MAX(inclusive). - Error
Port OutOf Range - Error indicating that a provided port index (
u8) is outside the valid range defined byPort::MINandPort::MAX(inclusive). - Port
- Represents a validated port index, guaranteed to be within the valid range
0..NUMBER_OF_PORTS. - Port
States - Represents the collective states of all
NUMBER_OF_PORTSports. - Ports
All - A zero-sized type providing constants for controlling all ports simultaneously.
Enums§
- Port
State - Represents the state of a single digital I/O port (e.g., relay).
Constants§
- NUMBER_
OF_ PORTS - The total number of controllable digital I/O ports on the module.
Type Aliases§
- Word
- Represents a single 16-bit value stored in a Modbus register.