Table of Contents
Introduction
Scope
The goal of this application note is to provide indications on how to setup data transformation for intra-ECU communication. In particular, RTA-RTE supports the data transformation by CompuMethods definition linked to the Application Data Types. This feature is exploited in this application note developing the following demo application:
- An Application SWC sends application data to another Application SWC that receives the converted application data. The conversion is just a multiplying factor.
Definitions and Abbreviations
BSW: AUTOSAR Basic Software, Hardware independent service layer
ECU: Electronic Control Unit
RTE: AUTOSAR Run-Time Environment
OS: AUTOSAR Operating System
SWC: Software Component
Toolchain
It is assumed you are using the RTA-CAR 9.2.0 toolchain:
RTA-CAR 9.2.0 toolchain | |
---|---|
ISOLAR-AB | v 9.2.0 |
RTA-RTE | v 7.5.0 |
RTA-BSW | v 6.1.2 |
RTA-OS | v 6.2.0 |
RTE Data Transformation - Overview
In this application note it is exploited the data transformation for intra-ECU communication through the definition of CompuMethods. RTA-RTE does not support data conversion for CompuMethods definition in DataElements of the port interface, but it supports data conversion for CompuMethods that are defined in ApplicationDataTypes.
In order to support data transformation, two different port interfaces (Tx and Rx) are required. At this point a "conversion" between the data elements of the Tx interface and the data elements of the Rx interface must be defined. This is done by the definition of a DataMapping.
An additional mapping (DataTypeMappingSet) is required in order to map the ApplicationDataType to a respective ImplementationDataType.
The required structure can be summarized with the following schema:
RTE Data Transformation - Project Configuration
This application note can be executed step by step in any existing project, since all the required elements (except for the Application SWC) are created from scratch. Some adaptations are needed to the following configurations to meet the specific project needs.
Step 1 - Creation of CompuMethods
To start, we have to configure the Units that are used in the CompuMethod for TX and RX data. A Unit in AUTOSAR is a physical measurement unit. Configurations on the Unit are optional, for such reason, in this sample configuration, it is just added a Single Language Unit Name for the sake of completeness (it just specifies how the unit shall be displayed in documents or user interface tools). For further information in Unit configuration it is possible to refer AUTOSAR_TPS_SoftwareComponentTemplate specification.
In this project we are going to configure a couple of units: U_TxData_Application and U_TxData_Converted.
In the same way, it is created the U_TxData_Converted
At this point, it is possible to create the couple of CompuMethod for RX and TX sides. In AUTOSAR, with CompuMethods, it is possible to define the relationship between a physical value and a mathematical representation. Several categories of CompuMethods can be defined. In particular, the category "LINEAR" can be used to define a linear conversion of the data (multiply factor and offset). For more details on CompuMethods, and for the complete categories description it is possible to refer AUTOSAR_TPS_SoftwareComponentTemplate specification.
In the sample project, the CompuMethod "CM_TxData_Application" is created.
Now it is possible to double click on the CompuMethod that has been created. A window will pop up to setup the category. In this case LINEAR is selected.
Once the category has been selected, the Data Dictionary Editor will pop up, where it is possible to complete the configuration of the CompuMethod. The unit previously created must be referenced, and the CompuScale has to be configured.
Adding a new CompuScale triggers the window in the picture below. It provides an easy way to configure the linear conversion, in particular, the following formula will be applied in the data transformation:
Where:
- Physical: is the data output of the transformation
- Internal: is the data input of the transformation
- Offset, Num, Den: are the parameter that has to be configured in order to reach the desired transformation
In this sample configuration, since we want to reach a "multiply by 10" configuration, the following parameters have been configured: Offset = 0, Num = 10, Den = 1.
In the wizard it is also possible configure the limits of the data, expressing the range of the data:
- Lower Limit: the configuration parameter in the left side
- Upper Limit: the configuration parameter in the right side
In both upper and lower limits it is possible to configure if include the limit values have to be included "<=" or not "<".
In our sample project the following range has been configured:
Now, it is possible to proceed with the creation of another CompuMethod for RX side. In that case, it is mandatory to create an IDENTICAL one, and reference the Unit previously created.
Creating this IDENTICAL CompuMethod on the RX side is a mandatory step for the Data Transformation configuration. If not configured, RTE code generation will throw an error.
In the sample project, therefore, the CompuMethod "CM_TxData_Converted" is created that is referencing the Unit "U_TxData_Converted".
Step 2 - Creation of the Application Data Type
At this point it is possible to proceed with the creation of the Application Data Type for RX and TX sides.
An Application Data Type in AUTOSAR is used to define a data type from the application point of view. Different types of Application Data Types can be defined in AUTOSAR:
- Primitive Data Types: not composite data type, it is used to configured simple application data types
- Array Data Types: composite data type, it can be seen as an equivalent of an array
- Record Data Types: composite data type, it can be seen as an equivalent of a struct
For further information in Application Data Types it is possible to refer AUTOSAR_TPS_SoftwareComponentTemplate specification.
In this project the couple of Application Data Types "ADT_TxData_Application" and "ADT_TxData_Converted" are created. The first one is linked to the "CM_TxData_Application" CompuMethod, and the second one is linked to the "CM_TxData_Converted" CompuMethod. This link is established by the configuration of Sw Data Def Props Conditional in the Appplication Data Type. Since the purpose of this configuration is to exchange a simple data between two SWCs, the Application Primitive Data Type is used.
The CompuMethod previously created has to be associated to the Application Data Types
At this point the created Application Data Types, are not linked to any real implementation data types, since these are just an abstraction for the application level. In AUTOSAR an Application Data Type must be mapped to an Implementation Data Type. This is done by means of Data Mappings. Data Mappings are contained in the so called Data Type Mapping Set. Therefore, a Data Type Mapping Set can be seens as a container of Data Mappings.
For further information in Data Mapping and Data Type Mapping Set it is possible to refer AUTOSAR_TPS_SoftwareComponentTemplate specification.
Therefore in this configuration a Data Type Mapping Set "DTMS_TxData" is created as follows
Double clicking on the created DataTypeMappingSet, the Data Dictionary Editor is displayed. Here it is possible to configure the Data Mappings belonging to this DataTypeMappingSet. In this configuration, both the ADT_TxData_Application and ADT_TxData_Converted are mapped to uint16 Implementation Data Type. The mapping depends on the project specific use case, in this case uint16 is selected since this data type is able to cover the integer data ranges of the data that is being managed by the Application Data Types (see the above limits configuration).
Step 3 - Creation of Interface
Now that the infrastructure is almost ready, it is possible to proceed with the creation of the Port Interfaces that will be used by the ports of the SWCs. To trigger data transformation in RTE, it is needed that two different interfaces are created at TX and RX side. Therefore a couple of Sender Receiver Interface "SR_TxData_Application" and "SR_TxData_Converted" are created in this project.
Data Elements have to be defined for the interfaces. In this project a single Data Element is used, in order to exchange the desired data. Therefore, the Data Element "DE_TxData_Application", which type is set to "ADT_TxData_Application", is created for the "SR_TxData_Application", and the Data Element "DE_TxData_Converted", which type is set to "ADT_TxData_Application", is created for the "SR_TxData_Converted".
At this point, the port interfaces are set up. In AUTOSAR it is possible to create mappings between different interfaces in order to allow the connection of ports that have different interfaces. This is done by means of Port Interface Mappings that are contained in Port Interface Mapping Set. For further information in Port Interface Mappings and Port Interface Mapping Set it is possible to refer AUTOSAR_TPS_SoftwareComponentTemplate specification.
The Port Interface Mapping Set "PIMS_TxData" is therefore created in the project configuration as follows
And the relative Port Interface Mapping is created inside PIMS_TxData. In this project it is used the "Variable And Parameter Interface Mapping", since a mapping between two sender / receiver interface Data Elements "DE_TxData_Application" and "DE_TxData_Converted" is being established.
Step 4 - SWC Ports and Internal Behavior
Now, it is possible to proceed with the port creations in the two different SWCs, selecting the Port Interfaces that have been created previously. In this project the provider port PP_TxData_Application, with port interface SR_TxData_Application, and the receiver port RP_TxData_Converted, with port interface SR_TxData_Converted, are created.
Please Notice: remember to configure at least a Data Receive Point for the RP_TxData_Converted and a Data Send Point for the PP_TxData_Application in the Runnable Entity of the SWC that makes use of the data. In case these are not created, the sets of APIs Rte_Write and Rte_Read is not generated by RTA-RTE.
The Data Send Point DSP_TxData_Application is therefore configured in the project as follows
In the same way, it is configured the Data Receive Point By Arguments DRPA_TxData_Converted. Therefore, the following configuration is achieved:
To complete the infrastructure the DataTypeMappingSet that has been previously defined shall be referenced in the two Internal Behavior of the SWCs.
Step 5 - Software Composition and RTE generation
The final step is to connect the two ports in the TopLevelComposition. Since the port interface of the two ports are different, the tool does not recognize the two port interface as "compatible ports". Therefore, the option "Show in-compatible ports" must be selected. At this point it is possible to create a connection between the two ports.
Please Notice: the tool will mark the connection as an "Invalid Connection". Don't care about this point, and proceed with the final part of the application note. RTA-RTE will properly recognize this connection and will generate the expected code.
The created connection should refer to the Port Interface Mapping Set previously defined. To do this, it is needed to navigate in the Assembly Connectors, and double click on it.
Shortcut: when the connection is created, it is displayed in the GUI. It is possible to right-click on the connector name and select "Show In AR Explorer". The tool will navigate automatically in the desired place (AR Explorer menu).
At this point the configuration is completed, and it is possible to proceed with:
- Update ECU Extract
- RTE Generation
It is possible to notice that the following implementations are generated by RTA-RTE. The data conversion happens when the Rte_Write is invoked.