Configure AUTOSAR Adaptive Software Component Ports and Interfaces
R2026bAfter you create an AUTOSAR Adaptive software component model in Simulink® (see Create AUTOSAR Adaptive Software Component Model), you configure software component ports, interfaces, and services. AUTOSAR Blockset software reduces the effort of configuring AUTOSAR Adaptive software components by providing the AUTOSAR Component Quick Start tool.
Configure AUTOSAR Adaptive Software Component Model
Configure the model as an AUTOSAR Adaptive software component by using the AUTOSAR
Component Quick Start tool. Open your saved version of model
my_autosar_LaneGuidance, and from the Apps tab,
open the AUTOSAR Component
Designer app. When you open the app for a model that uses
autosar_adaptive.tlc system target file but has no AUTOSAR
information saved for the model, then the AUTOSAR Component Quick Start tool runs.

Advance through the steps of the AUTOSAR Component Quick Start tool. Each step prompts you for input that the tool uses to define your software component configuration. For this tutorial, use the defaults. After you click Finish, the tool:
Creates an initial software component service interface defining software component communication and execution behavior at run-time.
Opens the model in the AUTOSAR software component perspective. The AUTOSAR software component perspective shows an explicit boundary between the model algorithm and the boundary of the software component. Required and provided ports are created on the software component boundary.
Maps software component required and provided ports to root-level bus element ports in the model.
For example, In Bus Element blocks with the same port name, such as
LeftSensor.LaneDistance, LeftSensor.TurnIndicator,
LeftSensor.CarInBlindSpot all map to required port
LeftSensor.

Configure AUTOSAR Adaptive Software Component Port Interface
An AUTOSAR Adaptive software component communicates with other software components through its provided and required ports. A required port consumes a service from its communication partners, and a provided port provides a service to its communication partners. Each software component port has a communication interface called an AUTOSAR Adaptive Service Interface, based on functional requirements of the component. You view AUTOSAR Adaptive Service Interfaces in the AUTOSAR Dictionary.
In Simulink, you define data port interfaces with Simulink.dictionary.archdata.DataInterface objects in the Architectural Data
section of a data dictionary. You configure
Simulink.dictionary.archdata.DataInterface objects for AUTOSAR code
generation by specifying C++ namespaces and other code generation properties in the Architectural Data
Editor. For more information about defining AUTOSAR Adaptive software component
ports and interfaces, see Model AUTOSAR Adaptive Component and Elements in Simulink.
In this example, the PortInterfaces data dictionary already contains
the interfaces used in this tutorial. Link the dictionary to the model, assign port
interfaces, and configure C++ namespaces.
Link the data dictionary to my_autosar_LaneGuidance by using the
set_param function. Then assign data
interfaces to the appropriate ports by using set_param with the
Bus: prefix.
set_param("my_autosar_LaneGuidance","DataDictionary","PortInterfaces.sldd"); set_param("my_autosar_LaneGuidance/LeftSensor","OutDataTypeStr","Bus: SensorInterface"); set_param("my_autosar_LaneGuidance/RightSensor","OutDataTypeStr","Bus: SensorInterface"); set_param("my_autosar_LaneGuidance/HazardIndicator","OutDataTypeStr","Bus: HazardInterface");
Next, configure C++ namespaces for the data interfaces in the Architectural Data Editor.
Open the Architectural Data Editor by entering
archdataeditorin the MATLAB® Command Window. Then, open thePortInterfacesdata dictionary.In the Interfaces tab, select SensorInterface. In the right pane of the Architectural Data Editor, expand the Code Generation pane.
Set C++ Namespace to
company::chassis::perception. Set Header file toimpl_type_interfaces.h.In the Interfaces tab, select HazardInterface and expand the Code Generation pane.
Set C++ Namespace to
company::chassis::actuation. Set Header file toimpl_type_interfaces.h.
Save and close the data dictionary. Save the model.
Configure AUTOSAR Service Interface and Communication Error Handling
Add and configure status elements for bus element ports in Simulink by using the Property Inspector or Service Mappings Editor. The Service Mappings Editor displays AUTOSAR required and provided ports in the Simulink model in a tabbed table format.
First, copy the contents of the
LaneGuidanceAlgorithmsubsystem in example modelautosar_LaneGuidanceto replace theLaneGuidanceAlgorithmsubsystem inmy_autosar_LaneGuidance. This adds four inputs to the subsystem and disconnects existing ports in the model. Use the Service Mappings Editor to create status elements and map them to bus element ports.Open the Service Mappings Editor, from the Apps tab open the AUTOSAR Component Designer app, in the Prepare section click Service Mappings. Below the model the Service Mappings Editor opens. Select the Receivers tab, and verify that for each Source element, the editor shows these properties and values:
Receiver Service —
Default: QueuedStatus element —
<None>Initial value —
0
Add a status element for
LeftSensor.CarInBlindSpotby expanding theLeftSensorrow and setting Status element to<Add Status Element>. The tool adds a new bus element portLeftSensor.CarInBlindSpot_statuswith a status badge
to the Simulink canvas.Click the
CarInBlindSpotrow in the Service Mappings Editor and open the Property Inspector. Receiver portLeftSensornow contains elementsCarInBlindSpotandCarInBlindSpot_status.In the Property Inspector, select bus element port
CarInBlindSpot. On the Service tab, Status element is set toLeftSensor.CarInBlindSpot_status. In addition to Receiver service, Status element, and Initial value, you can edit these service communication and execution properties in the Property Inspector: Queue capacity, Timeout, and Sample time.
Add status elements for
LeftSensor.LaneDistance,RightSensor.LaneDistance, andRightSensor.CarInBlindSpot. Connect the bus element ports and status elements to theLaneGuidanceAlgorithmsubsystem.Save the model.
Next, see Simulate AUTOSAR Adaptive Software Component Model and Generate Code.