Main Content

setDataDefaults

R2026b

Set default data properties for AUTOSAR component model

Since R2022b

    Description

    setDataDefaults(slMap,"InportsOutports","EndToEndProtectionMethod",e2eMethod) sets the default end-to-end (E2E) protection method for root-level inports and outports of an AUTOSAR component model.

    Use E2E protection to optionally configure sender-receiver ports to securely transmit data between AUTOSAR components. The default E2E protection method sets the E2E protection method used for root-level inports and outports in the generated code. E2E protection methods are applied to AUTOSAR inports that are configured as EndToEndRead ports and AUTOSAR outports that are configured as EndToEndWrite ports.

    example

    setDataDefaults(slMap,elementCategory,"SwAddrMethod",SwAddrMethodName) sets the default software address method (SwAddrMethod) for the specified element category. Specify "InternalData" for internal data structures or "Constants" for constant data structures.

    example

    Examples

    collapse all

    Set the default E2E protection method for the AUTOSAR component model.

    Open example model autosar_swc and get the default E2E protection method.

    modelName = "autosar_swc";
    openExample(modelName);
    
    slMap = autosar.api.getSimulinkMapping(modelName);
    e2eMethod = getDataDefaults(slMap, ...
       "InportsOutports","EndToEndProtectionMethod")
    
    e2eMethod =
        'ProtectionWrapper'
    

    Set and then display the default E2E protection method.

    setDataDefaults(slMap,"InportsOutports", ...
       "EndToEndProtectionMethod","TransformerError");
    e2eMethod = getDataDefaults(slMap, ...
       "InportsOutports","EndToEndProtectionMethod")
    
    e2eMethod =
        'TransformerError'

    Configure default software address methods for the internal data and constants categories of an AUTOSAR component model.

    Open example model autosar_swc_counter and add a software address method for constants by using the addPackageableElement function.

    modelName = "autosar_swc_counter";
    openExample(modelName);
    
    arProps = autosar.api.getAUTOSARProperties(modelName);
    addPackageableElement(arProps,"SwAddrMethod",...
        "/Company/Powertrain/DataTypes/SwAddrMethods","Constant",...
        "SectionType","Const");
    

    Use the setDataDefaults function to set the default software address method for internal data and constants. If no data default is set, the getDataDefaults function returns an empty character vector.

    slMap = autosar.api.getSimulinkMapping(modelName);
    setDataDefaults(slMap,"InternalData","SwAddrMethod","VAR");
    getDataDefaults(slMap,"InternalData","SwAddrMethod")
    setDataDefaults(slMap,"Constants","SwAddrMethod","Constant");
    getDataDefaults(slMap,"Constants","SwAddrMethod")
    ans =
    
        'VAR'
    
    
    ans =
    
        'Constant'

    Input Arguments

    collapse all

    Simulink to AUTOSAR mapping information for a model, previously returned by slMap = autosar.api.getSimulinkMapping(model). model is a handle, character vector, or string scalar representing the model name.

    Example: slMap = autosar.api.getSimulinkMapping("modelName")

    Category of model data elements, specified as one of the following:

    • "InternalData" — Apply the SwAddrMethod property to internal data structures. The software address method must have section type Var.

    • "Constants" — Apply the SwAddrMethod property to constant data structures. The software address method must have section type Const.

    Data Types: char | string

    Name of the protection method, specified as one of the following:

    • "ProtectionWrapper" — Generated code uses an E2E protection wrapper in support of E2E data consistency checks.

    • "TransformerError" — E2E Transformer configures RTE calls to use a transformer error argument in the generated code.

      When the data type of the error status port is uint16, the error status value combines the return value of the Rte_Read function and the transformer error code to create a 16-bit error code, where the least significant eight bits are the output of the Rte_Read function and the most significant eight bits are the transformer error code.

      The TransformerError protection method is supported only when using AUTOSAR schema version 4.2 or later.

    Example: "TransformerError"

    Data Types: char | string

    Name of the software address method, specified as a character vector or string scalar. The software address method must exist in the AUTOSAR Dictionary with the appropriate section type for the specified element category.

    • For "InternalData" — Software address method section type must be Var.

    • For "Constants" — Software address method section type must be Const.

    The default software address method creates memory section infrastructure in the exported ARXML and MemMap.h file. It applies only to the top-level component model and does not propagate to referenced models.

    Example: "MY_VAR_SECTION"

    Data Types: char | string

    Version History

    Introduced in R2022b

    expand all