firmware-base/docs-c/core/error_codes.md
2025-06-04 16:50:34 +02:00

2.4 KiB

Error Codes

Path: src/modbus/error_codes.h

Revision History: Initial documentation

A comprehensive collection of error codes used throughout the Modbus implementation. This header defines specific error code enumerations for different types of errors that can occur during Modbus operations.

REQUIREMENTS

No specific hardware pins required. This is a pure software component providing error code definitions.

PROVIDES

  • ModbusErrorCode - Enumeration for general Modbus error codes
  • ModbusDeviceErrorCode - Enumeration for device-specific Modbus error codes
  • ModbusExceptionCode - Enumeration for standard Modbus exception codes

FEATURES

  • Standardized error code definitions for Modbus protocol implementation
  • Clear separation between different categories of errors
  • Compliance with standard Modbus exception codes
  • Error codes to handle both protocol-level and device-specific errors

DEPENDENCIES

None. This is a standalone header file defining error code enumerations.

graph TD
    ErrorCodes[Error Codes]

BEHAVIOUR

The error codes are used to report and handle various error conditions throughout the Modbus implementation.

graph TD
    Start[Operation Start] --> Operation[Modbus Operation]
    Operation --> CheckError{Error?}
    CheckError -->|No| Success[Operation Successful]
    CheckError -->|Yes| Identify[Identify Error Type]
    Identify -->|Protocol Error| ProtocolError[ModbusErrorCode]
    Identify -->|Device Error| DeviceError[ModbusDeviceErrorCode]
    Identify -->|Exception| Exception[ModbusExceptionCode]
    ProtocolError --> Handle[Handle Error]
    DeviceError --> Handle
    Exception --> Handle
    Handle --> End[End Operation]
    Success --> End

TODOS

PERFORMANCE

  • Consider optimizing error handling mechanisms for minimal runtime overhead

SECURITY

  • Review error codes to ensure they don't expose sensitive system information
  • Consider adding error codes for security-related issues (authentication failures, access violations)

COMPLIANCE

  • Verify that all Modbus exception codes match the latest Modbus specification
  • Consider adding compliance with IEC 61131-3 error handling recommendations

RECOMMENDATIONS

  • Use appropriate error codes consistently across the codebase
  • Consider extending error codes with additional information for debugging purposes
  • Implement comprehensive error logging using these error codes