Confidential Prerelease Documentation — Subject to Nondisclosure Agreement
Simulate AUTOSAR component calls to Basic Software memory and diagnostic services using reference implementations
The AUTOSAR standard defines Basic Software (BSW) services that run in the AUTOSAR Runtime Environment (RTE). The services include NVRAM Manager (NvM) and Diagnostic Event Manager (Dem) services. In the AUTOSAR RTE, AUTOSAR software components typically access BSW services using client-server or sender-receiver communication.
In your AUTOSAR software component model, to implement client calls to NvM and Dem service interfaces, you drag and drop preconfigured NvM and Dem caller blocks. Each block has prepopulated parameters, such as Client port name and Operation. You configure the block parameters, for example, to select an NvM or Dem service operation to call. To configure the added caller blocks in the AUTOSAR software component, you synchronize the model. The software creates AUTOSAR client-service interfaces, operations, and ports, and maps each Simulink function call to an AUTOSAR client port and operation. For more information, see Configure Calls to AUTOSAR NVRAM Manager Service (Embedded Coder) and Configure Calls to AUTOSAR Diagnostic Event Manager Service (Embedded Coder).
Here is a throttle position integration model, which integrates two throttle position sensor components and a throttle position monitor component. The sensor components take a raw throttle position sensor (TPS) value and convert it to a TPS percent value. The monitor component takes the TPS percent values provided by the primary and secondary sensor components and decides which TPS signal to pass through. The sensor components call BSW NvM and Dem services, and the monitor component calls BSW Dem services.
addpath(fullfile(autosarroot,'autosar_examples','BasicSoftware')); open_system('ThrottlePositionIntegration_presim');
Sensor components ThrottlePositionSensorComponent1
and ThrottlePositionSensorComponent2
each contain an Initialize Function block, which calls the NvM service interface NvMService
. The calls are implemented using the Basic Software library block NvMServiceCaller. Each block is configured to call the NvMService
operation ReadBlock
. The ReadBlock
calls use client ports S1LowSetPoint
and S2LowSetPoint
. Here is the Initialize Function block for ThrottlePositionSensorComponent1
.
Here is the NvMServiceCaller block dialog box for the ReadBlock
call in the Initialize Function block. For more information, see NvMServiceCaller.
Sensor components ThrottlePositionSensorComponent1
and
ThrottlePositionSensorComponent2
each contain two calls to the DEM service interface DiagnosticMonitor
. Both calls are implemented using the Basic Software library block DiagnosticMonitorCaller. Each block is configured to call the DiagnosticMonitor
operation SetEventStatus
. The SetEventStatus
calls use client ports S1StuckLow
, S1StuckHigh
, S2StuckLow
, and S2StuckHigh.
Here is the DiagnosticMonitorCaller block dialog box for the StuckLow
call in the first sensor component. For more information, see DiagnosticMonitorCaller.
Monitor component ThrottlePositionMonitorComponent
contains a call to the Dem service interface DiagnosticMonitor
and four calls to the DEM service interface DiagnosticInfo.
As in the sensor component, a DiagnosticMonitorCaller
block implements the DiagnosticMonitor
call, and it is configured to call the SetEventStatus
operation. The client port name is TPS
.
The four DiagnosticInfo
calls are implemented using the Basic Software library block DiagnosticInfoCaller. Each block is configured to call the DiagnosticInfo
operation GetEventFailed
. The GetEventFailed
calls.use client ports TPS1StuckLow,
TPS1StuckHigh
, TPS2StuckLow
, and TPS2StuckHigh.
Here is the DiagnosticinfoCaller
block dialog box for the TPS1StuckLow
call. For more information, see DiagnosticInfoCaller.
To generate C code and export arxml
descriptions for the NvM and Dem service calls, you can open and build each component model. For example, to build model ThrottlePositionMonitorComponent
, open the model. Press Ctrl+B or enter the MATLAB command rtwbuild('ThrottlePositionMonitorComponent')
.
To see the results of the model build, examine the code generation report.
To simulate an AUTOSAR component model that calls BSW services, create a containing composition, system, or harness model. In that containing model, provide reference implementations of the NvM and Dem service operations called by the component.
The AUTOSAR Basic Software block library includes an NVRAM Service Component block and a Diagnostic Service Component block. The blocks provide reference implementations of NvM and Dem service operations. To support simulation of component calls to the NvM and Dem services, include the blocks in the containing model. You can insert the blocks in either of two ways:
Automatically insert the blocks by creating a Simulink Test harness model
Manually insert the blocks into a containing composition, system, or harness model
To automatically insert NVRAM and Diagnostic Service Component blocks for a model that calls BSW NvM and Dem services, open the model (or a containing model) and create a Simulink Test harness. Select Analysis > Test Harness > Create for Model. In the Create Test Harness dialog box, click OK. The software compiles the model, adds NVRAM and Diagnostic Service Component blocks, and creates ports and other elements required for simulation. For example, here is a test harness created for the throttle position integration model.
To manually insert NVRAM and Diagnostic Service Component blocks for the NvM and Dem service calls in this example, open the integration model. Using the Library Browser or add_block
commands, or by typing block names in the model window, add the NVRAM and Diagnostic Service Component blocks to the model.
addpath(fullfile(autosarroot,'autosar_examples','BasicSoftware')); open_system('ThrottlePositionIntegration_presim'); add_block('autosarspkglib/Basic Software/NVRAM Manager (NvM)/NVRAM Service Component','ThrottlePositionIntegration_presim/NVRAM Service Component'); add_block('autosarspkglib/Basic Software/Diagnostic Event Manager (Dem)/Diagnostic Service Component','ThrottlePositionIntegration_presim/Diagnostic Service Component'); set_param('ThrottlePositionIntegration_presim','SimulationCommand','update');
The NVRAM Service Component block has prepopulated parameters, including NVRAM Properties parameters and Runtime Environment (RTE) parameters. Examine the parameter settings to see if any need modifying, based on how you are using the NvM service operations. For more information, see NVRAM Service Component.
The RTE tab table lists component client ports and their mapping to NvM service block IDs. Each row in the table represents a call into NvM services from a Basic Software caller block. Calls that act on the same NvM block should use the same block ID. This example maps the NvM ReadBlock
client ports to different block IDs.
The Diagnostic Service Component block has prepopulated parameters, including Counter-Based Debouncing parameters and RTE parameters. Examine the parameter settings to see if any need modifying, based on how you are using the Dem service operations.
The Counter-Based Debouncing parameters control the counter-based debounce algorithm that is implemented by the Dem service reference implementations. During multiple simulation runs, you can tune event step size and threshold parameters and observe the effects. For more information, see Diagnostic Service Component.
The RTE tab table lists component client ports and their mapping to Dem service event IDs. Each row in the table represents a call into Dem services from a Basic Software caller block. Calls that act on the same event should use the same event ID. This example maps the Dem SetEventStatus
client ports to different event IDs, and then maps the Dem GetEventFailed
client ports to event IDs that are shared with SetEventStatus
ports. For example, SetEventStatus
port S1StuckHigh
and GetFailedEvent
port TPS1StuckHigh
share event ID 1; S1Stucklow
and TPS1StuckLow
share event ID 2; and so on.
After manually adding NVRAM and Diagnostic Service Component blocks to the integration model, simulate the model. The simulation exercises the AUTOSAR NvM and Dem service calls in the throttle position sensor and monitor component models.
addpath(fullfile(autosarroot,'autosar_examples','BasicSoftware')); open_system('ThrottlePositionIntegration'); simOutIntegration = sim('ThrottlePositionIntegration');
Model AUTOSAR Basic Software Service Calls (Embedded Coder)
Configure Calls to AUTOSAR NVRAM Manager Service (Embedded Coder)
Configure Calls to AUTOSAR Diagnostic Event Manager Service (Embedded Coder)
Configure AUTOSAR Basic Software Service Implementations for Simulation (Embedded Coder)