Common Terms Used in Autosar - Runnable Entity
Runnable Entity
Runnable entity is a part of SWC where the application behavior logic is written.
Runnable is similar to functions in C.
In AUTOSAR, we create Runnable in a SWC during configuration and that runnable or function skeleton is generated in respective source files of SWCs.
We need to write our code in this function/Runnable which will be then executed by AUTOSAR OS, this code is the application which the SWC should perform.
Runnables also have variables, and some Runnables also have trigger points which “calls” or triggers our runnable when a specific condition is met.
Such conditions can be defined during configuration, conditions can be: Init Runnable which will be called on initialization,periodic call of runnable which can be used to send some periodic data, different RTE events based triggering, etc.
Below is the example of runnable skeleton generated after configuration, this runnable is of Indicator SWC named Runnable1.
Such runnable skeletons are generated in SWC .c files.
/*Indicator.c*/
void Runnable1(){
/*runnable logic code here*/
}
There are generally three types of runnables:
- Init Runnable: This runnable is called on init of ECU
- Periodic Runnable: This runnable is used when we need to trigger this runnable periodically to execute some operation periodically.
- Server Runnable: This runnable is used to implement server of Client/Server port interface.
Runnables can be configured to be activated on RTE events like:
- Timing Event:
- Whenever a set time is reached, this event will trigger/call dedicated runnable
- and it will perform the logic written in it.
- This is relatable to timer interrupt we use in general Embedded systems programming,
- where ISR ( Interrupt Service Routines , 中断服务程序 ) is called on each timer overflow.
- Data received event:
- As the name suggests, such event will trigger a runnable whenever data is received by ports.
- Operation Invoked Event:
- This event is called by client, when invoking a server runnable using Client/server port interface.
- Mode Switch Event:
- Whenever ECU mode is changed, runnable can be triggered to perform some work.
- For example ECU shutdown mode,
- if ECU needs to perform some work before shutdown,
- then such event shall be hooked with(与...挂钩) that runnable
- which will perform the work before shutdown.
- Whenever ECU mode is changed, runnable can be triggered to perform some work.
- Data Received Error Event:
- Whenever any error occurs in data receiving, a runnable can be called to take action on such event.
- Data Send Completed Event:
- This event will trigger a runnable if data is sent successfully to take action further on
- data transmission completion.