Main Content

Customize Generated ASAP2 File

You can customize the fields of an ASAP2 file by using the code generator in any of these ways:

Customize Computation Method Names

In generated ASAP2 files, computation methods translate the electronic control unit (ECU) internal representation of measurement and calibration quantities into a physical model-oriented representation. Using Simulink® Coder™ software, you can customize the names of computation methods. You can provide names that are more intuitive, enhancing ASAP2 file readability, or names that meet organizational requirements.

To customize computation method names, use the MATLAB® function getCompuMethodName, which is defined in matlabroot/toolbox/rtw/targets/asap2/asap2/user/getCompuMethodName.m.

The getCompuMethodName function constructs a computation method name. The function prototype is:

cmName = getCompuMethodName(dataTypeName, cmUnits)

where

  • dataTypeName is the name of the data type associated with the computation method.

  • cmUnits are the units as specified in the Unit property of a Simulink.Parameter or Simulink.Signal object (for example, rpm or m/s).

  • cmName returns the constructed computation method name.

The default constructed name returned by the function has the format:

<localPrefix><datatype>_<cmUnits>

where

  • <local_Prefix> is a local prefix, CM_, defined in matlabroot/toolbox/rtw/targets/asap2/asap2/user/getCompuMethodName.m.

  • <datatype> and <cmUnits> are the arguments that you specified to the getCompuMethodName function.

Special characters in cmUnits are not supported in the computation method name in ASAP2 file. The special characters are converted as shown in this table.

Special CharacterConversion
%_percent_
-_dash_
/_per_
*_into_
°_deg_

For example, if you call the getCompuMethodName function by using the dataTypeName argument 'int16' and the cmUnits argument 'm/s', and then generate an ASAP2 file for a model named myModel, the computation method name appears in the generated file:

/begin COMPU_METHOD
   /* Name of CompuMethod */ myModel_CM_int16_m_per_s
   /* Units */ "m/s"
   ...
/end COMPU_METHOD

Exclude Referenced Model Elements

Starting in R2024b, you can exclude the referenced model elements in the generated A2L file. By default, referenced model elements are included in the A2L file.

  1. Open the sldemo_fuelsys model.

    open_system("sldemo_fuelsys")

  2. Build the model.

  3. Generate the ASAP2 file by using this command:

    coder.asap2.export("sldemo_fuelsys", IncludeReferencedModels=false)

    The generated ASAP2 file does not have referenced model elements.

Exclude Structures and 64-Bit Integers

Starting in R2022a, you can exclude the structure elements and 64-bit integers in the generated A2L file. By default, structures and 64-bit integers are included in the A2L file.

  1. Open the sldemo_fuelsys model.

    open_system("sldemo_fuelsys")

  2. Build the model.

  3. Generate the ASAP2 file by using this command:

    coder.asap2.export("sldemo_fuelsys", SupportStructureElements=false, ...
    Support64bitIntegers=false)

    The generated ASAP2 file does not have 64-bit integers and structure elements in it.

Export Characteristics and Measurement Objects in Groups

Starting in R2021b, you can group the characteristic and measurement objects in the ASAP2 file based on their properties. By default, the generated ASAP2 file contains GROUPS and SUB_GROUPS based on the subsystems present in the model.

  1. Open the sldemo_fuelsys model.

    openExample("sldemo_fuelsys")

  2. Use Simulink Coder Quick Start app by entering into code perspective of the model and clicking C Code > Quick Start.

  3. Build the model.

  4. Generate the ASAP2 file by using the Generate Calibration Files tool or by using this command:

    coder.asap2.export("sldemo_fuelsys")

    The data elements are grouped based on the model architecture. The top model is referred to as GROUP and subsystems in the model are referred to as SUB_GROUPS. The generated file contains these lines:

     /begin GROUP
        /* Name                   */      sldemo_fuelsys
        /* Long identifier        */      "sldemo_fuelsys"
        /* Root                   */      ROOT
        /begin SUB_GROUP
          rtB.es_o
          sldemo_fuelsys_Dashboard
          sldemo_fuelsys_Engine_Gas_Dynamics
          sldemo_fuelsys_Throttle_Command
          sldemo_fuelsys_To_Controller
          sldemo_fuelsys_To_Plant
          sldemo_fuelsys_fuel_rate_control
        /end SUB_GROUP
      /end GROUP

  5. To group the scalar objects into a group named GROUP_TYPE_SCALAR in the ASAP2 file, use this command:

    coder.asap2.export("sldemo_fuelsys",CustomizeGroupsBy={'SCALAR'})

You can also group the objects of type array, and lookup tables into MAP, CURVE, CUBOID, CUBE_4, and CUBE_5 based on dimensions of the table.

Generate ASAP2 Containing Default Event List

Starting in R2022a, for a multirate model, the ASAP2 file contains the IF_DATA section that has the DEFAULT_EVENT_LIST, enabling you to view the respective raster values for the data elements in the calibration tools.

  1. Open the sldemo_fuelsys model.

    open_system("sldemo_fuelsys")

  2. Build the model.

  3. Generate the ASAP2 file by using Generate Calibration Files tool or by using this command:

    coder.asap2.export("sldemo_fuelsys")

  4. The model has a single rate of 0.01. The generated file defines measurements as:

       /begin MEASUREMENT
        /* Name                   */      rtB.es_o.throttle
        /* Long identifier        */      ""
        /* Data type              */      FLOAT32_IEEE
        /* Conversion method      */      sldemo_fuelsys_CM_single
        /* Resolution (Not used)  */      0      
        /* Accuracy (Not used)    */      0      
        /* Lower limit            */      -3.4E+38
        /* Upper limit            */      3.4E+38
        ECU_ADDRESS                       0x0000 /* @ECU_Address@rtB.es_o.throttle@ */
      /end MEASUREMENT

  5. Convert the model into multirate model by using this command:

    blockName = ['sldemo_fuelsys' '/EGO Fault Switch'];
    set_param(blockName, 'SampleTime', '0.02');

  6. Build the model.

  7. Generate the ASAP2 file by using this command:

    coder.asap2.export("sldemo_fuelsys")

  8. The generated file now defines the measurements as:

       /begin MEASUREMENT 
        /* Name                   */      rtB.es_o.throttle
        /* Long identifier        */      ""
        /* Data type              */      FLOAT32_IEEE
        /* Conversion method      */      sldemo_fuelsys_CM_single
        /* Resolution (Not used)  */      0      
        /* Accuracy (Not used)    */      0      
        /* Lower limit            */      -3.4E+38
        /* Upper limit            */      3.4E+38
        ECU_ADDRESS                       0x0000 /* @ECU_Address@rtB.es_o.throttle@ */
        /begin IF_DATA XCP
          /begin DAQ_EVENT VARIABLE
              /begin DEFAULT_EVENT_LIST
                EVENT  0x0001
              /end DEFAULT_EVENT_LIST
          /end DAQ_EVENT
         /end IF_DATA
      /end MEASUREMENT 

  9. To generate the ASAP2 file without DEFAULT_EVENT_LIST, use the command:

    coder.asap2.export("sldemo_fuelsys",IncludeDefaultEventList=false);

Generate Record Layouts in Separate File

  1. Open the sldemo_fuelsys model.

    open_system("sldemo_fuelsys")

  2. Build the model.

  3. Generate the ASAP2 file by using this command:

    coder.asap2.export("sldemo_fuelsys",IncludeAllRecordLayouts=true)

  4. The RecordLayouts.a2l file is generated according to the version of the ASAP2 file. In the ASAP2 file, verify this line:

    /include "RecordLayouts.a2l"

  5. The generated RecordLayouts.a2l file contains the record layouts of the data types present in the model.

    Note

    The RecordLayouts.a2l file is required to be in the same folder as the ASAP2 file.

  6. coder.asap2.export("sldemo_fuelsys",IncludeAllRecordLayouts=false) does not generate separate record layouts file, but includes the record layouts of the data types of exported data objects in the ASAP2 file.

    /begin  RECORD_LAYOUT Scalar_FLOAT32_IEEE
        FNC_VALUES 1 FLOAT32_IEEE COLUMN_DIR DIRECT
      /end  RECORD_LAYOUT 
    
      /begin  RECORD_LAYOUT Scalar_FLOAT64_IEEE
        FNC_VALUES 1 FLOAT64_IEEE COLUMN_DIR DIRECT
      /end  RECORD_LAYOUT
    ...

Merge ASAP2 Files

Starting in R2023a, you can merge the data elements of multiple A2L files to a Simulink model. Use the coder.asap2.merge function to create the merged descriptor object and generate an A2L file containing the data elements of the model and merged A2L files.

Vehicle Network Toolbox™ is required to merge A2L files using the coder.asap2.merge (Embedded Coder) function.

  1. Open the sldemo_fuelsys model.

    open_system("sldemo_fuelsys")

  2. Build the model.

  3. Merge the data elements of an A2L file to the model using the command:

    mergeObj = coder.asap2.merge("sldemo_fuelsys",{"ASAP2File1.a2l"})

    To merge more than one A2L file, specify the files in comma separated format. For example:

    mergeObj = coder.asap2.merge("sldemo_fuelsys",{"ASAP2File1.a2l","ASAP2File2.a2l"})

  4. Generate the A2L file using the mergeObj.

    coder.asap2.export("sldemo_fuelsys",CustomEcuDescriptions=mergeObj)

The generated A2L file contains the data elements present in sldemo_fuelsys model and the ASAP2File1 A2L file.

Specify ECU Address Extension

Starting in R2022a, you can specify additional address information in the ASAP2 file by specifying an integer value for the EcuAddressExtension property. By default, no additional address information is provided.

  1. Open the sldemo_fuelsys model.

    open_system("sldemo_fuelsys")

  2. Build the model.

  3. Generate the ASAP2 file by using this command:

    coder.asap2.export("sldemo_fuelsys",EcuAddressExtension=4)

    The ECU_ADDRESS_EXTENSION key word for the characteristics, measurements, and axis points are in the ASAP2 file, enabling you to specify additional address information.

     /begin MEASUREMENT 
       /* Name                   */      rtB.MinMax
       /* Long identifier        */      ""
       /* Data type              */      FLOAT64_IEEE
       /* Conversion method      */      sldemo_fuelsys_CM_double
       /* Resolution (Not used)  */      0      
       /* Accuracy (Not used)    */      0      
       /* Lower limit            */      -1.7E+308
       /* Upper limit            */      1.7E+308
       ECU_ADDRESS                       0x0000 /* @ECU_Address@rtB.MinMax@ */
       ECU_ADDRESS_EXTENSION 4
     /end MEASUREMENT 

See Also

|

Related Topics