Main Content

Configure AUTOSAR Data Types Export

The AUTOSAR standard defines an approach to AUTOSAR data types in which base data types are mapped to implementation data types and application data types. Application and implementation data types separate application-level physical attributes from implementation-level attributes. Examples of application-level physical attributes are real-world ranges of values, data structures, and physical semantics. Examples of implementation-level attributes are stored-integer minimum and maximum values and specifications of AUTOSAR platform types (such as, integer, Boolean, or real). For information about modeling data types, see Model AUTOSAR Data Types.

The software supports AUTOSAR data types in Simulink® originated, round-trip, and top-down workflows:

  • For AUTOSAR components originated in Simulink, the software generates AUTOSAR application, implementation, and base types to preserve the information contained within Simulink data types.

  • For round-trip and top-down workflows involving AUTOSAR components that originated outside MATLAB®, the ARXML importer and exporter preserve data type information and mapping for each imported AUTOSAR data type.

For AUTOSAR data types that originated in Simulink, you can control some aspects of data type export. For example, you can control when application data types are generated, specify the AUTOSAR package and short name exported for AUTOSAR data type mapping sets, or force ARXML export of internal data constraints for AUTOSAR implementation data types.

Control Application Data Type Generation

The software, by default, generates application data types only for fixed-point data types, enumerated data types with storage types, Simulink.ValueType objects, and lookup table data types. If you want to override the default behavior for generating application data types, you can configure the ARXML exporter to generate an application data type, along with the implementation data type and base type, for each exported AUTOSAR data type. However, the software always generates an implementation data type and application data type in the generated ARXML when exporting a Simulink.ValueType object.

Use the XML options parameter ImplementationDataType Reference (XMLOptions property ImplementationDataTypeReference), for which you can specify the following values:

  • Allowed (default) — Allow direct reference of implementation types in the generated ARXML code. If an application data type is not strictly required to describe an AUTOSAR data type, use an implementation data type reference.


    This setting will not remove application data types that were generated by selecting NotAllowed on a prior model build.

  • NotAllowed — Do not allow direct reference of implementation data types in the generated ARXML code. Generate an application data type for each AUTOSAR data type.

To set the ImplementationDataTypeReference property in the AUTOSAR Dictionary, select XML Options. Select a value for parameter ImplementationDataType Reference. Click Apply.

For more information about setting this parameter programmatically see AUTOSAR XML Options Settings.

Configure DataTypeMappingSet Package and Name

For AUTOSAR software components created in Simulink, you can control the AUTOSAR package and short name exported for AUTOSAR data type mapping sets. To configure the data type mapping set package for export, set the XMLOptions property DataTypeMappingPackage using the AUTOSAR Dictionary or the AUTOSAR property set function.

hModel = "autosar_swc_expfcns";

The exported ARXML code uses the specified package. The default mapping set short-name is the component name ASWC prefixed to DataTypeMappingsSet.


You can specify a short name for a data type mapping set using the AUTOSAR property function addPackageableElement. The following example specifies a custom data type mapping set package and name using MATLAB commands.

% Add a new data type mapping set
modelName = "autosar_swc_expfcns";
propObj = autosar.api.getAUTOSARProperties(modelName);
newMappingSetPath = '/myPkg/mySubpkg/MyMappingSets';
newMappingSetName = 'MappingSetName';
newMappingSet = [newMappingSetPath '/' newMappingSetName];

% Configure the component behavior to use the new data type mapping set
swc = get(propObj,"XmlOptions","ComponentQualifiedName");
ib = get(propObj,swc,"Behavior","PathType","FullyQualified");

% Force generation of application data types

% Build

The exported ARXML code uses the specified package and name, as shown below.


Initialize Data with ApplicationValueSpecification

To initialize AUTOSAR data objects typed by application data type, the AUTOSAR standard (R4.1 or later) requires AUTOSAR application value specifications (ApplicationValueSpecifications). Embedded Coder® provides the following support:

  • The ARXML importer uses ApplicationValueSpecifications found in imported ARXML files to initialize the corresponding data objects in the Simulink model.

  • Code generation exports ARXML code that uses ApplicationValueSpecifications to specify initial values for AUTOSAR data.

For AUTOSAR parameters typed by implementation data type, code generation exports ARXML code that uses NumericalValueSpecifications and (for enumerated types) TextValueSpecifications to specify initial values. If initial values for parameters specify multiple values, generated code uses ArrayValueSpecifications.

Configure AUTOSAR Internal Data Constraints Export

AUTOSAR applications use data constraints to implement limits on data types and provide a controlled range of possible values. Internal data constraints represent minimum and maximum values for implementation data types, reflecting the internal or machine view of the data.

By default, code generation does not export internal data constraint information for AUTOSAR implementation data types in ARXML code. If you want to force export of internal data constraints for implementation data types, select the XML option Internal DataConstraints Export.

If you select Internal DataConstraints Export, the exporter generates internal data constraints into an AUTOSAR package with a default name, DataConstrs, at a fixed location under the AUTOSAR data type package. Optionally, use the XML option Internal DataConstraints Package to specify a different AUTOSAR package name and path.

To configure export of AUTOSAR internal data constraint information in your model:

  1. Open the AUTOSAR Dictionary. On the AUTOSAR tab, select Code Interface > AUTOSAR Dictionary.

  2. Select XML Options. In the XML options view, under Additional Options, select Internal DataConstraints Export.

  3. Optionally, under Additional Packages, enter a package path for Internal DataConstraints Package.

  4. Build the model and inspect the generated code. Here is an example of an AUTOSAR internal data constraint exported to ARXML code.

            <DATA-CONSTR UUID="...">
                            <LOWER-LIMIT INTERVAL-TYPE="CLOSED">-128</LOWER-LIMIT>
                            <UPPER-LIMIT INTERVAL-TYPE="CLOSED">127</UPPER-LIMIT>

Alternatively, you can programmatically configure the AUTOSAR XML options Internal DataConstraints Export and Internal DataConstraints Package. For example:

arProps = autosar.api.getAUTOSARProperties(hModel);

For more information, see Configure AUTOSAR XML Options and AUTOSAR XML Options Settings.

Related Examples

More About