Optional: Generate AUTOSAR Adaptive Software Component Code (Requires Embedded Coder)
If you have access to Simulink® Coder™ and Embedded Coder® software, you can build an AUTOSAR adaptive model. When you build an AUTOSAR adaptive model, the code generator produces C++ code that complies with the AUTOSAR standard for the Adaptive Platform and ARXML descriptions.
If not already open, open your configured version of model
Initiate code generation by pressing Ctrl+B. The code generator produces C++ code and ARXML files. The generated code complies with the AUTOSAR standard so that you can schedule the code with the AUTOSAR run-time environment.
The code generator also produces and displays a code generation report.
In the code generation report, review the generated code. In your current MATLAB® folder, the
my_autosar_LaneGuidance_autosar_adaptivefolder contains the primary files listed in this table.
Generated Code Files
Contains entry points for the code that implements the model algorithm. This file includes the rate scheduling code.
Declares model data structures and a public interface to the model entry points and data structures.
Defines data types, structures, and macros that the generated code requires.
The main ARXML file contains elements and objects that represent AUTOSAR software components, ports, interfaces, data types, and packages. The manifest files provide deployment-related and service-configuration information. You integrate ARXML files into an AUTOSAR run-time environment. You can import ARXML files into the Simulink environment by using the AUTOSAR ARXML importer tool.
Provide a framework for running adaptive software component service code.
Open and review the Code Interface Report. This information is captured in the ARXML files. The run-time environment generator uses the ARXML descriptions to interface the code into an AUTOSAR run-time environment.
Initialization entry-point function —
void my_autosar_LaneGuidanceModelClass::initialize(). At startup, call this function once.
Output entry-point function —
void my_autosar_LaneGuidanceModelClass::step(). Call this function periodically, every 0.1 seconds.
Termination entry-point function —
void my_autosar_LaneGuidanceModelClass::terminate(). At shutdown, call this function once.
Block leftLaneDistance — Require port, interface: sender-receiver of type real-T of 1 dimension
Block leftTurnIndicator — Require port, interface: sender-receiver of type real-T of 1 dimension
Block rightLaneDistance — Require port, interface: sender-receiver of type real-T of 1 dimension
Block rightTurnIndicator — Require port, interface: sender-receiver of type real-T of 1 dimension
Block leftCarInBlindSpot — Require port, interface: sender-receiver of type real-T of 1 dimension
Block rightCarInBlindSpot — Require port, interface: sender-receiver of type real-T of 1 dimension
Block leftHazardIndicator — Port defined externally of type real-T of 1 dimension
Block rightHazardIndicator — Port defined externally of type real-T of 1 dimension
Check whether the configuration changes that you made appear in the generated code by using the Code panel in the Code perspective. To open the Code panel, on the AUTOSAR tab, click View Code. The Code panel opens to the right of the model.
my_autosar_LaneGuidance.cppselected, in the search field, type
company(one of the namespace values that you defined for the service interfaces). The Code view highlights instances of
company, showing how the namespace symbols are applied in the code.
Use the Code perspective Code panel to explore other aspects of the generated code. For example, if you select file
my_autosar_LaneGuidance.cpp, and then click in the search field, a list of links to code elements appear. Use the links to quickly navigate to key areas of the generated code.