Skip to content

ModbusTypes Reference

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.

  • ESP32 microcontroller
  • Platform.io development environment
  • C++17 compatible compiler
  • Enumerations:

    • E_FN_CODE: Modbus function codes
    • E_MB_OpType: Modbus operation types
    • E_MB_OpStatus: Operation status
    • MB_Error: Error codes
    • E_FilterType: Filter types for operation filtering
    • E_ModbusAccess: Access types (from config-modbus.h)
  • Structures:

    • MB_Registers: Register definition structure
    • ModbusBlockView: Non-owning view of register blocks
    • MB_UpdateData: RTU update data
    • ModbusOperation: Modbus operation structure
    • ModbusValueEntry: Register or coil value entry
    • SlaveData: Modbus slave data
    • ModbusReadBlock: Mandatory read block definition
  • Classes:

    • ModbusOperationFilter: Base class for operation filters
    • DuplicateOperationFilter: Filter to remove duplicate operations
    • RateLimitFilter: Filter to limit operation rates
    • PriorityFilter: Filter for prioritizing operations
    • OperationLifecycleFilter: Filter for managing operation lifecycle
    • RegisterState: Class for register state management
    • RTU_Base: Base class for RTU devices
  • Callback Types:

    • ResponseCallback: Callback for slave responses
    • OnRegisterChangeCallback: Callback for register changes
    • OnWriteCallback: Callback for write operations
    • OnErrorCallback: Callback for error handling
    • OperationExistsCallback: Callback for checking if operation exists
  • 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

ModbusTypes

ArduinoLog

Component

Vector

macros

constants

config-modbus

enums

ModbusRTU

RTUDevices

RS485

initialize()

initialization complete

operations pending

operations complete

timeout

timeout

response received

UNINITIALIZED

INITIALIZING

IDLE

RUNNING

ERROR

  • Consider more efficient data structures for queuing operations
  • Optimize memory usage in filter chain implementations
  • Implement operation batching for improved throughput
  • Add validation for input parameters to prevent buffer overflows
  • Consider implementing authentication mechanisms for Modbus TCP
  • Add checks for unauthorized register access
  • Ensure full compliance with Modbus specification
  • Review handling of exceptional responses
  • Validate operation against industrial standards
  • 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