[AutoSar]BSW_Diagnostic_006 RoutineControl (0x31)的配置和实现

目录

关键词

嵌入式、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!
 *********************************************************************************************************************/
}

>>>>>>>>>>>>>>>>>>>>>>>>>回到总目录<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

相关推荐
龙智DevSecOps解决方案2 天前
TESSY AUTOSAR插件详解:从ARXML模型到自动化测试的完整工作流
autosar·tessy
说不得明天3 天前
网络管理:AutoarNM部分
c语言·网络·mcu·汽车·autosar
小凡子空白在线学习3 天前
汽车点火各状态
汽车·uds
内容为空7 天前
comm网络开启流程
autosar
内容为空7 天前
comm网络关闭流程
autosar
想成为优秀工程师的爸爸10 天前
车载以太网之要火系列 - 第35篇:郭大侠学UDS(34/36/37服务)- 环环相扣展神奇,丝滑更新不迷离
网络协议·uds·车载以太网
内容为空11 天前
AUTOSAR COM 发送流程笔记:Com_SendSignal 与 Com_MainFunctionTx
autosar
嵌软小白呗13 天前
Autosar-SecOC功能详解(一)
e2e·can·autosar·crc·secoc
内容为空18 天前
TC397 CAN 模块硬件资源与配置详解笔记
autosar
阿歪i20 天前
EB 配置MCAL (1)
s32k144·autosar·mcal