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.
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.
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.
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);
...