3.1.19. waf_tools.diag_array_config_validate

Validate and render the foxBMS diagnosis array configuration.

This module validates the diag_array_cfg.json configuration file that defines the diagnostic event table used by the foxBMS diagnostic engine. It ensures consistency between the JSON configuration, the DIAG_ID_e enumeration in diag_cfg.h, and the DBC file’s fatal error signal choices.

The validation performs the following checks:
  • Structure - All required keys (event, sensitivity, severity, delay, enabled, callback) are present in each entry.

  • Value ranges - Sensitivity, severity, delay, and enabled values are restricted to the supported C literal mappings.

  • Header consistency - Event names and their order match the DIAG_ID_e enum entries in src/app/engine/config/diag_cfg.h.

  • DBC consistency - All fatal error events have matching entries in the FatalErrorCode signal choices of the f_BmsFatalError CAN message defines in tools/dbc/foxbms.dbc.

Additionally, the module provides render_diag_array() which converts validated entries into C struct initializer lines for use by the code generator (waf_tools.config_codegen_task).

3.1.19.1. Usage

The validator is typically passed as a callback to the codegen_config feature in a waf build script:

bld(
    features="codegen_config",
    json=bld.srcnode.find_node(f"conf/bms/diag_array_cfg.json"),
    validator=diag_array_config_validate.validate_diag_array_configuration,
    target=f"{cp}diag_array_cfg",
)

3.1.19.2. Dependencies

Functions

render_diag_array(entries)

Render validated diagnostic array entries into C initializer lines.

validate_diag_array_configuration(bld, ...)

Validate the diagnostic array configuration file.

Classes

DiagArrayConfiguration(entries)

Complete diagnostic array configuration.

DiagArrayEntry(event, description, ...)

Single entry in the diagnostic array configuration.

Exceptions

InvalidDiagConfigurationError

Raised for an invalid diagnostic array configuration.