To generate AUTOSAR-compliant C++ code and ARXML component descriptions from a model configured for the AUTOSAR Adaptive platform:
In the Configuration Parameters dialog box, on the Code Generation > AUTOSAR Code Generation Options pane, configure AUTOSAR code generation parameters.
Configure AUTOSAR XML export options by using the AUTOSAR Dictionary or AUTOSAR property functions.
Build the model.
For import and export of ARXML files and generation of AUTOSAR-compliant C++ code, AUTOSAR Blockset supports the following AUTOSAR Adaptive Platform schema versions:
00047 (R19-03)
00046 (R18-10)
Selecting the AUTOSAR adaptive system target file for your model for the first time
sets the schema version parameter to the default value 00047
(R19-03)
.
If you import ARXML files into Simulink®, the ARXML importer detects and uses the schema version. It sets the schema version parameter in the model. For example, if you import ARXML files based on schema 00047 (R19-03), the importer sets the matching schema version in the model.
When you build an AUTOSAR adaptive model, the code generator exports ARXML descriptions and generates C++ code that are compliant with the current AUTOSAR schema version value.
Before exporting your AUTOSAR software component, check the selected schema version. If you need to change the selected schema version, use the model configuration parameter Generate XML file for schema version.
Set the AUTOSAR model configuration parameters to the same values for top and referenced models. This guideline applies to Generate XML file for schema version, Maximum SHORT-NAME length, Transport layer, IP address, Port, Verbose, and Use custom XCP Slave.
The AUTOSAR standard specifies that the maximum length of
SHORT-NAME
XML elements is 128 characters.
To specify a maximum length for SHORT-NAME
elements exported by the
code generator, set the model
configuration parameter Maximum SHORT-NAME
length to a positive number of characters less than or equal to 128.
The default is 128 characters.
XCP is a network protocol originating from ASAM for connecting calibration systems to electronic control units. It enables read and write access to variables and memory contents of micro controller systems at runtime. As a two-layer protocol, XCP separates the protocol and transport layers and adheres to a Single-Master/Multi-Slave concept. Transport layer selection does not affect the XCP protocol layer.
Currently, the following transport layers are defined as standard by ASAM:
XCP on CAN
XCP on Sxl
XCP on Ethernet (TCP/IP or UDP/IP)
XCP on USB
XCP on Flex Ray
To select the transport layer used by the AUTOSAR adaptive application (XCP Slave), use the model configuration parameter Transport layer. Selecting an XCP transport layer enables other XCP parameters.
For more information, see Configure AUTOSAR Adaptive Data for Run-Time Measurement and Calibration.
Internet Protocol (IP) is the principal communications protocol for relaying datagrams across network boundaries. The Internet Protocol is responsible for addressing host interfaces, encapsulating data into datagrams, and routing datagrams from a source host interface to a destination host interfaces across one or more IP networks.
Each datagram has two components: a header and a payload. The IP header includes source IP address, destination IP address, and other metadata needed to route and deliver the datagram. The payload is the data that it transported.
To specify the IP address of the machine on which the AUTOSAR adaptive application (XCP Slave) executes, use the model configuration parameter IP address. The IP address parameter is enabled by selecting a value for Transport layer.
For more information, see Configure AUTOSAR Adaptive Data for Run-Time Measurement and Calibration.
A port number is the logical address of each application or process that uses a network or the Internet to communicate. Port number primarily aids in the transmission of data between a network and an application. Port numbers work in collaboration with networking protocols to achieve this.
A port number uniquely identifies a network-based application on a computer. Each application is allocated a 16-bit integer port number. This number is assigned by the operating system, set manually by the user, or set as a default.
To specify the network port on which the AUTOSAR adaptive application (XCP Slave) serves XCP Master commands, use the model configuration parameter Port. The Port parameter is enabled by selecting a value for Transport layer.
For more information, see Configure AUTOSAR Adaptive Data for Run-Time Measurement and Calibration.
Verbosity is the level of technical detail included in software messages. Verbose messages can help in debugging and understanding XCP communication.
To enable verbose messages for the AUTOSAR adaptive application (XCP Slave), select the model configuration parameter Verbose. The Verbose parameter is enabled by selecting a value for Transport layer.
For more information, see Configure AUTOSAR Adaptive Data for Run-Time Measurement and Calibration.
By default, the MathWorks® XCP Slave is used for communication. You can use a custom XCP Slave for
the Ethernet (TCP/IP) transport layer. A custom XCP Slave implementation is required to
establish the interface. Define the implementation in header file
xcp_slave.h
in folder
.matlabroot
/toolbox/coder/autosar/adaptive
To enable use of a custom XCP Slave, select the model configuration parameter Use custom XCP Slave. The Use custom XCP Slave parameter is enabled by selecting a value for Transport layer.
For more information, see Configure AUTOSAR Adaptive Data for Run-Time Measurement and Calibration.
Examine the XML options that you configured by using the AUTOSAR Dictionary. If you have not yet configured the options, see Configure AUTOSAR Adaptive XML Options.
After configuring AUTOSAR code generation and XML options, generate code. To generate C++ code and export XML descriptions, build the adaptive component model.
The build process generates AUTOSAR-compliant C++ code and AUTOSAR XML descriptions to the model build folder. The exported XML files include:
One or more
files, based on whether you set Exported XML file packaging
to modelname
*.arxmlSingle file
or
Modular
.
Manifests for AUTOSAR executables and service instances.
If you imported ARXML files into Simulink, updated versions of those files.
This table lists
files
that are generated based on the value of the Exported XML file
packaging option configured in the AUTOSAR Dictionary.modelname
*.arxml
Exported XML File Packaging Value | Exported File Name | Default Contents |
---|---|---|
Single file |
| All AUTOSAR elements. |
| Deployment-related information for applications. | |
| Configuration of service-oriented communication. | |
Modular |
| Software components. This file is the main ARXML file exported for the Simulink model. The file includes elements for which AUTOSAR packages (AR-PACKAGEs) are not configured and AR-PACKAGEs that do not align with the package paths in the other exported ARXML files. For more information on AR-PACKAGEs and their location in modular exported ARXML files, see AR-PACKAGE Location in Exported ARXML Files. |
| Data types and related elements. | |
| Interfaces, including adaptive service interfaces. | |
| Deployment-related information for applications. | |
| Configuration of service-oriented communication. |
You can merge the AUTOSAR adaptive XML component descriptions into an AUTOSAR authoring tool. The AUTOSAR component information is partitioned into separate files to facilitate merging. The partitioning attempts to minimize the number of merges that you must do. You do not need to merge the data type file into the authoring tool because data types are defined early in the design process. You must merge the internal behavior file because this information is part of the model implementation.
To help support the round trip of AUTOSAR elements between an AUTOSAR authoring tool (AAT) and the Simulink Model-Based Design environment, the code generator preserves AUTOSAR elements and their universal unique identifiers (UUIDs) across ARXML import and export. For more information, see Round-Trip Preservation of AUTOSAR XML File Structure and Element Information.
For an example of how to generate AUTOSAR-compliant C++ code and export AUTOSAR XML component descriptions from a Simulink model, see Generate AUTOSAR Adaptive C++ Code and XML Descriptions.
Generate XML file for schema version | IP address | Maximum SHORT-NAME length | Port | Transport layer | Use custom XCP Slave | Verbose