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

  

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

  

  

相关推荐
硅农深芯1 天前
解读AUTOSAR:定义现代汽车电子的标准化架构
架构·汽车·autosar
叶修_A7 天前
【IF-SAFE-05】MTU内存测试 - ASIL-B安全机制
autosar
飞斯柯罗10 天前
[飞斯柯罗] 为满足网络安全要求,是否必须使用AUTOSAR?
autosar·crypto·mcal·软件复用·汽车网络安全·iso21434·控制器开发
叶修_A11 天前
【CP-11】复杂驱动设计 - AUTOSAR CP驱动架构与实现
架构·嵌入式·autosar·cp·驱动设计
青草地溪水旁11 天前
UDS 0x27服务:安全级别与算法类型的“灵活婚约”
uds·autosar cp·27服务
青草地溪水旁11 天前
UDS 0x27服务完全解读:从诊断协议到AUTOSAR实现的安全解锁之道
uds·autosar cp·27服务
Chasing_Chasing12 天前
82 【无人机】001 RID远程识别信息广播
rid·无人机rid·gb46750广播·无人机远程识别·gb46750广播数据格式
赞哥哥s13 天前
诊断请求1101到MCU复位的完整流程
autosar·dcm·1101
无畏jh16 天前
CCFC3008PCSN与Vector适配经验分享
autosar·国产化·汽车嵌入式·ccfc3008pcsn
Electron-er17 天前
什么是 UDS?汽车 ECU 诊断协议入门详解(工程师视角)
汽车·诊断·uds·bootloader·诊断测试