Main Content

writeHardwareInterface

Get or set custom data to describe ECU interface data

Since R2025a

Description

hardwareInterface = writeHardwareInterface(UserCustomizeBaseObj) returns the text that describes ECU interface specific data in the ASAP2 file. To add a custom text, derive an object from the coder.asap2.UserCustomizeBase class. Use the derived object to update the writeHardwareInterface function by adding custom text.

example

Examples

collapse all

This example shows how to add custom text to the ASAP2 file.

To add custom data, you need to derive an object from the coder.asap2.UserCustomizeBase class. Use the derived object to pass the custom data such as header comments, text at the beginning and ending of the ASAP2 file, and description about ECU interface specific data.

This example uses ASAP2Demo model.

Build the Model

Open the model and build it.

open_system("ASAP2Demo");
slbuild("ASAP2Demo");

Create Derived Object

To create a derived object from coder.asap2.UserCustomizeBase class and reuse the functions by adding custom data, copy the below code and save it in a m-file.

% classdef TestASAP2Customization < coder.asap2.UserCustomizeBase
%     %   Customization class for asap2 file
%     methods
%         function header = writeHeader(obj)
%             header = sprintf(['  /begin HEADER ' 'test Header text'  '\n',...
%                 'header test comments from user\n',...
%                 '  /end HEADER']);
%         end
% 
%         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']);
%         end
% 
%         function fileTail = writeFileTail(obj)
%             fileTail = sprintf(['/* This File can be used for ' ,...
%                 'calibration .*/\n'...
%                 '/* EOF ',obj.ASAP2FileName, '*/']);
%         end
% 
%         function fileHeader = writeFileHead(obj)
%             fileHeader = sprintf(['/******************************************\n',...
%                 ' This is an a2l file which can be used for calibration ',...
%                 ' with INCA or CANAPE\n',...
%                 ' ************************************************************/'
%                 ]);
%         end
%     end
% end

Run the m-file to create a derived object and add the custom data to the object. Run the TestASAP2Customization m-file from the example folder that contains the class definition for the derived object.

obj = TestASAP2Customization;

Generate ASAP2 File

Generate the ASAP2 file for the model by passing the object created as a customization object.

coder.asap2.export('ASAP2Demo', CustomizationObject = obj);

An ASAP2 file generates by adding the custom data provided in the derived object.

Input Arguments

collapse all

Specify the name of the object that is derived from coder.asap2.UserCustomizeBase class.

Example: CustomizationObject

Version History

Introduced in R2025a