Main Content

Configure AUTOSAR Runnables and Events

The internal behavior of an AUTOSAR software component is implemented by a set of runnable entities (runnables). A runnable is a sequence of operations provided by the component that can be started by the run-time environment (RTE). The component configures an event to activate each runnable – for example, a timing event, data received, a client request, a mode change, component startup or shutdown, or a trigger.

In Simulink®, you can configure these types of AUTOSAR events.

Event TypeWorkflowExample
DataReceivedEventSender-receiver (S-R) communicationProgrammatically Configure AUTOSAR Runnables and Events
DataReceiveErrorEventSender-receiver (S-R) communicationConfigure AUTOSAR Receiver Port for DataReceiveErrorEvent
ExternalTriggerOccurredEventExternal trigger event communicationConfigure Receiver for AUTOSAR External Trigger Event Communication
InitEventActivation of initialization runnableConfigure AUTOSAR Initialization Runnable (R4.1)
ModeSwitchEventMode-switch (M-S) communicationConfigure AUTOSAR Mode-Switch Communication
OperationInvokedEventClient-server (C-S) communicationConfigure AUTOSAR Client-Server Communication
TimingEventPeriodic activation of runnableProgrammatically Configure AUTOSAR Runnables and Events

To configure an AUTOSAR runnable in Simulink:

  1. Open a model that is configured for AUTOSAR code generation. This example uses a writable copy of the example model autosar_swc.

  2. In the model, create or identify a root-level Simulink subsystem or function that implements a sequence of operations. The subsystem or function must generate an entry-point function in C code. In autosar_swc, the subsystem SS1 generates rate-based model step function Runnable_1s.

  3. Create or identify an AUTOSAR runnable to which to map the Simulink entry point function. Open the AUTOSAR Dictionary. Expand AtomicComponents, expand the component, and select the Runnables view. If you need to create a new AUTOSAR runnable, click the plus sign. The model autosar_swc contains the periodic runnable Runnable_1s.

  4. Select the row containing the runnable and configure its properties, including name and symbol. The AUTOSAR runnable symbol-name that you specify is exported in ARXML descriptions and C code. For an AUTOSAR server runnable, set the runnable property canBeInvokedConcurrently to designate whether to enforce concurrency constraints. For non-server runnables, leave canBeInvokedConcurrently set to false. For more information, see Concurrency Constraints for AUTOSAR Server Runnables.

  5. Configure an event to activate the runnable. Go to the Events pane for the selected runnable. If you need to create an event, click Add Event. Enter an event name and set the event type.

    The steps to configure an event depend on the type of event. If the event relies on a communication interface, such as data received (sender-receiver) or client request (client-server), you must first configure the communication interface before configuring the event.

    In the model autosar_swc, the periodic runnable Runnable_1s is activated by a TimingEvent named Event_1s.

  6. Map the Simulink entry-point function to the AUTOSAR runnable. Open the Code Mappings editor and select the Functions tab. For model autosar_swc, select the periodic function with a 1s sample time and map it to AUTOSAR runnable Runnable_1s.

To see the results of AUTOSAR runnable and event configuration in ARXML descriptions and C code, build the model.

If an AUTOSAR software component model contains multiple runnables, you can configure the order in which runnables execute. For more information, see Configure AUTOSAR Runnable Execution Order.

Related Examples

More About