Documentation

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®supportsarxmlimport 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 theSwImplPolicyorSwRecordLayoutproperties, but the properties are exported inarxmlcode.

For more information, seeConfigure SwCalibrationAccess,Configure DisplayFormat,Configure SwAddrMethod,Configure SwAlignment,出口SwImplPolicy, andExport SwRecordLayout for Lookup Table Data.

ConfigureSwCalibrationAccess

You can specify theSwCalibrationAccessproperty 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 theSwCalibrationAccessproperty in the following ways:

SpecifySwCalibrationAccessfor AUTOSAR Data Elements

You can use either the AUTOSAR Dictionary or MATLAB®function calls to specify theSwCalibrationAccessproperty for the following AUTOSAR data elements:

  • Sender-receiver interface data elements

  • Nonvolatile interface data elements

  • Client-server arguments

  • Inter-runnable variables

For example:

  1. Open a model that is configured for AUTOSAR.

  2. Open the AUTOSAR Dictionary. Navigate to one of the following views:

    • S-R or NV interface,DataElementsview

    • C-S interface,Argumentsview

    • Atomic component,IRVview

  3. 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 theSwCalibrationAccessproperty for AUTOSAR data elements. For example, the following code opens theautosar_swc_fcncallsexample 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 propertiessetfunction to setSwCalibrationAccessfor 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 DefaultSwCalibrationAccessfor Application Data Types

The AUTOSAR XML options includeSwCalibrationAccess DefaultValue(propertySwCalibrationAccessDefault), which defines the defaultSwCalibrationAccessvalue 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_fcncallsexample model and changes the default measurement and calibration access for AUTOSAR application data types fromReadOnlytoReadWrite.

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®Cprintfspecifiers, with the following form:

%[flags][width][.precision]type
Field Description
flags
(optional)

Characters specifying flags supported by AUTOSAR schemas:

  • (''): Insert a space before the value.

  • -: Left-justify.

  • +: Display plus or minus sign, even for positive numbers.

  • #:

    • For typeso,x, andX, display0,0x, or0Xprefix.

    • For typese,E, andf, display decimal point even if the precision is 0.

    • For typesgandG, do not remove trailing zeros or decimal point.

width
(optional)

Positive integer specifying the minimum number of characters to display.

precision
(optional)

Positive integer specifying the precision to display:

  • For integer type values (d,i,o,u,x, andX), specifies the minimum number of digits.

  • For typese,E, andf, specifies the number of digits to the right of the decimal point.

  • For typesgandG, specifies the number of significant digits.

type

Characters specifying a numeric conversion type supported by AUTOSAR schemas:

  • d: Signed decimal integer.

  • i: Signed decimal integer.

  • o: Unsigned octal integer.

  • u: Unsigned decimal integer.

  • x: Unsigned hexadecimal integer, using characters "abcdef".

  • X: Unsigned hexadecimal integer, using characters "ABCDEF”.

  • e: Signed floating-point value in exponential notation. The value has the form[-]d.dddd e [sign]ddd.

    • dis a single decimal digit.

    • ddddis one or more decimal digits.

    • dddis exactly three decimal digits.

    • signis+or-.

  • E: Identical to theeformat except thatE, rather thane, introduces the exponent.

  • f: Signed floating-point value in fixed-point notation. The value has the form[-]dddd.dddd.

    • ddddis one or more decimal digits.

    • The number of digits before the decimal point depends on the magnitude of the number.

    • The number of digits after the decimal point depends on the requested precision.

  • g: Signed value printed infore格式,哪个是更紧凑的弗吉尼亚州lue and precision. Trailing zeros are truncated, and the decimal point appears only if one or more digits follow it.

  • G: Identical to thegformat, except thatE, rather thane, introduces the exponent (where required).

For example, the format specifier%2.1dspecifies 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, exportingarxmlcode generates a corresponding DISPLAY-FORMAT specification.

 INC VALUE    READ-WRITE %2.6f STANDARD    ... 

ConfigureSwAddrMethod

AUTOSAR software components use software address methods (SwAddrMethods) 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 associateSwAddrMethods 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 useSwAddrMethods in an AUTOSAR model:

  1. ImportSwAddrMethods fromarxmlfiles or createSwAddrMethods in Simulink.

    • To importSwAddrMethods fromarxmlfiles, use anarxml.importerfunction –createComponentAsModelorcreateCompositionAsModelfor a new model, orupdateModelorupdateAUTOSARPropertiesfor an existing model.

    • To createSwAddrMethod在现有的模型,打开AUTOSAR Dictionary, SwAddrMethods view, and click theAddbutton. Alternatively, use equivalent AUTOSAR property functions. For more information, seeCreate SwAddrMethods in Simulink.

  2. AssociateSwAddrMethods 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.

  3. Generate code for your AUTOSAR model. (This example uses a signal mapped to AUTOSAR static memory in the modelautosar_swc_counter.) In the generated files:

    • Exportedarxmlfiles containSwAddrMethoddescriptions 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#defineand#includestatements that provide a wrapper around data or function definitions belonging to eachSwAddrMethodmemory 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"

CreateSwAddrMethods 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'}

AssociateSwAddrMethodwith Model Data or Function

To associateSwAddrMethods 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,SwAddrMethodVAR 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

TheSwAlignmentproperty describes the intended alignment of AUTOSAR data within a memory section.SwAlignmentdefines a quantity of bits. Valid values include 8, 12, 32, UNKNOWN (deprecated), UNSPECIFIED, and BOOLEAN. For numeric data, typicalSwAlignmentvalues are 8, 16, and 32.

If you do not define theSwAlignmentproperty, theswBaseTypesize and thememoryAllocationKeywordPolicyof the referencedSwAlignmentdetermine the alignment.

You can use the AUTOSAR property functionsetto setSwAlignmentfor 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, thearxmlimporter imports and preserves theSwAlignmentproperty 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

TheSwImplPolicyproperty specifies the implementation policy for a data element, regarding consistency mechanisms of variables. You cannot modify theSwImplPolicyproperty, but the property is set tostandardorqueuedfor AUTOSAR data in exportedarxmlcode. The value is set to:

  • standardfor

    • Per-instance memory

    • Inter-runnable variables

    • Software component parameters

    • Parameter interface data elements

    • Client-server interface operation arguments

    • Static and constant memory

  • standardorqueuedfor

    Sender-receiver interface data elements

ExportSwRecordLayoutfor Lookup Table Data

AUTOSAR software components use software record layouts (SwRecordLayouts) to specify how to serialize data in the memory of an AUTOSAR ECU. Thearxmlimporter imports and preserves theSwRecordLayoutproperty for AUTOSAR data.

You can importSwRecordLayouts fromarxmlfiles in either of two ways:

  • If you create your AUTOSAR model fromarxmlfiles using importer functioncreateComponentAsModel, include anarxmlfile that containsSwRecordLayoutdefinitions in the import. The importedSwRecordLayouts are preserved and later exported inarxmlcode.

  • If you create your AUTOSAR model in Simulink, you can import shared definitions ofSwRecordLayouts fromarxmlfiles. Use importer functionupdateAUTOSARProperties. For example:

    importerObj = arxml.importer(arxmlFileName); updateAUTOSARProperties(importerObj,modelName);

    When you generate model code, the exportedarxmlcode contains references to the imported read-onlySwRecordLayoutelements, but not their definitions.

    For more information, seeReuse AUTOSAR Element Descriptions.

Related Examples

More About