バックナンバーはこちら。
https://www.simulationroom999.com/blog/diagnostic-communication-backnumber/
はじめに
AUTOSAR-Dcmのコンフィグレーションの話。
Dspのコンフィグレーションコードについて。
登場人物
博識フクロウのフクさん
イラストACにて公開の「kino_k」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=iKciwKA9&area=1
エンジニア歴8年の太郎くん
イラストACにて公開の「しのみ」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=uCKphAW2&area=1
AUTOSAR-Dcm Dspのコンフィグレーションコード
じゃ、早速Dspのコンフィグレーションコード。
シンプルであって欲しい!
#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のコンフィグレーションコード解説
うーん、シンプルな方な気がするが、
具体的に何を定義したのかわからん。
まず、セキュリティレベルをDspSecurityListのところで以下のとおりに規定した。
- 0:defaultSession時
- 5:Level5
- 10:Level 10
- 15:Level 15
- 20:Level 20
そして、DspSessionListで各種セッションを定義
- 1:defaultSession
- 2:programSession
- 3:extendedSession
- 4:safetySystemSession
あー、これの実体を定義しておいて、
Dcm_DspSecurityRowTypeやDcm_DspSessionRowTypeで、サポートリストを作ってるのか。
そのサポートリストをDcm_DspDidReadTypeとDcm_DspDidWriteTypeに紐づけてる感じか。
その通り!
もうちょい踏み込むと・・・。
DIDの読み出しはセキュリティロックは書けずに、
DIDの書き込みにセキュリティレベル10以上が必要って設定だね。
おーバッチリだ!
かなり久々に褒められた!
じゃー次回からぼちぼちシミュレーションを開始する感じでー。
まとめ
まとめだよ。
- Dspのコンフィグレーションコードを書いた。
- 大部分はセキュリティ、セッションの定義とDIDとの紐づけ。
バックナンバーはこちら。
コメント