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


  

关键词

嵌入式、C语言、autosar、OS、BSW、UDS、diagnostic

平台说明

项目Value
OSautosar 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】

在这里插入图片描述
  
  
>>>>>>>>>>>>>>>>>>>>>>>>>回到总目录<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

  
  

缩写描述
DEMDiagnostic Event Manager
DETDevelopment Error Tracer
DDMDiagnostic Data Modifier
DCMDiagnostic Communication Manager
LSBleast significant byte
MSBmost significant byte
DIDData dentifier
DSDDiagostic Service Dispatcher (submodule of the DCM module)
DSLDiagostic Session Layer (submodule of the DCM module)
DSPDiagostic Service Processing (submodule of the DCM module)
ResDataresponse Data
ReqDatarequest 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中:
生成相应代码

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报文。

# define DCM_E_PENDING                                               ((Std_ReturnType)10)         /*!< Invoked callout (operation) needs to be called again */
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!
 *********************************************************************************************************************/
}

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

  
  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老灰╮(╯-╰)╭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值