AutoSAR Series Explanation (Introduction) 3.4-RTE Support for Ports (Part 2)

1. Realization of C/S interface

I talked about the C/S interface in Chapter 2 AppL before, and here is a more in-depth explanation of its implementation principle: First, the C/S interface is the client/service interface, and this interface is one of the operations that the client calls the server. interface. That is to say, as I was writing, I found that I wanted to call a function. This function was in other C files, so I asked RTE to help call it.

or give an example

I, the client, want to execute a function, which is written on the server. Because there is a gap between me and the server (SWC cannot communicate directly), at this time, I quietly tell RTE that I want to execute that function, and RTE will help me tell the server to execute the function. And here are two ways: asynchronous and synchronous:

  • Synchronization means that I am lazy. I have to wait for the server to finish running this function and RTE to return the result of this function before I continue my work;
  • Asynchronous means that I am very diligent. After I notify RTE to help tell the server to run the function, I will continue to do my work. After a while, I estimate that the function has finished running, and I will request the result of the function

2. Different methods of C/S interface

Synchronous and asynchronous calls are not distinguished by functions, which must be configured in advance and generated by RTE, so this option is available when configuring the runnable port in Davinci (of course, only C/S interface is required)

 

1. Synchronous call

From the above example, we can see that the synchronous call is actually the same as our usual call function, which is equivalent to embedding the called function code into the currently called function code to run.

 

Let's also use code to actually illustrate

//假如我们的被调函数是:

Std_ReturnType RunnableServer(int *param)

//那我们的客户中应该写的调用函数就是:

Std_ReturnType Rte_Call_Port>_RunnableServer(int *param)

//这个param就是我们希望被调函数操作的变量

2. Asynchronous call

An asynchronous call is equivalent to having two threads, one thread runs the contents of our original function, and the other executes the contents of the called function. Then you can read the return result of the called function after a while

 

At this time, how do you know whether the called function has finished executing? There are three methods:

1. Loop detection is to wait there until the value is returned. In this case, it is almost the same as synchronization and has little meaning

2. Timeout detection , set a time, read it when the time is up, and continue to run my program when the time is not up

3. Event triggering , when the service function finishes running, RTE can trigger the original function to tell it that the called function has finished running, and you can read the return value. Read the function and explain it in code

// After executing the following function, the parameters can be returned

Std_ReturnType Rte_Result_Port>_RunnableServer(int *param)

Guess you like

Origin blog.csdn.net/qq_42700289/article/details/131404720