Main Content

Configure AUTOSAR Sender-Receiver Communication

In AUTOSAR port-based sender-receiver (S-R) communication, AUTOSAR software components read and write data to other components or services. To implement S-R communication, AUTOSAR software components define:

  • An AUTOSAR sender-receiver interface with data elements.

  • AUTOSAR provide and require ports that send and receive data.

In Simulink®, you can:

  1. Create AUTOSAR S-R interfaces and ports by using the AUTOSAR Dictionary, or if using a Simulink data dictionary, using the Architectural Data Editor.

  2. Model AUTOSAR provide and require ports by using Simulink root-level outports and inports.

  3. Map the outports and inports to AUTOSAR provide and require ports by using the Code Mappings editor.

    Note

    If you are using a Simulink data dictionary to store interfaces, you must configure these interfaces using either the Architectural Data Editor or the relevant programmatic interfaces, Simulink.dictionary.ArchitecturalData.

For queued sender-receiver communication, see Configure AUTOSAR Queued Sender-Receiver Communication.

For an example modeling sender-receiver communication using Simulink bus ports, see Configure AUTOSAR Ports By Using Simulink Bus Ports.

Configure AUTOSAR Sender-Receiver Interface

This procedure outlines the general workflow for modeling AUTOSAR sender and receiver components in Simulink. This example assumes that a Simulink data dictionary is not used to store interfaces. If you are using a Simulink data dictionary to store interfaces, you must configure these interfaces using either the Architectural Data Editor or the relevant programmatic interfaces, Simulink.dictionary.ArchitecturalData.

To create an S-R interface and ports in Simulink:

  1. Open the AUTOSAR Dictionary and select S-R Interfaces. Click the Add button to create a new AUTOSAR S-R data interface. Specify its name and the number of associated S-R data elements.

  2. Select and expand the new S-R interface. Select DataElements, and modify the AUTOSAR data element attributes.

  3. In the AUTOSAR Dictionary, expand the AtomicComponents node and select an AUTOSAR component. Expand the component.

  4. Select and use the ReceiverPorts, SenderPorts, and SenderReceiverPorts views to add AUTOSAR S-R ports that you want to associate with the new S-R interface. For each new S-R port, select the S-R interface you created.

    Optionally, examine the communication attributes for each S-R port and modify where required. For more information, see Configure AUTOSAR Sender-Receiver Port ComSpecs.

  5. Open the Code Mappings editor. Select and use the Inports and Outports tabs to map Simulink inports and outports to AUTOSAR S-R ports. For each inport or outport, select an AUTOSAR port, data element, and data access mode.

Configure AUTOSAR Provide-Require Port

AUTOSAR Release 4.1 introduced the AUTOSAR provide-require port (PRPort). Modeling an AUTOSAR PRPort involves using a Simulink inport and outport pair with matching data type, dimension, and signal type. You can associate a PRPort with a sender-receiver (S-R) interface or a nonvolatile (NV) data interface.

To configure an AUTOSAR PRPort for S-R communication in Simulink:

  1. Open a model that is configured for AUTOSAR, and in which a runnable has an inport and an outport suitable for pairing into an AUTOSAR PRPort. In this example, the RPort_DE1 inport and PPort_DE1 outport both use data type int8, port dimension 1, and signal type real.

  2. Open the AUTOSAR Dictionary and navigate to the SenderReceiverPorts view. (To configure a PRPort for NV communication, use the NvSenderReceiverPorts view instead.)

  3. To add a sender-receiver port, click the Add button . In the Add Ports dialog box, specify Name as PRPort and select an Interface from the list of available S-R interfaces. Click Add.

  4. Open the Code Mappings editor and select the Inports tab. To map a Simulink inport to the AUTOSAR sender-receiver port you created, select the inport, set Port to the value PRPort, and set Element to a data element that the inport and outport will share.

  5. Select the Outports tab. To map a Simulink outport to the AUTOSAR sender-receiver port you created, select the outport, set Port to the value PRPort, and set Element to the same data element selected in the previous step.

  6. Click the Validate button to validate the updated AUTOSAR component configuration. If errors are reported, address them and then retry validation. A common error flagged by validation is mismatched properties between the inport and outport that are mapped to the AUTOSAR PRPort.

Alternatively , you can programmatically add and map a PRPort port using AUTOSAR property and map functions. The following example adds an AUTOSAR PRPort (sender-receiver port) and then maps it to a Simulink inport and outport pair.

hModel = 'my_autosar_expfcns';
open_system(hModel)
arProps = autosar.api.getAUTOSARProperties(hModel);
swcPath = find(arProps,[],'AtomicComponent')
swcPath = 
    'ASWC
add(arProps,'ASWC','SenderReceiverPorts','PRPort','Interface','Interface1')
prportPath = find(arProps,[],'DataSenderReceiverPort')
prportPath = 
    'ASWC/PRPort'
slMap = autosar.api.getSimulinkMapping(hModel);
mapInport(slMap,'RPort_DE1','PRPort','DE1','ImplicitReceive')
mapOutport(slMap,'PPort_DE1','PRPort','DE1','ImplicitSend')
[arPortName,arDataElementName,arDataAccessMode] = getOutport(slMap,'PPort_DE1')
arPortName =
PRPort

arDataElementName =
DE1

arDataAccessMode =
ImplicitSend

Configure AUTOSAR Receiver Port for IsUpdated Service

AUTOSAR defines quality-of-service attributes, such as ErrorStatus and IsUpdated, for sender-receiver interfaces. The IsUpdated attribute allows an AUTOSAR explicit receiver to detect whether a receiver port data element has received data since the last read occurred. When data is idle, the receiver can save computational resources.

For the sender, the AUTOSAR Runtime Environment (RTE) sets the status of an update flag, indicating whether the data element has been written. The receiver calls the Rte_IsUpdated_Port_Element API, which reads the update flag and returns a value indicating whether the data element has been updated since the last read.

In Simulink, you can:

  • Import an AUTOSAR receiver port for which IsUpdated service is configured.

  • Configure an AUTOSAR receiver port for IsUpdated service.

  • Generate C and ARXML code for an AUTOSAR receiver port for which IsUpdated service is configured.

To model IsUpdated service in Simulink, you pair an inport that is configured for ExplicitReceive data access with a new inport configured for IsUpdated data access. To configure an AUTOSAR receiver port for IsUpdated service:

  1. Open a model for which an AUTOSAR sender-receiver interface is configured.

  2. Identify the inport that corresponds to the AUTOSAR receiver port for which IsUpdated service is required. Create a second inport, set its data type to boolean, and connect it to the same block. For example:

  3. Open the Code Mappings editor. Select the Inports tab. In the inports view, configure the mapping properties for both inports.

    1. If the data inport is not already configured, set DataAccessMode to ExplicitReceive. Select Port and Element values that map the inport to the AUTOSAR receiver port and data element for which IsUpdated service is required.

    2. For the quality-of-service inport, set DataAccessMode to IsUpdated. Select Port and Element values that exactly match the data inport.

  4. To validate the AUTOSAR component configuration, click the Validate button .

  5. Build the model and inspect the generated code. The generated C code contains an Rte_IsUpdated API call.

    if (Rte_IsUpdated_Input_DE1()) {
      …
      Rte_Read_Input_DE1(&tmp);
      …
    }

    The exported ARXML code contains the ENABLE-UPDATE setting true for the AUTOSAR receiver port.

    <R-PORT-PROTOTYPE UUID="...">
        <SHORT-NAME>Input</SHORT-NAME>
        <REQUIRED-COM-SPECS>
            <NONQUEUED-RECEIVER-COM-SPEC>
                <DATA-ELEMENT-REF DEST="VARIABLE-DATA-PROTOTYPE">/pkg/if/Input/DE1
                                                               </DATA-ELEMENT-REF>
                …
                <ENABLE-UPDATE>true</ENABLE-UPDATE>
                …
            </NONQUEUED-RECEIVER-COM-SPEC>
        </REQUIRED-COM-SPECS>
        …
    </R-PORT-PROTOTYPE>

Configure AUTOSAR Sender-Receiver Data Invalidation

The AUTOSAR standard defines an invalidation mechanism for AUTOSAR data elements used in sender-receiver (S-R) communication. A sender component can notify a downstream receiver component that data in a sender port is invalid. Each S-R data element can have an invalidation policy. In Simulink, you can:

  • Import AUTOSAR sender-receiver data elements for which an invalidation policy is configured.

  • Use a Signal Invalidation block to model sender-receiver data invalidation for simulation and code generation. Using block parameters, you can specify a signal invalidation policy and an initial value for an S-R data element.

  • Generate C code and ARXML descriptions for AUTOSAR sender-receiver data elements for which an invalidation policy is configured.

For each S-R data element, you can set the Signal Invalidation block parameter Signal invalidation policy to Keep, Replace, or DontInvalidate. If an input data value is invalid (invalidation control flag is true), the resulting action is determined by the value of Signal invalidation policy:

  • Keep - Replace the input data value with the last valid signal value.

  • Replace - Replace the input data value with an Initial value parameter.

  • DontInvalidate - Do not replace the input data value.

To configure an invalidation policy for an AUTOSAR S-R data element in Simulink:

  1. Open a model for which an AUTOSAR sender-receiver interface is configured. For example, suppose that:

    • A Simulink outport named Out is mapped to AUTOSAR sender port PPort and data element OutElem. In the AUTOSAR Dictionary, AUTOSAR sender port PPort selects S-R interface Out, which contains the data element OutElem.

    • A Simulink inport named In1 is mapped to AUTOSAR receiver port RPort1 and data element InElem1. In the AUTOSAR Dictionary, AUTOSAR receiver port RPort1 selects S-R interface In1, which contains the data element InElem1. In the Code Mappings editor, Inports tab, here is the mapping for inport In1.

  2. Add a Signal Invalidation block to the model.

    1. The block must be connected directly to a root outport block. Connect the block to root outport Out.

    2. Connect the first block input, a data value, to the data path from root inport In1.

    3. For the second block input, an invalidation control flag, add a root inport named In2 to the model. Set its data type to scalar boolean. Map the new inport to a second AUTOSAR receiver port. If a second AUTOSAR receiver port does not exist, use the AUTOSAR Dictionary to create the AUTOSAR port, S-R interface, and data element.

      In this example, Simulink inport In2 is mapped to AUTOSAR receiver port RPort2 and data element InElem2. In the AUTOSAR Dictionary, AUTOSAR receiver port RPort2 selects S-R interface In2, which contains the data element InElem2.

      Connect the second block input to root inport In2.

  3. View the Signal Invalidation block parameters dialog box. Examine the Signal invalidation policy and Initial value attributes. For more information, see the Signal Invalidation block reference page.

  4. Open the Code Mappings editor and select the Outports tab. For the root outport Out, verify that the AUTOSAR data access mode is set to ExplicitSend or EndToEndWrite.

  5. To validate the AUTOSAR component configuration, open the Code Mappings editor and click the Validate button .

  6. Build the model and inspect the generated code. When the signal is valid, the generated C code calls Rte_Write_Port_Element. When the signal is invalid, the C code calls Rte_Invalidate_Port_Element.

    /* SignalInvalidation: '<Root>/Signal Invalidation' incorporates:
     *  Inport: '<Root>/In2'
     */
    if (!Rte_IRead_Runnable_Step_RPort2_InElem2()) {
      /* Outport: '<Root>/Out' */
      (void) Rte_Write_PPort_OutElem(mSignalInvalidation_B.Gain);
    } else {
      Rte_Invalidate_PPort_OutElem();
    }

    The exported ARXML code contains the invalidation setting for the data element.

    <INVALIDATION-POLICY>
        <DATA-ELEMENT-REF DEST="VARIABLE-DATA-PROTOTYPE">/pkg/if/Out/OutElem</DATA-ELEMENT-REF>
        <HANDLE-INVALID>KEEP</HANDLE-INVALID>
    </INVALIDATION-POLICY>
    

Configure AUTOSAR S-R Interface Port for End-To-End Protection

AUTOSAR end-to-end (E2E) protection for sender and receiver ports is based on the E2E library. E2E is a C library that you use to transmit data securely between AUTOSAR components. End-to-end protection adds additional information to an outbound data packet. The component receiving the packet can then verify independently that the received data packet matches the sent packet. Potentially, the receiving component can detect errors and take action.

For easier integration of AUTOSAR generated code with AUTOSAR E2E solutions, Embedded Coder® supports AUTOSAR E2E protection. In Simulink, you can:

  • Import AUTOSAR sender port and receiver ports for which E2E protection is configured.

  • Configure an AUTOSAR sender or receiver port for E2E protection.

  • Generate C and ARXML code for AUTOSAR sender and receiver ports for which E2E protection is configured.

Simulink supports using either the E2E Transformer method or the E2E Protection Wrapper to implement end-to-end protection in the generated code. You can retrieve which end-to-end protection method is configured by using the function getDataDefaults. You set the end-to-end protection method by using the function setDataDefaults.

  • E2E Transformer:

    • Is invoked by the AUTOSAR runtime environment (RTE). E2E transformer generates Rte_Write and Rte_Read calls that take an additional transformer error argument, Rte_TransformerError, to indicate error status.

    • Is supported when using AUTOSAR schema version 4.2 and later.

  • E2E Protection Wrapper:

    • Inserts a wrapper around the Rte_Write and Rte_Read functions. The body of the E2E protection wrapper that contains the Rte_Write and Rte_Read calls is implemented external to the generated code.

    • Is the default end-to-end protection method.

Configure E2E protection for individual AUTOSAR sender and receiver ports that use explicit write and read data access modes. When you change the data access mode of an AUTOSAR port from explicit write to end-to-end write, or from explicit read to end-to-end read.

  • Simulation behavior is unaffected.

  • Code generation is similar to explicit write and read, with these differences:

Generated ItemE2E Protection WrapperE2E Transformer
Generated Code for InitializationCalls E2EPW_ReadInit_<Port> or E2EPW_WriteInit_<Port>None
Generated Code for Function SignatureUses uint32 E2EPW_Read_<Port>(data*) or (void) E2EPW_Write_<Port>Uses uint8 Rte_Read_<Port>(data*, Rte_TransformerError*) or (void)Rte_Write_<Port>(data, Rte_TransformerError*)
ARXML Exporter for Receiver and Sender COM-SPECsGenerates property USES-END-TO-END-PROTECTION with value trueGenerates property USES-END-TO-END-PROTECTION with value true
ARXML Exporter for Receiver and Sender API Extensions PORT-API-OPTIONSNoneGenerates property ERROR-HANDLING with value TRANSFORMER-ERROR-HANDLING

To configure an AUTOSAR sender or receiver port for E2E transformer protection:

  1. Open a model for which an AUTOSAR sender-receiver interface is configured.

  2. In the MATLAB Command Window, configure TransformerError as the default E2E protection method.

    slMap = autosar.api.getSimulinkMapping(modelName);
    setDataDefaults(slMap, 'InportsOutports', ...
        'EndToEndProtectionMethod', 'TransformerError');

  3. Open the Configuration Parameters. Verify the AUTOSAR schema version is 4.2 or later.

  4. Open the Code Mappings editor. Navigate to the Simulink inport or outport that models the AUTOSAR receiver or sender port for which you want to configure E2E protection. Select the port.

  5. Set the AUTOSAR data access mode to EndToEndRead (inport) or EndToEndWrite (outport).

  6. To validate the AUTOSAR component configuration, click the Validate button .

  7. Build the model and inspect the generated code.

    The generated C code contains RTE read and write API calls that pass the transformer error argument.

    void Runnable(void)
    {
      Rte_TransformerError transformerError_Input;
      float64 tmpRead;
      …
      /* Inport: '<Root>/Input' */
      Rte_Read_RPort_InputDE(&tmpRead, &transformerError_Input);
      …
      /* Outport: '<Root>/Output'... */
      (void) Rte_Write_PPort_OutputDE(data, &transformerError_Input);
      …
    }
    

    The generated header file Rte_model.h contains the transformer error declaration.

    /* Transformer Classes */
    typedef enum {
      RTE_TRANSFORMER_UNSPECIFIED = 0x00,
      RTE_TRANSFORMER_SERIALIZER = 0x01,
      RTE_TRANSFORMER_SAFETY = 0x02,
      RTE_TRANSFORMER_SECURITY = 0x03,
      RTE_TRANSFORMER_CUSTOM = 0xff
    } Rte_TransformerClass;
    	
    typedef uint8 Rte_TransformerErrorCode;
    
    typedef struct {
      Rte_TransformerErrorCode errorCode;
      Rte_TransformerClass transformerClass;
    } Rte_TransformerError;
    

    The exported ARXML code contains the E2E settings for the AUTOSAR receiver and sender ports.

    <REQUIRED-COM-SPECS>
      <NONQUEUED-RECEIVER-COM-SPEC>
        …
        <USES-END-TO-END-PROTECTION>true</USES-END-TO-END-PROTECTION>
      …
      <NONQUEUED-SENDER-COM-SPEC>
        …
        <USES-END-TO-END-PROTECTION>true</USES-END-TO-END-PROTECTION>
      …
    </REQUIRED-COM-SPECS>
    …
    </PORT-API-OPTIONS>  
      <PORT-API-OPTION>
        <ERROR-HANDLING>TRANSFORMER-ERROR-HANDLING</ERROR-HANDLING>
        <PORT-REF DEST="R-PORT-PROTOTYPE">/pkg/swc/ASWC/RPort</PORT-REF>
      </PORT-API-OPTION>
      …
      <PORT-API-OPTION>
        <ERROR-HANDLING>TRANSFORMER-ERROR-HANDLING</ERROR-HANDLING> 
        <PORT-REF DEST="P-PORT-PROTOTYPE">/pkg/swc/ASWC/PPort</PORT-REF>
      </PORT-API-OPTION>
      …
    </PORT-API-OPTIONS>

To configure an AUTOSAR sender or receiver port for E2E wrapper protection:

  1. Open a model for which an AUTOSAR sender-receiver interface is configured.

  2. In the MATLAB Command Window, configure ProtectionWrapper as the default E2E protection method.

    slMap = autosar.api.getSimulinkMapping(modelName);
    setDataDefaults(slMap, 'InportsOutports', ...
        'EndToEndProtectionMethod', 'ProtectionWrapper');

  3. Open the Code Mappings editor. Navigate to the Simulink inport or outport that models the AUTOSAR receiver or sender port for which you want to configure E2E protection. Select the port.

  4. Set the AUTOSAR data access mode to EndToEndRead (inport) or EndToEndWrite (outport).

  5. To validate the AUTOSAR component configuration, click the Validate button .

  6. Build the model and inspect the generated code. The generated C code contains E2E API calls.

    void Runnable_Step(void)
    {
      …
      /* Inport: '<Root>/Input' */
      E2EPW_Read_RPort_InputDE(…);
      …
      /* Outport: '<Root>/Output'... */
      (void) E2EPW_Write_PPort_OutputDE(…);
      …
    }
    …
    void Runnable_Init(void)
    {
      …
      /* End-to-End (E2E) initialization */
      E2EPW_ReadInit_RPort_InputDE();
      E2EPW_WriteInit_PPort_OutputDE();
      …
    }
    

    The exported ARXML code contains the E2E settings for the AUTOSAR receiver and sender ports.

    <NONQUEUED-RECEIVER-COM-SPEC>
        …
        <USES-END-TO-END-PROTECTION>true</USES-END-TO-END-PROTECTION>
    …
    <NONQUEUED-SENDER-COM-SPEC>
        …
        <USES-END-TO-END-PROTECTION>true</USES-END-TO-END-PROTECTION>

Configure AUTOSAR Receiver Port for DataReceiveErrorEvent

In AUTOSAR sender-receiver communication between software components, the Runtime Environment (RTE) raises a DataReceiveErrorEvent when the communication layer reports an error in data reception by the receiver component. For example. the event can indicate that the sender component failed to reply within an AliveTimeout limit, or that the sender component sent invalid data.

Embedded Coder supports creating DataReceiveErrorEvents in AUTOSAR receiver components. In Simulink, you can:

  • Import an AUTOSAR DataReceiveErrorEvent definition.

  • Define a DataReceiveErrorEvent.

  • Generate ARXML code for AUTOSAR receiver ports for which a DataReceiveErrorEvent is configured.

You should configure a DataReceiveErrorEvent for an AUTOSAR receiver port that uses ImplicitReceive, ExplicitReceive, or EndToEndRead data access mode.

To configure an AUTOSAR receiver port for a DataReceiveErrorEvent:

  1. Open a model for which the receiver side of an AUTOSAR sender-receiver interface is configured.

  2. Open the Code Mappings editor. Select the Inports tab. Select the data inport that is mapped to the AUTOSAR receiver port for which you want to configure a DataReceiveErrorEvent. Set its AUTOSAR data access mode to ImplicitReceive, ExplicitReceive, or EndToEndRead. Here are two examples, without and with a coupled ErrorStatus port.

  3. Open the AUTOSAR Dictionary. Expand the AtomicComponents node. Expand the receiver component and select Runnables.

  4. In the runnables view, create a runnable to handle DataReceiveErrorEvents.

    1. Click the Add button to add a runnable entry.

    2. Select the new runnable entry to configure its name and other properties.

    3. Go to the Events pane, and configure a DataReceiveErrorEvent for the runnable. Click Add Event, select type DataReceiveErrorEvent, and enter an event name.

    4. Under Event Properties, select the trigger for the event. The selected trigger value indicates the AUTOSAR receiver port and the data element for which the runnable is handling DataReceiveErrorEvents.

      Alternatively, you can programmatically create a DataReceiveErrorEvent.

      arProps = autosar.api.getAUTOSARProperties(mdlname);
      add(arProps,ibQName,'Events','DRE_Evt',...
          'Category','DataReceiveErrorEvent','Trigger','rPort.DE1',...
          'StartOnEvent',runnableQName);
  5. Build the model and inspect the generated code. The exported ARXML code defines the error-handling runnable and its triggering event.

    <EVENTS>
        <DATA-RECEIVE-ERROR-EVENT UUID="...">
            <SHORT-NAME>DRE_Evt</SHORT-NAME>
            <START-ON-EVENT-REF DEST="RUNNABLE-ENTITY">
              /Root/mDemoModel_swc/ReceivingASWC/IB/Run_ErrorHandling</START-ON-EVENT-REF>
            <DATA-IREF>
                <CONTEXT-R-PORT-REF DEST="R-PORT-PROTOTYPE">
                  /Root/mDemoModel_swc/ReceivingASWC/rPort</CONTEXT-R-PORT-REF>
                <TARGET-DATA-ELEMENT-REF DEST="VARIABLE-DATA-PROTOTYPE">
                  /Root/Interfaces/In/DE</TARGET-DATA-ELEMENT-REF>
            </DATA-IREF>
        </DATA-RECEIVE-ERROR-EVENT>
    </EVENTS>
    ...
    <RUNNABLES>
        ...
        <RUNNABLE-ENTITY UUID="...">
            <SHORT-NAME>Run_ErrorHandling</SHORT-NAME>
            <MINIMUM-START-INTERVAL>0</MINIMUM-START-INTERVAL>
            <CAN-BE-INVOKED-CONCURRENTLY>false</CAN-BE-INVOKED-CONCURRENTLY>
            ...
            <SYMBOL>Run_ErrorHandling</SYMBOL>
        </RUNNABLE-ENTITY>
    </RUNNABLES>

Configure AUTOSAR Sender-Receiver Port ComSpecs

In AUTOSAR software components, a sender or receiver port optionally can specify a communication specification (ComSpec). ComSpecs describe additional communication requirements for port data.

To model AUTOSAR sender and receiver ComSpecs in Simulink, you can:

  • Import sender and receiver ComSpecs from ARXML files.

  • Create sender and receiver ComSpecs in Simulink.

  • For nonqueued sender ports, modify ComSpec attribute InitValue.

  • For nonqueued receiver ports, modify ComSpec attributes AliveTimeout, HandleNeverReceived, and InitValue.

  • For queued receiver ports, modify ComSpec attribute QueueLength.

  • Export ComSpecs to ARXML files

For example, if you create an AUTOSAR receiver port in Simulink, you use the Code Mappings editor to map a Simulink inport to the AUTOSAR receiver port and an S-R data element. You can then select the port and specify its ComSpec attributes.

Here are the properties for a queued receiver port.

If you import or create an AUTOSAR receiver port, you can use the AUTOSAR Dictionary to view and edit the ComSpec attributes of the mapped S-R data elements in the AUTOSAR port.

To programmatically modify ComSpec attributes of an AUTOSAR port, use the AUTOSAR property function set. For example:

hModel = 'autosar_swc';
openExample(hModel);
arProps = autosar.api.getAUTOSARProperties(hModel);

% Find ComSpec path
portPath = find(arProps,[],'DataReceiverPort','PathType','FullyQualified');
ifPath = find(arProps,[],'SenderReceiverInterface','Name','Input_If','PathType','FullyQualified');
dataElementPath = find(arProps,ifPath{1},'FlowData','Name','In1','PathType','FullyQualified');
infoPath = find(arProps,portPath{1},'PortInfo',...
    'PathType','FullyQualified','DataElements',dataElementPath{1});
comSpecPath = find(arProps,infoPath{1},'PortComSpec','PathType','FullyQualified');

% Set ComSpec attributes
set(arProps,comSpecPath{1},'AliveTimeout',30,'HandleNeverReceived',true,'InitValue',1);
get(arProps,comSpecPath{1},'AliveTimeout')
get(arProps,comSpecPath{1},'HandleNeverReceived')
get(arProps,comSpecPath{1},'InitValue')

To set the QueueLength attribute for a queued receiver port:

set(arProps,comSpecPath,'QueueLength',10);

When you generate code for an AUTOSAR model that specifies ComSpec attributes, the exported ARXML port descriptions include the ComSpec attribute values.

<PORTS>
    <R-PORT-PROTOTYPE UUID="...">
        <SHORT-NAME>ReceivePort</SHORT-NAME>
        <REQUIRED-COM-SPECS>
            <NONQUEUED-RECEIVER-COM-SPEC>
                <DATA-ELEMENT-REF DEST="VARIABLE-DATA-PROTOTYPE">
                  /Company/Powertrain/Interfaces/Input_If/In1
                </DATA-ELEMENT-REF>
...
                <ALIVE-TIMEOUT>30</ALIVE-TIMEOUT>
                <HANDLE-NEVER-RECEIVED>true</HANDLE-NEVER-RECEIVED>
...
                <INIT-VALUE>
                    <CONSTANT-REFERENCE>
                        <SHORT-LABEL>DefaultInitValue_Double_1</SHORT-LABEL>
                        <CONSTANT-REF DEST="CONSTANT-SPECIFICATION">
                          /Company/Powertrain/Constants/DefaultInitValue_Double_1
                        </CONSTANT-REF>
                    </CONSTANT-REFERENCE>
                </INIT-VALUE>
            </NONQUEUED-RECEIVER-COM-SPEC>
        </REQUIRED-COM-SPECS>
    </R-PORT-PROTOTYPE>
</PORTS>
...
<CONSTANT-SPECIFICATION UUID="...">
    <SHORT-NAME>DefaultInitValue_Double_1</SHORT-NAME>
    <VALUE-SPEC>
      <NUMERICAL-VALUE-SPECIFICATION>
          <SHORT-LABEL>DefaultInitValue_Double_1</SHORT-LABEL>
          <VALUE>1</VALUE>
      </NUMERICAL-VALUE-SPECIFICATION>
  </VALUE-SPEC>
</CONSTANT-SPECIFICATION>

See Also

Related Examples

More About