Search code examples
global-variablesautosar

AUTOSAR SWC Global Variables


How can I define a global variable within a component that can be accessed by all runnables that belong to this component without using IRVs in a component model?


Solution

  • There are three possible ways to achieve this:

    • InternalBehavior.staticMemory: this kind of variable is typically defined if you want to make a variable in your code visible to a measurement and calibration system, i.e. it is possible to derive an A2L description of the variable for downstream processing in a M&C tool. This variant is only a viable option if the enclosing software-component isn’t multiply instantiated.
    • SwcInternalBehavior.arTypedPerInstanceVariable: here you define a variable that is supported in multiply defined software-components. The variable has a modeled data type and is allocated by the RTE that also provides a dedicated API for accessing the variable.
    • SwcInternalBehavior.perInstanceMemory: here you define a variable by directly using the C data type, i.e. there is no modeling of the data type. The variable is allocated by the RTE that also provides a dedicated API for accessing the variable.

    None of the mentioned approaches provide any form of automatic consistency mechanism. Securing data consistency is entirely left to the application software with the help of mechanisms standardized by AUTOSAR.