Contenido principal

coder.asap2.getEcuDescriptions

R2026b

ECU description object for model

Since R2022b

    Description

    An ECU description object and its functions allows you to add, delete, find, filter, update, and fetch ECU descriptions in an ASAP2 file. You can use the function to create the information object for a model.

    Creation

    descObj = coder.asap2.getEcuDescriptions(modelName) creates an ECU description object with name descObj for the model modelName.

    Properties

    expand all

    Generate the A2L file by including or excluding comments.

    Example: Comments=true

    Create a user base and customize the ASAP2 fields such as:

    • ASAP2FileName

    • ByteOrder

    • HeaderComment

    • ModParComment

    • ModCommonComment

    Example: CustomizationObject=obj

    Group the parameters and signals based on their properties.

    Example: CustomizeGroupsBy={'ARRAY','MAP'}

    Specify a 32-bit integer value to specify additional address information in the ASAP2 file. By default, no additional address information is required.

    Example: EcuAddressExtension=4

    Name for the exported A2L file.

    Example: FileName='test_car'

    Full path to a folder in which to place an exported A2L file.

    Example: Folder='/home/temp/prjct/'

    Generate the A2L file by including or excluding A2ML and IF_DATA sections.

    Example: GenerateXCPInfo=true

    Export record layouts of all the base data types to a file named RecordLayouts.a2l according to the version of the A2L file.

    Example: IncludeAllRecordLayouts=true

    Generate the A2L file by including or excluding the AUTOSAR RTE elements.

    Note

    This option is applicable only for AUTOSAR classic models.

    Example: IncludeAutosarRteElements=true

    Specify true to include a default event list in the A2L file.

    Example: IncludeDefaultEventList=true

    Specify true to include referenced model elements in ASAP2 file. Specify false to exclude.

    Example: IncludeReferencedModels=true

    Generate separate A2L files for compu methods and record layouts.

    Note

    This option is applicable for models with ERT - based system target files.

    Example: IncludeSharedElements=true

    Specify true to export variant parameters to ASAP2 file. Specify false to skip the variant parameters.

    Example: IncludeVariantCoding=true

    Generate an A2L file by following indentation.

    Example: IndentFile=true

    Name of the model symbol file that contains symbols of generated code. For example, the addresses of variables used in generated code.

    Example: MapFile='model.elf'

    Custom model instance name in an A2L file. This argument is applicable only for AUTOSAR adaptive models.

    Example: ModelClassInstanceName='customObj' or ModelClassInstanceName='customNameSpace::customObj'

    Specify false to exclude 64-bit integers in the generated ASAP2 file.

    Example: Support64bitIntegers=false

    Specify false to exclude elements that are part of the structure in the generated ASAP2 file.

    Example: SupportStructureElements=false

    Update the array layout to ROW_DIR or COL_DIR to view the array data in row wise or column wise.

    Example: ToggleArrayLayout=true

    Save the preferences made and generate the ASAP2 file with the preferences updated such as including the comments, version of the ASAP2 file.

    Example: UseSavedSettings=false

    A2L file format based on the ASAM MCD-2 MC standard defined by ASAM. There are multiple versions of the ASAM MCD-2 MC standard. Specify the version of A2L that you want.

    Example: Version='1.61' or Version='1.31'

    Object Functions

    addAdd element to ASAP2 file
    deleteRemove element from ASAP2 file
    findFilter and get ECU description names
    getReturn ASAP2 properties of data element
    setSet property for data element

    Examples

    collapse all

    This example shows how to programmatically customize ECU descriptions in an ASAP2 file by adding, modifying, and removing computation methods, characteristics, measurements, and lookup table parameters.

    Use functions to create an ECU description object from a built model, find and filter its contents, and export a customized ASAP2 file.

    In this example, you:

    • Build a model and create an ECU description object

    • Find and filter computation methods by properties

    • Add and modify a custom computation method

    • Add and modify a custom characteristic and measurement

    • Add a lookup table parameter with axis information

    • Export the customized ASAP2 file

    Open and Build the Model

    Open the example model ASAP2Demo and generate code from it. Building the model is a prerequisite for creating the ECU description object.

    open_system("ASAP2Demo");

    slbuild("ASAP2Demo");
    ### Searching for referenced models in model 'ASAP2Demo'.
    ### Total of 2 models to build.
    ### Starting serial code generation build.
    ### Starting model reference code generation target build for: ASAP2DemoModelRef
    ### Successfully updated the model reference code generation target for: ASAP2DemoModelRef
    ### Starting top model code generation target build for: ASAP2Demo
    ### Successful completion of build procedure for: ASAP2Demo
    
    Build Summary
    
    Model reference code generation targets:
    
    Model              Build Reason                                 Status                        Build Duration
    ============================================================================================================
    ASAP2DemoModelRef  Target (ASAP2DemoModelRef.c) did not exist.  Code generated and compiled.  0h 0m 8.5322s
    
    Top model targets:
    
    Model      Build Reason                         Status                        Build Duration
    ============================================================================================
    ASAP2Demo  Target (ASAP2Demo.c) did not exist.  Code generated and compiled.  0h 0m 16.383s
    
    2 of 2 models built (0 models already up to date)
    Build duration: 0h 0m 27.316s
    

    Create and Explore ECU Descriptions

    Create the ECU description object for the built model. Use the find function to list available computation methods.

    descObj = coder.asap2.getEcuDescriptions("ASAP2Demo");
    Export duration: 0h 0m 0s 227ms
    
    find(descObj, "CompuMethod")
    ans = 1×9 string
        "CM_double"    "CM_double_m_per_U0028_s_U005E_2_U0029"    "CM_double_rpm"    "CM_int16_rpm"    "CM_int32"    "CM_single"    "CM_single_m_per_U0028_s_U005E_2_U0029"    "CM_single_rpm"    "CM_uint8"
    
    

    Filter the computation methods to get only those that use rpm as the unit.

    find(descObj, "CompuMethod", Units="rpm")
    ans = 1×3 string
        "CM_double_rpm"    "CM_int16_rpm"    "CM_single_rpm"
    
    

    Add a Custom Computation Method

    Create a computation method with a linear conversion type and add it to the ECU description object.

    CompuMethod_1 = coder.asap2.CompuMethod;
    CompuMethod_1.Name = 'CompuMethod_1';
    CompuMethod_1.ConversionType = "LINEAR";
    CompuMethod_1.Coefficients = [2 3];
    CompuMethod_1.LongIdentifier = "longIdentifierTest";
    CompuMethod_1.Format = "%2.3";
    CompuMethod_1.Units = "s";
    add(descObj, CompuMethod_1);

    Verify the properties of the newly added computation method.

    get(descObj, "CompuMethod", "CompuMethod_1")
    ans = 
      CompuMethod with properties:
    
                   Name: 'CompuMethod_1'
         LongIdentifier: "longIdentifierTest"
                 Format: "%2.3"
                  Units: "s"
           Coefficients: [2 3]
         ConversionType: "LINEAR"
        CompuVTabValues: [1×1 struct]
             CustomData: ""
    
    

    Update the conversion type to TAB_VERB and define the corresponding CompuVTabValues. Use the set function to modify properties of an existing description.

    set(descObj, "CompuMethod", "CompuMethod_1", ConversionType="TAB_VERB");
    set(descObj, "CompuMethod", "CompuMethod_1", CompuVTabValues=struct("Literals", ["false" "true"], "Values", [0 1]));

    Verify the modified fields.

    modifiedProp = get(descObj, "CompuMethod", "CompuMethod_1")
    modifiedProp = 
      CompuMethod with properties:
    
                   Name: 'CompuMethod_1'
         LongIdentifier: "longIdentifierTest"
                 Format: "%2.3"
                  Units: "s"
           Coefficients: [2 3]
         ConversionType: "TAB_VERB"
        CompuVTabValues: [1×1 struct]
             CustomData: ""
    
    
    modifiedProp.CompuVTabValues
    ans = struct with fields:
        Literals: ["false"    "true"]
          Values: [0 1]
    
    

    Add a Custom Characteristic

    Create a characteristic that represents a calibration parameter and add it to the ECU description object. Then update its UpperLimit property.

    param1 = coder.asap2.Characteristic;
    param1.Name = "Custom_parameter1";
    param1.LongIdentifier = "longIdentifierParam";
    param1.UpperLimit = 255;
    param1.LowerLimit = 0;
    add(descObj, param1);
    get(descObj, "Characteristic", "Custom_parameter1")
    ans = 
      Characteristic with properties:
    
                       Name: "Custom_parameter1"
             LongIdentifier: "longIdentifierParam"
                       Type: 'VALUE'
                 EcuAddress: '0x0000'
            CompuMethodName: 'NO_COMPU_METHOD'
                 LowerLimit: 0
                 UpperLimit: 255
          EcuAddressComment: ""
        EcuAddressExtension: []
          CalibrationAccess: 'Calibration'
          DisplayIdentifier: ""
                     Format: ""
                    BitMask: []
                   AxisInfo: []
               RecordLayout: ""
                 Dimensions: []
                     Export: 1
                 MaxRefresh: [1×1 struct]
                 SymbolLink: [1×1 struct]
                 CustomData: ""
    
    
    set(descObj, "Characteristic", "Custom_parameter1", UpperLimit=128)

    Add a Custom Measurement

    Create a measurement that represents a signal and add it to the ECU description object. Then update its CalibrationAccess property.

    signal1 = coder.asap2.Measurement;
    signal1.Name = "Custom_signal1";
    signal1.LongIdentifier = "longIdentifierSignal";
    signal1.UpperLimit = 255;
    signal1.LowerLimit = 0;
    add(descObj, signal1);
    get(descObj, "Measurement", "Custom_signal1")
    ans = 
      Measurement with properties:
    
                       Name: "Custom_signal1"
             LongIdentifier: "longIdentifierSignal"
                   DataType: 'UBYTE'
                 EcuAddress: '0x0000'
            CompuMethodName: ""
                 LowerLimit: 0
                 UpperLimit: 255
                     Raster: [1×1 struct]
          EcuAddressComment: ""
        EcuAddressExtension: []
          CalibrationAccess: 'NoCalibration'
          DisplayIdentifier: ""
                     Format: ""
                    BitMask: []
                 Dimensions: []
                     Export: 1
                   MaskData: [1×1 struct]
                 MaxRefresh: [1×1 struct]
                 SymbolLink: [1×1 struct]
                 CustomData: ""
    
    
    set(descObj, "Measurement", "Custom_signal1", CalibrationAccess="Calibration")

    Add a Lookup Table Parameter

    Create a lookup table parameter of type MAP with two axes. Each axis requires a name, computation method, maximum number of axis points, and axis type.

    lutParam = coder.asap2.Characteristic;
    lutParam.Name = "custom_lookup_table";
    lutParam.Type = "MAP";
    axisData = coder.asap2.AxisInfo;
    axisData(1).Name = "BP3";
    axisData(2).Name = "Bp4";
    axisData(1).CompuMethodName = "ASAP2Demo_CM_double";
    axisData(2).CompuMethodName = "ASAP2Demo_CM_double";
    axisData(1).MaxAxisPoints = "3";
    axisData(2).MaxAxisPoints = "3";
    axisData(1).AxisType = "STD_AXIS";
    axisData(2).AxisType = "STD_AXIS";
    lutParam.AxisInfo = axisData;
    add(descObj, lutParam)

    Export the Customized ASAP2 File

    Export the ASAP2 file using the updated ECU description object. Verify that the generated file contains the custom computation method, characteristic, measurement, and lookup table parameter.

    coder.asap2.export("ASAP2Demo", CustomEcuDescriptions=descObj);

    Remove Custom Descriptions

    Remove the custom descriptions from the ECU description object.

    delete(descObj, "CompuMethod", "CompuMethod_1");
    delete(descObj, "Characteristic", "Custom_parameter1");
    delete(descObj, "Measurement", "Custom_signal1");

    Version History

    Introduced in R2022b