Main Content

Customize Using Base Files

You can add custom A2L file fragments such as PROJECT, MODULE, MOD, MOD_PAR, and MOD_COMMON settings to the ASAP2 file. You can do it in the following ways:

Customize ASAP2 Fields by Using Base Class

  1. Create an object from the base class using the coder.asap2.UserCustomizeBase function.

    obj = coder.asap2.UserCustomizeBase;

  2. Define the object fields.

    obj.HeaderComment = 'Header comment';
    obj.ModParComment = 'Mod Par comment';
    obj.ModCommonComment = 'Mod Common comment';
    obj.ASAP2FileName = 'File_name';
    obj.ByteOrder = 'BYTEORDER MSB_LAST';

  3. Pass the object to the function and generate the ASAP2 file.


Customize ASAP2 Sections by Deriving from Base Class

  1. Derive from the base class coder.asap2.UserCustomizeBase. You can place the derived file anywhere on the MATLAB path.

  2. To edit the Header section, use the writeHeader function.

  3. Use the writeHardwareInterface function to edit the hardware interface section consisting of the MOD_PAR and MOD_COMMON fields of the ASAP2 file.

  4. To add text at the beginning of the ASAP2 file, use the writeFileHead function.

  5. To add text at the end of the ASAP2 file, use the writeFileTail function.

    For example, the code for generating a derived class TestASAP2Customization might look like this code:

    classdef TestASAP2Customization < coder.asap2.UserCustomizeBase
        %   Customization class for asap2 file
            function header = writeHeader(obj)
                header = sprintf(['  /begin HEADER ' 'test Header text'  '\n',...
                    'header test comments from user\n',...
                    '  /end HEADER']);
            function hardwareInterface = writeHardwareInterface(obj)
                hardwareInterface = sprintf(['    /begin MOD_PAR "' 'UserDefined' '"\n',...
                    '      test comments from user\n',...
                    '    /end MOD_PAR\n\n',...
                    '    /begin MOD_COMMON "'  'UserDefined MOD_COMMON' '"\n',...
                    '      user defined values for MOD_COMMON\n',...
                    '     ' obj.ByteOrder '\n',...
                    '     /end MOD_COMMON']);
            function fileTail = writeFileTail(obj)
                fileTail = sprintf(['/* This File can be used for ' ,...
                    'calibration .*/\n'...
                    '/* EOF ',obj.ASAP2FileName, '*/']);
            function fileHeader = writeFileHead(obj)
                fileHeader = sprintf(['/******************************************************************************\n',...
                    ' This is a a2l file which can be used for calibration with INCA or CANAPE\n',...
                    ' ******************************************************************************/'

  6. Create an object from the derived class. For example, this command creates an object from TestASAP2Customization.

    obj = TestASAP2Customization;

  7. Pass the object to the function that generates the ASAP2 file.


See Also


Related Topics