Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

// State variable

typedef enum

DCM_UNINITIALIZED = 0,

DCM_INITIALIZED

} Dcm_StateType;

//lint -esym(551,dcmState) PC-Lint - Turn of warning of dcmState not accessed when


having DCM_DEV_ERROR_DETECT to STD_OFF

static Dcm_StateType dcmState = DCM_UNINITIALIZED;

static boolean firstMainAfterInit = TRUE;

/* Global configuration */

/*lint -e9003 Allow global scope */

const Dcm_ConfigType *Dcm_ConfigPtr;

/*********************************************

* Interface for upper layer modules (8.3.1) *

*********************************************/

1. void Dcm_Init(const Dcm_ConfigType *ConfigPtr)


Service for basic initialization of DCM module

ConfigPtr: Pointer to configuration set in Variant Post-Build

After Dcm_Init, the Dcm shall set ActiveDiagnostic to ’DCM_COMM_ACTIVE’


It is the responsibility of the software integrator to ensure that the data
contained in Dcm_ProgConditionsType is valid when Dcm_Init is called.

Dcm_Init shall initialize all Dcm global variables with the values of the
configuration.

DCM_ROE_Init();

DslInit();

DsdInit();

DspInit(TRUE);

void Dcm_MainFunction(void)

This service is used for processing the tasks of the main loop

DcmSetProtocolStartRequestsAllowed(TRUE);
#ifdef DCM_USE_SERVICE_RESPONSEONEVENT

DcmRoeCheckProtocolStartRequest();
#endif

DspCheckProtocolStartRequests();

DcmSetProtocolStartRequestsAllowed(FALSE);
DcmExecuteStartProtocolRequest();
firstMainAfterInit = FALSE;

DslMain();

DspTimerMain();
} else {

/* @req DCM593 */

DspPreDsdMain();

DsdMain();

DspMain();

#ifdef DCM_USE_SERVICE_RESPONSEONEVENT

Dcm_ROE_MainFunction();

#endif

} else {

/* @req DCM593 */

#else

/*

* Interface for basic software scheduler

*/

DcmSetProtocolStartRequestsAllowed(TRUE);
#ifdef DCM_USE_SERVICE_RESPONSEONEVENT

DcmRoeCheckProtocolStartRequest();

#endif

DspCheckProtocolStartRequests();

DcmSetProtocolStartRequestsAllowed(FALSE);

DcmExecuteStartProtocolRequest();

firstMainAfterInit = FALSE;

DspPreDsdMain();

DsdMain();

DspMain();

DspTimerMain();

DslMain();

#ifdef DCM_USE_SERVICE_RESPONSEONEVENT

Dcm_ROE_MainFunction();

ResponseOnEvent (RoE) With the UDS Service ResponseOnEvent (0x86), a tester requests the server
to start or stop transmission of responses initiated by a specified server event. [SWS_Dcm_01625]
Support of ResponseOnEvent dThe Dcm shall support the UDS service ResponseOnEvent (0x86) and
all subfunctions of this service according to ISO 14229-1:2020 [8].c(RS_Diag_04160)
[SWS_Dcm_01626] Not supported storageState bit dIf DcmDspRoeStoreEventSupport is set to false
and a RoE request is received with the storeEvent bit set to 1, the Dcm shall send a NRC 0x31
(requestOutOfRange).c (RS_Diag_04160) [SWS_Dcm_00894] Support of eventWindowTime dThe
Dcm shall support a eventWindowTime set to infiniteTimeToResponse and powerWindowTime
according to ISO 14229-1:2020 [8].c(RS_Diag_04160) [SWS_Dcm_01627] DTC status changed trigger
dThe Dcm shall use calls to Dcm_DemTriggerOnDTCStatus() as trigger for changes of a DTC
status.c(RS_Diag_- 04160) The Dcm leaves it open who is calling the Dcm_DemTriggerOnDTCStatus().
However, the Dcm API is designed to be compatible to the Dem module. If the Dem is used, it is
recommended to map one Dem DTC status trigger notification to Dcm_DemTriggerOnDTCStatus().

#endif

} else {

/* @req DCM593 */
}

#endif

/***********************************************

* Interface for BSW modules and SW-Cs (8.3.2) *

***********************************************/

BufReq_ReturnType
Dcm_StartOfReception(PduIdType dcmRxPduId,
PduLengthType tpSduLength, PduLengthType
*rxBufferSizePtr)
{

BufReq_ReturnType returnCode;

VALIDATE_RV(dcmState == DCM_INITIALIZED, DCM_START_OF_RECEPTION_ID,


DCM_E_UNINIT, BUFREQ_NOT_OK);

VALIDATE_RV(dcmRxPduId < DCM_DSL_RX_PDU_ID_LIST_LENGTH,


DCM_START_OF_RECEPTION_ID, DCM_E_PARAM, BUFREQ_NOT_OK);

returnCode = DslStartOfReception(dcmRxPduId, tpSduLength, rxBufferSizePtr, FALSE);

return returnCode;

}
BufReq_ReturnType Dcm_CopyRxData(PduIdType
dcmRxPduId, PduInfoType *pduInfoPtr,
PduLengthType *rxBufferSizePtr)
{

VALIDATE_RV(dcmState == DCM_INITIALIZED, DCM_COPY_RX_DATA_ID, DCM_E_UNINIT,


BUFREQ_NOT_OK);

VALIDATE_RV(dcmRxPduId < DCM_DSL_RX_PDU_ID_LIST_LENGTH,


DCM_COPY_RX_DATA_ID, DCM_E_PARAM, BUFREQ_NOT_OK);

return DslCopyDataToRxBuffer(dcmRxPduId, pduInfoPtr, rxBufferSizePtr);

/*lint -e{818} this defined as per autosar api cannot be changed */

void Dcm_TpRxIndication(PduIdType dcmRxPduId,


NotifResultType result)
{

VALIDATE_NO_RV(dcmState == DCM_INITIALIZED, DCM_TP_RX_INDICATION_ID,


DCM_E_UNINIT);

VALIDATE_NO_RV(dcmRxPduId < DCM_DSL_RX_PDU_ID_LIST_LENGTH,


DCM_TP_RX_INDICATION_ID, DCM_E_PARAM);

DslTpRxIndicationFromPduR(dcmRxPduId, result, FALSE, FALSE);


}

Std_ReturnType Dcm_GetActiveProtocol(Dcm_ProtocolType *activeProtocol)


{

Std_ReturnType returnCode;

VALIDATE_RV(dcmState == DCM_INITIALIZED, DCM_GET_ACTIVE_PROTOCOL_ID,


DCM_E_UNINIT, E_NOT_OK);

/* According to 4.0.3 spec. E_OK should always be returned.

* But if there is no active protocol? */

returnCode = DslGetActiveProtocol(activeProtocol);

return returnCode;

SecLevel Active Security Level value Conversion formula to calculate SecurityLevel out of tester
requested SecurityAccessType parameter: SecurityLevel = (SecurityAccessType + 1) / 2 Content of
SecurityAccessType is according to "securityAccessType" parameter of SecurityAccess request

Std_ReturnType Dcm_GetSecurityLevel(Dcm_SecLevelType
*secLevel)
This function provides the active security level value.

VALIDATE_RV(dcmState == DCM_INITIALIZED, DCM_GET_SECURITY_LEVEL_ID,


DCM_E_UNINIT, E_NOT_OK);

/* According to 4.0.3 spec. E_OK should always be returned.

* So if we cannot get the current security level using DslGetSecurityLevel,

* and this probably due to that there is no active protocol,

* we report the default security level according to DCM033 */

if( E_OK != DslGetSecurityLevel(secLevel) ) {


*secLevel = DCM_SEC_LEV_LOCKED;

return E_OK;

Std_ReturnType
Dcm_GetSesCtrlType(Dcm_SesCtrlType *sesCtrlType)
This function provides the active session control type value

SesCtrlType: Active Session Control Type value Content is according to "diagnosticSessionType"


parameter of DiagnosticSessionControl request

VALIDATE_RV(dcmState == DCM_INITIALIZED, DCM_GET_SES_CTRL_TYPE_ID,


DCM_E_UNINIT, E_NOT_OK);

/* According to 4.0.3 spec. E_OK should always be returned.

* So if we cannot get the current session using DslGetSesCtrlType,

* and this probably due to that there is no active protocol,

* we report the default session according to DCM034 */

if( E_OK != DslGetSesCtrlType(sesCtrlType) ) {

*sesCtrlType = DCM_DEFAULT_SESSION;

return E_OK;

void Dcm_TpTxConfirmation(PduIdType dcmTxPduId, NotifResultType result)

{
VALIDATE_NO_RV(dcmState == DCM_INITIALIZED, DCM_TP_TX_CONFIRMATION_ID,
DCM_E_UNINIT);

VALIDATE_NO_RV((dcmTxPduId < DCM_DSL_TX_PDU_ID_LIST_LENGTH) ||


IS_PERIODIC_TX_PDU(dcmTxPduId), DCM_TP_TX_CONFIRMATION_ID, DCM_E_PARAM);

DslTpTxConfirmation(dcmTxPduId, result);

BufReq_ReturnType Dcm_CopyTxData(PduIdType dcmTxPduId, PduInfoType


*pduInfoPtr, RetryInfoType *periodData, PduLengthType *txDataCntPtr)

VALIDATE_RV(dcmState == DCM_INITIALIZED, DCM_COPY_TX_DATA_ID, DCM_E_UNINIT,


BUFREQ_NOT_OK);

VALIDATE_RV((dcmTxPduId < DCM_DSL_TX_PDU_ID_LIST_LENGTH) ||


IS_PERIODIC_TX_PDU(dcmTxPduId), DCM_COPY_TX_DATA_ID, DCM_E_PARAM,
BUFREQ_NOT_OK);

return DslCopyTxData(dcmTxPduId, pduInfoPtr, periodData, txDataCntPtr);

/**

* Used to reset to default session from the application.

* @return E_OK is always returned according to AUTOSAR

*/

Std_ReturnType Dcm_ResetToDefaultSession( void ) {


VALIDATE_RV((DCM_INITIALIZED == dcmState), DCM_RESETTODEFAULTSESSION_ID,
DCM_E_UNINIT, E_NOT_OK);
DslSetSesCtrlType(DCM_DEFAULT_SESSION);

DslComModeEntered(NetworkId, DCM_NO_COM);

void Dcm_ComM_NoComModeEntered (uint8 NetworkId)


This call informs the Dcm module about a ComM mode change to COMM_NO_ COMMUNICATION.

NetworkId: Identifier of the network concerned by the mode change

void Dcm_ComM_FullComModeEntered( uint8 NetworkId )

VALIDATE_NO_RV((DCM_INITIALIZED == dcmState),
DCM_COMM_FULL_COM_MODE_ENTERED_ID, DCM_E_UNINIT);

/* !req DCM157 */

/* !req DCM159 */

/* !req DCM160 */

/* !req DCM161 */

/* !req DCM162 */

#if defined(USE_COMM)

DslComModeEntered(NetworkId, DCM_FULL_COM);

#else

(void)NetworkId;

#endif

/**

* Used by service interpreter outside of DCM to indicate that a the final response

* shall be a negative one. Dcm_ExternalSetNegResponse will not finalize the response


processing.
* @param pMsgContext

* @param ErrorCode

*/

/* @req DCM761 */

/*lint --e{818} ARGUMENT CHECK pMsgContext is ASR specific cannot modify decleration*/

void Dcm_ExternalSetNegResponse(Dcm_MsgContextType* pMsgContext,


Dcm_NegativeResponseCodeType ErrorCode)

VALIDATE_NO_RV((DCM_INITIALIZED == dcmState),
DCM_EXTERNALSETNEGRESPONSE_ID, DCM_E_UNINIT);

VALIDATE_NO_RV((NULL != pMsgContext), DCM_EXTERNALSETNEGRESPONSE_ID,


DCM_E_PARAM);

DsdExternalSetNegResponse(pMsgContext, ErrorCode);
}

/**

* Used by service interpreter outside of DCM to indicate that a final response can be sent.

* @param pMsgContext

*/

/* @req DCM762 */

/*lint --e{818} ARGUMENT CHECK pMsgContext is ASR specific cannot modify decleration*/

void Dcm_ExternalProcessingDone(Dcm_MsgContextType* pMsgContext)

VALIDATE_NO_RV((DCM_INITIALIZED == dcmState),
DCM_EXTERNALPROCESSINGDONE_ID, DCM_E_UNINIT);

VALIDATE_NO_RV((NULL != pMsgContext), DCM_EXTERNALPROCESSINGDONE_ID,


DCM_E_PARAM);
DsdExternalProcessingDone(pMsgContext);

You might also like