目录
- 关键词
- 平台说明
- 背景
- 一、配置DcmDspRoutineInfos
- 二、配置DcmDspRoutines
- 三、创建一个ASWC
- [四、mapping DCM port](#四、mapping DCM port)
- 五、生成代码
-
- 5.1.在设置中勾选生成.c模板
- [5.2 生成模块](#5.2 生成模块)
- 六、code
-
- [6.1 添加自定义代码](#6.1 添加自定义代码)
关键词
嵌入式、C语言、autosar、OS、BSW、UDS、diagnostic
平台说明
项目 | Value |
---|---|
OS | autosar OS |
autosar厂商 | vector |
芯片厂商 | TI |
编程语言 | C,C++ |
编译器 | HighTec (GCC) |
autosar版本 | 4.3.1 |
参考文档 | TechnicalReference_Dcm.pdf AUTOSAR_SRS_DiagnosticLogAndTrace.pdf AUTOSAR_SWS_DiagnosticCommunicationManager.pdf AUTOSAR_SWS_DiagnosticEventManager.pdf AUTOSAR_SWS_FunctionInhibitionManager.pdf- 【14229-1.2.3】,【15765-1.2.3.4】. 【11898】 |
>>>>>>>>>>>>>>>>>>>>>>>>>回到总目录<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
缩写 | 描述 |
---|---|
DEM | Diagnostic Event Manager |
DET | Development Error Tracer |
DDM | Diagnostic Data Modifier |
DCM | Diagnostic Communication Manager |
LSB | least significant byte |
MSB | most significant byte |
DID | Data dentifier |
DSD | Diagostic Service Dispatcher (submodule of the DCM module) |
DSL | Diagostic Session Layer (submodule of the DCM module) |
DSP | Diagostic Service Processing (submodule of the DCM module) |
ResData | response Data |
ReqData | request Data |
背景
项目已经导入过CDD文件,有基础的的DSD,DSL,DSP配置。 可以通过编写CDD文件实现本文的功能,这里将手动配置。
以0X0201为例,需要配置0x1,0x2,0x3subfunction,data长度为1个byte。
一、配置DcmDspRoutineInfos
注意:请别把ResData和ReqData弄反了。
二、配置DcmDspRoutines
三、创建一个ASWC
在davinci developer中创建一个ASWC 用于所有诊断相关的服务操作。这里创建CtDiagHandler,保存同步到CFG中,然后**关闭davinci developer软件。不关闭会导致在cfg中mapping失败**
四、mapping DCM port
五、生成代码
5.1.在设置中勾选生成.c模板
5.2 生成模块
六、code
在CtDiagHandler.c中:
生成相应代码
c
FUNC(Std_ReturnType, CtDiagHandler_CODE) RoutineServices_Routine_Request_to_Switch_Night_light_0201_Start(P2CONST(Dcm_StartDataIn_Routine_Request_to_Switch_Night_light_0201_ReqDataArrayType, AUTOMATIC, RTE_CTDIAGHANDLER_APPL_DATA) ReqData, Dcm_OpStatusType OpStatus, P2VAR(Dcm_StartDataOut_Routine_Request_to_Switch_Night_light_0201_ResDataArrayType, AUTOMATIC, RTE_CTDIAGHANDLER_APPL_VAR) ResData, P2VAR(Dcm_NegativeResponseCodeType, AUTOMATIC, RTE_CTDIAGHANDLER_APPL_VAR) ErrorCode) /* PRQA S 0624, 3206 */ /* MD_Rte_0624, MD_Rte_3206 */
{
/**********************************************************************************************************************
* DO NOT CHANGE THIS COMMENT! << Start of runnable implementation >> DO NOT CHANGE THIS COMMENT!
* Symbol: RoutineServices_Routine_Request_to_Switch_Night_light_0201_Start (returns application error)
*********************************************************************************************************************/
return RTE_E_OK;
/**********************************************************************************************************************
* DO NOT CHANGE THIS COMMENT! << End of runnable implementation >> DO NOT CHANGE THIS COMMENT!
*********************************************************************************************************************/
}
}
6.1 添加自定义代码
注意如果该routine触发后台其他异步操作,可以返回DCM_E_PENDING ,dcm将会再次触发该routine,在p2*时间返回0x78报文。
c
# define DCM_E_PENDING ((Std_ReturnType)10) /*!< Invoked callout (operation) needs to be called again */
c
FUNC(Std_ReturnType, CtDiagHandler_CODE) RoutineServices_Routine_Request_to_Switch_Night_light_0201_Start(P2CONST(Dcm_StartDataIn_Routine_Request_to_Switch_Night_light_0201_ReqDataArrayType, AUTOMATIC, RTE_CTDIAGHANDLER_APPL_DATA) ReqData, Dcm_OpStatusType OpStatus, P2VAR(Dcm_StartDataOut_Routine_Request_to_Switch_Night_light_0201_ResDataArrayType, AUTOMATIC, RTE_CTDIAGHANDLER_APPL_VAR) ResData, P2VAR(Dcm_NegativeResponseCodeType, AUTOMATIC, RTE_CTDIAGHANDLER_APPL_VAR) ErrorCode) /* PRQA S 0624, 3206 */ /* MD_Rte_0624, MD_Rte_3206 */
{
/**********************************************************************************************************************
* DO NOT CHANGE THIS COMMENT! << Start of runnable implementation >> DO NOT CHANGE THIS COMMENT!
* Symbol: RoutineServices_Routine_Request_to_Switch_Night_light_0201_Start (returns application error)
*********************************************************************************************************************/
Std_ReturnType u_RetVal = DCM_E_NOT_OK;
uint8 ligth_status = *ReqData;
switch (OpStatus)
{
case DCM_INITIAL:
if(( NULL == ReqData )||( NULL == ResData ))
{
/* (void)Det_ReportError(, , , );*/
}
else
{
if(0x1u == ligth_status)
{
/*open ligth*/
}
else
{
/*close ligth*/
}
u_RetVal = DCM_E_OK;
}
break;
case DCM_PENDING:
break;
}
return u_RetVal;
return RTE_E_OK;
/**********************************************************************************************************************
* DO NOT CHANGE THIS COMMENT! << End of runnable implementation >> DO NOT CHANGE THIS COMMENT!
*********************************************************************************************************************/
}
>>>>>>>>>>>>>>>>>>>>>>>>>回到总目录<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<