[Dcm] Vehicle Diagnostic Communication Part 68 [Simulation 7]

[Dcm] Vehicle Diagnostic Communication Part 68 [Simulation 7] 車両診断通信
[Dcm] Vehicle Diagnostic Communication Part 68 [Simulation 7]

Click here for back issues.
https://www.simulationroom999.com/blog/diagnostic-communication-en-back-issue/

Introduction.

AUTOSAR-Dcm Configuration Explained.
In this article, the Dsl configuration code will be explained.

AUTOSAR-Dcm Dsl configuration code

Previously I explained the following.

  • Overview of Dsl.
  • Class diagram of Dsl and its overview.

So this time, I’ll write the configuration code based on this information! (I wrote it!)

//----------------------------------------------------------------
//		  DSL				
//----------------------------------------------------------------

#define	DCM_BUF_SIZE	4095
#define	CANTP_DIAG_P2P_REQ	0
#define	CANTP_DIAG_P2P_ACK	1

static uint8 rxDcmBuffer_DiagP2P[DCM_BUF_SIZE];
static Dcm_DslBufferRuntimeType rxBufferParams_DiagP2P =
{
	NOT_IN_USE	/* status */
};
static uint8 txDcmBuffer_DiagP2P[DCM_BUF_SIZE];
static Dcm_DslBufferRuntimeType txBufferParams_DiagP2P =
{
	NOT_IN_USE	/* status */
};
static const Dcm_DslBufferType DcmDslBufferList[DCM_DSL_BUFFER_LIST_LENGTH] = {
	{
		0,	/* DslBufferID */
		DCM_BUF_SIZE,	/* DslBufferSize */
		{
			rxDcmBuffer_DiagP2P,	/* pduInfo.SduDataPtr */
			DCM_BUF_SIZE,	/* pduInfo.SduLength */
		},
		&rxBufferParams_DiagP2P	/* externalBufferRuntimeData */
	},
	{
		1,	/* DslBufferID */
		DCM_BUF_SIZE,	/* DslBufferSize */
		{
			txDcmBuffer_DiagP2P,	/* pduInfo.SduDataPtr */
			DCM_BUF_SIZE,	/* pduInfo.SduLength */
		},
		&txBufferParams_DiagP2P	/* .externalBufferRuntimeData */
	},
};

static const Dcm_DslCallbackDCMRequestServiceType DCMRequestServiceList[] = {
	{ // vRequestService_1
		Diag_RequestServiceStart,	/* StartProtocol */  // must at least config one
		Diag_RequestServiceStop,	/* StopProtocol */
		FALSE	/* Arc_EOL */
	},
	{
		NULL_PTR,	/* StartProtocol */  // must at least config one
		NULL_PTR,	/* StopProtocol */
		TRUE	/* Arc_EOL */
	}
};

static const Dcm_DslServiceRequestIndicationType DCMServiceRequestIndicationList[] = {
	{
		Diag_RequestServiceIndication,	/* Indication */
		FALSE	/* Arc_EOL */
	},
	{
		NULL_PTR,	/* Indication */
		TRUE	/* Arc_EOL */
	}
};

extern const Dcm_DslMainConnectionType DslMainConnectionList[];

static const Dcm_DslProtocolRxType DcmDslProtocolRxList[] = {
	{
		&DslMainConnectionList[0],	/* DslMainConnectionParent */
		DCM_PROTOCOL_PHYSICAL_ADDR_TYPE,	/* DslProtocolAddrType */
		CANTP_DIAG_P2P_REQ,	/* DcmDslProtocolRxPduId */
		0,	/* DcmDslProtocolRxTesterSourceAddr_v4 */		//.Value is not configurable
		0,	/* DcmDslProtocolRxChannelId_v4 */				//.Value is not configurable
		FALSE	/* Arc_EOL */
	},
	{// EOL
		NULL_PTR,	/* DslMainConnectionParent */
		0,	/* DslProtocolAddrType */
		-1,	/* DcmDslProtocolRxPduId */
		0,	/* DcmDslProtocolRxTesterSourceAddr_v4 */		//.Value is not configurable
		0,	/* DcmDslProtocolRxChannelId_v4 */				//.Value is not configurable
		TRUE	/* Arc_EOL */
	}
};

static const Dcm_DslProtocolTxType DcmDslProtocolTxList[] = {
	{
		&DslMainConnectionList[DCM_DIAG_P2P_ACK],	/* DslMainConnectionParent */
		CANTP_DIAG_P2P_ACK,	/* DcmDslProtocolTxPduId */
		DCM_DIAG_P2P_ACK,	/* DcmDslProtocolDcmTxPduId */
		FALSE	/* Arc_EOL */
	},
	{// EOL
		NULL_PTR,	/* DslMainConnectionParent */
		-1,	/* DcmDslProtocolTxPduId */
		-1,	/* DcmDslProtocolDcmTxPduId */
		TRUE	/* Arc_EOL */
	}
};

extern const Dcm_DslConnectionType DslConnectionList[];

const Dcm_DslMainConnectionType DslMainConnectionList[] = {
	{
		&DslConnectionList[0],	/* DslConnectionParent */
		NULL_PTR,	/* DslPeriodicTransmissionConRef */		//.Value is not configurable
		NULL_PTR,	/* DslROEConnectionRef */				//.Value is not configurable
		&DcmDslProtocolTxList[DCM_DIAG_P2P_ACK],	/* DslProtocolTx */
	},
};

extern const Dcm_DslProtocolRowType DslProtocolRowList[];

const Dcm_DslConnectionType DslConnectionList[] = {
	{
		&DslProtocolRowList[0],	/* DslProtocolRow */
		&DslMainConnectionList[0],	/* DslMainConnection */
		NULL_PTR,	/* DslPeriodicTransmission */	//.Value is not configurable
		NULL_PTR,	/* DslResponseOnEvent */	//.Value is not configurable
		FALSE	/* Arc_EOL */
	},
	{// EOL
		NULL_PTR,	/* DslProtocolRow */
		NULL_PTR,	/* DslMainConnection */
		NULL_PTR,	/* DslPeriodicTransmission */	//.Value is not configurable
		NULL_PTR,	/* DslResponseOnEvent */	//.Value is not configurable
		TRUE	/* Arc_EOL */
	}
};

extern const Dcm_DslProtocolTimingRowType ProtocolTimingList[];

static Dcm_DslRunTimeProtocolParametersType dcmDslRuntimeVariables[2]; // for DIAG_P2P and DIAG_P2A
const Dcm_DslProtocolRowType DslProtocolRowList[]= {
	{
		DCM_UDS_ON_CAN,	/* DslProtocolID */
		FALSE,	/* DslProtocolIsParallelExecutab */ // not supported
		0,	/* DslProtocolPreemptTimeout */	// not supported
		0,	/* DslProtocolPriority */	// not supported
		DCM_PROTOCOL_TRANS_TYPE_1,	/* DslProtocolTransType */
		&DcmDslBufferList[0],	/* DslProtocolRxBufferID */
		&DcmDslBufferList[1],	/* DslProtocolTxBufferID */
		&DsdServiceTable[0],	/* DslProtocolSIDTable */
		&ProtocolTimingList[0],	/* DslProtocolTimeLimit */
		DslConnectionList,	/* DslConnection */
		&dcmDslRuntimeVariables[0],	/* DslRunTimeProtocolParameters */
		FALSE	/* Arc_EOL */
	},
	{//EOL
		-1,	/* DslProtocolID */
		FALSE,	/* DslProtocolIsParallelExecutab */ // not supported
		0,	/* DslProtocolPreemptTimeout */	// not supported
		0,	/* DslProtocolPriority */	// not supported
		0,	/* DslProtocolTransType */
		NULL_PTR,	/* DslProtocolRxBufferID */
		NULL_PTR,	/* DslProtocolTxBufferID */
		NULL_PTR,	/* DslProtocolSIDTable */
		NULL_PTR,	/* DslProtocolTimeLimit */
		NULL_PTR,	/* DslConnection */
		NULL_PTR,	/* DslRunTimeProtocolParameters */
		TRUE	/* Arc_EOL */
	}
};

static const Dcm_DslProtocolType DslProtocol = {
    DcmDslProtocolRxList,	/* DslProtocolRxGlobalList */
    DcmDslProtocolTxList,	/* DslProtocolTxGlobalList */
    DslProtocolRowList	/* DslProtocolRowList */
};

const Dcm_DslProtocolTimingRowType ProtocolTimingList[] = {
	{
		50,	/* TimStrP2ServerMax */		// ms
		10,	/* TimStrP2ServerMin */
		5000,	/* TimStrP2StarServerMax */		//.Value is not configurable
		2000,	/* TimStrP2StarServerMin */		//.Value is not configurable
		5000,	/* TimStrS3Server */
		FALSE	/* Arc_EOL */
	},
	{//EOL
		0,	/* TimStrP2ServerMax */		// ms
		0,	/* TimStrP2ServerMin */
		0,	/* TimStrP2StarServerMax */		//.Value is not configurable
		0,	/* TimStrP2StarServerMin */		//.Value is not configurable
		0,	/* TimStrS3Server */
		TRUE	/* Arc_EOL */
	},
};

const Dcm_DslProtocolTimingType ProtocolTiming = {
    ProtocolTimingList	/* DslProtocolTimingRow */
};

static const Dcm_DslSessionControlType SessionControlList[] = {
	{
		 Diag_GetSesChgPer,	/* GetSesChgPermission */
		 NULL_PTR,	/* ChangeIndication */
		 NULL_PTR,	/* ConfirmationRespPend */
		 FALSE	/* Arc_EOL */
	},
	{//EOL
		 NULL_PTR,	/* GetSesChgPermission */
		 NULL_PTR,	/* ChangeIndication */
		 NULL_PTR,	/* ConfirmationRespPend */
		 TRUE	/* Arc_EOL */
	}
};

static const Dcm_DslDiagRespType DiagResp = {
    TRUE,	/* DslDiagRespForceRespPendEn */
    10	/* DslDiagRespMaxNumRespPend */
};

static const Dcm_DslType Dsl = {
    DcmDslBufferList,	/* DslBuffer */
    DCMRequestServiceList,	/* DslCallbackDCMRequestService */
    &DiagResp,	/* DslDiagResp */
    &DslProtocol,	/* DslProtocol */
    &ProtocolTiming,	/* DslProtocolTiming */
    DCMServiceRequestIndicationList,	/* DslServiceRequestIndication */
    SessionControlList	/* DslSessionControl */
};

AUTOSAR-Dcm Dsl configuration code explanation

At first glance, you probably won’t be able to decipher it.
You’ll have to follow it while staring at the class diagram.
One trick is that the end of the structure array can be specified in a member variable called Arc_EOL, which is treated as the end of the structure array if it is TURE.
You don’t need to read this.

Dsl Class Diagram,Dcm_DslType,Dcm_DslCallbackDCMRequestServiceType,Dcm_DslDiagRespType,Dcm_DslProtocolType,Dcm_DslProtocolTimingType,Dcm_DslServiceRequestIndicationType,Dcm_DslSessionControlType,Dcm_DslProtocolTxType,Dcm_DslProtocolRowType,Dcm_ProtocolAddrTypeType,Dcm_DslProtocolRxType,Dcm_DslMainConnectionType,Dcm_DslRunTimeProtocolParametersType,Dcm_DslProtocolTimingRowType,Dcm_DslBufferType,Dcm_DslConnectionType,Dcm_DslBufferUserType,Dcm_DslLocalBufferType,PduInfoType,Dcm_DslBufferRuntimeType,Dcm_DsdServiceTableType,Dcm_DsdServiceType,Dcm_DspSecurityRowType,Dcm_DspSessionRowType,Callbacks on diagnostic protocol startup/termination,PduId of CanTp and Dcm side used for transmission,Definition of PduId of CanTp to be used when receiving,Association of CanTp for receiving with CanTp for transmitting,Various parameters during protocol operation,Reference to protocol parameters to be used,Actual transmitting and receiving buffer,Enable/disable status of various services,Security status associated with the service,Session state associated with the service

I also define the following callback functions.

  • Diag_RequestServiceStart: Called when the diagnostic service starts.
  • Diag_RequestServiceStop: Called when the diagnostic service ends.
  • Diag_RequestServiceIndication: Read when a valid service request is made.
  • Diag_GetSesChgPer: Called at session transition (source and destination are known by arguments).

Currently, these functions are empty, but will be implemented little by little after the operation is confirmed.

Conclusion.

  • I wrote the code for the Dsl structure definition.
  • The end of the list is when Arc_EOL is TURE.
    • ArcCore (OpenSAR) proprietary specification.
  • Callback functions can be defined to trigger diagnostic service start/stop, valid service request, and session transition.

Click here for back issues.

コメント

タイトルとURLをコピーしました