文章目录
- 前言
- Dcm配置
- DcmDsd
- DcmDsp
- DcmDspMemoryIdInfo
 
 
- 代码分析
- 总结
 
前言
一般在调教开发阶段,会使用XCP进行观测和标定,本质上也是操作指定的内存地址。量产后,一般XCP会取消。本文介绍的UDS ReadMemoryByAddress服务,也是读取内存地址的值。在没有XCP时,通过ReadMemoryByAddress服务,也可以实现特定地址的观测。
 
Dcm配置
DcmDsd
需要配置对应的Service,包括ID,关联的会话模式,安全等级。示例配置如下:
 只允许在扩展会话下读取,不需要安全等级解锁
 
 此处配置了会话及等级,在后面还可以单独对每一块内存配置
DcmDsp
配置对应的内存范围,AddressAndLengthFormatIdentifier无法通过工具配置,默认是都支持的。
DcmDspMemoryIdInfo
配置内存,ReadMemory相关,DcmDspReadMemoryRangeInfo
 DcmDspReadMemoryRangeHigh:读取内存的高字节
 DcmDspReadMemoryRangeLow:读取内存的低字节
 DcmDspReadMemoryRangeSecurityLevelRef:配置对应的安全等级
 DcmDspReadMemoryRangeSessionLevelRef:配置对应的会话模式
 示例配置如下:
 
 配置完后生成BSW代码即可
代码分析
实际处理函数为:Dcm_DcmReadMemoryByAddress
 生成的内存配置:
const Dcm_RMBAConfig_tst Dcm_RMBAConfig_cast []=
{
    {
    
                0x6FFFD8uL,   /*Lower memory address range allowed for reading*/
        0x6FFFE0uL,  /*High memory address range allowed for reading*/
        0x2uL,   /* Allowed Read Security levels */
        0x4uL,     /* Allowed Read Session levels */
        NULL_PTR,                                              /* No User specific Mode Rule function configured */
        0           /*Value of Memory Identifier to select the desired memory device*/
    }
};
函数调用流:

 最终调用的函数为DcmAppl_Dcm_ReadMemory,该函数需要用户自行实现
 输入的参数为:memoryaddress,datalength
 实际在该函数中完成对应的读取功能
 Dcm_ReturnReadMemoryType DcmAppl_Dcm_ReadMemory(Dcm_OpStatusType Rmba_Opstatus,
 														uint8 memoryid,
 														uint32 memoryaddress,
 														uint32 datalength,
 														uint8 * respbuf,
 														Dcm_NegativeResponseCodeType * ErrorCode)
 {
	/* User Application should add the necessary code to Read the data from the memory address specified by the tester */
    Dcm_ReturnReadMemoryType retVal = DCM_READ_OK;
	//添加Read内存的代码,示例如下
    rba_BswSrv_MemCopy8(respbuf,memoryaddress,datalength);
	return(retVal);
}
总结
量产取消了XCP后,ReadMemoryByAddress如果利用的合理的话,对调试帮助还是非常大的。



















