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 Buses.
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:
Create or open an AUTOSAR software component model. The examples in this topic use a writable copy of the example model
For reference, the example model
shows the end result of these procedures.
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.
Delete the existing Inport blocks in the model.
Create an In Bus Element block. Open the block parameters dialog box. Set Port name to
ReceivePortand the signal name to
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
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.
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.
Delete the existing Outport blocks in the model.
Create an Out Bus Element block. Open the block parameters dialog box. Set Port name to
SenderPortand the signal name to
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
The Out Bus Element block parameters dialog box now lists both signals.
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. The reference model
mAutosarSwcBusPortsspecifies implicit receive and send data access to match the original settings for
Optionally, open the AUTOSAR Dictionary and view the AUTOSAR component ports, runnables, S-R interfaces, and data elements.
If you generate code for the model:
The generated ARXML file
autosar_swc_component.arxmldescribes periodic runnables for each sample rate, named
The generated code file
autosar_swc.cdefines the rate-based functions
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
autosar_swc with a new interface named
With the modified
autosar_swcopen, open the Bus Editor. On the Modeling tab, in the Design gallery, select Bus Editor.
In the Bus Editor, add a
Simulink.Busobject and name it
SenderInterface. Add two
Simulink.BusElementobjects and name them
Optionally, before you exit the dialog, save the
SenderInterfacebus object to a MAT file for later use. The example model
mAutosarSwcBusPortsdoes not load a MAT file. Instead, it uses a
PreLoadFcnmodel callback to programmatically create the
SenderPortblock dialog box. Pause on the bus object named
SenderPortand click the button that appears. Set the Data type of the bus object to
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
SenderPortand S-R interface
To generate and map the new sender interface, either call function
autosar.api.createto update the model mapping or press Ctrl+B to generate model code (requires Embedded Coder®). Here is the
Optionally, open the AUTOSAR Dictionary and view the new sender port and S-R interface definitions.
For reference, the example model
shows the end result of these