
/******************************************************************************
 * Description:     : Include File Section 									
******************************************************************************/

#include"Dcm_Cfg.h"

/******************************************************************************
 * Description:     : Global Variable Definition Section 									
 ******************************************************************************/




/******************************************************************************
 * Description:     : Static Variable Definition Section 									
 ******************************************************************************/



 /*SID  条件检查项列表*/
#if 0
/*SID  条件检查项*/
typedef struct
{
  uint8  SupportSession;  /*支持的会话模式*/
  uint8  SupportSecurityAccess;   /*支持的安全权限*/
  uint8  SupportRequestAddress;   /*支持的请求方式*/
  uint8  MinDL;           /*SID 对应的最小DL*/
  uint8  SubCount;        /*子服务个数 */
  uint8  Sid;             /*SID */
  ServerDealfunc SidFunction;
}TsDcm_h_SidCheckInfoType;
#endif
const TsDcm_h_SidCheckInfoType CaDcm_h_SidCheckInfoTable[DCM_SUPPORTSID_COUNT]={
// 会话模式															；			安全权限				；				请求方式								；子服务最小DL；子服务个数；SID；处理函数地址
{DCM_DEFAULT_SESSION | DCM_EXTEND_SESSION | DCM_PROGRAMME_SESSION	,	DCM_SECURITY_LEVEL_DEFAULT	,	DCM_PHYSICAL_ADDRESS | DCM_FUNCTIONAL_ADDRESS	,	2	,	3	,	0x10	,	&MngDcm_SessionControlService},
{DCM_DEFAULT_SESSION | DCM_EXTEND_SESSION | DCM_PROGRAMME_SESSION	,	DCM_SECURITY_LEVEL_DEFAULT	,	DCM_PHYSICAL_ADDRESS | DCM_FUNCTIONAL_ADDRESS	,	2	,	1	,	0x11	,	&MngDcm_ECUResetService},
{					   DCM_EXTEND_SESSION | DCM_PROGRAMME_SESSION	,	DCM_SECURITY_LEVEL_DEFAULT	,	DCM_PHYSICAL_ADDRESS 						 	,	2	,	2	,	0x27	,	&MngDcm_SecurityAccessService},
{					   DCM_EXTEND_SESSION | DCM_PROGRAMME_SESSION  	,	DCM_SECURITY_LEVEL_DEFAULT	,	DCM_PHYSICAL_ADDRESS | DCM_FUNCTIONAL_ADDRESS	,	3	,	3	,	0x28	,	&MngDcm_CommunicationControlService},
{DCM_DEFAULT_SESSION | DCM_EXTEND_SESSION | DCM_PROGRAMME_SESSION	,	DCM_SECURITY_LEVEL_DEFAULT	,	DCM_PHYSICAL_ADDRESS | DCM_FUNCTIONAL_ADDRESS	,	2	,	1	,	0x3E	,	&MngDcm_TesterPresentService},
{DCM_DEFAULT_SESSION | DCM_EXTEND_SESSION | DCM_PROGRAMME_SESSION	,	DCM_SECURITY_LEVEL_DEFAULT	,	DCM_PHYSICAL_ADDRESS | DCM_FUNCTIONAL_ADDRESS	,	2	,	2	,	0x85	,	&MngDcm_DTCSettingControlService},
{DCM_DEFAULT_SESSION | DCM_EXTEND_SESSION | DCM_PROGRAMME_SESSION	,	DCM_SECURITY_LEVEL_DEFAULT	,	DCM_PHYSICAL_ADDRESS | DCM_FUNCTIONAL_ADDRESS	,	3	,	0	,	0x22	,	&MngDcm_ReadDidDataService},
{					   DCM_EXTEND_SESSION | DCM_PROGRAMME_SESSION	,	DCM_SECURITYACCESS_LEVEL_L1	,	DCM_PHYSICAL_ADDRESS 						 	,	4	,	0	,	0x2E	,	&MngDcm_WriteDidDataService},										
//{DCM_DEFAULT_SESSION | DCM_EXTEND_SESSION 							,	DCM_SECURITY_LEVEL_DEFAULT	,	DCM_PHYSICAL_ADDRESS | DCM_FUNCTIONAL_ADDRESS	,	4	,	0	,	0x14	,	&MngDcm_CleanDTCService},											
//{DCM_DEFAULT_SESSION | DCM_EXTEND_SESSION 							,	DCM_SECURITY_LEVEL_DEFAULT	,	DCM_PHYSICAL_ADDRESS | DCM_FUNCTIONAL_ADDRESS	,	2	,	5	,	0x19	,	&MngDcm_ReadDTCInfoService},											
//{					   DCM_EXTEND_SESSION 		,	DCM_SECURITYACCESS_LEVEL_L1	,	DCM_PHYSICAL_ADDRESS 						 	,	4	,	0	,	0x2F	,	&MngDcm_IOCtrlDIDService},	
{					                        DCM_PROGRAMME_SESSION	,	DCM_SECURITY_LEVEL_DEFAULT	,	DCM_PHYSICAL_ADDRESS 						 	,	4	,	3	,	0x31	,	&MngDcm_RoutineControlService},
{                                           DCM_PROGRAMME_SESSION	,	DCM_SECURITYACCESS_LEVEL_L2	,	DCM_PHYSICAL_ADDRESS 						 	,	5	,	0	,	0x34	,	&MngDcm_RequestDownloadService},
{					   						DCM_PROGRAMME_SESSION	,	DCM_SECURITYACCESS_LEVEL_L2	,	DCM_PHYSICAL_ADDRESS 						 	,	3	,	0	,	0x36	,	&MngDcm_TransmitDataService},
{					   						DCM_PROGRAMME_SESSION	,	DCM_SECURITYACCESS_LEVEL_L2	,	DCM_PHYSICAL_ADDRESS 						 	,	1	,	0	,	0x37	,	&MngDcm_TransmitExitService}
};	


/*10服务 子服务信息列表*/
const TsDcm_h_SubCheckType CaDcm_h_10SubCheckTable[DCM_10SUB_COUNT]={
{0x01,2,&MngDcm_DefaultSessionDeal},
{0x02,2,&MngDcm_ProgramSessionDeal},
{0x03,2,&MngDcm_ExtendedSessionDeal}
};


/*11服务 子服务信息列表*/
const TsDcm_h_SubCheckType CaDcm_h_11SubCheckTable[DCM_11SUB_COUNT]={
	{0x01,2,&MngDcm_SoftResetDeal},
//	{0x02,2,&MngDcm_SoftResetDeal},
	{0x03,2,&MngDcm_SoftResetDeal}	
};

/*19服务 子服务信息列表*/
#if 0
const TsDcm_h_SubCheckType CaDcm_h_19SubCheckTable[DCM_19SUB_COUNT]={
	{0x01,3,&MngDcm_ReportNumberOfDTCByStatusMask},
	{0x02,3,&MngDcm_ReportDTCByStatusMask},
//	{0x04,6,&MngDcm_ReportDTCSnapshotRecordByDTCNumber},
//	{0x06,6,&MngDcm_ReportDTCExtendedDataRecordByDTCNumber},
	{0x0A,2,&MngDcm_ReportSupportedDTC}
};
#endif
/*27服务 子服务信息列表*/
const TsDcm_h_WithParaSubCheckType CaDcm_h_27SubCheckTable[DCM_27SUB_COUNT]={
//{0x01,2,&MngDcm_RequestSeekDeal},
//{0x02,6,&MngDcm_KeyCkeckDeal},
{0x11,2,&MngDcm_RequestSeekDeal},
{0x12,6,&MngDcm_KeyCkeckDeal},
};


/*28服务 子服务信息列表*/
const TsDcm_h_WithParaSubCheckType CaDcm_h_28SubCheckTable[DCM_28SUB_COUNT]={
{0x00,3,&MngDcm_CtrlCommunication},
{0x01,3,&MngDcm_CtrlCommunication},
{0x03,3,&MngDcm_CtrlCommunication},
};




/*3E服务 子服务信息列表*/
const TsDcm_h_SubCheckType CaDcm_h_3ESubCheckTable[DCM_3ESUB_COUNT]={
{0x00,2,&MngDcm_TesterPresentDeal}

};

/*85服务 子服务信息列表*/
const TsDcm_h_SubCheckType CaDcm_h_85SubCheckTable[DCM_85SUB_COUNT]={
{0x01,2,&MngDcm_DTCSettingEnable},
{0x02,2,&MngDcm_DTCSettingDisenable}
};

/*2C服务 子服务信息列表*/
const TsDcm_h_SubCheckType CaDcm_h_2CSubCheckTable[DCM_2CSUB_COUNT]={
{0x01,8,&MngDcm_DynamicaDefineNewDid},
{0x03,4,&MngDcm_ClearDynamicaDid}
};

/*2F 服务 DID  条件检查项列表*/
const TsDcm_h_DidCheckType CaDcm_h_IODidCheckInfoTable[DCM_IO_DIDSUP_COUNT]={
	{DCM_EXTEND_SESSION,DCM_SECURITYACCESS_LEVEL_L1,2,0x6300,&Dcm_DidServices_0x6300_WriteData},
	{DCM_EXTEND_SESSION,DCM_SECURITYACCESS_LEVEL_L1,2,0x6308,&Dcm_DidServices_0x6308_WriteData},
	{DCM_EXTEND_SESSION,DCM_SECURITYACCESS_LEVEL_L1,2,0x630B,&Dcm_DidServices_0x630B_WriteData},
	{DCM_EXTEND_SESSION,DCM_SECURITYACCESS_LEVEL_L1,2,0x630C,&Dcm_DidServices_0x630C_WriteData},
	{DCM_EXTEND_SESSION,DCM_SECURITYACCESS_LEVEL_L1,2,0x630E,&Dcm_DidServices_0x630E_WriteData},
};
 /*22 服务 DID  条件检查项列表*/
const TsDcm_h_DidCheckType CaDcm_h_ReadDidCheckInfoTable[DCM_READ_DIDSUP_COUNT + DCM_PERIODIC_DATA_COUNT]={
{0x07,0x07, 8,0x0200,&Dcm_DidServices_0x0200_ReadData},
{0x07,0x07, 8,0x0201,&Dcm_DidServices_0x0201_ReadData},
//{0x07,0x07, 8,0xF110,&Dcm_DidServices_0xF110_ReadData},
//{0x07,0x07, 8,0xF112,&Dcm_DidServices_0xF112_ReadData},
{0x07,0x07, 8,0xF113,&Dcm_DidServices_0xF113_ReadData},
{0x07,0x07,16,0xF180,&Dcm_DidServices_0xF180_ReadData},
{0x07,0x07, 1,0xF186,&Dcm_DidServices_0xF186_ReadData},
{0x07,0x07,11,0xF187,&Dcm_DidServices_0xF187_ReadData},
{0x07,0x07,10,0xF18A,&Dcm_DidServices_0xF18A_ReadData},
{0x07,0x07, 3,0xF18B,&Dcm_DidServices_0xF18B_ReadData},
{0x07,0x07,17,0xF190,&Dcm_DidServices_0xF190_ReadData},
{0x07,0x07,16,0xF195,&Dcm_DidServices_0xF195_ReadData},
{0x07,0x07,16,0xF193,&Dcm_DidServices_0xF193_ReadData},
//{0x07,0x07, 8,0xF197,&Dcm_DidServices_0xF197_ReadData},
{0x07,0x07,16,0xF198,&Dcm_DidServices_0xF198_ReadData},
{0x07,0x07, 4,0xF199,&Dcm_DidServices_0xF199_ReadData},
{0x07,0x07, 4,0xF19D,&Dcm_DidServices_0xF19D_ReadData},
//{0x07,0x07, 1,0x6300,&Dcm_DidServices_0x6300_ReadData},
//{0x07,0x07, 1,0x6308,&Dcm_DidServices_0x6308_ReadData},
//{0x07,0x07, 1,0x630B,&Dcm_DidServices_0x630B_ReadData},
//{0x07,0x07, 1,0x630C,&Dcm_DidServices_0x630C_ReadData},
//{0x07,0x07, 1,0x630D,&Dcm_DidServices_0x630D_ReadData},
//{0x07,0x07, 1,0x630F,&Dcm_DidServices_0x630F_ReadData},
//{0x07,0x07, 1,0xDF00,&Dcm_DidServices_0xFD00_ReadData},
#if (defined (DAMING_CAN_BOOT) && (DAMING_CAN_BOOT == YES))
{0x07,0x07,1,0xF188,&Dcm_DidServices_0xF193_ReadData},
{0x07,0x07,1,0xF191,&Dcm_DidServices_0xF195_ReadData},
#endif
/*********************End of SID $22******************************/
};


 /*2E 服务 DID  条件检查项列表*/
const TsDcm_h_DidCheckType CaDcm_h_WriteDidCheckInfoTable[DCM_WRITE_DIDSUP_COUNT]={
	{0x06,DCM_SECURITYACCESS_LEVEL_L1,16,0xF198,&Dcm_DidServices_0xF198_WriteData},
	{0x06,DCM_SECURITYACCESS_LEVEL_L1, 4,0xF199,&Dcm_DidServices_0xF199_WriteData},
};

/*Rid FF00 检查列表*/
const TsDcm_h_RidSubCheckType CaDcm_h_RidFF00SubCheckTable[DCM_RIDFF00_SUB_COUNT]=
{
 {0x01,13,&MngDcm_RoutineFF00Start},
 {0x02,5,&MngDcm_RoutineFF00Stop},
 {0x03,5,&MngDcm_RoutineFF00Result}
};

/*Rid FF01 检查列表*/
const TsDcm_h_RidSubCheckType CaDcm_h_RidFF01SubCheckTable[DCM_RIDFF01_SUB_COUNT]=
{
 {0x01,4,&MngDcm_RoutineFF01Start},
 {0x02,5,&MngDcm_RoutineFF01Stop},
 {0x03,5,&MngDcm_RoutineFF01Result}
};

/*Rid FF02 检查列表*/
const TsDcm_h_RidSubCheckType CaDcm_h_RidFF02SubCheckTable[DCM_RIDFF02_SUB_COUNT]=
{
 {0x01,4,&MngDcm_RoutineFF02Start},
 {0x02,4,&MngDcm_RoutineFF02Stop},
 {0x03,4,&MngDcm_RoutineFF02Result}
};

/*Rid 202 检查列表*/
const TsDcm_h_RidSubCheckType CaDcm_h_Rid0202SubCheckTable[DCM_RIDF001_SUB_COUNT]=
{
	{0x01,8,&MngDcm_Routine0202Start },
	{0x02,5,&MngDcm_Routine0202Stop  },
	{0x03,5,&MngDcm_Routine0202Result}
};

/*Rid 总检查列表*/
const TsDcm_h_RidCheckType CaDcm_h_RidCheckInfoTable[DCM_31RID_COUNT]={
{DCM_PROGRAMME_SESSION,DCM_SECURITYACCESS_LEVEL_L2,	ROUTINECTRL_DID_EraseMemory,				  CaDcm_h_RidFF00SubCheckTable},
{DCM_PROGRAMME_SESSION,DCM_SECURITYACCESS_LEVEL_L2,	ROUTINECTRL_DID_CheckProgrammingDependencies, CaDcm_h_RidFF01SubCheckTable},
{DCM_PROGRAMME_SESSION,DCM_SECURITYACCESS_LEVEL_L2,	ROUTINECTRL_DID_CheckProgrammingIntegrity,	  CaDcm_h_Rid0202SubCheckTable},
{DCM_EXTEND_SESSION | DCM_PROGRAMME_SESSION,DCM_SECURITYACCESS_DEFAULT,	ROUTINECTRL_DID_CheckProgrammingPreconditions,CaDcm_h_RidFF02SubCheckTable},
};



/******************************************************************************
 * Description:     : Static Function Prototype Declaration									
 *****************************************************************************/
/*@静态函数声明*/
static uint8 MngDcm_SubCheckAvailable(uint8 LeDcm_u_ListLenth,uint8 LeDcm_u_Sub,const TsDcm_h_SubCheckType LeDcm_h_SubTable[]);
static uint8 MngDcm_SubCheckDL(uint8 LeDcm_u_SubIndex,uint16 LeDcm_u_DL,const TsDcm_h_SubCheckType LeDcm_h_SubTable[]);
static uint8 MngDcm_ReadDidCheckDL(uint16 LeDcm_u_DL);
static uint8 MngDcm_2AReadDidCheckDL(uint16 LeDcm_u_DL);
static uint8 MngDcm_WriteDidCheckDL(uint8 LeDcm_u_DidIndex,const TsDcm_h_DidCheckType LaDcm_h_DidTable[]);
static uint8 MngDcm_IoDidCheckDL(uint8 LeDcm_u_DidIndex,const TsDcm_h_DidCheckType LaDcm_h_DidTable[]);
static uint8 MngDcm_DidCheckAvailable(uint8 LeDcm_u_ListLenth,uint16 LeDcm_u_Did,const TsDcm_h_DidCheckType LeDcm_h_DidTable[]);
static uint8 MngDcm_DidCheckSession(uint8 LeDcm_u_DidIndex,const TsDcm_h_DidCheckType LaDcm_h_DidTable[]);
static uint8 MngDcm_DidCheckSecurityAccess(uint8 LeDcm_u_DidIndex,const TsDcm_h_DidCheckType LaDcm_h_DidTable[]);
static uint8 MngDcm_RidCheckAvailable(uint8 LeDcm_u_ListLenth,uint16 LeDcm_u_Rid,const TsDcm_h_RidCheckType LeDcm_h_RidTable[]);
static uint8 MngDcm_RidCheckSession(uint8 LeDcm_u_RidIndex,const TsDcm_h_RidCheckType LeDcm_h_RidTable[]);
static uint8 MngDcm_RidCheckSecurityAccess(uint8 LeDcm_u_RidIndex,const TsDcm_h_RidCheckType LeDcm_h_RidTable[]);
static uint8 MngDcm_RidCheckDL(uint8 LeDcm_u_RidIndex,uint8 LeDcm_u_RidSubIndex,const TsDcm_h_RidCheckType LeDcm_h_RidTable[]);
static uint8 MngDcm_RidSubAvailable(uint8 LeDcm_u_RidIndex,uint8 LeDcm_u_RidSub,uint8 LeDcm_u_ListLength,const TsDcm_h_RidCheckType LeDcm_h_RidTable[]);

static void MngDcm_ReadDidDataPack(uint8* LeDcm_u_Buffer,uint8* LeDcm_u_Post,uint16 LeDcm_u_Did,uint8* LeDcm_u_Data,uint8 LeDcm_u_Length);




/******************************************************************************
 * Description:     : Write User Function Code								
 *****************************************************************************/
/*@函数头注释格式，所有函数头按照此格式注释*/




/******************************************************************************
 *函数名称    : uint8 MngDcm_SIDCheckAvailable(uint8 LeDcm_u_Sid)

 *参数        : LeDcm_u_Sid  请求的SID

 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查SID的有效性

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/
uint8 MngDcm_SIDCheckAvailable(uint8 LeDcm_u_Sid)
{
    uint8 i;
    uint8 LeDcm_u_TempResult = DCM_NORESULT;
    for(i=0 ; i < DCM_SUPPORTSID_COUNT; i++)
    {
        if(LeDcm_u_Sid == CaDcm_h_SidCheckInfoTable[i].Sid)
        {
             LeDcm_u_TempResult = i;
             break;
        }
    }
    
    return LeDcm_u_TempResult;
}


/******************************************************************************
 *函数名称    : uint8 MngDcm_SIDCheckSession(uint8 LeDcm_u_SidIndex)

 *参数        : LeDcm_u_SidIndex  请求的SID在条件列表中的索引值

 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前模式是否支持

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/
uint8 MngDcm_SIDCheckSession(uint8 LeDcm_u_SidIndex)
{
    
    uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if(_FALSE != (CaDcm_h_SidCheckInfoTable[LeDcm_u_SidIndex].SupportSession&(MngDcm_GetDiagnosticSession())))
    {
         LeDcm_u_TempResult = DCM_CHECK_OK;
    }
 
    
    return LeDcm_u_TempResult;
   
}


/******************************************************************************
 *函数名称    : uint8 MngDcm_SIDCheckSecurityAccess(uint8 LeDcm_u_SidIndex)

 *参数        : LeDcm_u_SidIndex  请求的SID在条件列表中的索引值

 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前安全权限是否满足

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/
uint8 MngDcm_SIDCheckSecurityAccess(uint8 LeDcm_u_SidIndex)
{
    
    uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if(_FALSE != (CaDcm_h_SidCheckInfoTable[LeDcm_u_SidIndex].SupportSecurityAccess&(MngDcm_GetSecurityAccessSts())))
    {
         LeDcm_u_TempResult = DCM_CHECK_OK;
    }
 
    
    return LeDcm_u_TempResult;
}


/******************************************************************************
 *函数名称    : uint8 MngDcm_SIDFuncAddressAvailable(uint8 LeDcm_u_SidIndex)

 *参数        : LeDcm_u_SidIndex  请求的SID在条件列表中的索引值

 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前请求方式是否支持

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/
uint8 MngDcm_SIDFuncAddressAvailable(uint8 LeDcm_u_SidIndex)
{
    
     uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if(_FALSE != (CaDcm_h_SidCheckInfoTable[LeDcm_u_SidIndex].SupportRequestAddress&VeDcm_h_RqustInfo.RequstSty))
    {
         LeDcm_u_TempResult = DCM_CHECK_OK;
    }
 
    
    return LeDcm_u_TempResult;
}



/******************************************************************************
 *函数名称    : uint8 MngDcm_SIDCheckMinDL(uint8 LeDcm_u_SidIndex,uint8 LeDcm_u_DL)

 *参数        : LeDcm_u_SidIndex  请求的SID在条件列表中的索引值，LeDcm_u_DL 客户端请求的 DL

 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前请求的DL 是否满足索引的SID的最小DL

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/
uint8 MngDcm_SIDCheckMinDL(uint8 LeDcm_u_SidIndex,uint16 LeDcm_u_DL)
{
    
    uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if(CaDcm_h_SidCheckInfoTable[LeDcm_u_SidIndex].MinDL <= LeDcm_u_DL)
    {
         LeDcm_u_TempResult = DCM_CHECK_OK;
    }
 
    
    return LeDcm_u_TempResult;
}







/******************************************************************************
 *函数名称    : uint8 MngDcm_SubCheckAvailable(uint8 LeDcm_u_ListLenth,uint8 LeDcm_u_Sub,const TsDcm_h_SubCheckType LeDcm_h_SubTable[])

 *参数        : LeDcm_u_ListLenth  请求的SID的子服务信息列表长度
                LeDcm_u_Sub        请求的子服务
                LeDcm_h_SubTable[] 请求的SID的子服务信息列表

 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前请求子服务是否支持

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/
uint8 MngDcm_SubCheckAvailable(uint8 LeDcm_u_ListLenth,uint8 LeDcm_u_Sub,const TsDcm_h_SubCheckType LeDcm_h_SubTable[])
{
    uint8 i;
    uint8 LeDcm_u_TempResult = DCM_NORESULT;
    for(i=0 ; i < LeDcm_u_ListLenth; i++)
    {
        if((LeDcm_u_Sub&0x7F)== LeDcm_h_SubTable[i].Sub)
        {
             LeDcm_u_TempResult = i;
             break;
        }
    }
    
    return LeDcm_u_TempResult;
}



/******************************************************************************
 *函数名称    : uint8 MngDcm_SubCheckDL(uint8 LeDcm_u_SubIndex,uint8 LeDcm_u_DL,const TsDcm_h_SubCheckType LeDcm_h_SubTable[])

 *参数        : LeDcm_u_SubIndex   请求的SID的子服务在子服务信息列表中的索引值
                LeDcm_u_DL         请求的DL
                LeDcm_h_SubTable[] 请求的SID的子服务信息列表

 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前请求子服务是否支持

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/
uint8 MngDcm_SubCheckDL(uint8 LeDcm_u_SubIndex,uint16 LeDcm_u_DL,const TsDcm_h_SubCheckType LeDcm_h_SubTable[])
{   
    
    uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if(LeDcm_h_SubTable[LeDcm_u_SubIndex].DL == LeDcm_u_DL)
    {
         LeDcm_u_TempResult = DCM_CHECK_OK;
    }
       
    return LeDcm_u_TempResult;
   
}





/******************************************************************************
 *函数名称    : uint8 MngDcm_ReadDidCheckDL(uint8 LeDcm_u_DL)

 *参数        : LeDcm_u_DL         请求的DL
               
 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前请求的DL是否满足要求

 *编辑时间    : 2015-10-10

 *备注        : 检查22 服务请求DL有效性函数
 *****************************************************************************/
uint8 MngDcm_ReadDidCheckDL(uint16 LeDcm_u_DL)
{   
 
    uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if(LeDcm_u_DL>2&&LeDcm_u_DL<(DCM_READDID_MAXNUMBER*2+2)&&(LeDcm_u_DL%2==1))
    {
        LeDcm_u_TempResult = LeDcm_u_DL/2;
    }
            
    return LeDcm_u_TempResult;
   
}



/******************************************************************************
 *函数名称    : uint8 MngDcm_ReadDidCheckDL(uint8 LeDcm_u_DL)

 *参数        : LeDcm_u_DL         请求的DL
				
 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前请求的DL是否满足要求

 *编辑时间    : 2015-10-10

 *备注        : 检查22 服务请求DL有效性函数
 *****************************************************************************/
uint8 MngDcm_2AReadDidCheckDL(uint16 LeDcm_u_DL)
{   
	
    uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if((LeDcm_u_DL>2)&&((LeDcm_u_DL<=DCM_PERIODIC_DATA_COUNT)))
    {
        LeDcm_u_TempResult = LeDcm_u_DL-2;
    }
	
    return LeDcm_u_TempResult;
	
}


/******************************************************************************
 *函数名称    : uint8 MngDcm_WriteDidCheckDL(uint8 LeDcm_u_DidIndex,const TsDcm_h_DidCheckType LaDcm_h_DidTable[])

 *参数        : LeDcm_u_DidIndex        请求的DID 在2E支持的DID信息列表中的索引值
                LaDcm_h_DidTable[]      2E支持的DID信息列表
               
 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前请求的DL是否满足要求

 *编辑时间    : 2015-10-10

 *备注        : 2E 服务检查请求DL有效性函数
 *****************************************************************************/
uint8 MngDcm_WriteDidCheckDL(uint8 LeDcm_u_DidIndex,const TsDcm_h_DidCheckType LaDcm_h_DidTable[])
{
    uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if(((LaDcm_h_DidTable[LeDcm_u_DidIndex].DataLength +3U) == VeDcm_h_RqustInfo.DL))
    {
         LeDcm_u_TempResult = DCM_CHECK_OK;
    }
 
    
    return LeDcm_u_TempResult;
}

uint8 MngDcm_IoDidCheckDL(uint8 LeDcm_u_DidIndex,const TsDcm_h_DidCheckType LaDcm_h_DidTable[])
{
    uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if((((LaDcm_h_DidTable[LeDcm_u_DidIndex].DataLength +3U) == VeDcm_h_RqustInfo.DL))||(((LaDcm_h_DidTable[LeDcm_u_DidIndex].DataLength +2U) == VeDcm_h_RqustInfo.DL)))
    {
		LeDcm_u_TempResult = DCM_CHECK_OK;
    }
	
    
    return LeDcm_u_TempResult;
}

/******************************************************************************
 *函数名称    : uint8 MngDcm_DidCheckAvailable(uint8 LeDcm_u_ListLenth,uint16 LeDcm_u_Did,const TsDcm_h_DidCheckType LeDcm_h_DidTable[])

 *参数        : LeDcm_u_ListLenth       请求的DID信息列表长度
                LeDcm_u_Did             请求的DID
                LaDcm_h_DidTable[]      DID信息列表
               
 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前请求的DID是支持

 *编辑时间    : 2015-10-10

 *备注        : 检测DID是否在列表中 如果存在 返回索引  不存在 返回 DCM_NORESULT 没找到
 *****************************************************************************/
uint8 MngDcm_DidCheckAvailable(uint8 LeDcm_u_ListLenth,uint16 LeDcm_u_Did,const TsDcm_h_DidCheckType LeDcm_h_DidTable[])
{
    uint8 i;
    uint8 LeDcm_u_TempResult = DCM_NORESULT;
    for(i=0 ; i < LeDcm_u_ListLenth; i++)
    {
        if(LeDcm_u_Did == LeDcm_h_DidTable[i].Did)
        {
             LeDcm_u_TempResult = i;
             break;
        }
    }
    
    return LeDcm_u_TempResult;

    
}




/******************************************************************************
 *函数名称    : uint8 MngDcm_DidCheckSession(uint8 LeDcm_u_DidIndex,const TsDcm_h_DidCheckType LaDcm_h_DidTable[])

 *参数        : LeDcm_u_DidIndex       请求的DID在DID信息列表中的索引值
                LaDcm_h_DidTable[]      DID信息列表
               
 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前会话模式是否支持

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/
uint8 MngDcm_DidCheckSession(uint8 LeDcm_u_DidIndex,const TsDcm_h_DidCheckType LaDcm_h_DidTable[])
{
    
    uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if(_FALSE != (LaDcm_h_DidTable[LeDcm_u_DidIndex].SupportSession&(MngDcm_GetDiagnosticSession())))
    {
         LeDcm_u_TempResult = DCM_CHECK_OK;
    }
 
    
    return LeDcm_u_TempResult;
   
}



/******************************************************************************
 *函数名称    : uint8 MngDcm_DidCheckSession(uint8 LeDcm_u_DidIndex,const TsDcm_h_DidCheckType LaDcm_h_DidTable[])

 *参数        : LeDcm_u_DidIndex       请求的DID在DID信息列表中的索引值
                LaDcm_h_DidTable[]      DID信息列表
               
 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前安全权限是否满足要求

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/
uint8 MngDcm_DidCheckSecurityAccess(uint8 LeDcm_u_DidIndex,const TsDcm_h_DidCheckType LaDcm_h_DidTable[])
{
    
    uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if(_FALSE != (LaDcm_h_DidTable[LeDcm_u_DidIndex].SupportSecurityAccess&(MngDcm_GetSecurityAccessSts())))
    {
         LeDcm_u_TempResult = DCM_CHECK_OK;
    }
 
    
    return LeDcm_u_TempResult;
}

 
 /******************************************************************************
 *函数名称    : uint8 MngDcm_RidCheckAvailable(uint8 LeDcm_u_ListLenth,uint16 LeDcm_u_Rid,const TsDcm_h_RidCheckType LeDcm_h_RidTable[])

 *参数        : LeDcm_u_ListLenth       请求的RID信息列表长度
                LeDcm_u_Rid             请求的RID
                LeDcm_h_RidTable[]      RID信息列表
               
 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前请求的RID是否支持

 *编辑时间    : 2015-10-10

 *备注        : 31服务  检测RID是否在列表中 如果存在 返回索引  不存在 返回 DCM_NORESULT 没找到
 *****************************************************************************/
uint8 MngDcm_RidCheckAvailable(uint8 LeDcm_u_ListLenth,uint16 LeDcm_u_Rid,const TsDcm_h_RidCheckType LeDcm_h_RidTable[])
{
    uint8 i;
    uint8 LeDcm_u_TempResult = DCM_NORESULT;
    for(i=0 ; i < LeDcm_u_ListLenth; i++)
    {
        if(LeDcm_u_Rid == LeDcm_h_RidTable[i].Rid)
        {
             LeDcm_u_TempResult = i;
             break;
        }
    }
    
    return LeDcm_u_TempResult;
}


/******************************************************************************
 *函数名称    : uint8 MngDcm_RidCheckSession(uint8 LeDcm_u_RidIndex,const TsDcm_h_RidCheckType LeDcm_h_RidTable[])

 *参数        : LeDcm_u_RidIndex       请求的RID在RID信息列表中的索引值
                LeDcm_h_RidTable[]      RID信息列表
               
 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前会话模式是否支持

 *编辑时间    : 2015-10-10

 *备注        : 31服务 检查当前模式是否支持该RID
 *****************************************************************************/
uint8 MngDcm_RidCheckSession(uint8 LeDcm_u_RidIndex,const TsDcm_h_RidCheckType LeDcm_h_RidTable[]) 
{
    uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if(_FALSE != (LeDcm_h_RidTable[LeDcm_u_RidIndex].SupportSession&(MngDcm_GetDiagnosticSession())))
    {
         LeDcm_u_TempResult = DCM_CHECK_OK;
    }
 
    
    return LeDcm_u_TempResult;    
   
} 

/******************************************************************************
 *函数名称    : uint8 MngDcm_RidCheckSecurityAccess(uint8 LeDcm_u_RidIndex,const TsDcm_h_RidCheckType LeDcm_h_RidTable[])
 
 *参数        : LeDcm_u_RidIndex       请求的RID在RID信息列表中的索引值
                LeDcm_h_RidTable[]      RID信息列表
               
 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查当前安全权限是否满足要求

 *编辑时间    : 2015-10-10

 *备注        : 31服务 检查权限是否满足要求
 *****************************************************************************/ 
uint8 MngDcm_RidCheckSecurityAccess(uint8 LeDcm_u_RidIndex,const TsDcm_h_RidCheckType LeDcm_h_RidTable[])
{
   uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if(_FALSE != (LeDcm_h_RidTable[LeDcm_u_RidIndex].SupportSecurityAccess&(MngDcm_GetSecurityAccessSts())))
    {
         LeDcm_u_TempResult = DCM_CHECK_OK;
    }
 
    
    return LeDcm_u_TempResult;
}


/******************************************************************************
 *函数名称    : uint8 MngDcm_RidSubAvailable(uint8 LeDcm_u_RidIndex,uint8 LeDcm_u_RidSub,uint8 LeDcm_u_ListLength,const TsDcm_h_RidCheckType LeDcm_h_RidTable[])
 
 *参数        : LeDcm_u_RidIndex       请求的RID在RID信息列表中的索引值
                LeDcm_u_RidSub         请求的Sub
                LeDcm_u_ListLength     RID支持的子服务信息列表长度
                LeDcm_h_RidTable[]     RID信息列表
               
 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查请求的RID是否支持当前请求的Sub

 *编辑时间    : 2015-10-10

 *备注        : 31服务 检查请求的RID是否支持当前请求的Sub
 *****************************************************************************/       
uint8 MngDcm_RidSubAvailable(uint8 LeDcm_u_RidIndex,uint8 LeDcm_u_RidSub,uint8 LeDcm_u_ListLength,const TsDcm_h_RidCheckType LeDcm_h_RidTable[])
{
    uint8 i;
    uint8 LeDcm_u_TempResult = DCM_NORESULT;
    for(i=0 ; i < LeDcm_u_ListLength; i++)
    {
        if((LeDcm_u_RidSub&0x7F) == LeDcm_h_RidTable[LeDcm_u_RidIndex].RidSubTable[i].Sub)
        {
             LeDcm_u_TempResult = i;
             break;
        }
    }
    
    return LeDcm_u_TempResult;   
}  

/******************************************************************************
 *函数名称    : uint8 MngDcm_RidCheckSecurityAccess(uint8 LeDcm_u_RidIndex,const TsDcm_h_RidCheckType LeDcm_h_RidTable[])
 
 *参数        : LeDcm_u_RidIndex       请求的RID在RID信息列表中的索引值
                LeDcm_u_RidSubIndex    请求的SUB在RID支持的子服务信息列表中的索引值
                LeDcm_h_RidTable[]      RID信息列表
               
 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 检查请求的DL是否满足要求

 *编辑时间    : 2015-10-10

 *备注        : 31服务 检查请求的DL是否满足要求
 *****************************************************************************/     
uint8 MngDcm_RidCheckDL(uint8 LeDcm_u_RidIndex,uint8 LeDcm_u_RidSubIndex,const TsDcm_h_RidCheckType LeDcm_h_RidTable[])
{
    uint8 LeDcm_u_TempResult = DCM_CHECK_NOK;
    
    if(((LeDcm_h_RidTable[LeDcm_u_RidIndex].RidSubTable[LeDcm_u_RidSubIndex].DL) == VeDcm_h_RqustInfo.DL))
    {
         LeDcm_u_TempResult = DCM_CHECK_OK;
    }
 
    
    return LeDcm_u_TempResult;
} 

  






/******************************************************************************
 *函数名称    : void MngDcm_ReadDidDataPack(uint8* LeDcm_u_Buffer,uint8* LeDcm_u_Post,uint16 LeDcm_u_Did,uint8* LeDcm_u_Data,uint8 LeDcm_u_Length)
 
 *参数        : LeDcm_u_Buffer          数据目标缓存数组
                LeDcm_u_Post            目标缓存数组数据填充位置
                LeDcm_u_Did             当前处理的DID
                LeDcm_u_Data            数据的源地址
                LeDcm_u_Length          数据长度
               
 *返回值      : LeDcm_u_TempResult  处理结果

 *描述        : 22 DID 读取服务的数据整理函数

 *编辑时间    : 2015-10-10

 *备注        : 对单个DID的处理，22服务请求有多个DID时会多次调用
 *****************************************************************************/ 
void MngDcm_ReadDidDataPack(uint8* LeDcm_u_Buffer,uint8* LeDcm_u_Post,uint16 LeDcm_u_Did,uint8* LeDcm_u_Data,uint8 LeDcm_u_Length)
{
    uint8 i;
    uint8 LeDcm_u_DidHigh;
    uint8 LeDcm_u_DidLow;
    
    LeDcm_u_DidLow = LeDcm_u_Did&0xFF;
    LeDcm_u_DidHigh = LeDcm_u_Did>>8;
    
    LeDcm_u_Buffer[(*LeDcm_u_Post)] = LeDcm_u_DidHigh;
    (*LeDcm_u_Post)++;
    LeDcm_u_Buffer[(*LeDcm_u_Post)] = LeDcm_u_DidLow;
    (*LeDcm_u_Post)++;
    
    for(i = 0;i < LeDcm_u_Length;i++)
    {
           LeDcm_u_Buffer[(*LeDcm_u_Post) + i] = LeDcm_u_Data[i];
           
    }
    
    (*LeDcm_u_Post) = (*LeDcm_u_Post) + LeDcm_u_Length;
    
}



/**********************************************诊断服务入口函数**************/


/******************************************************************************
 *函数名称    : TeDcm_h_ResultType MngDcm_SessionControlService(void)
 
 *参数        : void
               
 *返回值      : LeDcm_u_FinallyResult  处理结果

 *描述        : 10 服务入口函数

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/ 
TeDcm_h_ResultType MngDcm_SessionControlService(void)
 { 
     uint8 LeDcm_u_SubInex = 0xFF; 
     uint8 LeDcm_u_DLCheckResult;
     uint8 LaDcm_u_TempBuffer[6];
     TeDcm_h_ResultType LeDcm_u_FinallyResult;  
     VeDcm_h_RqustInfo.Sub = VeDcm_P_DataAddress[1];    /*调试暂用*/   //从TP数据提取   
     
     LeDcm_u_SubInex = MngDcm_SubCheckAvailable(DCM_10SUB_COUNT,VeDcm_h_RqustInfo.Sub,CaDcm_h_10SubCheckTable);  /*检查子服务是否支持*/
     if(DCM_NORESULT == LeDcm_u_SubInex)
     {
         if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
         {
             SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNoRsp;          /*设置为不响应*/
         }
         else
         {
            /*设置NRC12*/
            MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC12]);    /*整理负响应数据*/
            SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
            LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
         }
         
     }
     else
     {
         LeDcm_u_DLCheckResult = MngDcm_SubCheckDL(LeDcm_u_SubInex,VeDcm_h_RqustInfo.DL,CaDcm_h_10SubCheckTable);
         if(DCM_CHECK_OK  == LeDcm_u_DLCheckResult)
         {
              LeDcm_u_FinallyResult = CaDcm_h_10SubCheckTable[LeDcm_u_SubInex].SubFunction();
         }
         else
         {
              /*设置NRC13*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC13]);    /*整理负响应数据*/
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;
         }
     }
     
  
       return  LeDcm_u_FinallyResult;
 }

 

 /******************************************************************************
 *函数名称    :  TeDcm_h_ResultType MngDcm_ECUResetService(void)
 
 *参数        : void
               
 *返回值      : LeDcm_u_FinallyResult  处理结果

 *描述        : 11 服务入口函数

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/ 
 TeDcm_h_ResultType MngDcm_ECUResetService(void)
 {
     uint8 LeDcm_u_SubInex = 0xFF; 
     uint8 LeDcm_u_DLCheckResult;
     TeDcm_h_ResultType LeDcm_u_FinallyResult;
     uint8 LaDcm_u_TempBuffer[6];  
     VeDcm_h_RqustInfo.Sub = VeDcm_P_DataAddress[1];  //从TP数据提取
     
     LeDcm_u_SubInex = MngDcm_SubCheckAvailable(DCM_11SUB_COUNT,VeDcm_h_RqustInfo.Sub,CaDcm_h_11SubCheckTable);  /*检查子服务是否支持*/
     if(DCM_NORESULT == LeDcm_u_SubInex)
     {
         if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
         {
             SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNoRsp;          /*设置为不响应*/
         }
         else
         {
             /*设置NRC12*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC12]);    /*整理负响应数据*/
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
         }
         
         
     }
     else
     {
         LeDcm_u_DLCheckResult = MngDcm_SubCheckDL(LeDcm_u_SubInex,VeDcm_h_RqustInfo.DL,CaDcm_h_11SubCheckTable);
         if(DCM_CHECK_OK  == LeDcm_u_DLCheckResult)
         {
              LeDcm_u_FinallyResult = CaDcm_h_11SubCheckTable[LeDcm_u_SubInex].SubFunction();
         }
         else
         {
              /*设置NRC13*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC13]);    /*整理负响应数据*/
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;
         }
     }
     
  
       return  LeDcm_u_FinallyResult;
 }
 
 
 
 
  
 
 
 
 
 
 
  /******************************************************************************
 *函数名称    : TeDcm_h_ResultType MngDcm_ReadDidDataService(void)
 
 *参数        : void
               
 *返回值      : LeDcm_u_FinallyResult  处理结果

 *描述        : 22 服务入口函数

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/ 
 #if (defined (DID_RECORD) && (DID_RECORD == YES))
 uint16 DidList[16];
 uint8 Didcnt;
 
 #endif
 TeDcm_h_ResultType MngDcm_ReadDidDataService(void)
 {   
     
     uint8 i = 0U;
     uint8 LeDcm_u_DidNumber;
     uint8 LeDcm_u_NotSupDidNumber =0U;
     uint8 LeDcm_u_DidIndex;
     uint8 LeDcm_u_SessionCheckResult;
     uint8 LeDcm_u_SecurityAccessCheckResult;
     uint8 LeDcm_u_FuncDealResult;
     uint16 LeDcm_u_CurrentDid;
     uint8 LaDcm_u_TempBuffer[6];
     uint8 LeDcm_u_SingleDidBuffer[DCM_ONEDID_MAXDATALENGTH];
     uint8 LeDcm_u_SingleDidDataLength;
     
     uint8 LeDcm_u_CollectDataBuffer[DCM_TXBUFFER_LENGTH - 2U];
     uint8 LeDcm_u_CollectDataPost = 1U;
     
     uint8 LeDcm_u_BreakFlag = 0U;
    
     
     TeDcm_h_ResultType LeDcm_u_FinallyResult;  
  
                                
      
     LeDcm_u_DidNumber = MngDcm_ReadDidCheckDL(VeDcm_h_RqustInfo.DL);           /*函数返回值为不合格 或 DID 数目  */
     if(DCM_CHECK_NOK != LeDcm_u_DidNumber)
     {
         VeDcm_h_RqustInfo.DidCount = LeDcm_u_DidNumber;                   /*将得到的DID 个数保存到 结构体中 */
         
                              
         MngDcm_DataMoveDeal(VeDcm_h_RqustInfo.Did,0,VeDcm_P_DataAddress,1,LeDcm_u_DidNumber*2);     /*将具体DID 提取到结构体中*/
         
         while(VeDcm_h_RqustInfo.DidCount > _NULL)
         {
              /*将两个did 数组元素转换成 uint16 类型的 did  便于比较 */
             LeDcm_u_CurrentDid = (((uint16)VeDcm_h_RqustInfo.Did[i])<<8) + ((uint16)VeDcm_h_RqustInfo.Did[i+1U]);
             i = i + 2U;   /*指向下一个did */
             
 #if (defined (DID_RECORD) && (DID_RECORD == YES))
             DidList[Didcnt++] = LeDcm_u_CurrentDid;
 #endif
             
             LeDcm_u_DidIndex = MngDcm_DidCheckAvailable(DCM_READ_DIDSUP_COUNT + DCM_PERIODIC_DATA_COUNT,LeDcm_u_CurrentDid,CaDcm_h_ReadDidCheckInfoTable);   /*检查是否是否支持该DID*/  /*返回为当前DID索引或不支持*/
             
             if(DCM_NORESULT != LeDcm_u_DidIndex)
             {
                   
                 LeDcm_u_SessionCheckResult = MngDcm_DidCheckSession(LeDcm_u_DidIndex,CaDcm_h_ReadDidCheckInfoTable);  /*检查当前模式是否支持该DID*/
                 if(DCM_CHECK_OK == LeDcm_u_SessionCheckResult)
                 {
                     LeDcm_u_SecurityAccessCheckResult = MngDcm_DidCheckSecurityAccess(LeDcm_u_DidIndex,CaDcm_h_ReadDidCheckInfoTable);  /*检查当前权限是否满足*/
                     if(DCM_CHECK_OK == LeDcm_u_SecurityAccessCheckResult)
                     {
                         LeDcm_u_FuncDealResult = CaDcm_h_ReadDidCheckInfoTable[LeDcm_u_DidIndex].Function(LeDcm_u_SingleDidBuffer,&LeDcm_u_SingleDidDataLength);   /*查表调用具体DID处理函数*/
                         
                         VeDcm_h_RqustInfo.DidCount = VeDcm_h_RqustInfo.DidCount - 1U;            /*减去已处理的DID*/
                    
                         if(DCM_CHECK_OK !=LeDcm_u_FuncDealResult)    /*如果具体处理函数产生NRC*/
                         {
                             /*接收返回值作为NRC*/ 
                             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[LeDcm_u_FuncDealResult]);    /*整理负响应数据*/
                             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
                             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;
                             break;
                         }
                         else
                         {
                             MngDcm_ReadDidDataPack(LeDcm_u_CollectDataBuffer,&LeDcm_u_CollectDataPost,LeDcm_u_CurrentDid,LeDcm_u_SingleDidBuffer,LeDcm_u_SingleDidDataLength);  /*将读取的DID数据整合到一个数组*/
                         }
                         
                        
                     }
                     else
                     {
                         /*设置NRC 33*/
                         MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC33]);    /*整理负响应数据*/
                         SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
                         LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;
                         LeDcm_u_BreakFlag = 1U;
                         break;
                     }
                
                 }
                 else
                 {
                     LeDcm_u_NotSupDidNumber++;                     /*当前不支持加1*/
                     VeDcm_h_RqustInfo.DidCount--;              /*减去已处理的DID*/
                 }
           
             }
             else
             {
                LeDcm_u_NotSupDidNumber++;                    /*当前不支持加1 不支持的DID 暂时做成当前不支持*/
                VeDcm_h_RqustInfo.DidCount--;             /*减去已处理的DID*/
             }
         }
          
        
          
         /*所有DID处理完成*/
         if(0U==LeDcm_u_BreakFlag)
         {
             if(LeDcm_u_NotSupDidNumber == LeDcm_u_DidNumber)
             {
                 if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
                 {
                     SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
                     LeDcm_u_FinallyResult = CeDcm_e_ResultNoRsp; 
                 }
                 else
                 {
                     /*设置NRC 31*/
                     MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC31]);    /*整理负响应数据*/
                     SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
                     LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;
                 }
             }
             else
             {
                 LeDcm_u_CollectDataBuffer[0] =  VeDcm_h_RqustInfo.Sid + 0x40;
                 SetCanTp_TxBuffer(LeDcm_u_CollectDataPost,LeDcm_u_CollectDataBuffer);      /*调用接口发送响应数据*/
                 LeDcm_u_FinallyResult = CeDcm_e_ResultPosRsp;
             }
          }
          else
          {}
              
    
     }
     else
     {
         /*设置NRC13*/
         MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC13]);    /*整理负响应数据*/
         SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
         LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;
     }
     
     return LeDcm_u_FinallyResult;
 }
 
 /******************************************************************************
 *函数名称    : TeDcm_h_ResultType MngDcm_ReadMemoryDataService
 
 *参数        : void
               
 *返回值      : LeDcm_u_FinallyResult  处理结果

 *描述        : 23 服务入口函数

 *编辑时间    : 2016-12-25

 *备注        : 
 *****************************************************************************/ 
 
 TeDcm_h_ResultType MngDcm_ReadMemoryDataService(void)
 {
	
 }
 /******************************************************************************
 *函数名称    : TeDcm_h_ResultType MngDcm_SecurityAccessService(void)
 
 *参数        : void
               
 *返回值      : LeDcm_u_FinallyResult  处理结果

 *描述        : 27 服务入口函数

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/ 
 TeDcm_h_ResultType MngDcm_SecurityAccessService(void)
 {
     uint8 LeDcm_u_SubIndex = 0xFF; 
     uint8 LeDcm_u_DLCheckResult;
     TeDcm_h_ResultType LeDcm_u_FinallyResult; 
     uint8 LaDcm_u_TempBuffer[6]; 
     VeDcm_h_RqustInfo.Sub = VeDcm_P_DataAddress[1]; ; /*从TP数据提取*/
     
     LeDcm_u_SubIndex = MngDcm_SubCheckAvailable(DCM_27SUB_COUNT,VeDcm_h_RqustInfo.Sub,CaDcm_h_27SubCheckTable);  /*检查子服务是否支持*/
     if(DCM_NORESULT == LeDcm_u_SubIndex)
     {
         if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
         {
             SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNoRsp; 
         }
         else
         {
             /*设置NRC12*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC12]);    /*整理负响应数据*/
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
         }
         
         
     }
     else
     {
         LeDcm_u_DLCheckResult = MngDcm_SubCheckDL(LeDcm_u_SubIndex,VeDcm_h_RqustInfo.DL,CaDcm_h_27SubCheckTable);
         if(DCM_CHECK_OK  == LeDcm_u_DLCheckResult)
         {
			 LeDcm_u_FinallyResult = CaDcm_h_27SubCheckTable[LeDcm_u_SubIndex].SubFunction( CaDcm_h_27SubCheckTable[LeDcm_u_SubIndex].Sub);    
         }
         else
         {
              /*设置NRC13*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC13]);    /*整理负响应数据*/ 
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;
         }
     }
     
  
       return  LeDcm_u_FinallyResult;
 }
 
 
  
 /******************************************************************************
 *函数名称    :  TeDcm_h_ResultType MngDcm_CommunicationControlService(void)
 
 *参数        : void
               
 *返回值      : LeDcm_u_FinallyResult  处理结果

 *描述        : 28 服务入口函数

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/ 
 TeDcm_h_ResultType MngDcm_CommunicationControlService(void)
 {
     uint8 LeDcm_u_SubIndex = 0xFF; 
     uint8 LeDcm_u_DLCheckResult;
     TeDcm_h_ResultType LeDcm_u_FinallyResult; 
     uint8 LaDcm_u_TempBuffer[6]; 
      VeDcm_h_RqustInfo.Sub = VeDcm_P_DataAddress[1]; //从TP数据提取
     
     LeDcm_u_SubIndex = MngDcm_SubCheckAvailable(DCM_28SUB_COUNT,VeDcm_h_RqustInfo.Sub,CaDcm_h_28SubCheckTable);  /*检查子服务是否支持*/
     if(DCM_NORESULT == LeDcm_u_SubIndex)
     {
         if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
         {
             SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNoRsp; 
         }
         else
         {
             /*设置NRC12*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC12]);    /*整理负响应数据*/
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
         }
         
     }
     else
     {
         LeDcm_u_DLCheckResult = MngDcm_SubCheckDL(LeDcm_u_SubIndex,VeDcm_h_RqustInfo.DL,CaDcm_h_28SubCheckTable);
         if(DCM_CHECK_OK  == LeDcm_u_DLCheckResult)
         {
              LeDcm_u_FinallyResult = CaDcm_h_28SubCheckTable[LeDcm_u_SubIndex].SubFunction(VeDcm_P_DataAddress[2]);
         }
         else
         {
              /*设置NRC13*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC13]);    /*整理负响应数据*/ 
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;
         }
     }
     
  
       return  LeDcm_u_FinallyResult;
 }
 
 
 
 /******************************************************************************
 *函数名称    :  TeDcm_h_ResultType MngDcm_WriteDidDataService(void)
 
 *参数        : void
               
 *返回值      : LeDcm_u_FinallyResult  处理结果

 *描述        : 2E 服务入口函数

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/ 
 TeDcm_h_ResultType MngDcm_WriteDidDataService(void)
 {
     uint8 i = 0U;
     uint8 LeDcm_u_DidIndex;
     uint8 LeDcm_u_DLCheckResult;
     uint8 LeDcm_u_SessionCheckResult;
     uint8 LeDcm_u_SecurityAccessCheckResult;
     uint8 LeDcm_u_FuncDealResult;
     uint8 LaDcm_u_TempBuffer[6];
     uint16 LeDcm_u_CurrentDid;
     uint8 LeDcm_u_DidDataLength;
     uint8 LeDcm_u_CollectDataBuffer[4U];
     uint8 LeDcm_u_CollectDataPost = 3U;
     TeDcm_h_ResultType LeDcm_u_FinallyResult;  
  
                              
     MngDcm_DataMoveDeal(VeDcm_h_RqustInfo.Did,0,VeDcm_P_DataAddress,1,2);     /*将具体DID 提取到结构体中*/
         
     LeDcm_u_CurrentDid = (((uint16)VeDcm_h_RqustInfo.Did[0])<<8) + ((uint16)VeDcm_h_RqustInfo.Did[1]);    /*将两个did 数组元素转换成 uint16 类型的 did  便于比较 */
       
#if (defined (DID_RECORD) && (DID_RECORD == YES))
	 DidList[Didcnt++] =    LeDcm_u_CurrentDid;     
#endif  
             
     LeDcm_u_DidIndex = MngDcm_DidCheckAvailable(DCM_WRITE_DIDSUP_COUNT,LeDcm_u_CurrentDid,CaDcm_h_WriteDidCheckInfoTable);   /*检查是否是否支持该DID*/  /*返回为当前DID索引或不支持*/
             
     if(DCM_NORESULT != LeDcm_u_DidIndex)
     {
         if((LeDcm_u_CurrentDid == 0xF15A)&&(VeDcm_h_RqustInfo.DL == 33))			/*  适应大明Boot软件 */
		 {
			LeDcm_u_DLCheckResult = DCM_CHECK_OK;
		 }
		 else
			LeDcm_u_DLCheckResult = MngDcm_WriteDidCheckDL(LeDcm_u_DidIndex,CaDcm_h_WriteDidCheckInfoTable);    /*检查DL是否满足要求  */  
         if(DCM_CHECK_OK == LeDcm_u_DLCheckResult)
         {          
             MngDcm_DataMoveDeal(VeDcm_h_RqustInfo.WriteData,0,VeDcm_P_DataAddress,3,CaDcm_h_WriteDidCheckInfoTable[LeDcm_u_DidIndex].DataLength);     /*将具体DID 提取到结构体中*/
             LeDcm_u_DidDataLength = CaDcm_h_WriteDidCheckInfoTable[LeDcm_u_DidIndex].DataLength;
                
             LeDcm_u_SessionCheckResult = MngDcm_DidCheckSession(LeDcm_u_DidIndex,CaDcm_h_WriteDidCheckInfoTable);  /*检查当前模式是否支持该DID*/
             if(DCM_CHECK_OK == LeDcm_u_SessionCheckResult)
             {
                 LeDcm_u_SecurityAccessCheckResult = MngDcm_DidCheckSecurityAccess(LeDcm_u_DidIndex,CaDcm_h_WriteDidCheckInfoTable);  /*检查当前权限是否满足*/
                 if(DCM_CHECK_OK == LeDcm_u_SecurityAccessCheckResult)
                 {
                 
                     LeDcm_u_FuncDealResult = CaDcm_h_WriteDidCheckInfoTable[LeDcm_u_DidIndex].Function(VeDcm_h_RqustInfo.WriteData,&LeDcm_u_DidDataLength);   /*查表调用具体DID处理函数*/
                    
                     if(DCM_CHECK_OK !=LeDcm_u_FuncDealResult)    /*如果具体处理函数产生NRC*/
                     {
                        /*接收返回值作为NRC*/ 
                        MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[LeDcm_u_FuncDealResult]);    /*整理负响应数据*/
                        SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
                        LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;
                      
                     }
                     else
                     {
                         LeDcm_u_CollectDataBuffer[0] = VeDcm_h_RqustInfo.Sid + 0x40;
                         LeDcm_u_CollectDataBuffer[1] = VeDcm_h_RqustInfo.Did[0];
                         LeDcm_u_CollectDataBuffer[2] = VeDcm_h_RqustInfo.Did[1];
                        
                         SetCanTp_TxBuffer(3U,LeDcm_u_CollectDataBuffer);      /*调用接口发送响应数据*/
                     }
                    
                 }
                 else
                 {
                 
                     /*设置NRC 33*/
                     MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC33]);    /*整理负响应数据*/
                     SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
                     LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;    
                 }       
                        
             }
             else
             {
                if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
                {
                    SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
                    LeDcm_u_FinallyResult = CeDcm_e_ResultNoRsp; 
                }
                else
                {
                    /*设置NRC 31*/
                    MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC31]);    /*整理负响应数据*/
                    SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
                    LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;
                }
                  
                    
             }
                
         }
         else
         {
             /*设置NRC 13*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC13]);    /*整理负响应数据*/
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      
              
         }
           
     }
     else
     {
     
         if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
         {
             SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNoRsp; 
         }
         else
         {
              /*设置NRC31*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC31]);    /*整理负响应数据*/
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
         }
         
    
     }
     
    return LeDcm_u_FinallyResult;
}
 
 /******************************************************************************
 *函数名称    :  TeDcm_h_ResultType MngDcm_WriteMemoryDataService(void)
 
 *参数        : void
               
 *返回值      : LeDcm_u_FinallyResult  处理结果

 *描述        : 3D 服务入口函数

 *编辑时间    : 2016-12-25

 *备注        : 
 *****************************************************************************/ 
 TeDcm_h_ResultType MngDcm_WriteMemoryDataService(void)
 {
	 TeDcm_h_ResultType LeDcm_u_FinallyResult;
	 /*设置NRC22*/
	 MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC22]);    /*整理负响应数据*/ 
	 SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
	 LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
	 
	 return LeDcm_u_FinallyResult;
 }

 /******************************************************************************
 *函数名称    :  TeDcm_h_ResultType MngDcm_DynamicaDefineIdentifier(void)
 
 *参数        : void
               
 *返回值      : LeDcm_u_FinallyResult  处理结果

 *描述        : 2C 服务入口函数

 *编辑时间    : 2016-12-25

 *备注        : 
 *****************************************************************************/ 
 TeDcm_h_ResultType MngDcm_DynamicaDefineIdentifier(void)
 {
	 TeDcm_h_ResultType LeDcm_u_FinallyResult;
			/*设置NRC22*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC22]);    /*整理负响应数据*/ 
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
			 
			 return LeDcm_u_FinallyResult;
 }
 

 /******************************************************************************
 *函数名称    : TeDcm_h_ResultType MngDcm_RoutineControlService(void)
 
 *参数        : void
               
 *返回值      : LeDcm_u_FinallyResult  处理结果

 *描述        : 31 服务入口函数

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/ 
 TeDcm_h_ResultType MngDcm_RoutineControlService(void)
 {
   
     uint8 LeDcm_u_RidIndex;
     uint8 LeDcm_u_DLCheckResult;
     uint8 LeDcm_u_RidSubIndex;
     uint8 LeDcm_u_SessionCheckResult;
     uint8 LeDcm_u_SecurityAccessCheckResult;
     TeDcm_h_ResultType LeDcm_u_FinallyResult; 
     uint8 LaDcm_u_TempBuffer[6]; 
  
     
     VeDcm_h_RqustInfo.Rid = (((uint16)VeDcm_P_DataAddress[2])<<8) + ((uint16)VeDcm_P_DataAddress[3]);     /*将具体RID 提取到结构体中*/
     VeDcm_h_RqustInfo.Sub = VeDcm_P_DataAddress[1];                                                      /*sub*/   //从TP数据提取           
     LeDcm_u_RidIndex = MngDcm_RidCheckAvailable(DCM_31RID_COUNT,VeDcm_h_RqustInfo.Rid,CaDcm_h_RidCheckInfoTable);   /*检查是否是否支持该RID*/  /*返回为当前RID索引或不支持*/
     if(DCM_NORESULT != LeDcm_u_RidIndex)
     {
         LeDcm_u_SessionCheckResult = MngDcm_RidCheckSession(LeDcm_u_RidIndex,CaDcm_h_RidCheckInfoTable);  /*检查当前模式是否支持该RID*/ 
         if(DCM_CHECK_OK == LeDcm_u_SessionCheckResult)
         {
             LeDcm_u_SecurityAccessCheckResult = MngDcm_RidCheckSecurityAccess(LeDcm_u_RidIndex,CaDcm_h_RidCheckInfoTable);
             if(DCM_CHECK_OK == LeDcm_u_SecurityAccessCheckResult)
             {
                 LeDcm_u_RidSubIndex =  MngDcm_RidSubAvailable(LeDcm_u_RidIndex,VeDcm_h_RqustInfo.Sub,DCM_RIDFF02_SUB_COUNT,CaDcm_h_RidCheckInfoTable); 
                 if(DCM_NORESULT != LeDcm_u_RidSubIndex)
                 {
                     LeDcm_u_DLCheckResult = MngDcm_RidCheckDL(LeDcm_u_RidIndex,LeDcm_u_RidSubIndex,CaDcm_h_RidCheckInfoTable);    /*检查DL是否满足要求  */  
                     
                     //LeDcm_u_DLCheckResult = DCM_CHECK_OK;	//boot add  //todo
                     
                     if(DCM_CHECK_OK == LeDcm_u_DLCheckResult)
                     {
                         LeDcm_u_FinallyResult = CaDcm_h_RidCheckInfoTable[LeDcm_u_RidIndex].RidSubTable[LeDcm_u_RidSubIndex].Function();    /*调用对应子函数处理  */  
                     }
                     else
                     {
                         MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC13]);    /*整理负响应数据*/
                         SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
                         LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
                       
                     }
                 
                 }
                 else
                 {
                     if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
                     { 
                         SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
                         LeDcm_u_FinallyResult = CeDcm_e_ResultNoRsp; 
                     }
                     else
                     {
                         MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC12]);    /*整理负响应数据*/
                         SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
                         LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
                     }
                     
                     
                 }
             }
             else
             {
                 MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC33]);    /*整理负响应数据*/
                 SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
                 LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
                 
             }
         }
         else
         {
         
             if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
             {
                 SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
                 LeDcm_u_FinallyResult = CeDcm_e_ResultNoRsp; 
             }
             else
             {
                 MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC31]);    /*整理负响应数据*/
                 SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
                 LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
             }
             
         
         }
     }
     else
     {
         
         if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
         {
             SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNoRsp;
         }
         else
         {
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC7E]);    /*整理负响应数据*/
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
         }
         
         
     }
         
    return LeDcm_u_FinallyResult;
 }
 
 
 
  /******************************************************************************
 *函数名称    :  TeDcm_h_ResultType MngDcm_TesterPresentService(void)
 
 *参数        : void
               
 *返回值      : LeDcm_u_FinallyResult  处理结果

 *描述        : 3E 服务入口函数

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/ 
 TeDcm_h_ResultType MngDcm_TesterPresentService(void)
 {
     uint8 LeDcm_u_SubInex = 0xFF; 
     uint8 LeDcm_u_DLCheckResult;
     TeDcm_h_ResultType LeDcm_u_FinallyResult;  
     uint8 LaDcm_u_TempBuffer[6];
     VeDcm_h_RqustInfo.Sub = VeDcm_P_DataAddress[1];    /*调试暂用*/   //从TP数据提取   
     
     LeDcm_u_SubInex = MngDcm_SubCheckAvailable(DCM_3ESUB_COUNT,VeDcm_h_RqustInfo.Sub,CaDcm_h_3ESubCheckTable);  /*检查子服务是否支持*/
     if(DCM_NORESULT == LeDcm_u_SubInex)
     {
         if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
         {
             SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNoRsp;
         }
         else
         {
             /*设置NRC12*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC12]);    /*整理负响应数据*/
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
         }
         
     }
     else
     {
         LeDcm_u_DLCheckResult = MngDcm_SubCheckDL(LeDcm_u_SubInex,VeDcm_h_RqustInfo.DL,CaDcm_h_3ESubCheckTable);
         if(DCM_CHECK_OK  == LeDcm_u_DLCheckResult)
         {
              LeDcm_u_FinallyResult = CaDcm_h_3ESubCheckTable[LeDcm_u_SubInex].SubFunction();
         }
         else
         {
              /*设置NRC13*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC13]);    /*整理负响应数据*/
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;
         }
     }
     
  
    return  LeDcm_u_FinallyResult;
 
}
 
 
 
  /******************************************************************************
 *函数名称    :TeDcm_h_ResultType MngDcm_DTCSettingControlService(void)
 
 *参数        : void
               
 *返回值      : LeDcm_u_FinallyResult  处理结果

 *描述        : 85 服务入口函数

 *编辑时间    : 2015-10-10

 *备注        : 
 *****************************************************************************/ 
 TeDcm_h_ResultType MngDcm_DTCSettingControlService(void)
 {
     uint8 LeDcm_u_SubIndex = 0xFF; 
     uint8 LeDcm_u_DLCheckResult;
     TeDcm_h_ResultType LeDcm_u_FinallyResult; 
     uint8 LaDcm_u_TempBuffer[6]; 
     VeDcm_h_RqustInfo.Sub = VeDcm_P_DataAddress[1];  /*从TP数据提取*/

     if(MngDcm_GetDiagnosticSession() != DCM_EXTEND_SESSION)
     {
         if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
         {
            SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
            return  CeDcm_e_ResultNoRsp; 
         }
         else
         {
            MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC7F]);    /*整理负响应数据*/
            SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);                              /*调用接口发送响应数据*/
            return  CeDcm_e_ResultNoRsp; 
            
         }
     } 

     
     LeDcm_u_SubIndex = MngDcm_SubCheckAvailable(DCM_85SUB_COUNT,VeDcm_h_RqustInfo.Sub,CaDcm_h_85SubCheckTable);  /*检查子服务是否支持*/
     if(DCM_NORESULT == LeDcm_u_SubIndex)
     {
         if(DCM_FUNCTIONAL_ADDRESS == VeDcm_h_RqustInfo.RequstSty)
         {
             SetCanTp_TxBuffer(0U,LaDcm_u_TempBuffer);      /*调用接口发送响应数据 0数据为不响应*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNoRsp;
         }
         else
         {
             /*设置NRC12*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC12]);    /*整理负响应数据*/ 
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;      /*负响应*/
         }
         
     }
     else
     {
         LeDcm_u_DLCheckResult = MngDcm_SubCheckDL(LeDcm_u_SubIndex,VeDcm_h_RqustInfo.DL,CaDcm_h_85SubCheckTable);
         if(DCM_CHECK_OK  == LeDcm_u_DLCheckResult)
         {
              LeDcm_u_FinallyResult = CaDcm_h_85SubCheckTable[LeDcm_u_SubIndex].SubFunction();
         }
         else
         {
              /*设置NRC13*/
             MngDcm_PrepareNegRsp(VeDcm_h_RqustInfo.Sid,CaDcm_u_NRCData[DCM_NRC13]);    /*整理负响应数据*/ 
             SetCanTp_TxBuffer(3U,VaDcm_u_NegRspTxBuffer);      /*调用接口发送响应数据*/ 
             LeDcm_u_FinallyResult = CeDcm_e_ResultNegRsp;
         }
     }
     
  
       return  LeDcm_u_FinallyResult;
 }
 
 
 



 
