Configure AUTOSAR Data for Measurement and Calibration
In Simulink®, you can import and export AUTOSAR software data definition properties and modify the properties for some forms of AUTOSAR data.
About Software Data Definition Properties (SwDataDefProps
)
Embedded Coder®supportsarxml
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
)——指定一个方法来访问一个数据对象(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 theSwImplPolicy
orSwRecordLayout
properties, but the properties are exported inarxml
code.
For more information, seeConfigure SwCalibrationAccess,Configure DisplayFormat,Configure SwAddrMethod,Configure SwAlignment,出口SwImplPolicy, andExport SwRecordLayout for Lookup Table Data.
ConfigureSwCalibrationAccess
You can specify theSwCalibrationAccess
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 theSwCalibrationAccess
property in the following ways:
SpecifySwCalibrationAccess
for AUTOSAR Data Elements
You can use either the AUTOSAR Dictionary or MATLAB®function calls to specify theSwCalibrationAccess
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,DataElementsview
C-S interface,Argumentsview
Atomic component,IRVview
Use theSwCalibrationAccessdrop-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 theSwCalibrationAccess
property for AUTOSAR data elements. For example, the following code opens theautosar_swc_fcncalls
example model and sets measurement and calibration access to inter-runnable variable IRV2 toReadWrite
.
hModel ='autosar_swc_fcncalls'; 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 propertiesset
function to setSwCalibrationAccess
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'
Specify DefaultSwCalibrationAccess
for Application Data Types
The AUTOSAR XML options includeSwCalibrationAccess DefaultValue(propertySwCalibrationAccessDefault
), which defines the defaultSwCalibrationAccess
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 theautosar_swc_fcncalls
example model and changes the default measurement and calibration access for AUTOSAR application data types fromReadOnly
toReadWrite
.
hModel ='autosar_swc_fcncalls'; 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'
ConfigureDisplayFormat
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 ofANSI®Cprintf
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.
TheDisplayFormatattribute 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'; open_system(hModel); slMap = autosar.api.getSimulinkMapping(hModel); mapParameter(slMap,'INC','ConstantMemory','DisplayFormat','%2.6f')
If you specify a display format, exportingarxml
code generates a corresponding DISPLAY-FORMAT specification.
INC VALUE ... READ-WRITE %2.6f STANDARD
ConfigureSwAddrMethod
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 associateSwAddrMethod
s with these elements:
Model parameter mapped to AUTOSAR constant memory
Model parameter mapped to AUTOSAR internal calibration parameter
Signal, state, or data store mapped to AUTOSAR static memory
Signal, state, or data store mapped to AUTOSAR per-instance memory
Model entry-point function mapped to AUTOSAR runnable
Internal data inside a model entry-point function
To create and useSwAddrMethod
s in an AUTOSAR model:
Import
SwAddrMethod
s fromarxml
files or createSwAddrMethod
s in Simulink.To import
SwAddrMethod
s fromarxml
files, use anarxml.importer
function –createComponentAsModel
orcreateCompositionAsModel
for a new model, orupdateModel
orupdateAUTOSARProperties
for an existing model.To create
SwAddrMethod
在现有的模型,打开AUTOSAR Dictionary, SwAddrMethods view, and click theAddbutton. Alternatively, use equivalent AUTOSAR property functions. For more information, seeCreate SwAddrMethods in Simulink.
Associate
SwAddrMethod
s with model data and functions. Open the Code Mappings editor and select theParameters,数据存储,Signals/States, orFunctionstab. Select an element within that tab and use the Property Inspector to set theSwAddrMethodattribute. Alternatively, use the equivalent AUTOSAR map function. For more information, seeAssociate 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 containSwAddrMethod
descriptions and references.SM_equal_to_count VALUE /Company/Powertrain/DataTypes/SwAddrMethods/VAR READ-ONLY STANDARD /Company/Powertrain/DataTypes/Boolean_volatile_my_qualifier AUTOSAR-compliant C code contains comments and
#define
and#include
statements that provide a wrapper around data or function definitions belonging to eachSwAddrMethod
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"
CreateSwAddrMethod
s in金宝app
To createSwAddrMethod
在现有的模型,打开AUTOSAR Dictionary, SwAddrMethods view, and click theAddbutton.
Alternatively, use equivalent AUTOSAR property functions. This code adds SwAddrMethods myCODE and myVAR to an AUTOSAR component model.
hModel ='autosar_swc_counter'; 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'}
AssociateSwAddrMethod
with Model Data or Function
To associateSwAddrMethod
s with model data and functions, open the Code Mappings editor and select theParameters,数据存储,Signals/States, orFunctionstab. Select an element within that tab and use the Property Inspector to set theSwAddrMethodattribute. In this example,SwAddrMethod
VAR is selected for signalequal_to_count
, which is mapped to AUTOSAR static memory.
Alternatively, use the equivalent AUTOSAR map function. For more information, see the reference page formapFunction
,mapParameter
,mapSignal
,mapState
, ormapDataStore
.
ConfigureSwAlignment
TheSwAlignment
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, typicalSwAlignment
values are 8, 16, and 32.
If you do not define theSwAlignment
property, theswBaseType
size and thememoryAllocationKeywordPolicy
of the referencedSwAlignment
determine the alignment.
You can use the AUTOSAR property functionset
to setSwAlignment
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, thearxml
importer imports and preserves theSwAlignment
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
ExportSwImplPolicy
TheSwImplPolicy
property specifies the implementation policy for a data element, regarding consistency mechanisms of variables. You cannot modify theSwImplPolicy
property, but the property is set tostandard
orqueued
for AUTOSAR data in exportedarxml
code. The value is set to:
standard
forPer-instance memory
Inter-runnable variables
Software component parameters
Parameter interface data elements
Client-server interface operation arguments
Static and constant memory
standard
orqueued
forSender-receiver interface data elements
ExportSwRecordLayout
for Lookup Table Data
AUTOSAR software components use software record layouts (SwRecordLayout
s) to specify how to serialize data in the memory of an AUTOSAR ECU. Thearxml
importer imports and preserves theSwRecordLayout
property for AUTOSAR data.
You can importSwRecordLayout
s fromarxml
files in either of two ways:
If you create your AUTOSAR model from
arxml
files using importer functioncreateComponentAsModel
, include anarxml
file that containsSwRecordLayout
definitions in the import. The importedSwRecordLayout
s are preserved and later exported inarxml
code.If you create your AUTOSAR model in Simulink, you can import shared definitions of
SwRecordLayout
s fromarxml
files. Use importer functionupdateAUTOSARProperties
. For example:importerObj = arxml.importer(arxmlFileName); updateAUTOSARProperties(importerObj,modelName);
When you generate model code, the exported
arxml
code contains references to the imported read-onlySwRecordLayout
elements, but not their definitions.For more information, seeReuse AUTOSAR Element Descriptions.
Related Examples
- Import AUTOSAR Software Component
- Model AUTOSAR Calibration Parameters and Lookup Tables
- Configure AUTOSAR CompuMethods
- Configure AUTOSAR Code Generation