Main Content

Configure AUTOSAR Ports By Using Simulink Bus Ports

In classic and adaptive AUTOSAR software components, you can model AUTOSAR ports by using root-level Simulink® bus ports instead of Inport and Outport blocks. Bus port blocks In Bus Element and Out Bus Element can simplify model interfaces. For more information, see Simplify Subsystem and Model Interfaces with Bus Element Ports.

Bus port blocks provide a more intuitive way to model AUTOSAR communication ports, interfaces, and groups of data elements. If you model AUTOSAR ports with In Bus Element and Out Bus Element blocks, and type the bus ports by using bus objects, basic properties of AUTOSAR ports, interfaces, and data elements are configured without using the AUTOSAR Dictionary. To manage component interfaces, you configure Simulink bus objects.

You can use root-level bus ports with:

  • AUTOSAR software components that use rate-based or export-function modeling styles.

  • AUTOSAR signal-based communication.

  • AUTOSAR message-based communication, including classic queued sender-receiver (S-R) or adaptive event-based messaging.

In AUTOSAR architecture models, you can link Classic Platform component models that have bus ports and then use the Schedule Editor to schedule the simulation.

Model AUTOSAR Ports By Configuring Simulink Bus Ports

To configure Simulink bus ports in an AUTOSAR model:

  1. Create or open an AUTOSAR software component model. The examples in this topic use a writable copy of the example model autosar_swc.

  2. Add two In Bus Element blocks to the model and connect them as root input ports. Configure the bus ports to share the same AUTOSAR port but have different elements. The bus port blocks are automatically mapped to AUTOSAR ports and elements.

    1. Delete the existing Inport blocks in the model.

    2. Create an In Bus Element block. Open the block parameters dialog box. Set Port name to ReceivePort and the signal name to In1.

    3. Connect the block to the first input signal. Make a copy of the block and connect it to the second input signal. In the model canvas (not the block parameters dialog box), click the name of the second block and change In1 to In2.

    4. The In Bus Element block parameters dialog box now lists both signals.

      Edit each signal and set the Sample time to 1 and 2, respectively.

  3. Add two Out Bus Element blocks to the model and connect them as root output ports. Configure the bus ports to share the same AUTOSAR port but have different elements. The bus port blocks are automatically mapped to AUTOSAR ports and elements.

    1. Delete the existing Outport blocks in the model.

    2. Create an Out Bus Element block. Open the block parameters dialog box. Set Port name to SenderPort and the signal name to Out1.

    3. Connect the block to the first output signal. Make a copy of the block and connect it to the second input signal. In this case, the signal name is automatically set to Out2.

      The Out Bus Element block parameters dialog box now lists both signals.

  4. From the Apps tab, open the AUTOSAR Component Designer app.

    • Use the Code Mappings editor to verify that the rate-based functions are correctly mapped to AUTOSAR runnables.

      Verify that the bus ports are correctly mapped to AUTOSAR ports.

      Examine the AUTOSAR data access mode selected for each port.

    • Optionally, open the AUTOSAR Dictionary and view the AUTOSAR component ports, runnables, S-R interfaces, and data elements.

  5. If you generate code for the model:

    • The generated ARXML file autosar_swc_component.arxml describes periodic runnables for each sample rate, named Runnable_1s and Runnable_2s.

    • The generated code file autosar_swc.c defines the rate-based functions Runnable_1s and Runnable_2s.

Model AUTOSAR Interfaces By Typing Bus Ports with Bus Objects

To define an AUTOSAR interface, type a bus port with a bus object. This example uses the same AUTOSAR software component model that was modified in the previous example. The example replaces the sender interface Output_If in autosar_swc with a new interface named SenderInterface.

  1. With the modified autosar_swc open, open the Type Editor. On the Modeling tab, in the Design gallery, select Type Editor.

  2. In the Type Editor, add a Simulink.Bus object and name it SenderInterface. Add two Simulink.BusElement objects and name them Out1 and Out2.

    Optionally, before you exit the Type Editor, save the SenderInterface bus object to a MAT file for later use. The example model mAutosarSwcBusPorts does not load a MAT file. Instead, it uses a PreLoadFcn model callback to programmatically create the SenderInterface bus object.

  3. Open the SenderPort block dialog box. Pause on the bus object named SenderPort and click the button that appears. Set the Data type of the bus object to Bus: SenderInterface.

  4. Because the new interface is replacing an existing mapped interface, you must explicitly delete the existing sender port and sender interface. Open the AUTOSAR Component Designer app and open AUTOSAR Dictionary. Select and delete sender port SenderPort and S-R interface Output_If.

  5. To generate and map the new sender interface, either call function autosar.api.create to update the model mapping or press Ctrl+B to generate model code (requires Embedded Coder®). Here is the autosar.api.create function call.

    autosar.api.create('autosar_swc');
  6. Optionally, open the AUTOSAR Dictionary and view the new sender port and S-R interface definitions.

See Also

| |

Related Examples

More About