Main Content

coder.asap2.getEcuDescriptions

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

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

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

    Name for the exported A2L file.

    Example: FileName='test_car'

    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'

    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'

    Generate the A2L file by including or excluding comments.

    Example: Comments=true

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

    Example: GenerateXCPInfo=true

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

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

    Generate an A2L file by following indentation.

    Example: IndentFile=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'}

    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

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

    Example: SupportStructureElements=false

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

    Example: Support64bitIntegers=false

    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

    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

    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

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

    Example: IncludeDefaultEventList=true

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

    Example: ToggleArrayLayout=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

    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

    Add, update, filter, find, and remove ECU descriptions in an ASAP2 file.

    Open and Build Example Model

    Open the example model ASAP2Demo

    open_system("ASAP2Demo");

    Build the model.

    rtwbuild("ASAP2Demo");
    ### Searching for referenced models in model 'ASAP2Demo'.
    ### Found 1 model references to update.
    ### Starting serial model reference code generation build.
    ### Successfully updated the model reference code generation target for: ASAP2DemoModelRef
    ### Starting build procedure for: ASAP2Demo
    ### Successful completion of build procedure for: ASAP2Demo
    
    Build Summary
    
    Code generation targets built:
    
    Model              Action                        Rebuild Reason                       
    ======================================================================================
    ASAP2DemoModelRef  Code generated and compiled.  ASAP2DemoModelRef.c does not exist.  
    
    Top model targets built:
    
    Model      Action                        Rebuild Reason                                    
    ===========================================================================================
    ASAP2Demo  Code generated and compiled.  Code generation information file does not exist.  
    
    2 of 2 models built (0 models already up to date)
    Build duration: 0h 0m 23.37s
    

    Create the ECU description object for the model.

    descObj = coder.asap2.getEcuDescriptions("ASAP2Demo");

    Get the list of available computation methods in the description object.

    find(descObj,"CompuMethod")
    ans = 1x10 string
        "ASAP2DemoModelRef_CM_double"    "ASAP2DemoModelRef_CM_int16_rpm"    "ASAP2Demo_CM_double"    "ASAP2Demo_CM_double_m_per__s_2_"    "ASAP2Demo_CM_double_rpm"    "ASAP2Demo_CM_int32"    "ASAP2Demo_CM_single"    "ASAP2Demo_CM_single_m_per__s_2_"    "ASAP2Demo_CM_single_rpm"    "ASAP2Demo_CM_uint8"
    
    

    Filter the computation methods and get a list of computation methods that use rpm as the unit.

    find(descObj,"CompuMethod",Units='rpm')
    ans = 1x3 string
        "ASAP2DemoModelRef_CM_int16_rpm"    "ASAP2Demo_CM_double_rpm"    "ASAP2Demo_CM_single_rpm"
    
    

    Create and Add Custom Computation Method

    To add a new computation method to the ASAP2 file, create a custom computation method.

    CompuMethod_CM1 = coder.asap2.CompuMethod;
    CompuMethod_CM1.Name = 'CompuMethod_1';
    CompuMethod_CM1.ConversionType = 'LINEAR';
    CompuMethod_CM1.Coefficients = [2 3];
    CompuMethod_CM1.LongIdentifier = 'longIdentifierTest';
    CompuMethod_CM1.Format = '%2.3';
    CompuMethod_CM1.Units = 's';

    Add the custom computation method to the ECU description object.

    add(descObj,CompuMethod_CM1);

    Get 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: [1x1 struct]
             CustomData: ""
    
    

    To modify a property of the computation method, use set function. Update the LongIdentifier field of the computation method.

    set(descObj,"CompuMethod","CompuMethod_1",LongIdentifier="longIdentifierCM1")

    Generate the ASAP2 file using the updated ECU description object and verify that the ASAP2 file contains the computation method CompuMethod_1.

    coder.asap2.export("ASAP2Demo",CustomEcuDescriptions=descObj);
    Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "ASAP2Demo_DW.ASAP2DemoModelRef_InstanceData"
    

    Delete Computation Method

    Remove the newly added computation method from the description object.

    delete(descObj,"CompuMethod","CompuMethod_1");

    Create and Add Custom Characteristic

    To add a new characteristic to the ASAP2 file, create a custom characteristic.

    Parameter_1 = coder.asap2.Characteristic;
    Parameter_1.Name = 'Custom_parameter1';
    Parameter_1.LongIdentifier = 'longIdentifierParam';
    Parameter_1.UpperLimit = 255;
    Parameter_1.LowerLimit = 0;

    Add the custom characteristic to the ECU description object.

    add(descObj,Parameter_1);

    Get the properties of the newly added characteristic.

    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: [1x1 struct]
                 SymbolLink: [1x1 struct]
                 CustomData: ""
    
    

    To modify a property of the characteristic, use set function. Update the UpperLimit field of the characteristic.

    set(descObj,"Characteristic","Custom_parameter1",UpperLimit=128)

    Generate the ASAP2 file using the updated ECU description object and verify that the ASAP2 file contains the characteristic Custom_parameter1.

    coder.asap2.export("ASAP2Demo",CustomEcuDescriptions=descObj);
    Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "ASAP2Demo_DW.ASAP2DemoModelRef_InstanceData"
    

    Remove the newly added characteristic from the description object.

    delete(descObj,"Characteristic","Custom_parameter1");

    Create and Add Custom Measurement

    To add a new measurement to the ASAP2 file, create a custom measurement.

    Signal_1 = coder.asap2.Measurement;
    Signal_1.Name = 'Custom_signal1';
    Signal_1.LongIdentifier = 'longIdentifierSignal';
    Signal_1.UpperLimit = 255;
    Signal_1.LowerLimit = 0;

    Add the custom measurement to the ECU description object.

    add(descObj,Signal_1);

    Get the properties of the newly added measurement.

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

    To modify a property of the measurement, use set function. Update the CalibrationAccess field of the measurement.

    set(descObj,"Measurement","Custom_signal1",CalibrationAccess='Calibration')

    Generate the ASAP2 file using the updated ECU description object and verify that the ASAP2 file contains the measurement with name Custom_signal1.

    coder.asap2.export("ASAP2Demo",CustomEcuDescriptions=descObj);
    Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "ASAP2Demo_DW.ASAP2DemoModelRef_InstanceData"
    

    Remove the newly added measurement from the description object.

    delete(descObj,"Measurement","Custom_signal1");

    Create and Add Lookup Table Parameter

    Add a lookup table parameter.

    LUT_Parameter = coder.asap2.Characteristic;
    LUT_Parameter.Name = "custom_lookup_table";
    LUT_Parameter.Type = "MAP";

    Create and add axis information to the parameter.

    axis_data = coder.asap2.AxisInfo;
    axis_data(1).Name = 'BP3';
    axis_data(2).Name = 'Bp4';
    axis_data(1).CompuMethodName = 'ASAP2Demo_CM_double';
    axis_data(2).CompuMethodName = 'ASAP2Demo_CM_double';
    axis_data(1).MaxAxisPoints = '3';
    axis_data(2).MaxAxisPoints = '3';
    axis_data(1).AxisType = 'STD_AXIS';
    axis_data(2).AxisType = 'STD_AXIS';
    LUT_Parameter.AxisInfo = axis_data;

    Add the lookup table parameter to the description object.

    add(descObj,LUT_Parameter)

    Generate the ASAP2 file using the updated ECU description object and verify that the ASAP2 file contains the lookup table parameter custom_lookup_table.

    coder.asap2.export("ASAP2Demo",CustomEcuDescriptions=descObj);
    Following Characteristics or Measurements with unsupported data types are not exported in ASAP2 file. "ASAP2Demo_DW.ASAP2DemoModelRef_InstanceData"
    

    Version History

    Introduced in R2022b