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.

Toolchain

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

RTA-CAR 8.0.1 toolchain

ISOLAR-ABv 8.0.1
RTA-RTEv 7.3.0
RTA-BSW6.0.0
RTA-OSv 6.1.0

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 containing the data element, Counter and CRC (Profile dependent). Ensure that the types for the Counter and CRC match the profile specification.

Complete the System Configuration with the required SwCs, Ports, Connections and Data Access for this new interface. There must be Data Access configured for each of the data elements within the interface.

BSW Configuration

Create the BSW Module E2E, under "Other Modules". Ensure the chosen profile 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 8bit CRC is required, confirm this is enabled.

Generate the BSW and RTE Implementation.

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 Wrapper are created of the form E2EPW_Write_<p>_<o>(<data>) and E2EPW_Read_<p>_<o>(<data>), and return 32-bit integers that represent the status. The 32-bit return status contains 4 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 */
}