How to synchronise AUTOSAR RTE write and read values with different task runnable?

771 Views Asked by At

I am new to AUTOSAR and I would like to call a RTE function to get a specific value from one SWC to another SWC. The RTE_Write is performing by one SWC 1 runnable with 10 msec task and RTE_read is performing by another SWC 2 with 15 msec task. I am using sender receiver interface to implement this concept.

SWC 1 :

Task_10msec()
{
  eg:

  int val = 0;
  val = val +1 ; 
  Rte_write_test_port(val);
}

SWC 2 :

Task_15msec()
{
  eg:

  int val = 0;
  Rte_read_test_port(&val);
}

Now here i am facing the problem is that RTE_read value is not sync with RTE_Write value because of the runnable timing (SWC 1 is 10 msec and SWC 2 is 15 msec). I would like to know, is there any way to design the interface/ any approach to get the exact read value in SWC 2 after writing from SWC 1?

2

There are 2 best solutions below

0
kesselhaus On BEST ANSWER

You could try to add a QueuedReceiverComSpec on the receiver port and set the queueLength to e.g. 2. You should then use Rte_Receive instead of Rte_Read API and read until it returns RTE_E_NO_DATA in order to get all values provided by the other component.

0
zepoo On

What do you want to achieve?

Shall the receiver only get the latest value written by the sender? Then your solution is already sufficient.

Shall the receiver get all values that the sender wrote to the interface? Then you need to introduce a queue on the receiver port. In the receiver runnable, you can then read all elements in the queue until it is empty.

For more details, check the AUTOSAR RTE specification (chapter 4.3.1).