Main Content

mapFunctionCaller

Map Simulink Function Caller block to AUTOSAR client port and operation

Description

mapFunctionCaller(slMap,slFcnName,arPortName,opName) maps the Simulink® Function Caller block specified by slFcnName to the AUTOSAR client port and operation, specified by arPortName and opName respectively.

If in your model Simulink function slFcnName has multiple callers then this function maps all of them to the AUTOSAR client port and operation.

example

mapFunctionCaller(___,ServerCallPoint=synchronicity) specifies whether function callers call servers synchronously or asynchronously.

example

Examples

collapse all

This example shows how to programmatically map Simulink® function callers to AUTOSAR client ports and operations.

Example model mControllerWithInterface_client has these blocks, ports, and functions:

  • Simulink function readData.

  • Function Caller block, readData, which calls Simulink function readData.

  • AUTOSAR client port, cPort, which has operation readData.

To map the Simulink function readData to the operation of the AUTOSAR client port, first open the model and extract the Simulink-to-AUTOSAR mapping information.

hModel = "mControllerWithInterface_client";
open_system(hModel);
slMap = autosar.api.getSimulinkMapping(hModel);

Then, by using the mapFunctionCaller function, you map the function caller readData to operation readData. Verify your changes by retrieving the function caller and confirming its mapping to the AUTOSAR client port and operation. In the following code, readData is the name of the Simulink function, cPort is the name of the AUTOSAR client port, and readData is the name of the operation of the client port cPort.

mapFunctionCaller(slMap,"readData","cPort","readData");
[arPort,arOp] = getFunctionCaller(slMap,"readData")
arPort = 
'cPort'
arOp = 
'readData'

In addition to mapping Simulink function callers to AUTOSAR client port operations you can also set the communication style of the server call point as either synchronous (blocking behavior) or asynchronous (nonblocking behavior). When the caller behavior is set to asynchronous, the software utilizes a polling approach, meaning that the runnable invokes the operation and checks if the server results are ready every time the runnable runs.

To set function caller readData so that it invokes the client asynchronously, set name-value argument ServerCallPoint to Asynchronous.

mapFunctionCaller(slMap,"readData","cPort","readData",ServerCallPoint="Asynchronous")

Generate and inspect code for the model. The generated code contains two calls: Rte_Call to invoke the server and Rte_Result to get the server results. The Rte_Call contains the list of IN and INOUT arguments, while the Rte_Result contains the list of INOUT and OUT arguments.

...
  /* FunctionCaller: '<S3>/readData' incorporates:
   *  DataTransferBlock generated from: '<Root>/Runnable2_subsystem'
   *  Inport: '<Root>/RPort_DE2'
   *  Product: '<S3>/Product'
   */
  Rte_Call_cPort_readData(Rte_IrvIRead_Runnable3_IRV4() *
    Rte_IRead_Runnable3_RPort_DE2());
  Rte_Result_cPort_readData(rtARID_DEF.readData_o1, &rtARID_DEF.readData_o2,
    &rtARID_DEF.readData_o3);
...

Input Arguments

collapse all

Simulink to AUTOSAR mapping information for a model, specified as an autosar.api.getSimulinkMapping object.

Qualified function name, specified as a character vector or string scalar. The qualified function name is shown on the Function Caller block icon.

Example: "readData"

Example: "ClientPort.readData"

Name of the AUTOSAR client port to which to map the specified Function Caller block, specified as a character vector or string scalar.

Example: "cPort"

Name of the AUTOSAR operation to which to map the specified Function Caller block to, specified as a character vector or string scalar.

Example: "readData"

Synchronicity of function callers, specified as either Synchronous or Asynchronous.

You can set the server call point as Asynchronous only for function callers that are used by models configured for the AUTOSAR Classic Platform.

Example: mapFunctionCaller(slMap,slFncName,arPortName,arOperationName,ServerCallPoint="Asynchronous")

Data Types: char | string

Version History

Introduced in R2014b