[Dcm] Vehicle Diagnostic Communication Part 72 [Simulation 11]

[Dcm] Vehicle Diagnostic Communication Part 72 [Simulation 11] 車両診断通信
[Dcm] Vehicle Diagnostic Communication Part 72 [Simulation 11]

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

Introduction.

AUTOSAR-Dcm configuration explanation.
In this article, I will explain the Dsp configuration code.

AUTOSAR-Dcm Dsp configuration code

The configuration code for Dsp is listed as follows.

#define DCM_SECURITY_EOL_INDEX ((sizeof(DspSecurityList)/sizeof(Dcm_DspSecurityRowType))-1)
#define DCM_SESSION_EOL_INDEX  ((sizeof(DspSessionList)/sizeof(Dcm_DspSessionRowType))-1)
#define DCM_DID_LIST_EOL_INDEX 2

#define DCM_BUF_SIZE	4095

static const Dcm_DspSecurityRowType DspSecurityList[] = {
	{ // Default Security Level, that is for each session
		0,	/* DspSecurityLevel */
		0,	/* DspSecurityDelayTimeOnBoot *///Value is not configurable
		0,	/* DspSecurityNumAttDelay */ 	//Value is not configurable
		0,	/* DspSecurityDelayTime */ 	//Value is not configurable
		0,	/* DspSecurityNumAttLock */ 	//Value is not configurable
		0,	/* DspSecurityADRSize */
		4,	/* DspSecuritySeedSize */
		4,	/* DspSecurityKeySize */
		NULL_PTR,	/* GetSeed */	// as each session entered, it is already in this level, cause send NRC
		NULL_PTR,	/* CompareKey */
		FALSE	/* Arc_EOL */
	},
	{ // Level 5 for Default Session
		5,	/* DspSecurityLevel */
		0,	/* DspSecurityDelayTimeOnBoot *///Value is not configurable
		0,	/* DspSecurityNumAttDelay */ 	//Value is not configurable
		0,	/* DspSecurityDelayTime */ 	//Value is not configurable
		0,	/* DspSecurityNumAttLock */ 	//Value is not configurable
		0,	/* DspSecurityADRSize */
		4,	/* DspSecuritySeedSize */
		4,	/* DspSecurityKeySize */
		Diag_GetSeed,	/* GetSeed */
		Diag_CompKey,	/* CompareKey */
		FALSE	/* Arc_EOL */
	},
	{ // Level 10 for Program Session
		10,	/* DspSecurityLevel */
		0,	/* DspSecurityDelayTimeOnBoot *///Value is not configurable
		0,	/* DspSecurityNumAttDelay */ 	//Value is not configurable
		0,	/* DspSecurityDelayTime */ 	//Value is not configurable
		0,	/* DspSecurityNumAttLock */ 	//Value is not configurable
		0,	/* DspSecurityADRSize */
		4,	/* DspSecuritySeedSize */
		4,	/* DspSecurityKeySize */
		Diag_GetSeed,	/* GetSeed */
		Diag_CompKey,	/* CompareKey */
		FALSE	/* Arc_EOL */
	},
	{ // Level 15 for Extended Session
		15,	/* DspSecurityLevel */
		0,	/* DspSecurityDelayTimeOnBoot *///Value is not configurable
		0,	/* DspSecurityNumAttDelay */ 	//Value is not configurable
		0,	/* DspSecurityDelayTime */ 	//Value is not configurable
		0,	/* DspSecurityNumAttLock */ 	//Value is not configurable
		0,	/* DspSecurityADRSize */
		4,	/* DspSecuritySeedSize */
		4,	/* DspSecurityKeySize */
		Diag_GetSeed,	/* GetSeed */
		Diag_CompKey,	/* CompareKey */
		FALSE	/* Arc_EOL */
	},
	{ // Level 20 for Safety System Session
		20,	/* DspSecurityLevel */
		0,	/* DspSecurityDelayTimeOnBoot *///Value is not configurable
		0,	/* DspSecurityNumAttDelay */ 	//Value is not configurable
		0,	/* DspSecurityDelayTime */ 	//Value is not configurable
		0,	/* DspSecurityNumAttLock */ 	//Value is not configurable
		0,	/* DspSecurityADRSize */
		4,	/* DspSecuritySeedSize */
		4,	/* DspSecurityKeySize */
		Diag_GetSeed,	/* GetSeed */
		Diag_CompKey,	/* CompareKey */
		FALSE	/* Arc_EOL */
	},
	{// EOL
		0,	/* DspSecurityLevel */
		0,	/* DspSecurityDelayTimeOnBoot *///Value is not configurable
		0,	/* DspSecurityNumAttDelay */ 	//Value is not configurable
		0,	/* DspSecurityDelayTime */ 	//Value is not configurable
		0,	/* DspSecurityNumAttLock */ 	//Value is not configurable
		0,	/* DspSecurityADRSize */
		0,	/* DspSecuritySeedSize */
		0,	/* DspSecurityKeySize */
		NULL_PTR,	/* GetSeed */	// as each session entered, it is already in this level, cause send NRC
		NULL_PTR,	/* CompareKey */
		TRUE	/* Arc_EOL */
	}
};

static const Dcm_DspSecurityType DspSecurity = {
	DspSecurityList	/* DspSecurityRow */
};
static const Dcm_DspSessionRowType DspSessionList[] = {
	{ //Session_default
		1,	/* DspSessionLevel */
		0x10,	/* DspSessionP2ServerMax */
		3000,	/* DspSessionP2StarServerMax */
		FALSE	/* Arc_EOL */
	},
	{ //Session_program
		2,	/* DspSessionLevel */
		0x20,	/* DspSessionP2ServerMax */
		5000,	/* DspSessionP2StarServerMax */
		FALSE	/* Arc_EOL */
	},
	{ //Session_extended
		3,	/* DspSessionLevel */
		0x30,	/* DspSessionP2ServerMax */
		5000,	/* DspSessionP2StarServerMax*/
		FALSE	/* Arc_EOL */
	},
	{ //Session_safety_system
		4,	/* DspSessionLevel */
		0x31,	/* DspSessionP2ServerMax */
		2000,	/* DspSessionP2StarServerMax */
		FALSE	/* Arc_EOL */
	},
	{ //EOL
		1,	/* DspSessionLevel */
		0x32,	/* DspSessionP2ServerMax */
		5000,	/* DspSessionP2StarServerMax */
		TRUE	/* Arc_EOL */
	},
};

static const Dcm_DspSessionType DspSession = {
    DspSessionList,	/* DspSessionRow */
};

static const Dcm_DspSecurityRowType *UnProtected_SecurityList[] = {
	// All Level Include the Default
	&DspSecurityList[0],	// Level 0, no security access before needed
	&DspSecurityList[1],    // Level 5
	&DspSecurityList[2],    // Level 10
	&DspSecurityList[3],	// Level 15
	&DspSecurityList[4],	// Level 20
	&DspSecurityList[DCM_SECURITY_EOL_INDEX]
};

static const Dcm_DspSecurityRowType *RWDID_SecurityList[] = {
	&DspSecurityList[2],    // Level 10
	&DspSecurityList[3],	// Level 15
	&DspSecurityList[4],	// Level 20
	&DspSecurityList[DCM_SECURITY_EOL_INDEX]
};

static const Dcm_DspSessionRowType *ALL_SessionList[] = {
	&DspSessionList[0],	// Session Default
	&DspSessionList[1],	// Session Program
	&DspSessionList[2],	// Session Extended
	&DspSessionList[3],	// Session Safety System
	&DspSessionList[DCM_SESSION_EOL_INDEX]
};

static const Dcm_DspDidReadType RWDID_DIDRead = {
    ALL_SessionList,	/* DspDidReadSessionRef */
    UnProtected_SecurityList	/* DspDidReadSecurityLevelRef */
};

static const Dcm_DspDidWriteType RWDID_DIDWrite = {
    ALL_SessionList,	/* DspDidWriteSessionRef */
    RWDID_SecurityList	/* DspDidWriteSecurityLevelRef */
};

static const Dcm_DspDidInfoType DspDidInfoList[] = {
	{	// RWDID_1234
		FALSE,	/* DspDidDynamicllyDefined */
		TRUE,	/* DspDidFixedLength */
		1,		/* DspDidScalingInfoSize */
		{
			&RWDID_DIDRead,	/* DspDidAccess.DspDidRead */
			&RWDID_DIDWrite,	/* DspDidAccess.DspDidWrite */
			NULL_PTR,	/* DspDidAccess.DspDidControl */
		},
	}, 
	{	// RWDID_5678
		FALSE,	/* DspDidDynamicllyDefined */
		TRUE,	/* DspDidFixedLength */
		1,		/* DspDidScalingInfoSize */
		{
			&RWDID_DIDRead,	/* DspDidAccess.DspDidRead */
			&RWDID_DIDWrite,	/* DspDidAccess.DspDidWrite */
			NULL_PTR,	/* DspDidAccess.DspDidControl */
		},
	}, 
};

extern const Dcm_DspDidType DspDidList[];
static const Dcm_DspDidType* NONE_RWDID_RefList[] =
{
    &DspDidList[DCM_DID_LIST_EOL_INDEX]  //add did ref by hand please,If you need it
};


const Dcm_DspDidType DspDidList[] = { 
	{ // RWDID 0x1234,
		FALSE,	/* DspDidUsePort *///Value is not configurable
		0x1234,	/* DspDidIdentifier */	// see ISO 14229:2006(E)  p101
		&DspDidInfoList[0],	/* DspDidInfoRef */ // Fixed Length
		NONE_RWDID_RefList,	/* DspDidRef */// TODO:
		128,	/* DspDidSize */
		NULL_PTR,	/* DspDidReadDataLengthFnc */		// So no need to get length
		Diag_ConditionCheckRead,	/* DspDidConditionCheckReadFnc */
		Diag_ReadDID_1234_Cbk,	/* DspDidReadDataFnc */
		Diag_ConditionCheckWrite,	/* DspDidConditionCheckWriteFnc */
		Diag_WriteDID_1234_Cbk,	/* DspDidWriteDataFnc */
		NULL_PTR,	/* DspDidGetScalingInfoFnc */
		NULL_PTR,	/* DspDidFreezeCurrentStateFnc */
		NULL_PTR,	/* DspDidResetToDefaultFnc */
		NULL_PTR,	/* DspDidReturnControlToEcuFnc */
		NULL_PTR,	/* DspDidShortTermAdjustmentFnc */
		NULL_PTR,	/* DspDidControlRecordSize */
		FALSE	/* Arc_EOL */
	},
	{ // RWDID 0x5678,
		FALSE,	/* DspDidUsePort *///Value is not configurable
		0x5678,	/* DspDidIdentifier */	// see ISO 14229:2006(E)  p101
		&DspDidInfoList[1],	/* DspDidInfoRef */ // Fixed Length
		NONE_RWDID_RefList,	/* DspDidRef */// TODO:
		4,	/* DspDidSize */
		NULL_PTR,	/* DspDidReadDataLengthFnc */		// So no need to get length
		Diag_ConditionCheckRead,	/* DspDidConditionCheckReadFnc */
		Diag_ReadDID_5678_Cbk,	/* DspDidReadDataFnc */
		Diag_ConditionCheckWrite,	/* DspDidConditionCheckWriteFnc */
		Diag_WriteDID_5678_Cbk,	/* DspDidWriteDataFnc */
		NULL_PTR,	/* DspDidGetScalingInfoFnc */
		NULL_PTR,	/* DspDidFreezeCurrentStateFnc */
		NULL_PTR,	/* DspDidResetToDefaultFnc */
		NULL_PTR,	/* DspDidReturnControlToEcuFnc */
		NULL_PTR,	/* DspDidShortTermAdjustmentFnc */
		NULL_PTR,	/* DspDidControlRecordSize */
		FALSE	/* Arc_EOL */
	},
	{ // EOL
		FALSE,	/* DspDidUsePort *///Value is not configurable
		0x0000,	/* DspDidIdentifier */	// see ISO 14229:2006(E)  p101
		NULL_PTR,	/* DspDidInfoRef */ // Fixed Length
		NULL_PTR,	/* DspDidRef */// TODO:
		0,	/* DspDidSize */
		NULL_PTR,	/* DspDidReadDataLengthFnc */		// So no need to get length
		NULL_PTR,	/* DspDidConditionCheckReadFnc */
		NULL_PTR,	/* DspDidReadDataFnc */
		NULL_PTR,	/* DspDidConditionCheckWriteFnc */
		NULL_PTR,	/* DspDidWriteDataFnc */
		NULL_PTR,	/* DspDidGetScalingInfoFnc */
		NULL_PTR,	/* DspDidFreezeCurrentStateFnc */
		NULL_PTR,	/* DspDidResetToDefaultFnc */
		NULL_PTR,	/* DspDidReturnControlToEcuFnc */
		NULL_PTR,	/* DspDidShortTermAdjustmentFnc */
		NULL_PTR,	/* DspDidControlRecordSize */
		TRUE	/* Arc_EOL */
	}
};

static const Dcm_DspType Dsp = {
    0x99,	/* DspMaxDidToRead *///????
    DspDidList,	/* DspDid */
    DspDidInfoList,	/* DspDidInfo */
    NULL_PTR,	/* DspEcuReset */
    NULL_PTR,	/* DspPid */
    NULL_PTR,	/* DspReadDTC */
    NULL_PTR,	/* DspRequestControl */
    NULL_PTR,	/* DspRoutine */
    NULL_PTR,	/* DspRoutineInfo */
    &DspSecurity,	/* DspSecurity */
    &DspSession,	/* DspSession */
    NULL_PTR,	/* DspTestResultByObdmid */
    NULL_PTR,	/* DspVehInfo */
    NULL_PTR	/* DspMemory */
};

AUTOSAR-Dcm Dsd configuration code explanation

Although the configuration is simple, you may not understand what exactly is defined in the code.

First, the security level is defined at DspSecurityList as follows.

  • 0: at defaultSession
  • 5: Level 5
  • 10: Level 10
  • 15: Level 15
  • 20: Level 20

Then, the various sessions were defined in DspSessionList.

  • 1:defaultSession
  • 2:programSession
  • 3:extendedSession
  • 4:safetySystemSession

After defining these entities, a support list is created with Dcm_DspSecurityRowType and Dcm_DspSessionRowType.
The support list is associated with Dcm_DspDspDidReadType and Dcm_DspDspDidWriteType.

To further explore, I’m setting that DID reads cannot be written with a security lock, but DID writes require a security level 10 or higher.

We will start simulation in the next article.

Conclusion.

  • I wrote the configuration code for Dsp.
  • Mostly security, session definition and association with DID.

Click here for back issues.

コメント

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