ModbusTypes Reference
ModbusTypes
Section titled “ModbusTypes”Path: src/modbus/ModbusTypes.h
Revision History: Initial documentation
A collection of enumerations, structures, and classes that define the foundational types used by the Modbus implementation. This component provides the core data types and interfaces for working with Modbus communication in industrial applications.
REQUIREMENTS
Section titled “REQUIREMENTS”- ESP32 microcontroller
- Platform.io development environment
- C++17 compatible compiler
PROVIDES
Section titled “PROVIDES”-
Enumerations:
E_FN_CODE
: Modbus function codesE_MB_OpType
: Modbus operation typesE_MB_OpStatus
: Operation statusMB_Error
: Error codesE_FilterType
: Filter types for operation filteringE_ModbusAccess
: Access types (from config-modbus.h)
-
Structures:
MB_Registers
: Register definition structureModbusBlockView
: Non-owning view of register blocksMB_UpdateData
: RTU update dataModbusOperation
: Modbus operation structureModbusValueEntry
: Register or coil value entrySlaveData
: Modbus slave dataModbusReadBlock
: Mandatory read block definition
-
Classes:
ModbusOperationFilter
: Base class for operation filtersDuplicateOperationFilter
: Filter to remove duplicate operationsRateLimitFilter
: Filter to limit operation ratesPriorityFilter
: Filter for prioritizing operationsOperationLifecycleFilter
: Filter for managing operation lifecycleRegisterState
: Class for register state managementRTU_Base
: Base class for RTU devices
-
Callback Types:
ResponseCallback
: Callback for slave responsesOnRegisterChangeCallback
: Callback for register changesOnWriteCallback
: Callback for write operationsOnErrorCallback
: Callback for error handlingOperationExistsCallback
: Callback for checking if operation exists
FEATURES
Section titled “FEATURES”- Comprehensive Modbus function code support
- Error handling with detailed error codes
- Operation filtering system for queue management
- Register state management
- Device state management through RTU_Base
- Support for mandatory read blocks
- Priority-based operation scheduling
- Callback systems for events
DEPENDENCIES
Section titled “DEPENDENCIES”BEHAVIOUR
Section titled “BEHAVIOUR”PERFORMANCE
Section titled “PERFORMANCE”- Consider more efficient data structures for queuing operations
- Optimize memory usage in filter chain implementations
- Implement operation batching for improved throughput
SECURITY
Section titled “SECURITY”- Add validation for input parameters to prevent buffer overflows
- Consider implementing authentication mechanisms for Modbus TCP
- Add checks for unauthorized register access
COMPLIANCE
Section titled “COMPLIANCE”- Ensure full compliance with Modbus specification
- Review handling of exceptional responses
- Validate operation against industrial standards
RECOMMENDATIONS
Section titled “RECOMMENDATIONS”- Implement appropriate error handling strategies
- Set appropriate timeouts based on network characteristics
- Use the filter chain to customize operation processing
- Leverage the callback system for event-based programming