In Simulink®, you can import and export AUTOSAR software data definition properties and modify the properties for some forms of AUTOSAR data.
SwDataDefProps
)Embedded Coder® supports ARXML import and export of the following
AUTOSAR software data definition properties
(SwDataDefProps
):
Software calibration access (SwCalibrationAccess
)
— Specifies measurement and calibration tool access to a data
object.
Display format (DisplayFormat
) — Specifies
measurement and calibration display format for a data object.
Software address method (SwAddrMethod
) —
Specifies a method to access a data object (for example, a measurement or
calibration parameter) according to a given address. Used to group data in
memory for access by run-time measurement and calibration
tools.
Software alignment (SwAlignment
) — Specifies
the intended alignment of a data object within a memory section.
Software implementation policy (SwImplPolicy
)
— Specifies the implementation policy for a data object, regarding
consistency mechanisms of variables.
Software record layout (SwRecordLayout
) —
Specifies how to serialize data in the memory of an AUTOSAR ECU.
In the Simulink environment, you can directly modify software data definition
properties for some forms of AUTOSAR data. You cannot modify the
SwImplPolicy
or SwRecordLayout
properties, but the properties are exported in ARXML code.
For more information, see Configure SwCalibrationAccess, Configure DisplayFormat, Configure SwAddrMethod, Configure SwAlignment, Export SwImplPolicy, and Export SwRecordLayout for Lookup Table Data.
SwCalibrationAccess
You can specify the SwCalibrationAccess
property for
measurement variables, calibration parameters, and signal and parameter data
objects. The valid values are:
ReadOnly
— Data element appears in the
generated description file with read access only.
ReadWrite
— Data element appears in the
generated description file with both read and write access.
NotAccessible
— Data element does not
appear in the generated description file and is not accessible with
measurement and calibration tools.
If you open a model with signals and parameters, you can specify the
SwCalibrationAccess
property in the following ways:
SwCalibrationAccess
for AUTOSAR Data ElementsYou can use either the AUTOSAR Dictionary or MATLAB® function calls to specify the
SwCalibrationAccess
property for the following AUTOSAR
data elements:
Sender-receiver interface data elements
Nonvolatile interface data elements
Client-server arguments
Inter-runnable variables
For example:
Open a model that is configured for AUTOSAR.
Open the AUTOSAR Dictionary. Navigate to one of the following views:
S-R or NV interface, DataElements view
C-S interface, Arguments view
Atomic component, IRV view
Use the SwCalibrationAccess drop-down list to select the level of measurement and calibration tool access to allow for the data element.
Alternatively, you can use the AUTOSAR property functions to specify the
SwCalibrationAccess
property for AUTOSAR data elements.
For example, the following code opens the
autosar_swc_fcncalls
example model and sets measurement
and calibration access to inter-runnable variable IRV2 to
ReadWrite
.
hModel = 'autosar_swc_fcncalls'; addpath(fullfile(matlabroot,'/examples/autosarblockset/main')); open_system(hModel) arProps = autosar.api.getAUTOSARProperties(hModel); get(arProps,'/Company/Powertrain/Components/ASWC/ASWC_IB/IRV2','SwCalibrationAccess') set(arProps,'/Company/Powertrain/Components/ASWC/ASWC_IB/IRV2','SwCalibrationAccess','ReadWrite'); get(arProps,'/Company/Powertrain/Components/ASWC/ASWC_IB/IRV2','SwCalibrationAccess')
ans = 'ReadOnly' ans = 'ReadWrite'
Here is a sample call to the AUTOSAR properties set
function to set
SwCalibrationAccess
for an S-R interface data element
in the same model.
set(arProps,'/Company/Powertrain/Interfaces/InIf/In1','SwCalibrationAccess','ReadWrite'); get(arProps,'/Company/Powertrain/Interfaces/InIf/In1','SwCalibrationAccess')
ans = 'ReadWrite'
SwCalibrationAccess
for Application Data TypesThe AUTOSAR XML options include SwCalibrationAccess
DefaultValue (property
SwCalibrationAccessDefault
), which defines the default
SwCalibrationAccess
value for AUTOSAR application data
types in your model. You can use the AUTOSAR property functions to modify the
default. For example, the following code opens the
autosar_swc_fcncalls
example model and changes the
default measurement and calibration access for AUTOSAR application data types
from ReadOnly
to ReadWrite
.
hModel = 'autosar_swc_fcncalls'; addpath(fullfile(matlabroot,'/examples/autosarblockset/main')); open_system(hModel) arProps = autosar.api.getAUTOSARProperties(hModel); get(arProps,'XmlOptions','SwCalibrationAccessDefault') set(arProps,'XmlOptions','SwCalibrationAccessDefault','ReadWrite'); get(arProps,'XmlOptions','SwCalibrationAccessDefault')
ans = 'ReadOnly' ans = 'ReadWrite'
DisplayFormat
AUTOSAR display format specifications control the width and precision display for measurement and calibration data. You can import and export AUTOSAR display format specifications, and edit the specifications in Simulink. You can specify display format for the following AUTOSAR elements:
Inter-runnable variables
Sender-receiver interface data elements
Client-server interface operation arguments
CompuMethods
The display format specification is a subset of ANSI® C
printf
specifiers, with the following form:
%[flags][width][.precision]type
Field | Description |
---|---|
flags (optional) | Characters specifying flags supported by AUTOSAR schemas:
|
width (optional) | Positive integer specifying the minimum number of characters to display. |
precision (optional) | Positive integer specifying the precision to display:
|
type | Characters specifying a numeric conversion type supported by AUTOSAR schemas:
|
For example, the format specifier %2.1d
specifies width 2,
precision 1, and type signed decimal, producing a displayed value such as
12.2.
The DisplayFormat attribute appears in dialog boxes for AUTOSAR elements to which it applies. You can specify display format in a dialog box or with an element API that can modify attributes.
hModel = 'autosar_swc_counter'; addpath(fullfile(matlabroot,'/examples/autosarblockset/main')); open_system(hModel); slMap = autosar.api.getSimulinkMapping(hModel); mapParameter(slMap,'INC','ConstantMemory','DisplayFormat','%2.6f')
If you specify a display format, exporting ARXML code generates a corresponding DISPLAY-FORMAT specification.
<PARAMETER-DATA-PROTOTYPE UUID="..."> <SHORT-NAME>INC</SHORT-NAME> <CATEGORY>VALUE</CATEGORY> <SW-DATA-DEF-PROPS> <SW-DATA-DEF-PROPS-VARIANTS> <SW-DATA-DEF-PROPS-CONDITIONAL> <SW-CALIBRATION-ACCESS>READ-WRITE</SW-CALIBRATION-ACCESS> <DISPLAY-FORMAT>%2.6f</DISPLAY-FORMAT> <SW-IMPL-POLICY>STANDARD</SW-IMPL-POLICY> </SW-DATA-DEF-PROPS-CONDITIONAL> </SW-DATA-DEF-PROPS-VARIANTS> </SW-DATA-DEF-PROPS> ... </PARAMETER-DATA-PROTOTYPE>
SwAddrMethod
AUTOSAR software components use software address methods
(SwAddrMethod
s) to group data and functions into memory
sections for access by run-time measurement and calibration tools. For a Simulink model mapped to an AUTOSAR software component, you can associate
SwAddrMethod
s with these elements:
Model parameter or lookup table mapped to:
AUTOSAR constant memory
AUTOSAR internal calibration parameter
AUTOSAR port parameter
Signal, state, or data store mapped to:
AUTOSAR static memory
AUTOSAR per-instance memory
Model entry-point function mapped to AUTOSAR runnable
Internal data inside a model entry-point function
To create and use SwAddrMethod
s in an AUTOSAR model:
Import SwAddrMethod
s from ARXML
files or create SwAddrMethod
s in Simulink.
To import SwAddrMethod
s from
ARXML files, use an
arxml.importer
function –
createComponentAsModel
or
createCompositionAsModel
for a new model,
or updateModel
or
updateAUTOSARProperties
for an existing
model.
To create SwAddrMethod
s in an existing model,
open the AUTOSAR Dictionary, SwAddrMethods view, and click the
Add button . Alternatively, use equivalent
AUTOSAR property functions. For more information, see Create SwAddrMethods in Simulink.
Associate SwAddrMethod
s with model data and functions.
Open the Code Mappings editor and select the
Parameters, Data Stores,
Signals/States, or Functions
tab. Select an element within that tab and use the Property Inspector to set
the SwAddrMethod attribute. Alternatively, use the
equivalent AUTOSAR map function. For more information, see Associate SwAddrMethod with Model Data or Function.
Generate code for your AUTOSAR model. (This example uses a signal mapped
to AUTOSAR static memory in the model
autosar_swc_counter
.) In the generated files:
Exported ARXML files contain
SwAddrMethod
descriptions and
references.
<VARIABLE-DATA-PROTOTYPE UUID="..."> <SHORT-NAME>SM_equal_to_count</SHORT-NAME> <CATEGORY>VALUE</CATEGORY> <SW-DATA-DEF-PROPS> <SW-DATA-DEF-PROPS-VARIANTS> <SW-DATA-DEF-PROPS-CONDITIONAL> <SW-ADDR-METHOD-REF DEST="SW-ADDR-METHOD"> /Company/Powertrain/DataTypes/SwAddrMethods/VAR </SW-ADDR-METHOD-REF> <SW-CALIBRATION-ACCESS>READ-ONLY</SW-CALIBRATION-ACCESS> <SW-IMPL-POLICY>STANDARD</SW-IMPL-POLICY> </SW-DATA-DEF-PROPS-CONDITIONAL> </SW-DATA-DEF-PROPS-VARIANTS> </SW-DATA-DEF-PROPS> <TYPE-TREF DEST="IMPLEMENTATION-DATA-TYPE"> /Company/Powertrain/DataTypes/Boolean_volatile_my_qualifier</TYPE-TREF> </VARIABLE-DATA-PROTOTYPE>
AUTOSAR-compliant C code contains comments and
#define
and #include
statements that provide a wrapper around data or function
definitions belonging to each SwAddrMethod
memory
section.
/* Static Memory for Internal Data */ /* SwAddrMethod VAR for Internal Data */ #define autosar_swc_counter_START_SEC_VAR #include "autosar_swc_counter_MemMap.h" volatile my_qualifier boolean SM_equal_to_count; #define autosar_swc_conter_STOP_SEC_VAR #include "autosar_swc_counter_MemMap.h"
SwAddrMethod
s in SimulinkTo create SwAddrMethod
s in an existing model, open the
AUTOSAR Dictionary, SwAddrMethods view, and click the Add
button .
Alternatively, use equivalent AUTOSAR property functions. This code adds SwAddrMethods myCODE and myVAR to an AUTOSAR component model.
hModel = 'autosar_swc_counter'; addpath(fullfile(matlabroot,'/examples/autosarblockset/main')); open_system(hModel) arProps = autosar.api.getAUTOSARProperties(hModel); addPackageableElement(arProps,'SwAddrMethod',... '/Company/Powertrain/DataTypes/SwAddrMethods','myCODE',... 'SectionType','Code') swAddrPaths = find(arProps,[],'SwAddrMethod','PathType','FullyQualified',... 'SectionType','Code') addPackageableElement(arProps,'SwAddrMethod',... '/Company/Powertrain/DataTypes/SwAddrMethods','myVAR',... 'SectionType','Var') swAddrPaths = find(arProps,[],'SwAddrMethod','PathType','FullyQualified',... 'SectionType','Var')
swAddrPaths = {'/Company/Powertrain/DataTypes/SwAddrMethods/CODE'} {'/Company/Powertrain/DataTypes/SwAddrMethods/myCODE'} swAddrPaths = {'/Company/Powertrain/DataTypes/SwAddrMethods/VAR'} {'/Company/Powertrain/DataTypes/SwAddrMethods/myVAR'}
SwAddrMethod
with Model Data or FunctionTo associate SwAddrMethod
s with model data and functions,
open the Code Mappings editor and select the Parameters,
Data Stores, Signals/States, or
Functions tab. Select an element within that tab and
use the Property Inspector to set the SwAddrMethod
attribute. In this example, SwAddrMethod
VAR is selected for
signal equal_to_count
, which is mapped to AUTOSAR static
memory.
Alternatively, use the equivalent AUTOSAR map function. For more information,
see the reference page for mapFunction
, mapParameter
, mapSignal
, mapState
, or mapDataStore
.
SwAlignment
The SwAlignment
property describes the intended alignment of
AUTOSAR data within a memory section. SwAlignment
defines a
quantity of bits. Valid values include 8, 12, 32, UNKNOWN (deprecated), UNSPECIFIED,
and BOOLEAN. For numeric data, typical SwAlignment
values are
8, 16, and 32.
If you do not define the SwAlignment
property, the
swBaseType
size and the
memoryAllocationKeywordPolicy
of the referenced
SwAlignment
determine the alignment.
You can use the AUTOSAR property function set
to set
SwAlignment
for S-R interface data elements and
inter-runnable variables. For example:
interfacePath = '/A/B/C/Interfaces/If1/'; dataElementName = 'El1'; swAlignmentValue = '32'; set(dataObj,[interfacePath dataElementName],'SwAlignment',swAlignmentValue);
To support the round-trip workflow, the ARXML importer imports
and preserves the SwAlignment
property for the following
AUTOSAR data:
Per-instance memory
Software component parameters
Parameter interface data elements
Client-server interface operation arguments
Static and constant memory
SwImplPolicy
The SwImplPolicy
property specifies the implementation policy
for a data element, regarding consistency mechanisms of variables. You cannot modify
the SwImplPolicy
property, but the property is set to
standard
or queued
for AUTOSAR data in
exported ARXML code. The value is set to:
standard
for
Per-instance memory
Inter-runnable variables
Software component parameters
Parameter interface data elements
Client-server interface operation arguments
Static and constant memory
standard
or queued
for
Sender-receiver interface data elements |
SwRecordLayout
for Lookup Table DataAUTOSAR software components use software record layouts
(SwRecordLayout
s) to specify how to serialize data in the
memory of an AUTOSAR ECU. The ARXML importer imports and
preserves the SwRecordLayout
property for AUTOSAR data.
You can import SwRecordLayout
s from ARXML
files in either of two ways:
If you create your AUTOSAR model from ARXML files using
importer function createComponentAsModel
, include an
ARXML file that contains
SwRecordLayout
definitions in the import. The
imported SwRecordLayout
s are preserved and later exported
in ARXML code.
If you create your AUTOSAR model in Simulink, you can import shared definitions of
SwRecordLayout
s from ARXML files. Use importer
function updateAUTOSARProperties
. For example:
importerObj = arxml.importer(arxmlFileName); updateAUTOSARProperties(importerObj,modelName);
When you generate model code, the exported ARXML code contains references
to the imported read-only SwRecordLayout
elements, but
not their definitions.
For more information, see Import and Reference Shared AUTOSAR Element Definitions.