Configure Calls to AUTOSAR NVRAM Manager Service
For the AUTOSAR Classic Platform, the AUTOSAR standard defines important services as part of Basic Software (BSW) that runs in the AUTOSAR Runtime Environment (RTE). Examples include services provided by the Diagnostic Event Manager (Dem), the Function Inhibition Manager (FiM), and the NVRAM Manager (NvM). In the AUTOSAR RTE, AUTOSAR software components typically access BSW services using client-server or sender-receiver communication.
To support system-level modeling of AUTOSAR components and services, AUTOSAR Blockset provides an AUTOSAR Basic Software block library. The library contains preconfigured blocks for modeling component calls to AUTOSAR BSW services and reference implementations of the BSW services. For information about using the blocks to model client calls to AUTOSAR BSW service interfaces, see Model AUTOSAR Basic Software Service Calls.
For a live-script example of simulating AUTOSAR BSW services, see example Simulate AUTOSAR Basic Software Services and Run-Time Environment.
For more information about modeling software component access to AUTOSAR nonvolatile memory, see Model AUTOSAR Nonvolatile Memory.
Here is an example of configuring client calls to NvM service interfaces in your AUTOSAR software component.
Open a model that is configured for AUTOSAR code generation. Using the Library Browser or by typing block names in the model window, add NvM blocks to the model. This example adds the blocks NvMAdminCaller and NvMServiceCaller to a writable copy of the example model
autosar_swc
.Open each block and examine the parameters, especially Operation. If you select a different operation and click Apply, the software updates the block inputs and outputs to match the arguments of the selected operation.
This example changes the Operation for the NvMServiceCaller block from
GetDataIndex
toReadBlock
. (For an example of usingreadBlock
in a throttle position sensor implementation, see example Simulate AUTOSAR Basic Software Services and Run-Time Environment.) The Operation parameter must be set to an operation supported by the schema currently specified by the model. The list of operations reflects the operations supported by the current schema.For some NvM operations, such as
ReadBlock
andWriteBlock
, the block parameters dialog box displays an argument specification parameter. The parameter specifies data type and dimension information for data to be read or written by the operation, set touint8(1)
by default.To specify a multidimensional data type, you can use array syntax, such as
int8([1 1; 1 1])
.To specify a structured data type, you can create a
Simulink.Parameter
data object, type it with aSimulink.Bus
object, and reference the parameter name.
Open the Code Mappings editor. To update the Simulink® to AUTOSAR mapping of the model with changes to Simulink function callers, click the Update button . The software creates AUTOSAR client-service interfaces, operations, and ports, and maps each Simulink function caller to an AUTOSAR client port and operation.
For example, for the NvMServiceCaller block in this example, for which the
ReadBlock
operation is selected:The software creates C-S interface
NvMService
, and underNvMService
, its supported operations. For each operation, arguments are provided with read-only properties. Here are the arguments for theNvMService
operationReadBlock
displayed in the AUTOSAR Dictionary.The software creates a client port with the default name
NvMService
. Unlike the C-S-interface, operation, and argument names, the client port name can be customized. The client port is mapped to theNvMService
interface.The Code Mappings editor, Function Callers tab, maps the
NvMService
function caller block to AUTOSAR client portNvMService
and AUTOSAR operationReadBlock
.
Optionally, build your model and examine the generated C and ARXML code.
In the block dialog step, if you selected operation
ReadBlock
for the NvMServiceCaller block, code generation requires adding data store blocks to the model. Connect the block first outport to a Data Store Write block, and add a Data Store Memory block. For both blocks, specify data store name A. For example:The C code includes the client calls to the BSW services, for example:
/* FunctionCaller: '<Root>/NvMServiceCaller' */ Rte_Call_NvMService_ReadBlock(&rtDW.A); ... /* FunctionCaller: '<Root>/NvMAdminCaller' */ Rte_Call_NvMAdmin_SetBlockProtection(false);
Generated RTE include files define the server operation call points, such as
Rte_Call_NvMService_ReadBlock
.The ARXML code defines the BSW service operations called by the component as server call points, for example:
<SERVER-CALL-POINTS> ... <ASYNCHRONOUS-SERVER-CALL-POINT UUID="..."> <SHORT-NAME>SC_NvMService_ReadBlock</SHORT-NAME> <OPERATION-IREF> <CONTEXT-R-PORT-REF DEST="R-PORT-PROTOTYPE"> /Company/Powertrain/Components/ASWC/NvMService </CONTEXT-R-PORT-REF> <TARGET-REQUIRED-OPERATION-REF DEST="CLIENT-SERVER-OPERATION"> /AUTOSAR/Services/NvM/NvMService/ReadBlock </TARGET-REQUIRED-OPERATION-REF> </OPERATION-IREF> <TIMEOUT>1</TIMEOUT> </ASYNCHRONOUS-SERVER-CALL-POINT> </SERVER-CALL-POINTS>
To simulate the component model, create a containing composition, system, or test harness model. In that containing model, insert reference implementations of the NvM
ReadBlock
andSetBlockProtection
service operations.The AUTOSAR Basic Software block library provides an NVRAM Service Component block, which provides reference implementations of NvM service operations. You can manually insert the block into a containing composition, system, or harness model, or automatically insert the block by creating a Simulink Test™ harness model.
For more information, see Configure AUTOSAR Basic Software Service Implementations for Simulation and Simulate AUTOSAR Basic Software Services and Run-Time Environment.
See Also
NvMAdminCaller | NvMServiceCaller | NVRAM Service Component
Related Examples
- Configure AUTOSAR Basic Software Service Implementations for Simulation
- Simulate AUTOSAR Basic Software Services and Run-Time Environment
- Configure AUTOSAR Client-Server Communication