Simulate and Generate Code for Adaptive AUTOSAR Methods in Simulink
AUTOSAR Blockset introduced support for Adaptive AUTOSAR modeling and code generation of client-server communication with synchronous call behaviors, which produce blocked client execution, where clients send requests to a server and wait for the response. In R2022b, AUTOSAR Blockset extends that support to asynchronous call behaviors, where clients send requests, continue execution after the request is sent, and process the response upon method completion. Learn how to model, simulate, and generate code and ARXML for methods compliant with the AUTOSAR Adaptive standard in Simulink®, leveraging the power of Model-Based Design for your AUTOSAR Adaptive software development.
Published: 18 Oct 2022
In the AUTOSAR adaptive platform, methods represent functions executed by a server on request of one or more clients. Client and server components are connected via service points.
Hi, I'm Phillip from MathWorks and in this video, I will show an example of method communication in Simulink where we can model service ports and their methods using function ports as well as function callers and Simulink functions.
In this example, we've got a client component called sensor. This component gets some data via a required port and then filters that data via a method called, to a service called filter via this function port. The function port resolves to a function caller block inside this subsystem.
The function caller takes the raw data as an input and outputs the filtered data. This filtered data is sent as an event via the filtered data provided port. The mapping shows that the function port maps to a service port and a method based on the block configuration. Let's now simulate the method communication between a client and the server component.
I've placed the client component inside the system model and connected it to a server component via this line. The server is a moving average filter. For a different use case, the server can replace by a different component implementing the same service interface. Let's look at the server model.
The server is another adaptive AUTOSAR software component, providing the filter service via a function port that resolves to this Simulink function. The arguments of this function match those on the function caller and the client component. For simulation, I'm providing some example data via test harness and I am triggering the client calls periodically with a 50 millisecond period.
That's now Simulinked. In blue, we can see the raw input data, the noisy sinoid wave. In orange, we can see this signal smoothed out as the result of the client server communication between two adaptive software components via methods.
I will now hand over to my colleague KC to talk about generating C++ code and ARXML for adaptive AUTOSAR are software component models.
Here we will show how to generate code from this adaptive AUTOSAR application. As Philip explained, the purpose of this model is to receive a message containing a payload of raw data, extract the data from the message and filter it by making a client call to a server, and then send the filtered data back out in a message.
Let's generate code for this model. Let's first take a look at the model class interface. Here we can see the step method, step 50ms on line 57, which will contain the application logic. And the proxy interface representing the service provided by filter RPORT interface is on line 73.
Now, let's take a look at the implementation of the step 50ms method. Here's the definition of the step 50ms method. This method calls into the filter method provided by the filter RPORT service interface on line 48. But the result of this server call is retrieved online 52 with a blocking call to get result that has value method of the result object instance is queried on line 56. If the server executed and returned a value successfully this will turn true. The filtered value will then be retrieved on line 60. Now, let's take a look at the generated ARXML. In the ARXML file we see a service interface with name filter RPORT and a method that is a client server operation with name filter.
Thank you, Casey. In summary, we've shown how to model and generate code for client server communication using methods in AUTOSAR. Thank you for watching.