[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!
 *********************************************************************************************************************/
}

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

相关推荐
Electron-er4 天前
汽车ECU重编程中的Bootloader设计原理:如何实现安全回滚?
autosar·uds·汽车电子·bootloader·功能安全·ecu刷写
yuanmenghao6 天前
Classic AUTOSAR深入浅出系列 - 【第十六篇】MCAL:为什么 MCU 换了,上层几乎不用动
单片机·嵌入式硬件·autosar
小丑小丑小丑11 天前
【AP AUTOSAR】AUTOSAR_PRS_SOMEIPProtocol解读
autosar·车载以太网·some/ip·autosar ap
AUTOSAR组织12 天前
深入解析AUTOSAR框架下的TCP/IP协议栈
网络协议·tcp/ip·汽车·autosar·软件架构·软件·培训
赞哥哥s12 天前
Autosar Com信号收不到排查-基于ETAS软件
can·autosar·com
wechat_Neal16 天前
AUTOSAR标准体系与域控制器开发流程简述
车载系统·autosar
linweidong16 天前
AUTOSAR中的软件更新(OTA)机制如何实现容错恢复?
autosar·ota
wechat_Neal16 天前
Autosar多核部署全面解析:从架构原则到部署策略
车载系统·autosar
linweidong16 天前
多个供应商模块如何集成到统一的AUTOSAR架构中?
架构·autosar
小丑小丑小丑16 天前
【AP AUTOSAR】COM通信模块api详解
中间件·汽车·autosar·autosar ap