RTA Knowledge Base

Introduction

Scope

This Application Note describes how to add E2E to an existing RTA-CAR project. This should not be confused with the AUTOSAR E2EXf concept.

Unlike the E2EXf concept, the user must develop E2E Protection Wrapper functions which handle the calling of the E2E library. These protection wrappers are then called inside the application code.

Definitions and Abbreviations

CRC: Cyclic Redundancy Check

Toolchain

It is assumed you are using the RTA-CAR 9.1.0 toolchain:

RTA-CAR 9.1.0 toolchain

ISOLAR-ABv 9.1.0
RTA-RTEv 7.4.1
RTA-BSW6.1.0
RTA-OS

v 6.1.3

Workflow

The configuration depends on the chosen E2E profile. This guide assumes profile 2 is being used, which requires a Counter, Data ID (for CRC calculation) and CRC. 

E2E MechanismDetected communication faults
CounterRepetition, Loss, insertion, incorrect sequence, blocking
Data ID + CRCMasquerade and incorrect addressing, insertion
CRCCorruption

Table 7-2: Specification of SW-C End-to-End Communication Protection Library AUTOSAR CP Release 4.3.0

System Configuration

For the data that is to be communicated using E2E, create a new Sender Receiver Interface (see the Application Software Configuration workflow on how to create an interface) containing the data elements for Data, Counter and CRC (where the CRC is a type of checksum - CKS in the image - and is Profile dependent). Ensure that the types for the Counter and CRC match the profile specification.



Complete the System Configuration with the required SwCs, Ports (see PPort and RPort creation in Application Software Configuration workflow), Connections (configure in the Composition Editor) and Data Access for this new interface. There must be Data Access configured for each of the data elements within the interface (see image below).

BSW Configuration

Create the BSW Module E2E, under "Other Modules". Ensure the chosen profile (details of the E2E profiles and configuration are in RTA-Safe_Stack_Reference_Guide and the AUTOSAR E2E Protocol Specification) is enabled in the E2E configuration, in addition to configuring any profile relevant settings.



Confirm that the required CRC operation is enabled in the BSW module Crc, for example if the 8bit CRC is required, confirm that Crc8 is enabled. 



RTA-BSW ConfGen does not support E2E currently, so manual configuration is required.

Then generate the BSW and RTE Implementation.

E2E Protection Wrapper (E2EPW)/ Application Software

To access the data in the E2E interface, an E2E Protection Wrapper is created. See the AUTOSAR "Specification of SW-C End-to-End Communication Protection Library" document, Section 12.1 for more details.

The E2E Protection Wrapper is responsible for calling the Rte_Write and Rte_Read functions, and invoking the protecting/validating the data using the E2E Library.

The Protection Wrappers are created of the form E2EPW_Write_<port>_<operation>(<data>) and E2EPW_Read_<p>_<o>(<data>), and return 32-bit integers that represent the status. The 32-bit return status contains four 8-bit statuses: byte 0 is the RTE API status, byte 1 is the status of runtime checks done within Protection Wrapper, byte 2 is the return value of E2E_PXXProtect/Check function and byte 3 is currently unused, therefore is populated with E2E_E_OK.


Example E2E Protection Wrappers
/* E2E Protection Wrapper to read data from the relevant ports for E2E_Rx then check data  */
FUNC(uint32, E2E_InterSWC_2) E2EPW_Read_E2E_E2E_Rx(E2EImplementationDataType *data)
{
    uint32 E2EPW_error = E2E_E_OK;
    Std_ReturnType E2E_error;
    E2EImplementationDataType data_tmp;

    /*Read the data*/
    Rte_Read_E2E_Rx_Alive_Cnt(&(data_tmp.Impl_Alive_Cnt));
    Rte_Read_E2E_Rx_CKS(&(data_tmp.Impl_CKS));
    Rte_Read_E2E_Rx_Data(&(data_tmp.Impl_Data));

    E2E_P02ReceiverState_E2ESWC.NewDataAvailable = TRUE;

    /*Data serialization can be done here if necessary */

    /* Check if the data received is correct (Checksum and alive counter)*/
    E2E_error = E2E_P02Check(&E2E_P02_StaticCfg_E2ESWC, &E2E_P02ReceiverState_E2ESWC, (uint8 *) &data_tmp);

    if ((E2E_P02ReceiverState_E2ESWC.Status == E2E_P02STATUS_OK) ||
        (E2E_P02ReceiverState_E2ESWC.Status == E2E_P02STATUS_INITIAL) ||
        (E2E_P02ReceiverState_E2ESWC.Status == E2E_P02STATUS_OKSOMELOST))
    {
        *data = *(E2EImplementationDataType *) &data_tmp;
    }

    return ((RTE_E_OK) | (E2EPW_error << 8) | (E2E_error << 16) | (E2E_P02ReceiverState_E2ESWC.Status << 24));
}


/* E2E Protection Wrapper to protect data then write to the relevant ports for E2E_Tx */
FUNC(uint32, E2E_InterSWC_1) E2EPW_Write_E2E_E2E_Tx(E2EImplementationDataType *data)
{
    uint32 E2EPW_error = E2E_E_OK;
    Std_ReturnType E2E_error;

    /* Call E2E library function to protect the data that will be transmitted over the port*/
    E2E_error = E2E_P02Protect(&E2E_P02_StaticCfg_E2ESWC, &E2E_P02SenderState_E2ESWC, (uint8 *) data);

    /* Transmit the data with alive counter and calculated CKS over the port */
    Rte_Write_E2E_Tx_Alive_Cnt(data->Impl_Alive_Cnt);
    Rte_Write_E2E_Tx_CKS(data->Impl_CKS);
    Rte_Write_E2E_Tx_Data(data->Impl_Data);

    return ((RTE_E_OK) | (E2EPW_error << 8) | (E2E_error << 16));
}


You can then use the Protection Wrappers within the Application Software:


Example E2E Protection Wrappers
/* Example Runnable */
FUNC(void, ApplicationSWC_CODE) TestE2E(void)
{
    E2EImplementationDataType E2E_InterSWC_TestRx;
    E2EImplementationDataType E2E_InterSWC_TestTx;
    uint8 directAccess_E2E_InterSWC_TestRx;
    uint32 E2EPW_error = E2E_E_OK;

    /* Get port data item, and call E2E Protection Wrapper. */
    E2EPW_error = E2EPW_Read_E2E_E2E_Rx(&E2E_InterSWC_TestRx);

    /* Check the E2E state - First data is given initial state, counter cannot be trusted */
    if ((E2EPW_error == (E2E_P02STATUS_INITIAL << 24) || (E2EPW_error == (E2E_E_OK << 24))
    {
        /* Perform data operation on 'E2E_InterSWC_TestRx.Impl_Data'*/
    }

	/* Write data by writing the data elements and calling E2E Protection Wrapper*/ 
    E2E_InterSWC_TestTx.Impl_Data = 123u;
    E2EPW_Write_E2E_E2E_Tx(&E2E_InterSWC_TestTx);
	/* Optionally check the E2EPW_Write status */
}