/**
	******************************************************************************
	* @file
	* @author
	* @version
	* @date
	* @brief
	* @function List:
	******************************************************************************
	* @attention
	*
	*
	* <h2><center>&copy; COPYRIGHT 2021 </center></h2>
	******************************************************************************
	* @History:
	* @Author:
	* @Data:
	* @Version:
*/

/*******************************************************************************
* Include files
********************************************************************************/
#include "Dcm.h"
#include "nvm.h"
#include "CanNm.h"
#include "CanTp.h"
#include "Demm.h"
#include "Dem.h"
#include "calibration.h"
#include "boot_app.h"
#include "Com.h"
#include "gpio_cfg.h"
#include "boot_app.h"
#include "system_config.h"
#include "common_cfg.h"
#include "service_27.h"
#include "common_memory.h"
#include "fault_detect.h"
#include "system_voltage_manage.h"
#include "key_app.h"
#include "can_app.h"
#include "WheelHeat.h"

void app_dcm_operate_service_27(u8 level,P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext);





















void app_dcm_task(void)
{
	#if 0 //己在main实现
	Dcm_MainFunction();
	CanTp_MainFunction();
	#endif
	//dtc_on_delay_valid_task();
}


bool check_date_valid(u8 *p_date);
u8 get_ant_dcm_to_peps(u8 ant_id);

/*******************************************************************************
* Macros and Tyedef
********************************************************************************/
uint8 gDTCSwitch;
u16 g_dtc_timecount=0u;
#define W8(addr, value)  (*((uint8 *) (addr)) = (value))
#define R8(addr)         (*((uint8 *) (addr)))

//STATIC uint8 testbyte_0x0110=0x01;
/*static void DynamicalDidCommon(Dcm_MsgContextType* pMsgContext,uint8 DidPosition);*/
/* For 0x19*/
/* For 0x22 */
	#define ReadHandle_0xF100            0u
	#define ReadHandle_0x01A0            1u
	#define ReadHandle_0xF1A0            2u
	#define ReadHandle_0xb070            3u
	#define ReadHandle_0xb071            4u
	#define ReadHandle_0xb072            5u
	#define ReadHandle_0xb073            6u
	#define ReadHandle_0xb074            7u
	#define ReadHandle_0xb075            8u
	#define ReadHandle_0xA030            9u
	#define ReadHandle_0xF1F2            10u
	#define ReadHandle_0xF1F1            11u
	#define ReadHandle_0xF19E            12u
	#define ReadHandle_0xF194            13u
	#define ReadHandle_0xF192            14u
	#define ReadHandle_0xF191            15u
	#define ReadHandle_0xF188            16u
	#define ReadHandle_0xF181            17u
	#define ReadHandle_0xF182            18u
	#define ReadHandle_0xF180            19u
	#define ReadHandle_0xF186            20u
	#define ReadHandle_0xF187            21u
	#define ReadHandle_0xF189            22u
	#define ReadHandle_0xF18A            23u
	#define ReadHandle_0xF18B            24u
	#define ReadHandle_0xF18C            25u
	#define ReadHandle_0xF190            26u
	#define ReadHandle_0xF193            27u
	#define ReadHandle_0xF195            28u
	#define ReadHandle_0xF197            29u
	#define ReadHandle_0xF198            30u
	#define ReadHandle_0xF199            31u
	#define ReadHandle_0xF19D            32u
	#define ReadHandle_0x0003            33u
/* For 0x27 */
	#define Request_Seed_L1_Hanle            0u
	#define Send_Key_L1_Hanle            1u
	#define Request_Seed_L2_Hanle            2u
	#define Send_Key_L2_Hanle            3u
/* For 0x2E */
	#define WriteHandle_0x01A0            0u
	#define WriteHandle_0xF1A0            1u
	#define WriteHandle_0xF112            2u
	#define WriteHandle_0xF190            3u
	#define WriteHandle_0xF197            4u
	#define WriteHandle_0xF198            5u
	#define WriteHandle_0xF199            6u
	#define WriteHandle_0xF19D            7u
	#define WriteHandle_0xF18C  8u

/* For 0x2F */
	#define IOcontrolHandle_0x3901            0u
	#define IOcontrolHandle_0x3902            1u
	#define IOcontrolHandle_0x3903            2u
	#define IOcontrolHandle_0x3904            3u
	#define IOcontrolHandle_0x3905            4u
/* For 0x31 */
	#define RoutineHandle_0x0206            0u
	#define RoutineHandle_0x0207            1u
	#define RoutineHandle_0x0208            2u
	#define RoutineHandle_0x5901            3u
	#define RoutineHandle_0x5902            4u
	#define RoutineHandle_0x5903            5u
	#define RoutineHandle_0x5904            6u
	#define RoutineHandle_0xDF30            7u
	#define RoutineHandle_0xDF31            8u
	#define RoutineHandle_0xDF32            9u
	#define RoutineHandle_0xDF33            10u
	#define RoutineHandle_0xDF34            11u
	#define RoutineHandle_0xDF35            12u
	#define RoutineHandle_0xDF36            13u
	#define RoutineHandle_0xDF37            14u
	#define RoutineHandle_0xDF38            15u
	#define RoutineHandle_0xDF39            16u
	#define RoutineHandle_0xDF3A            17u
	#define RoutineHandle_0xFF02            18u

/*******************************************************************************
* Global variables(Scope:local)
********************************************************************************/
#if(ISO_15031_5==STD_ON)
/* For 0x02*/
#if(DCM_SERVICE_02_ENABLED==STD_ON)
uint8  Service02_SID02DTC[2]=
{
	0x01,0x00
};
#endif
#if(DCM_SERVICE_03_ENABLED==STD_ON)
/* For 0x03*/
STATIC uint8 service03DTCNUM=2;
#endif

#if(DCM_SERVICE_04_ENABLED==STD_ON)
/* For 0x04*/
STATIC uint8  IgnitionON=1;
STATIC uint8  EngineRuning=0;
#endif

#if(DCM_SERVICE_07_ENABLED==STD_ON)
/* For 0x07*/
STATIC uint16 service07DTCNUM=5;
#endif

#if(DCM_SERVICE_08_ENABLED==STD_ON)
/* For 0x08*/
STATIC uint8  TestCondition=1;
STATIC uint8  EvaporativeLeakTest=0;
#endif
#if(DCM_SERVICE_0A_ENABLED==STD_ON)
/* For 0x0A*/
STATIC uint8 service0ADTCNUM=10;
#endif
#endif

/* For 0x19 */
STATIC uint8 DTCStatusAvailabilityMask=0x09;


#if 0
STATIC uint8 SupportedDTCPriority[NUM_OF_DTC]={
	 0
};
STATIC uint32 SupportedDTC[NUM_OF_DTC]=
{
		0xA20071u,
		0xA20171u,
		0xA20271u,
		0xA20371u,
		0xA20471u,
		0xA20516u,
		0xA20616u,
		0xA20716u,
		0xA20816u,
		0xA20916u,
		0xA20A16u,
		0xC07300u,
		0xC10087u,
		0xC15587u,
		0xC21487u,
		0xD11487u,
		0xF00616u,
		0xF00617u
};
#endif
#if 0
STATIC uint8 DTCStatus[NUM_OF_DTC]=
{
		0x08
};
#endif
/* For 0x22 */
STATIC uint8 DATA_0xF1A0[SYSDID_VEHICLE_CONFIG_CK_LEN];
STATIC uint8 DATA_0x01A0[SYSDID_MANUFAC_LIFECYCLE_COUNT_CK_LEN];
//STATIC uint8 DATA_0xB070[1];
STATIC uint8 DATA_0xB071[5];
STATIC uint8 DATA_0xB072[3];
STATIC uint8 DATA_0xB073[5];
STATIC uint8 DATA_0xB074[1];
STATIC uint8 DATA_0xB075[1];
STATIC uint8 DATA_0xA030[80];
STATIC uint8 DATA_0xF1F2[SYSDID_F1F2_CK_LEN];
STATIC uint8 DATA_0xF1F1[SYSDID_F1F1_CK_LEN];
STATIC uint8 DATA_0xF19E[SYSDID_F19E_CK_LEN];
STATIC uint8 DATA_0xF194[SYSDID_F194_CK_LEN];
STATIC uint8 DATA_0xF192[SYSDID_F192_CK_LEN];
STATIC uint8 DATA_0xF191[SYSDID_F191_CK_LEN];
//STATIC uint8 DATA_0x01A0[16];
STATIC uint8 DATA_0xF188[SYSDID_F188_CK_LEN];
STATIC uint8 DATA_0xF181[SYSDID_F181_CK_LEN];
STATIC uint8 DATA_0xF182[SYSDID_F182_CK_LEN];
STATIC uint8 DATA_0xF180[SYSDID_F180_CK_LEN];
STATIC uint8 DATA_0xF186[1];
STATIC uint8 DATA_0xF187[SYSDID_F187_CK_LEN];
STATIC uint8 DATA_0xF189[16];
STATIC uint8 DATA_0xF18A[SYSDID_F18A_CK_LEN];
STATIC uint8 DATA_0xF18B[SYSDID_F18B_CK_LEN];
STATIC uint8 DATA_0xF18C[SYSDID_F18C_CK_LEN];
STATIC uint8 DATA_0xF190[SYSDID_F190_VIN_CK_LEN];
STATIC uint8 DATA_0xF193[SYSDID_F193_CK_LEN];
STATIC uint8 DATA_0xF195[SYSDID_F195_CK_LEN];
STATIC uint8 DATA_0xF197[20];
STATIC uint8 DATA_0xF198[SYSDID_F198_REPAIR_SN_CK_LEN];
STATIC uint8 DATA_0xF199[SYSDID_F199_DATE_CK_LEN];
STATIC uint8 DATA_0xF19D[4];
STATIC uint8 DATA_0xF112[8];
STATIC uint8 ApplicationSoftwareIdentification[32]=
{
		0x00, 0x01, 0x02, 0x03,
		0x04, 0x05, 0x06, 0x07,
		0x08, 0x09, 0x0a, 0x0b,
		0x0c, 0x0d, 0x0e, 0x0f,
		0x10, 0x11, 0x12, 0x13,
		0x14, 0x15, 0x16, 0x17,
		0x18, 0x19, 0x1a, 0x1b,
		0x1c, 0x1d, 0x1e, 0x1f
};
/* For 0x27 */
STATIC uint8 bUpdateSeed = 0xffU;
#if(DCM_SERVICE_27_ENABLED==STD_ON)

#endif
/* For 0x2F,0x0107 is related to both IAC and EGR */
//STATIC  uint8 TEST[7]={0x01,0x02,0x03,0x04,0x05,0x06,0x07};
//STATIC  uint8 IAC[7]={0x01,0x02,0x03,0x04,0x05,0x06,0x07};
//STATIC  uint8 EGR[7]={0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6};


/***************************************************************************
* Global Function Implementation
****************************************************************************/
#if(DCM_GENERAL_DIAGNOSTIC_REQUEST_CTL==STD_ON)
/****************************************************************************
* Name         :App_DiagnosticActive
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :N/A
* Return code  :N/A
* Description  :Check is it possible to enable Dcm module.
* 				統一診斷通信條件檢查
*調用時機：收到任何一條診斷請求之後，DCM都將先調用函數App_DiagnosticActive檢查當前是否
*允許診斷通信，常見的條件如車速信號是否為0，點火鑰匙是否為關；
*如果當前條件允許診斷通信，則返回OK，如果不滿足，則調用函數DsdInternal_SetNegResponse設置否定響應碼，
*並返回notok
*注意事項：如果檢測發現當前情況不允許診斷通信，應必須返回NOT OK，否則會影響DCM模塊正常運行。
*只有當宏DCM_GENERAL_DIAGNOSTIC_REQUEST_CTL=STD_ON時，才存在本回調函數
******************************************************************************/
Std_ReturnType App_DiagnosticActive(void)
{
		 return E_OK;  //允許進行診斷通信
}
#endif
#if(DCM_SERVICE_10_ENABLED==STD_ON)
/******************************************************************************
* Name         :App_Default
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Default session callback function
*  DCM通知應用程序，DCM將跳轉到默認會話，應用程序判斷當前應用程序條件是否允許DCM執行默認會話狀態
*  跳轉，如果不允許，則調用函數DsdInternal_SetNegResponse設置否定響應碼。
*  調用時機，收到 10 01 或者 10 81
*  注意：本函數的默認代碼不能被刪除。除非有特殊檢查條件或肯定響應格式需求，本函數中的內容無需更改。
******************************************************************************/
FUNC(void,DCM_CODE) App_Default(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint32 tempP2Star;
		/* Step 1:Transmit positive response*/
		if(GetSuppressPosResponseBit()==0)/* If positive response is supressed, dont' need make it */
		{
				
				dem_enable_dtc_setting();
				#if(RESPONSE_WITH_P2TIMER==STD_ON)
				pMsgContext->resData[2]=(uint8)(gDcmDspSessionRow[0].DcmDspSessionP2ServerMax>>8);
				pMsgContext->resData[3]=(uint8)(gDcmDspSessionRow[0].DcmDspSessionP2ServerMax);
				tempP2Star=gDcmDspSessionRow[0].DcmDspSessionP2StarServerMax/10;
				pMsgContext->resData[4]=(uint8)(tempP2Star>>8);
				pMsgContext->resData[5]=(uint8)(tempP2Star);
				pMsgContext->resDataLen=6;
				#else
				pMsgContext->resDataLen=2;
				#endif
				DsdInternal_ProcessingDone(pMsgContext);
		}
		else
		{
				DsdInternal_ProcessingDoneNoResponse();
		}
}

/******************************************************************************
* Name         :App_DefaultSessionPost
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Jump to default session once positive response is transmitted.
*               Otherwise, do not change session type.
*               如果此函數被調用，表示當前會話狀態己經跳轉到默認會話，所有安全級別重新設置鎖定狀態。
*               如果應用程序有某些標志或狀態需要在DCM進行默認會話跳轉之後進行改變，可以在本函數中添加。
*               如果沒有，則無需更改本函數
*調用時機： 1.請求正確處理並且肯定響應發送成功後，2.請求正確處理後suppressPosRspMsgIndicationBit = TRUE， 3.應用層S3參數超時
*注意：不能刪除原代碼，除非有特殊要求。帶有Post后綴的回調函數中不能再調用DsdInternal_processingDone和DsdInternal_SetNegRespnse.
*
******************************************************************************/
FUNC(void,DCM_CODE) App_DefaultPost(Std_ReturnType Result)
{
	uint8 i=0;
	if(Result==E_OK)
	{
		dem_enable_dtc_setting();
		Set_SesCtrl(DCM_SESSION_DEFAULT);
		for(i=0;i<KIND_OF_SECURITY_LEVEL;i++)
		{
			gSecurityAcessSequence[i]=0;
		}
		gSecLevelType=DCM_SEC_LEV_LOCK;
		gS3ServerTimerStartFlag = DCM_FLAG_DISACTIVE;

		//reset routine Control
		#if(DCM_SERVICE_31_ENABLED==STD_ON)
		gRountineControlDidHandle=0xFFu;/* Reset */
		for(i=0;i<NUMBER_OF_RID;i++)
		{
			gRountineControlSequence[i] = 0;

		}
		#endif




		// add you code here
		(void)CAN_SetControlBy(CAN_CONTROL_BY_APP);
		(void)WheelHeat_ReturnControlForEcu();
		(void)Com_RxStart();
		#ifdef EEPROM_EXT_STATE_MACHILE_ENABLE
		#endif
		bUpdateSeed = 0XFFu;
	}
	else
	{
	}
}

u8 g_flag_goto_program =FLAG_REPROGRAM_ID;


/******************************************************************************
* Name         :App_Programming
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Default session callback function
*注意：一般應用是在bootloader跳轉前發送NRC0x78
******************************************************************************/
FUNC(void,DCM_CODE) App_Programming(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
#if 0
		uint32 tempP2Star;
		/* Step 1:Transmit positive response*/
		if(GetSuppressPosResponseBit()==0)/* If positive response is supressed, dont' need make it */
		{
				#if(RESPONSE_WITH_P2TIMER==STD_ON)
				pMsgContext->resData[2]=(uint8)(gDcmDspSessionRow[0].DcmDspSessionP2ServerMax>>8);
				pMsgContext->resData[3]=(uint8)(gDcmDspSessionRow[0].DcmDspSessionP2ServerMax);
				tempP2Star=gDcmDspSessionRow[0].DcmDspSessionP2StarServerMax/10;
				pMsgContext->resData[4]=(uint8)(tempP2Star>>8);
				pMsgContext->resData[5]=(uint8)(tempP2Star);
				pMsgContext->resDataLen=6;
				#else
				pMsgContext->resDataLen=2;
				#endif
				DsdInternal_ProcessingDone(pMsgContext);
		}
		else
		{
				DsdInternal_ProcessingDoneNoResponse();
		}
		//恆潤示例
		//DslInternal_RCRResponsePending(1u);
		//DsdInternal_ProcessingDoneNoResponse();
#else
	if(GetSuppressPosResponseBit()==0)/* If positive response is supressed, dont' need make it */
	{
		g_flag_goto_program = FLAG_REPROGRAM_ID;
		//DsdInternal_SetNegResponse(pMsgContext,DCM_E_CONDITIONSNOTCORRECT);
		DslInternal_RCRResponsePending(1u);	//手動發送 78服務
		Clr_DiagState(DIAG_UDS_PROCESSING);

	}
	else
	{
		g_flag_goto_program = FLAG_REPROGRAM_NORES_ID;
		//DsdInternal_SetNegResponse(pMsgContext,DCM_E_CONDITIONSNOTCORRECT);
		//DslInternal_RCRResponsePending(1u);	//手動發送 78服務
		DsdInternal_ProcessingDoneNoResponse();

	}
#endif
}

/******************************************************************************
* Name         :App_ProgrammingSessionPost
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Jump to default session once positive response is transmitted.
*               Otherwise, do not change session type.
*               如果此函數被調用，表示己經準備好跳轉到編程會話，在此函數中執行跳轉語句
*     調用時機：50 02或強制0x78否定響應發送成功之後，
******************************************************************************/
FUNC(void,DCM_CODE) App_ProgrammingPost(Std_ReturnType Result)
{
		//uint8 i=0;
		if(Result==E_OK)
		{
	#if 0
		Set_SesCtrl(DCM_SESSION_PROGRAMMING);
		for(i=0;i<KIND_OF_SECURITY_LEVEL;i++)
		{
		gSecurityAcessSequence[i]=0;
		}
		gSecLevelType=DCM_SEC_LEV_LOCK;

		//reset routine Control
		#if(DCM_SERVICE_31_ENABLED==STD_ON)
		gRountineControlDidHandle=0xFFu;/* Reset */
		for(i=0;i<NUMBER_OF_RID;i++)
		{
		gRountineControlSequence[i] = 0;

		}
		#endif
	#else
		/*cpu_reset();*/
	
		(void)Boot_ReprogramCallBack(g_flag_goto_program);
	#endif
				// add you code here
		}
		else
		{
		}
}
/******************************************************************************
* Name         :App_Extended_Diagnostic
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Default session callback function
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Extended_Diagnostic(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint32 tempP2Star;
		/* Step 1:Transmit positive response*/
		if(GetSuppressPosResponseBit()==0)/* If positive response is supressed, dont' need make it */
		{
				#if(RESPONSE_WITH_P2TIMER==STD_ON)
				pMsgContext->resData[2]=(uint8)(gDcmDspSessionRow[0].DcmDspSessionP2ServerMax>>8);
				pMsgContext->resData[3]=(uint8)(gDcmDspSessionRow[0].DcmDspSessionP2ServerMax);
				tempP2Star=gDcmDspSessionRow[0].DcmDspSessionP2StarServerMax/10;
				pMsgContext->resData[4]=(uint8)(tempP2Star>>8);
				pMsgContext->resData[5]=(uint8)(tempP2Star);
				pMsgContext->resDataLen=6;
				#else
				pMsgContext->resDataLen=2;
				#endif
				DsdInternal_ProcessingDone(pMsgContext);
		}
		else
		{
				DsdInternal_ProcessingDoneNoResponse();
		}
}

/******************************************************************************
* Name         :App_Extended_DiagnosticSessionPost
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Jump to default session once positive response is transmitted.
*               Otherwise, do not change session type.
******************************************************************************/
FUNC(void,DCM_CODE) App_Extended_DiagnosticPost(Std_ReturnType Result)
{
		uint8 i=0;
		if(Result==E_OK)
		{
				Set_SesCtrl(DCM_SESSION_EXTENDED_DIAGNOSTIC);
				for(i=0;i<KIND_OF_SECURITY_LEVEL;i++)
				{
						gSecurityAcessSequence[i]=0;
				}
				gSecLevelType=DCM_SEC_LEV_LOCK;
				gS3ServerTimerStartFlag = DCM_FLAG_ACTIVE;
				Set_S3_Server_Timer(gDcmDspNonDefaultSessionS3Server);

				 //reset routine Control
				 #if(DCM_SERVICE_31_ENABLED==STD_ON)
				 gRountineControlDidHandle=0xFFu;/* Reset */
				 for(i=0;i<NUMBER_OF_RID;i++)
				 {
						 gRountineControlSequence[i] = 0;

				 }
				 #endif

				// add you code here
		}
		else
		{
		}
}
/******************************************************************************
* Name         :App_Kuwe_Session
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Default session callback function
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Kuwe_Session(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint32 tempP2Star;
		/* Step 1:Transmit positive response*/
		if(GetSuppressPosResponseBit()==0)/* If positive response is supressed, dont' need make it */
		{
				#if(RESPONSE_WITH_P2TIMER==STD_ON)
				pMsgContext->resData[2]=(uint8)(gDcmDspSessionRow[0].DcmDspSessionP2ServerMax>>8);
				pMsgContext->resData[3]=(uint8)(gDcmDspSessionRow[0].DcmDspSessionP2ServerMax);
				tempP2Star=gDcmDspSessionRow[0].DcmDspSessionP2StarServerMax/10;
				pMsgContext->resData[4]=(uint8)(tempP2Star>>8);
				pMsgContext->resData[5]=(uint8)(tempP2Star);
				pMsgContext->resDataLen=6;
				#else
				pMsgContext->resDataLen=2;
				#endif
				DsdInternal_ProcessingDone(pMsgContext);
		}
		else
		{
				DsdInternal_ProcessingDoneNoResponse();
		}
}

/******************************************************************************
* Name         :App_KuweSessionPost
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Jump to default session once positive response is transmitted.
*               Otherwise, do not change session type.
******************************************************************************/
FUNC(void,DCM_CODE) App_Kuwe_SessionPost(Std_ReturnType Result)
{
		uint8 i=0;
		if(Result==E_OK)
		{
				Set_SesCtrl(DCM_SESSION_USERDEFINED1);
				for(i=0;i<KIND_OF_SECURITY_LEVEL;i++)
				{
						gSecurityAcessSequence[i]=0;
				}
				gSecLevelType=DCM_SEC_LEV_LOCK;

				 //reset routine Control
				 #if(DCM_SERVICE_31_ENABLED==STD_ON)
				 gRountineControlDidHandle=0xFFu;/* Reset */
				 for(i=0;i<NUMBER_OF_RID;i++)
				 {
						 gRountineControlSequence[i] = 0;

				 }
				 #endif

				// add you code here
		}
		else
		{
		}
}
#endif
#if(DCM_SERVICE_11_ENABLED==STD_ON)
/******************************************************************************
* Name         :App_HardReset
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :HardReset.
* DCM通知應用程序執行硬件復位操作，如果當前條件允許執行服務，則給出肯定響應，
* 注意：如果應用程序無法執行復位，應設置否定響應碼，並給出否定應答。
******************************************************************************/
FUNC(void,DCM_CODE) App_HardReset(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

	pMsgContext->resDataLen=2;
	DsdInternal_ProcessingDone(pMsgContext);

}

/******************************************************************************
* Name         :App_HardResetPost
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Std_ReturnType Result
* Return code  :N/A
* Description  : 51 01肯定響應發送成功之後，DCM將會調用本函數。當然ECU先前收到0x11 81診斷請求
* 且app_hardresetpost的處理結果不是否定響應的話，本函數也會被調用。
* 注意：帶有Post後綴的回調函數中，不能再調DsdInternal_ProcessingDone() 和 DsdInternal_SetNegResponse()
******************************************************************************/
FUNC(void,DCM_CODE) App_HardResetPost(Std_ReturnType Result)
{
		uint8 i=0;

		if(Result==E_OK)
		{
			Set_SesCtrl(DCM_SESSION_DEFAULT);

			for(i=0;i<KIND_OF_SECURITY_LEVEL;i++)
			{
				gSecurityAcessSequence[i]=0;
			}
			gSecLevelType=DCM_SEC_LEV_LOCK;
				#if(DCM_SERVICE_31_ENABLED==STD_ON)
				gRountineControlDidHandle=0xFFu;
				for(i=0;i<NUMBER_OF_RID;i++)
				{
					gRountineControlSequence[i] = 0;

				}
				#endif
			bUpdateSeed = 0XFFu;
			ResetMCUHandle();
		}
		else
		{
		}


}

/******************************************************************************
* Name         :App_SoftReset
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :SoftReset.
*
******************************************************************************/
FUNC(void,DCM_CODE) App_SoftReset(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{


	pMsgContext->resDataLen=2;
	DsdInternal_ProcessingDone(pMsgContext);

}

/******************************************************************************
* Name         :App_SoftResetPost
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Std_ReturnType Result
* Return code  :N/A
* Description  :
******************************************************************************/
FUNC(void,DCM_CODE) App_SoftResetPost(Std_ReturnType Result)
{
		uint8 i=0;

		if(Result==E_OK)
		{
				Set_SesCtrl(DCM_SESSION_DEFAULT);

				for(i=0;i<KIND_OF_SECURITY_LEVEL;i++)
				{
						gSecurityAcessSequence[i]=0;
				}
				gSecLevelType=DCM_SEC_LEV_LOCK;
				 #if(DCM_SERVICE_31_ENABLED==STD_ON)
				 gRountineControlDidHandle=0xFFu;
				 for(i=0;i<NUMBER_OF_RID;i++)
				 {
						 gRountineControlSequence[i] = 0;

				 }
				 #endif
		 bUpdateSeed = 0XFFu;
		 ResetMCUHandle();
		}
		else
		{
		}


}

#endif
#if(DCM_SERVICE_14_ENABLED==STD_ON)
/************************************************************************
* Name         :App_ClearDiagnosticInformation
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Clear single DTC or group of DTC.
* 14 服務
******************************************************************************/
FUNC(void,DCM_CODE) App_ClearDiagnosticInformation(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 error=0;
	//uint32 i;
	//uint32 SupportedDTCGroup=0x00;

	#if 1

	uint8 dtc[3];

	dtc[0] = pMsgContext->reqData[1];
	dtc[1] = pMsgContext->reqData[2];
	dtc[2] = pMsgContext->reqData[3];

	error = dem_clear_dtc(dtc);

	if(error == ERR_FAULT)
	{
		DsdInternal_SetNegResponse(pMsgContext,DCM_E_REQUESTOUTOFRANGE);
	}
	else if(error == ERR_OK)
	{
	

		pMsgContext->resDataLen=1;
		DsdInternal_ProcessingDone(pMsgContext);
		//clear you DTC information here
		//DtcAndDidVarInit(EEPROM_DTC_CLEAR);

	}
	else
	{
		//code
	}
	#else

		uint32 Dtc;

		Dtc=Make32Bit(pMsgContext->reqData[1],pMsgContext->reqData[2],pMsgContext->reqData[3]);

		for(i=0;i<NUM_OF_DTC;i++)
		{
				if(Dtc==SupportedDTC[i])
				{
						i=NUM_OF_DTC;
				}
				else
				{
						if(i==NUM_OF_DTC-1)
						{
								if( (Dtc!=0xffffff) && (Dtc!=SupportedDTCGroup))
								{
										error=1;
										DsdInternal_SetNegResponse(pMsgContext,DCM_E_REQUESTOUTOFRANGE);
								}
								else
								{
								}
						}
						else
						{
						}
				}
		}
		if(error==0)
		{
				for(i=0;i<NUM_OF_DTC;i++)
				{
					 DTCStatus[i]=0;
				}
				pMsgContext->resDataLen=1;
				DsdInternal_ProcessingDone(pMsgContext);
				//clear you DTC information here
		}
		else
		{
		}

	#endif

}
#endif


#if(DCM_SERVICE_22_ENABLED==STD_ON)
//#define EEPROM_DATA_Bs_ADDR	  (0x400)
//#define EEPROM_START_ADDRESS  (0x7e0)
/******************************************************************************
* Name         :App_Read0xF100
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF100(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		//uint8 i;
		u8 l_buf[SYSDID_ATTEMP_LEN+SYSDID_ATTEMP_MAX_LEN];
		//(void)nvm_read_bytes(NVM_TYPE_EEPROM,SYSDID_ATTEMP_ADDR,(u8*)&l_temp,SYSDID_ATTEMP_LEN);
		cal_read_did(0xF100u,(u8*)&l_buf[0],SYSDID_ATTEMP_LEN+SYSDID_ATTEMP_MAX_LEN);
		if( (l_buf[0]==0xffu) && (l_buf[1]==0xFFu) )
		{
			l_buf[0]=0u;
			l_buf[1]=0u;
		}
		pMsgContext->resData[2] =l_buf[0];
		pMsgContext->resData[3] =l_buf[1];
		pMsgContext->resData[4] =0xff;
		pMsgContext->resData[5] =0xff;

		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF100].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF100].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0x01A0
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0x01A0(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
		cal_read_did(0x01A0u,(u8*)&DATA_0x01A0[0],SYSDID_MANUFAC_LIFECYCLE_COUNT_CK_LEN);
		//(void)nvm_read_bytes(NVM_TYPE_EEPROM,SYSDID_MANUFAC_LIFECYCLE_COUNT_ADDR,(u8*)&DATA_0x01A0,SYSDID_MANUFAC_LIFECYCLE_COUNT_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0x01A0].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]= DATA_0x01A0[i]; //*(s_pgm_dt+8); // //*s_pgm_dt; //data[8]; //pgm_count_date[0]; //*pdata; ///DATA_0x01A0[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0x01A0].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0x01A0].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF1A0
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF1A0(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
		cal_read_did(0xF1A0u,(u8*)&DATA_0xF1A0[0],SYSDID_VEHICLE_CONFIG_CK_LEN);
		//(void)nvm_read_bytes(NVM_TYPE_EEPROM,SYSDID_MANUFAC_LIFECYCLE_COUNT_ADDR,(u8*)&DATA_0x01A0,SYSDID_MANUFAC_LIFECYCLE_COUNT_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF1A0].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]= DATA_0xF1A0[i]; //*(s_pgm_dt+8); // //*s_pgm_dt; //data[8]; //pgm_count_date[0]; //*pdata; ///DATA_0x01A0[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF1A0].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF1A0].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}
/******************************************************************************
* Name         :App_Read0xb070
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xb070(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	u16 l_sys_power;
	u8 l_buf[4];
	l_sys_power = adc_manage_get_sbat_voltage();
	l_buf[0] = l_sys_power/10000;
	l_buf[1] = (l_sys_power/1000)%10;
	l_buf[2] = (l_sys_power/100)%10;
	l_buf[3] = (l_sys_power/10)%10;

	pMsgContext->resData[2]= ((u8)l_buf[0]<<4u) | l_buf[1];
	pMsgContext->resData[3]= ((u8)l_buf[2]<<4u) | l_buf[3];

	//l_sys_power = adc_manage_get_mdfd_vol();
	l_buf[0] = l_sys_power/10000;
	l_buf[1] = (l_sys_power/1000)%10;
	l_buf[2] = (l_sys_power/100)%10;
	l_buf[3] = (l_sys_power/10)%10;
	pMsgContext->resData[4]= ((u8)l_buf[0]<<4u) | l_buf[1];
	pMsgContext->resData[5]= ((u8)l_buf[2]<<4u) | l_buf[3];

#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
	DsdInternal_DidProcessingDone();
#else
	pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xb070].DcmDspDataSize+2);
	pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xb070].DcmDspDataSize+2);
	DsdInternal_ProcessingDone(pMsgContext);
#endif

}

/******************************************************************************
* Name         :App_Read0x0005_left_sws
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0x0005_left_sws(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

	uint8 i;
	u8 l_res;
	DATA_0xB071[0] =0x00;
	DATA_0xB071[1] =0x00;
	DATA_0xB071[2] =0x00;
	DATA_0xB071[3] =0x00;
	DATA_0xB071[4] =0x00;
	//motor_state = motor_driver_get_state(MOTOR_DRIVER_CHANNEL_ID_M);
	l_res =0 ;
	DATA_0xB071[0] =  ((u8)key_app_get_digi_state(KEY_DIGI_ID_MUTE) << 1) | 
						((u8)key_app_get_adc_state(KEY_ADC_ID_CUSTOM) << 2)|
						//#endif  
						((u8)key_app_get_digi_state(KEY_DIGI_ID_RMENU) << 3) | 

					  ((u8)key_app_get_adc_state(KEY_ADC_ID_RES_SPD_ADD) << 7);
	DATA_0xB071[1]= (u8)key_app_get_adc_state(KEY_ADC_ID_SET_SPD_SUB) | ((u8)key_app_get_adc_state(KEY_ADC_ID_DSP_SUB) << 3) | ((u8)key_app_get_adc_state(KEY_ADC_ID_DSP_PLUS) << 4) ;
	DATA_0xB071[4]= l_res | ((u8)key_app_get_adc_state(KEY_ADC_ID_LPICK) << 3)  ;

	DATA_0xB071[0] = ~DATA_0xB071[0];
	DATA_0xB071[1] = ~DATA_0xB071[1];
	DATA_0xB071[4] = ~DATA_0xB071[4];
	for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xb071].DcmDspDataSize;i++)
	{
		pMsgContext->resData[2+i]=DATA_0xB071[i];
	}
	
#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
	DsdInternal_DidProcessingDone();
#else
	pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xb071].DcmDspDataSize+2);
	pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xb071].DcmDspDataSize+2);
	DsdInternal_ProcessingDone(pMsgContext);
#endif
}


/******************************************************************************
* Name         :App_Read0x0005_left_sws
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0x0003_net_type(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

    
	//for(i=0;i<gDcmDsdSubService_22[ReadHandle_0x0003].DcmDspDataSize;i++)
	{
		#if 1 //
	//	pMsgContext->resData[2]=can_app_get_bcml_nm_type_logic();
	//	pMsgContext->resData[3]=can_app_get_bcml_nm_type_flag()>>8;
	//	pMsgContext->resData[4]=can_app_get_bcml_nm_type_flag();
	//	pMsgContext->resData[5]=eeprom_ext_get_state(0);
	//	pMsgContext->resData[6]=eeprom_ext_get_state(1);
		#else  //测试用
		pMsgContext->resData[2]=rmu_get_value(0);
		pMsgContext->resData[3]=rmu_get_value(1);
		pMsgContext->resData[4]=rmu_get_value(2);
		#endif
	}
#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
	DsdInternal_DidProcessingDone();
#else
	pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0x0003].DcmDspDataSize+2);
	pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0x0003].DcmDspDataSize+2);
	DsdInternal_ProcessingDone(pMsgContext);
#endif
}


/******************************************************************************
* Name         :App_Read0x0004_right_sws
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0x0004_right_sws(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	u8 l_res;
	u8 voice=0;
	u8 voice_up=0;
	u8 voice_down=0;
	DATA_0xB072[0] =0x00;
	DATA_0xB072[1] =0x00;

	voice= key_encoder_get_event();
	if(voice == KEY_ENCODER_EVENT_UP)
	{
		voice_up = KEY_APP_INPUT_VALID;
		voice_down = KEY_APP_INPUT_NULL;
	}
	else if(voice == KEY_ENCODER_EVENT_DOWN)
	{
		voice_up = KEY_APP_INPUT_NULL;
		voice_down = KEY_APP_INPUT_VALID;
	}
	else
	{
		voice_up = KEY_APP_INPUT_NULL;
		voice_down = KEY_APP_INPUT_NULL;
	}
	l_res = 0;
	DATA_0xB072[0]= voice_up | voice_down << 1  | ((u8)key_app_get_digi_state(KEY_DIGI_ID_PREV) << 2)  | ((u8)key_app_get_digi_state(KEY_DIGI_ID_NEXT) << 3)
				|  ((u8)key_app_get_digi_state(KEY_DIGI_ID_PHONE) << 5);

	DATA_0xB072[1]= l_res | ((u8)key_app_get_digi_state(KEY_DIGI_ID_VOICE) << 1) | ((u8)key_app_get_adc_state(KEY_ADC_ID_VEDIO) <<6);

	DATA_0xB072[0] = ~DATA_0xB072[0];
	DATA_0xB072[1] = ~DATA_0xB072[1];

	for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xb072].DcmDspDataSize;i++)
	{
		pMsgContext->resData[2+i]=DATA_0xB072[i];
	}
#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
	DsdInternal_DidProcessingDone();
#else
	pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xb072].DcmDspDataSize+2);
	pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xb072].DcmDspDataSize+2);
	DsdInternal_ProcessingDone(pMsgContext);
#endif
}

/******************************************************************************
* Name         :App_Read0x0008_right_pick
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0x0008_right_pick(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	u8 l_res;
	DATA_0xB073[0] =0x00;
	DATA_0xB073[1] =0x00;
	DATA_0xB073[2] =0x00;
	DATA_0xB073[3] =0x00;
	DATA_0xB073[4] =0x00;
	l_res = 0;
	DATA_0xB073[4]= l_res | ((u8)key_app_get_digi_state(KEY_DIGI_ID_RPICK) << 2)  ;        

	DATA_0xB073[4] = ~DATA_0xB073[4];

	for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xb073].DcmDspDataSize;i++)
	{
		pMsgContext->resData[2+i]=DATA_0xB073[i];
	}
#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
	DsdInternal_DidProcessingDone();
#else
	pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xb073].DcmDspDataSize+2);
	pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xb073].DcmDspDataSize+2);
	DsdInternal_ProcessingDone(pMsgContext);
#endif
}

/******************************************************************************
* Name         :App_Read0xB101_right_pick
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xB101_left_menu(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	u8 l_res;
	DATA_0xB074[0] =0x00;
	l_res = 0;
	DATA_0xB074[0]=(u8)key_app_get_adc_state(KEY_ADC_ID_LMENU);         

	DATA_0xB074[0] = ~DATA_0xB074[0];

	for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xb074].DcmDspDataSize;i++)
	{
		pMsgContext->resData[2+i]=DATA_0xB074[i];
	}
#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
	DsdInternal_DidProcessingDone();
#else
	pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xb074].DcmDspDataSize+2);
	pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xb074].DcmDspDataSize+2);
	DsdInternal_ProcessingDone(pMsgContext);
#endif
}

/******************************************************************************
* Name         :App_Read0xb073
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xb073(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

	uint8 i;

//	motor_driver_feedback(MOTOR_DRIVER_CHANNEL_ID_M,&DATA_0xB073[0]);

	for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xb073].DcmDspDataSize;i++)
	{
		pMsgContext->resData[2+i]=DATA_0xB073[i];
	}
#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
	DsdInternal_DidProcessingDone();
#else
	pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xb073].DcmDspDataSize+2);
	pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xb073].DcmDspDataSize+2);
	DsdInternal_ProcessingDone(pMsgContext);
#endif
}

/******************************************************************************
* Name         :App_Read0xb074
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xb074(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
//		DATA_0xB074[0]=led_driver_get_cmd(LED_ID_ILL);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xb074].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xB074[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xb074].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xb074].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xb075
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xb075(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
//		DATA_0xB075[0]=led_driver_get_level(LED_ID_ILL);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xb075].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xB075[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xb075].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xb075].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xA030
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xA030(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
		u8 len=POWER_SUPPLY_HIS_MAX;
		power_supply_history_s l_his[POWER_SUPPLY_HIS_MAX];
		fault_detect_get_power_history(&l_his[0],&len);
		for(i=0;i<POWER_SUPPLY_HIS_MAX;i++)
		{
			DATA_0xA030[0+i*10]= l_his[i].poweroff | l_his[i].out30s<<2 | l_his[i].out30r<<4 | l_his[i].out15d<<6;
			DATA_0xA030[1+i*10]= l_his[i].sigt30s | l_his[i].sigt30r<<2 | l_his[i].sigt15d<<4;
			DATA_0xA030[2+i*10]= l_his[i].year;
			DATA_0xA030[3+i*10]= l_his[i].month;
			DATA_0xA030[4+i*10]= l_his[i].day;
			DATA_0xA030[5+i*10]= l_his[i].hour;
			DATA_0xA030[6+i*10]= l_his[i].min;
			DATA_0xA030[7+i*10]= l_his[i].sec;
		}
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xA030].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xA030[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xA030].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xA030].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF1F2
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF1F2(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		//(void)flash_read_bytes(SYSDID_F1F2_ADDR,DATA_0xF1F2,SYSDID_F1F2_CK_LEN);
		cal_read_did(0xF1F2u,(u8*)&DATA_0xF1F2[0],SYSDID_F1F2_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF1F2].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF1F2[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF1F2].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF1F2].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF1F1
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF1F1(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		cal_read_did(0xF1F1u,(u8*)&DATA_0xF1F1[0],SYSDID_F1F1_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF1F1].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF1F1[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF1F1].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF1F1].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF19E
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF19E(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		cal_read_did(0xF19Eu,(u8*)&DATA_0xF19E[0],SYSDID_F19E_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF19E].DcmDspDataSize;i++)
		{
			 pMsgContext->resData[2+i]=DATA_0xF19E[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF19E].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF19E].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF194
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF194(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		cal_read_did(0xF194u,(u8*)&DATA_0xF194[0],SYSDID_F194_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF194].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF194[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF194].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF194].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF192
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF192(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		cal_read_did(0xF192u,(u8*)&DATA_0xF192[0],SYSDID_F192_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF192].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF192[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF192].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF192].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF191
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF191(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	cal_read_did(0xF191u,(u8*)&DATA_0xF191[0],SYSDID_F191_CK_LEN);
	for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF191].DcmDspDataSize;i++)
	{
		pMsgContext->resData[2+i]=DATA_0xF191[i];
	}
	#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
	DsdInternal_DidProcessingDone();
	#else
	pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF191].DcmDspDataSize+2);
	pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF191].DcmDspDataSize+2);
	DsdInternal_ProcessingDone(pMsgContext);
	#endif
}

/******************************************************************************
* Name         :App_Read0xF188
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF188(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		cal_read_did(0xF188u,(u8*)&DATA_0xF188[0],SYSDID_F188_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF188].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF188[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF188].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF188].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF181
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF181(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	//(void)flash_read_bytes(SYSDID_F181_ADDR,DATA_0xF181,SYSDID_F181_CK_LEN);
	cal_read_did(0xF181u,(u8*)&DATA_0xF181[0],SYSDID_F181_CK_LEN);
	for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF181].DcmDspDataSize;i++)
	{
		pMsgContext->resData[2+i]=DATA_0xF181[i];
	}
#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
	DsdInternal_DidProcessingDone();
#else
	pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF181].DcmDspDataSize+2);
	pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF181].DcmDspDataSize+2);
	DsdInternal_ProcessingDone(pMsgContext);
#endif
}

/******************************************************************************
* Name         :App_Read0xF182
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF182(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		//flash_read_bytes(SYSDID_F182_ADDR,DATA_0xF182,SYSDID_F182_CK_LEN);
		//common_memory_copys(DATA_0xF182,(u8*)&g_sysdid_f182,SYSDID_F182_LEN);
		cal_read_did(0xF182u,(u8*)&DATA_0xF182[0],SYSDID_F182_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF182].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF182[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF182].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF182].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF180
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF180(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		//(void)flash_read_bytes(SYSDID_F180_ADDR,DATA_0xF180,SYSDID_F180_CK_LEN);
		cal_read_did(0xF180u,(u8*)&DATA_0xF180[0],SYSDID_F180_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF180].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF180[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF180].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF180].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF186
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF186(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;

		DATA_0xF186[0] = 0xFF;
		if (gSesCtrlType == DCM_SESSION_DEFAULT)
		{
				DATA_0xF186[0] = 0x01;
		}
		else if (gSesCtrlType == DCM_SESSION_PROGRAMMING)
		{
				DATA_0xF186[0] = 0x02;
		}
		else if (gSesCtrlType == DCM_SESSION_EXTENDED_DIAGNOSTIC)
		{
				DATA_0xF186[0] = 0x03;
		}
		else if (gSesCtrlType == DCM_SESSION_USERDEFINED1)
		{
				DATA_0xF186[0] = 0x60;
		}
		else
		{
			//code
		}

		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF186].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF186[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF186].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF186].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF187
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF187(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		cal_read_did(0xF187u,(u8*)&DATA_0xF187[0],SYSDID_F187_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF187].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF187[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF187].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF187].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF189
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF189(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		#if 1
		(void)cal_read_did(0xF189,DATA_0xF189,sizeof(DATA_0xF189));
		#else
		DATA_0xF189[0]=0x89;
		#endif
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF189].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF189[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF189].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF189].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF18A
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF18A(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		cal_read_did(0xF18Au,(u8*)&DATA_0xF18A[0],SYSDID_F18A_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF18A].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF18A[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF18A].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF18A].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF18B
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF18B(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		cal_read_did(0xF18Bu,(u8*)&DATA_0xF18B[0],SYSDID_F18B_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF18B].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF18B[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF18B].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF18B].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF18C
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF18C(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		cal_read_did(0xF18Cu,(u8*)&DATA_0xF18C[0],SYSDID_F18C_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF18C].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF18C[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF18C].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF18C].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF190
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF190(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		cal_read_did(0xF190u,(u8*)&DATA_0xF190[0],SYSDID_F190_VIN_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF190].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF190[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF190].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF190].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF193
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF193(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		cal_read_did(0xF193u,(u8*)&DATA_0xF193[0],SYSDID_F193_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF193].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF193[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF193].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF193].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF195
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF195(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

	uint8 i;
	cal_read_did(0xF195u,(u8*)&DATA_0xF195[0],SYSDID_F195_CK_LEN);
	for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF195].DcmDspDataSize;i++)
	{
			pMsgContext->resData[2+i]= DATA_0xF195[i];
	}
	#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
	DsdInternal_DidProcessingDone();
	#else
	pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF195].DcmDspDataSize+2);
	pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF195].DcmDspDataSize+2);
	DsdInternal_ProcessingDone(pMsgContext);
	#endif
}

/******************************************************************************
* Name         :App_Read0xF197
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF197(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		#if 1 
		(void)cal_read_did(0xF197,DATA_0xF197,sizeof(DATA_0xF197));
		#else
		DATA_0xF197[0]=0x97;
		#endif
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF197].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF197[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF197].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF197].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF198
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/

FUNC(void,DCM_CODE) App_Read0xF198(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
		cal_read_did(0xF198u,(u8*)&DATA_0xF198[0],SYSDID_F198_REPAIR_SN_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF198].DcmDspDataSize;i++)
		{
			pMsgContext->resData[2+i]= DATA_0xF198[i];   //DATA_0xF198[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF198].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF198].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF199
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF199(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
		cal_read_did(0xF199u,(u8*)&DATA_0xF199[0],SYSDID_F199_DATE_CK_LEN);
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF199].DcmDspDataSize;i++)
		{
			pMsgContext->resData[2+i] = DATA_0xF199[i]; //data[i+10]; // pgm_count_date[2+i]; //*pdata; //DATA_0xF199[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF199].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF199].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

/******************************************************************************
* Name         :App_Read0xF19D
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :activeDiagnosticSessionDataIdentifier,Data lenth=1 Byte
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Read0xF19D(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 i;
		#if 1 
		(void)cal_read_did(0xF19d,DATA_0xF19D,sizeof(DATA_0xF19D));
		#endif
		for(i=0;i<gDcmDsdSubService_22[ReadHandle_0xF19D].DcmDspDataSize;i++)
		{
				pMsgContext->resData[2+i]=DATA_0xF19D[i];
		}
		#if(DCM_SERVICE_22_COMBINED_DID==STD_ON)
		DsdInternal_DidProcessingDone();
		#else
		pMsgContext->resData+=(gDcmDsdSubService_22[ReadHandle_0xF19D].DcmDspDataSize+2);
		pMsgContext->resDataLen+=((uint32)gDcmDsdSubService_22[ReadHandle_0xF19D].DcmDspDataSize+2);
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
}

#endif
#if(DCM_SERVICE_2E_ENABLED==STD_ON)
/******************************************************************************
* Name         :App_Write0x01A0
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Write0x01A0(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
		for(i=0;i<gDcmDsdSubService_2E[WriteHandle_0x01A0].DcmDspDataSize;i++)
		{
				DATA_0x01A0[i] = pMsgContext->resData[2+i];
		}
		cal_write_did(0x01A0u,(u8*)&DATA_0x01A0[0],SYSDID_MANUFAC_LIFECYCLE_COUNT_CK_LEN);
		//(void)nvm_write_bytes(NVM_TYPE_EEPROM,SYSDID_MANUFAC_LIFECYCLE_COUNT_ADDR,DATA_0x01A0,SYSDID_MANUFAC_LIFECYCLE_COUNT_CK_LEN);
		gMsgContextType.resDataLen=3;
		DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_Write0xF1A0
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Write0xF1A0(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
		for(i=0;i<gDcmDsdSubService_2E[WriteHandle_0xF1A0].DcmDspDataSize;i++)
		{
				DATA_0xF1A0[i] = pMsgContext->resData[2+i];
		}
		cal_write_did(0xF1A0u,(u8*)&DATA_0xF1A0[0],SYSDID_VEHICLE_CONFIG_CK_LEN);
		gMsgContextType.resDataLen=3;
		DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_Write0xF112
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Write0xF112(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
		for(i=0;i<gDcmDsdSubService_2E[WriteHandle_0xF112].DcmDspDataSize;i++)
		{
				DATA_0xF112[i] = pMsgContext->resData[2+i];
		}
		#if 1 
		(void)cal_write_did(0xF112,DATA_0xF112,sizeof(DATA_0xF112));
		#endif
		gMsgContextType.resDataLen=3;
		DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_Write0xF190
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Write0xF190(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
		for(i=0;i<gDcmDsdSubService_2E[WriteHandle_0xF190].DcmDspDataSize;i++)
		{
				DATA_0xF190[i] = pMsgContext->resData[2+i];
		}
		cal_write_did(0xF190u,(u8*)&DATA_0xF190[0],SYSDID_F190_VIN_CK_LEN);
		gMsgContextType.resDataLen=3;
		DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_Write0xF197
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Write0xF197(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
		for(i=0;i<gDcmDsdSubService_2E[WriteHandle_0xF197].DcmDspDataSize;i++)
		{
				DATA_0xF197[i] = pMsgContext->resData[2+i];
		}
		#if 1 
		(void)cal_write_did(0xF197,DATA_0xF197,sizeof(DATA_0xF197));
		#endif
		gMsgContextType.resDataLen=3;
		DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_Write0xF198
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Write0xF198(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
		for(i=0;i<gDcmDsdSubService_2E[WriteHandle_0xF198].DcmDspDataSize;i++)
		{
				DATA_0xF198[i] = pMsgContext->resData[2+i];
		}
		(void)nvm_write_bytes(NVM_TYPE_EEPROM,SYSDID_F198_REPAIR_SN_ADDR,DATA_0xF198,SYSDID_F198_REPAIR_SN_CK_LEN);
		//(void)cal_write_did(0xF198,DATA_0xF198,sizeof(DATA_0xF198));
		gMsgContextType.resDataLen=3;
		DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_Write0xF199
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Write0xF199(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	bool l_result;

	for(i=0;i<gDcmDsdSubService_2E[WriteHandle_0xF199].DcmDspDataSize;i++)
	{
		 DATA_0xF199[i] = pMsgContext->resData[2+i];
	}

	#if 1
	(void)nvm_write_bytes(NVM_TYPE_EEPROM,SYSDID_F199_DATE_ADDR,DATA_0xF199,SYSDID_F199_DATE_CK_LEN);
	/*日期合法的判斷*/
	l_result = check_date_valid(DATA_0xF199);

	if(l_result == FALSE)
	{
		DsdInternal_SetNegResponse(pMsgContext,DCM_E_REQUESTOUTOFRANGE);
	}
	else
	{
			//(void)cal_write_did(0xF199,DATA_0xF199,sizeof(DATA_0xF199));

			gMsgContextType.resDataLen=3;
			DsdInternal_ProcessingDone(pMsgContext);
	}
	#else

			(void)cal_write_did(0xF199,DATA_0xF199,sizeof(DATA_0xF199));
			gMsgContextType.resDataLen=3;
			DsdInternal_ProcessingDone(pMsgContext);

	#endif

}

/******************************************************************************
* Name         :App_Write0xF19D
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :
*
******************************************************************************/
FUNC(void,DCM_CODE) App_Write0xF19D(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
	bool l_result;

		for(i=0;i<gDcmDsdSubService_2E[WriteHandle_0xF19D].DcmDspDataSize;i++)
		{
				DATA_0xF19D[i] = pMsgContext->resData[2+i];
		}

	/*日期合法的判斷*/
	l_result = check_date_valid(DATA_0xF19D);

	if(l_result == FALSE)
	{
		DsdInternal_SetNegResponse(pMsgContext,DCM_E_REQUESTOUTOFRANGE);
	}
	else
	{
			#if 1 
			(void)cal_write_did(0xF19d,DATA_0xF19D,sizeof(DATA_0xF19D));
			#endif
			gMsgContextType.resDataLen=3;
			DsdInternal_ProcessingDone(pMsgContext);
	}



}

FUNC(void,DCM_CODE) App_Write0xF18C(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	//bool l_result;

	for(i=0;i<gDcmDsdSubService_2E[WriteHandle_0xF18C].DcmDspDataSize;i++)
	{
		DATA_0xF18C[i] = pMsgContext->resData[2+i];
	}
	#if 1 
	(void)cal_write_did(0xF18C,DATA_0xF18C,sizeof(DATA_0xF18C));
	#endif
	gMsgContextType.resDataLen=3;
	DsdInternal_ProcessingDone(pMsgContext);


}

#endif

#if(DCM_SERVICE_2F_ENABLED==STD_ON)

#define DCM_NO_USE_NES_RESPONSE_FOR_2F  DCM_E_REQUESTOUTOFRANGE

/******************************************************************************
* Name         :App_ReturnControlToEcu0x201f_motor
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_ReturnControlToEcu0x201f_motor(Dcm_MsgContextType* pMsgContext)
{
//	output_app_ctrl(OUTPUT_TYPE_MOTOR,MOTOR_DRIVER_CHANNEL_ID_M,MOTOR_DRIVER_LEVEL_DEFAULT,MOTOR_DRIVER_CMD_OFF);
	pMsgContext->resData[3] = 0x00;  //unsigned---命令必须
//	pMsgContext->resData[4] = motor_driver_get_state(MOTOR_DRIVER_CHANNEL_ID_M);  //unsigned
	pMsgContext->resDataLen=5;
	DsdInternal_ProcessingDone(pMsgContext);
}
/******************************************************************************
* Name         :App_ShortTermAdjustment201f_motor
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_ShortTermAdjustment201f_motor(Dcm_MsgContextType* pMsgContext)
{
//	motor_driver_reactive(MOTOR_DRIVER_CHANNEL_ID_M);
//	output_app_ctrl(OUTPUT_TYPE_MOTOR,MOTOR_DRIVER_CHANNEL_ID_M,MOTOR_DRIVER_LEVEL_DEFAULT,pMsgContext->reqData[4]);
	pMsgContext->resData[3] = 0x03;  //unsigned---命令必须
//	pMsgContext->resData[4] = motor_driver_get_state(MOTOR_DRIVER_CHANNEL_ID_M);  //unsigned
	pMsgContext->resDataLen=5;
	DsdInternal_ProcessingDone(pMsgContext);

}
/******************************************************************************
* Name         :App_ReturnControlToEcu0xff00
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_ReturnControlToEcu0xff00(Dcm_MsgContextType* pMsgContext)
{
	#if 0
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_2F);
	#else
	WheelHeat_ReturnControlForEcu();
	pMsgContext->resData[3] = 0x00;  //unsigned---命令必须
	pMsgContext->resData[4] = 0x00;  //unsigned---命令必须
	pMsgContext->resDataLen=5;
	DsdInternal_ProcessingDone(pMsgContext);
	#endif
}
/******************************************************************************
* Name         :App_ShortTermAdjustment0xff00
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
* reqData[1]=0XB0.reqData[2]=0X80.reqData[3]=0X03.reqData[4]=0X01CMD reqData[5]=0X0A LEVEL
******************************************************************************/
FUNC(void,DCM_CODE) App_ShortTermAdjustment0xff00(Dcm_MsgContextType* pMsgContext)
{
	#if 0
	u8 l_cmd;
	u8 l_level;
	#ifdef APP_DCM_DEBUG_EN
	u8 i;
	g_app_decm_debug.len = pMsgContext->reqDataLen;
	for(i=0;i<10;i++)
	{
		g_app_decm_debug.buf[i]=pMsgContext->reqData[i];
	}
	#endif
	app_dcm_io_ctrl_led_set_state(APP_DCM_IO_CTRL_STATE_RUN_LED);
	if(pMsgContext->reqData[4]==1)
	{
		l_cmd = LED_DRIVER_CMD_ON;
	}
	else
	{
		l_cmd = LED_DRIVER_CMD_OFF;
	}
	l_level =pMsgContext->reqData[5] ;
	output_app_ctrl(OUTPUT_TYPE_LED,LED_ID_ILL,l_level,l_cmd);
	{
		pMsgContext->resData[3] = 0x03;  //unsigned---命令必须
		pMsgContext->resData[4] = led_driver_get_cmd(LED_ID_ILL);  //unsigned
		pMsgContext->resData[5] = led_driver_get_level(LED_ID_ILL);  //unsigned
	}
	pMsgContext->resDataLen=6;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_2F);
	#endif
}
/******************************************************************************
* Name         :App_ReturnControlToEcu0x2020
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_ReturnControlToEcu0x2020(Dcm_MsgContextType* pMsgContext)
{
	#if 0
	WheelHeat_ControlForDcm();
	pMsgContext->resData[3] = 0x00;  //unsigned---命令必须
	pMsgContext->resDataLen=4;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_2F);
	#endif
}
/******************************************************************************
* Name         :App_ShortTermAdjustment0x2020
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/

FUNC(void,DCM_CODE) App_ShortTermAdjustment0x2020(Dcm_MsgContextType* pMsgContext)
{
	if(pMsgContext->reqData[4])
	{
		WheelHeat_ControlForDcm(WHEEL_HEAT_DCM_CONTROL_OPEN);
	}
	else
	{
		WheelHeat_ControlForDcm(WHEEL_HEAT_DCM_CONTROL_CLOSE);
	}


	pMsgContext->resData[3] = 0x03;  //unsigned---命令必须
	pMsgContext->resData[4] = pMsgContext->reqData[4];
	pMsgContext->resDataLen=5;
	DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_ReturnControlToEcu0x5001
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_ReturnControlToEcu0x5001(Dcm_MsgContextType* pMsgContext)
{
	#if 0
	WheelHeat_ControlForDcm();
	pMsgContext->resData[3] = 0x00;  //unsigned---命令必须
	pMsgContext->resDataLen=4;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_2F);
	#endif
}
/******************************************************************************
* Name         :App_ShortTermAdjustment0x5001
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/

FUNC(void,DCM_CODE) App_ShortTermAdjustment0x5001(Dcm_MsgContextType* pMsgContext)
{
	u8 car_show_state=0;
	u8 output=0;
	car_show_state = pMsgContext->reqData[4];
	if(car_show_state == KEY_DCM_SHOW_IN)
	{
		output=1;
		app_sig_sws_r_auto_show_in_tx_process(output, 3, 3);
		
	}
	else if(car_show_state == KEY_DCM_SHOW_OUT)
	{
		output=1;
		app_sig_sws_r_auto_show_out_tx_process(output, 3, 3);
	}
	else if(car_show_state == KEY_DCM_SHOW_UP)
	{
		output=0;
		Com_SendSignal(COM_TX_SIGSWS_R_MULTIMEDIA, &output);	
		app_sig_sws_r_auto_show_out_tx_process(output, 3, 0);
	}
	pMsgContext->resData[3] = 0x03;  //unsigned---命令必须
	pMsgContext->resData[4] = pMsgContext->reqData[4];
	pMsgContext->resDataLen=5;
	DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_ReturnControlToEcu0x3904
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_ReturnControlToEcu0x3904(Dcm_MsgContextType* pMsgContext)
{
	#if 0
	#if 0
	escl_drive_cmd_req(ESCL_CMD_POWER_OFF);
	escl_drive_cmd_req(ESCL_CMD_GND_OFF);
	escl_drive_cmd_req(ESCL_CMD_LOCK_ENABLE_OFF);
	#endif
	pMsgContext->resData[4]=0;
	pMsgContext->resDataLen=5;
	DsdInternal_ProcessingDone(pMsgContext); 
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_2F);
	#endif
}
/******************************************************************************
* Name         :App_ShortTermAdjustment0x3904
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_ShortTermAdjustment0x3904(Dcm_MsgContextType* pMsgContext)
{
	#if 0
	uint8_t l_req_data[2]={0}, i;
	pMsgContext->resData[4]=l_req_data[0];
	pMsgContext->resDataLen=5;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_2F);
	#endif
}
/******************************************************************************
* Name         :App_ReturnControlToEcu0x3905
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_ReturnControlToEcu0x3905(Dcm_MsgContextType* pMsgContext)
{
	#if 0
	/*¼ÌµçÆ÷ÍË³öÕï¶Ï¿ØÖÆ*/
	//power_relay_res_cmd(RELAY_CMD_DCM_EXIT, 0);

	pMsgContext->resData[4]= 0;
	pMsgContext->resDataLen=5;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_2F);
	#endif
}
/******************************************************************************
* Name         :App_ShortTermAdjustment0x3905
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
#define POWER_RELAY_OPERATE_ACC		0x04
#define POWER_RELAY_OPERATE_IG1		0x02
#define POWER_RELAY_OPERATE_IG2		0x01
#define POWER_RELAY_OPERATE_START	0x08
FUNC(void,DCM_CODE) App_ShortTermAdjustment0x3905(Dcm_MsgContextType* pMsgContext)
{
	#if 0
	/*¼ÌµçÆ÷¿ØÖÆ*/

	uint8_t l_req_data[2]={0}, i;
	u8 l_output = 0;

	for(i=0;i<gDcmDsdSubService_2F[IOcontrolHandle_0x3905].RecordSizes.DcmDspDidControlEnableMaskRecordSize;i++)
	{
		l_req_data[i] = pMsgContext->resData[4+i];
	}
	#if 0
	if((l_req_data[0] & 0x0f) == 0x00)
	{
		power_relay_res_cmd(RELAY_CMD_DCM_ENTER,POWER_RELAY_OFF);
	}
	else if((l_req_data[0] & 0x0f) == 0x01)
	{
		power_relay_res_cmd(RELAY_CMD_DCM_ENTER,POWER_RELAY_ACC);
	}
	else if((l_req_data[0] & 0x0f) == 0x07)
	{
		power_relay_res_cmd(RELAY_CMD_DCM_ENTER,POWER_RELAY_ON);
	}
	else if((l_req_data[0] & 0x0f) == 0x0a)
	{
		power_relay_res_cmd(RELAY_CMD_DCM_ENTER,POWER_RELAY_CRANK);
	}
	else
	{
		//code
	}
	#endif
	pMsgContext->resData[4]=l_req_data[0];
	pMsgContext->resDataLen=5;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_2F);
	#endif
}
#endif
/* 19 */
/******************************************************************************
* Name         :App_ReportNumberOfDTCByStatusMask
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Report number of DTC by status mask.
*19-01  讀取當前DTC個數，by status mask
******************************************************************************/
FUNC(void,DCM_CODE) App_ReportNumberOfDTCByStatusMask(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	//uint8  result=0;
	uint16 counter=0;
	uint8  DtcStatus;
	DtcStatus=pMsgContext->reqData[2];
	for(i=0;i<NUM_OF_DTC;i++)
	{
	
		if( (DtcStatus&_dem_get_state(i)) != 0u)
		//if((DtcStatus&DTCStatus[i])!=0)
		{
				counter++;
		}
		else
		{
		}
	
	}
	//pMsgContext->resData[1]=pMsgContext->reqData[1];
	pMsgContext->resData[2]=DTCStatusAvailabilityMask;
	pMsgContext->resData[3]=0x00;/* 0x00 ISO15031-6Format,0x01 ISO14229-1Format,0x02 J1939 Format */
	pMsgContext->resData[4]=(uint8)(counter>>8);
	pMsgContext->resData[5]=(uint8)(counter);
	pMsgContext->resDataLen=6;/* Always equals 6 */
	DsdInternal_ProcessingDone(pMsgContext);
}
/******************************************************************************
* Name         :App_ReportDTCByStatusMask
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Report DTC by status mask.
*19-02 讀取當前dtc，各狀態 by status mask
******************************************************************************/
FUNC(void,DCM_CODE) App_ReportDTCByStatusMask(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		uint8 i;
		uint16 counter=0;
		uint8  DtcStatus,tmp;

		DtcStatus=pMsgContext->reqData[2];

		for(i=0;i<NUM_OF_DTC;i++)
		{
			//if((DtcStatus&DTCStatus[i])!=0)
		
			tmp = _dem_get_state(i);

			if( (DtcStatus&tmp) != 0u)
			{

					pMsgContext->resData[3+counter*4]=(uint8)(SupportedDTC[i]>>16);
					pMsgContext->resData[4+counter*4]=(uint8)(SupportedDTC[i]>>8);
					pMsgContext->resData[5+counter*4]=(uint8)SupportedDTC[i];
					pMsgContext->resData[6+counter*4]=tmp;
		
					counter++;
			}
			else
			{
			}
		}
		pMsgContext->resData[1]=pMsgContext->reqData[1];
		pMsgContext->resData[2]=DTCStatusAvailabilityMask;
		pMsgContext->resDataLen=3+(counter*4);
		DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_ReportDTCSnapshortRecordByDTCNumber
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*  19-04
******************************************************************************/
 FUNC(void,DCM_CODE) App_ReportDTCSnapshotRecordByDTCNumber(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 error=0;
	uint32 Dtc;
	uint8 i,dtc_index=0xffu;
	uint8 DTCSnapshotRecordNumber;
	uint8 DTCSnapshotRecordLength = 0;/* according to Spec */
	DTCSnapshotRecordNumber = pMsgContext->reqData[5];
	Dtc=Make32Bit(pMsgContext->reqData[2],pMsgContext->reqData[3],pMsgContext->reqData[4]);
	/* Check	DTC  */
	for(i=0;i<NUM_OF_DTC;i++)
	{

		if(Dtc==SupportedDTC[i])
		{		
			pMsgContext->resData[5] =  _dem_get_state(i);  /*DTCStatus[i]; */
	
			dtc_index = i;//0x13;
			i=NUM_OF_DTC;  //相當於break跳了出來;
		}
		else
		{
			if(i==NUM_OF_DTC-1)
			{
				error=1;
				DsdInternal_SetNegResponse(pMsgContext,DCM_E_REQUESTOUTOFRANGE);
			}
			else
			{

			}
		}
	}
	if(error == 0)
	{
		switch(DTCSnapshotRecordNumber)
		{
			case 0xFF: /*return all DTCSnapshotRecordnumber*/
			case 0x01:
				pMsgContext->resData[6] = 0x01;/*DTCSnapshotRecordNumber #2*/
				pMsgContext->resData[7] = 0x03;/*DTCSnapshotRecordNumberOfIdentifiers #2*/

				//pdata = &pMsgContext->resData[8];
	
				if(demm_copy_snap_short_data_to_dcm_txbuff(dtc_index, &pMsgContext->resData[8]) != FALSE)
				{
					DTCSnapshotRecordLength = (8+ DTC_SNAPSHOT_RECORD_LENGTH) ;/* change according to App ,if the current DTCSnapshotRecordNumber is not available the length should 0*/
					//cpu_nop();
				}
				else
				{
					DsdInternal_SetNegResponse(pMsgContext,DCM_E_REQUESTOUTOFRANGE);
					error = 1;
				}
				/*the first Identifier 0x9abc  */
				//pMsgContext->resData[8] = 0x9a;/*Dataidentifier#1  byte#1(MSB)*/
				//pMsgContext->resData[9] = 0xbc;/*Dataidentifier#1  byte#1(LSB)*/
				//pMsgContext->resData[10] = 0x13;/*SnapshotData#1	byte#1*/
				//pMsgContext->resData[11] = 0x13;/*SnapshotData#1	byte#2*/
				//pMsgContext->resData[12] = 0x13;/*SnapshotData#1	byte#3*/

				//DTCSnapshotRecordLength = 7u;/* change according to App	,if the current DTCSnapshotRecordNumber is not available the length should 0*/

			break;

			default:
				DsdInternal_SetNegResponse(pMsgContext,DCM_E_REQUESTOUTOFRANGE);
				error = 1;
			break;
		}
	}
	else
	{

	}
	if(error==0)
	{
		pMsgContext->resDataLen=(DTCSnapshotRecordLength);  //8
		DsdInternal_ProcessingDone(pMsgContext);
	}
	else
	{
		DsdInternal_ProcessingDone(pMsgContext);
	}
}

/******************************************************************************
* Name         :App_ReportDTCExtendedDataRecordByDTCNumber
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
* 19-06
******************************************************************************/
FUNC(void,DCM_CODE) App_ReportDTCExtendedDataRecordByDTCNumber(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

		uint8 error=0;
		uint32 Dtc;
		uint8 i,dtc_index=0xffu;
		uint8 DTCExtendedDataRecordNumber = 0;
		uint8 DTCExtendedDataRecordLength = 0;/* according to Spec */

		if(( (pMsgContext->reqData[5]>=0x00) && (pMsgContext->reqData[5]<=0x8f) )||(pMsgContext->reqData[5]==0xff))
		{
			DTCExtendedDataRecordNumber= pMsgContext->reqData[5];
			Dtc=Make32Bit(pMsgContext->reqData[2],pMsgContext->reqData[3],pMsgContext->reqData[4]);
			for(i=0;i<NUM_OF_DTC;i++)
			{
				if(Dtc==SupportedDTC[i])

				{

					pMsgContext->resData[5] =  _dem_get_state(i);  /*DTCStatus[i]; */

					dtc_index = i;
					i=NUM_OF_DTC;

				}
				else
				{
						if(i==NUM_OF_DTC-1)
						{
								if(Dtc!=0xffffff)
								{
										error=1;
										DsdInternal_SetNegResponse(pMsgContext,DCM_E_REQUESTOUTOFRANGE);
								}
								else
								{
								}
						}
						else
						{
						}
				}
			}
		}
		else
		{
				error=1;
				DsdInternal_SetNegResponse(pMsgContext,DCM_E_REQUESTOUTOFRANGE);
		}

		if(error==0)
		{

		switch(DTCExtendedDataRecordNumber)
		{
			case 0xFF: /*return all DTCSnapshotRecordnumber*/
			case 0x01:
		
				pMsgContext->resData[2]=(uint8)(SupportedDTC[dtc_index]>>16);
				pMsgContext->resData[3]=(uint8)(SupportedDTC[dtc_index]>>8);
				pMsgContext->resData[4]=(uint8)SupportedDTC[dtc_index];
	
				///pMsgContext->resData[5]=tmp;
				pMsgContext->resData[6] = 0x01;/*DTCSnapshotRecordNumber #2*/
				//pMsgContext->resData[7] = 0x01;/*DTCSnapshotRecordNumberOfIdentifiers #2*/

				if(demm_copy_extdata_to_dcm_txbuff(dtc_index, &pMsgContext->resData[7]) != FALSE)
				{
					DTCExtendedDataRecordLength = (6+ DTC_EXTDATA_RECORD_LENGTH) ;/* change according to App ,if the current DTCSnapshotRecordNumber is not available the length should 0*/
					//cpu_nop();
				}
				else
				{
					DsdInternal_SetNegResponse(pMsgContext,DCM_E_REQUESTOUTOFRANGE);
					error = 1;
				}
			break;
			default:
				DsdInternal_SetNegResponse(pMsgContext,DCM_E_REQUESTOUTOFRANGE);
				error = 1;
				break;
		}
		}
		else
		{
		}
	if(error==0)
	{
		pMsgContext->resDataLen = DTCExtendedDataRecordLength;  //8
		DsdInternal_ProcessingDone(pMsgContext);
	}
	else
	{
		DsdInternal_ProcessingDone(pMsgContext);
	}
}

/******************************************************************************
* Name         :App_ReportSupportedDTC
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
* 19-0a
******************************************************************************/
FUNC(void,DCM_CODE) App_ReportSupportedDTC(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
		//uint8 result=0;
		uint32 i;
		pMsgContext->resData[2]=DTCStatusAvailabilityMask;
		for(i=0;i<NUM_OF_DTC;i++)
		{
			 pMsgContext->resData[3+i*4]=(uint8)(SupportedDTC[i]>>16);
			 pMsgContext->resData[4+i*4]=(uint8)(SupportedDTC[i]>>8);
			 pMsgContext->resData[5+i*4]=(uint8)(SupportedDTC[i]);
			 //pMsgContext->resData[6+i*4]=DTCStatus[i];		//為什麼這個變量沒有用到； _dem_get_state(i)
			 pMsgContext->resData[6+i*4]=_dem_get_state(i);		//應該是這狀態

		}
		pMsgContext->resDataLen=3+NUM_OF_DTC*4;
		DsdInternal_ProcessingDone(pMsgContext);
}
/* 23 */
/******************************************************************************
* Name         :App_ReadAddress
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
#if(DCM_SERVICE_23_ENABLED==STD_ON)
void App_ReadAddress(Dcm_MsgContextType* pMsgContext)
{
		/* if too many datas to be readed ,and it is impossible read all data one time,
		App should remember the address and conter of data for the next Call .*/
		uint32 startAddress;
	uint32 memorySize;
	uint32 i;
	startAddress=0;
	memorySize=0;
	/* Calculate start address */
	for(i=0;i<gMemoryAddressFormat;i++)
	{
			startAddress|=(uint32)(pMsgContext->reqData[2u+i])<<(uint8)(8u*(gMemoryAddressFormat-1u-i));
	}
	/* Calculate size  */
	for(i=0;i<gMemorySizeFormat;i++)
	{
			memorySize|=(uint32)(pMsgContext->reqData[2u+gMemoryAddressFormat+i])<<(uint8)(8u*(gMemorySizeFormat-1u-i));
	}

	for(i=0;i<memorySize;i++)
	{
			pMsgContext->resData[1u+i]=R8(startAddress+i);
	}

	pMsgContext->resDataLen=(1u+memorySize);
	DsdInternal_ProcessingDone(pMsgContext);
}
#endif
/* 27 */
#if(DCM_SERVICE_27_ENABLED==STD_ON)

/******************************************************************************
* Name         :App_Request_Seed_Lv1
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
* 27 01
******************************************************************************/
FUNC(void,DCM_CODE) App_Request_Seed_L1(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	if((bUpdateSeed & 0x1U) != 0)
	{
		service_27_generate_seed();
		bUpdateSeed &= (u8)(~0x01);
	}
	pMsgContext->resData[1]=pMsgContext->reqData[1];
	for(i=0;i<gDcmDspSecurityRow[0].DcmDspSecuritySeedSize;i++)
	{
			/* add user code here ,generate App Seed */
			gMsgContextType.resData[2+i]=service_27_get_seed_element(i);
	}
	pMsgContext->resDataLen=gDcmDspSecurityRow[0].DcmDspSecuritySeedSize+2;
	DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_Send_Key_Lv2
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
* 27 02
******************************************************************************/


FUNC(void,DCM_CODE) App_Send_Key_L1(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	app_dcm_operate_service_27(1,pMsgContext);
}



/******************************************************************************
* Name         :App_Request_Seed_Lv3
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
* 27 03
******************************************************************************/
FUNC(void,DCM_CODE) App_Request_Seed_L2(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	if((bUpdateSeed & 0x2U) != 0)
	{
		service_27_generate_seed();
		bUpdateSeed &= (u8)(~0x02);
	}
	pMsgContext->resData[1]=pMsgContext->reqData[1];
	for(i=0;i<gDcmDspSecurityRow[1].DcmDspSecuritySeedSize;i++)
	{
			/* add user code here ,generate App Seed */
			gMsgContextType.resData[2+i]=service_27_get_seed_element(i);
	}
	pMsgContext->resDataLen=gDcmDspSecurityRow[1].DcmDspSecuritySeedSize+2;
	DsdInternal_ProcessingDone(pMsgContext);
}
/******************************************************************************
* Name         :App_Send_Key_Lv4
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
* 27 04
******************************************************************************/
FUNC(void,DCM_CODE) App_Send_Key_L2(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	app_dcm_operate_service_27(2,pMsgContext);
}

/******************************************************************************
* Name         :App_Request_Seed_Lv5
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
* 27 05
******************************************************************************/
FUNC(void,DCM_CODE) App_Request_Seed_L3(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	if((bUpdateSeed & 0x04U) != 0)
	{
		service_27_generate_seed();
		bUpdateSeed &= (u8)(~0x04);
	}
	pMsgContext->resData[1]=pMsgContext->reqData[1];
	for(i=0;i<gDcmDspSecurityRow[0].DcmDspSecuritySeedSize;i++)
	{
			/* add user code here ,generate App Seed */
			gMsgContextType.resData[2+i]=service_27_get_seed_element(i);
	}
	pMsgContext->resDataLen=gDcmDspSecurityRow[0].DcmDspSecuritySeedSize+2;
	DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_Send_Key_Lv6
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
* 27 06
******************************************************************************/
FUNC(void,DCM_CODE) App_Send_Key_L3(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	app_dcm_operate_service_27(3,pMsgContext);
}

/******************************************************************************
* Name         :App_Request_Seed_Lv7
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
* 27 07
******************************************************************************/
FUNC(void,DCM_CODE) App_Request_Seed_L4(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	if((bUpdateSeed & 0x08U) != 0)
	{
		service_27_generate_seed();
		bUpdateSeed &= (u8)(~0x08);
	}
	pMsgContext->resData[1]=pMsgContext->reqData[1];
	for(i=0;i<gDcmDspSecurityRow[0].DcmDspSecuritySeedSize;i++)
	{
			/* add user code here ,generate App Seed */
			gMsgContextType.resData[2+i]=service_27_get_seed_element(i);
	}
	pMsgContext->resDataLen=gDcmDspSecurityRow[0].DcmDspSecuritySeedSize+2;
	DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_Send_Key_Lv8
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
* 27 08
******************************************************************************/
FUNC(void,DCM_CODE) App_Send_Key_L4(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	app_dcm_operate_service_27(4,pMsgContext);
}

/******************************************************************************
* Name         :App_Request_Seed_Lv9
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
* 27 09
******************************************************************************/
FUNC(void,DCM_CODE) App_Request_Seed_L5(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	if((bUpdateSeed & 0x10U) != 0)
	{
		service_27_generate_seed();
		bUpdateSeed &= (u8)(~0x10);
	}
	pMsgContext->resData[1]=pMsgContext->reqData[1];
	for(i=0;i<gDcmDspSecurityRow[0].DcmDspSecuritySeedSize;i++)
	{
			/* add user code here ,generate App Seed */
			gMsgContextType.resData[2+i]=service_27_get_seed_element(i);
	}
	pMsgContext->resDataLen=gDcmDspSecurityRow[0].DcmDspSecuritySeedSize+2;
	DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_Send_Key_LvA
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
* 27 0A
******************************************************************************/
FUNC(void,DCM_CODE) App_Send_Key_L5(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	app_dcm_operate_service_27(5,pMsgContext);
}

/******************************************************************************
* Name         :App_Request_Seed_LvB
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
* 27 0B
******************************************************************************/
FUNC(void,DCM_CODE) App_Request_Seed_L6(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	uint8 i;
	if((bUpdateSeed & 0x20U) != 0)
	{
		service_27_generate_seed();
		bUpdateSeed &= (u8)(~(u8)0x20);
	}
	pMsgContext->resData[1]=pMsgContext->reqData[1];
	for(i=0;i<gDcmDspSecurityRow[0].DcmDspSecuritySeedSize;i++)
	{
			/* add user code here ,generate App Seed */
			gMsgContextType.resData[2+i]=service_27_get_seed_element(i);
	}
	pMsgContext->resDataLen=gDcmDspSecurityRow[0].DcmDspSecuritySeedSize+2;
	DsdInternal_ProcessingDone(pMsgContext);
}

/******************************************************************************
* Name         :App_Send_Key_LvC
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
* 27 0C
******************************************************************************/
FUNC(void,DCM_CODE) App_Send_Key_L6(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0  //验证了，先回忙，是可以的。还会再进来，
	static u8 ls_flag =0;
	if(ls_flag==0)
	{
		DsdInternal_SetNegResponse(pMsgContext,DCM_E_REQUESTCORRECTLYRECEIVED_RESPONSEPENDING);  // DCM_E_CONDITIONSNOTCORRECT  // DCM_E_INVALIDKEY
		//DsdInternal_SetNegResponse(pMsgContext,DCM_E_INVALIDKEY);  // DCM_E_CONDITIONSNOTCORRECT  // DCM_E_INVALIDKEY
		ls_flag=1;
	}
	else
	{
		ls_flag=0;
		DsdInternal_SecurityAccessKeyCompared(6,KEY_IS_VALID);
		pMsgContext->resDataLen=2;
		DsdInternal_ProcessingDone(pMsgContext);
	}
	#else
	app_dcm_operate_service_27(6,pMsgContext);
	#endif
}


//因为处理AES 比较费时间，所以放在外面主循环处理
void app_dcm_operate_service_27(u8 level,P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	u8 i;
	u8 l_input[DCM_KEY_LEN];
	u8 l_seed[SERVICE_SEED_LEN_MAX];
	u8 l_compare=0;
	u8 l_buf_level_for_key[8]={0xff,1,3,5,7,9,11,13};
	u8 l_buf_level[8] = {DCM_SEC_LEV_LOCK,DCM_SEC_LEV_L1,DCM_SEC_LEV_L2,DCM_SEC_LEV_L3,DCM_SEC_LEV_L4,DCM_SEC_LEV_L5,DCM_SEC_LEV_L6,DCM_SEC_LEV_L7};

	if( (level!=0)  && (level<8) )
	{
		bUpdateSeed |= (u8)0x01 << (level-1);
		for(i=0;i<DCM_KEY_LEN;i++)
		{
			l_input[i] = pMsgContext->reqData[2+i];
		}
		//計算出來的key 放在 l_seed
		service_27_get_key(l_buf_level_for_key[level],l_seed);
		//開始比較
		for(i=0;i<SERVICE_SEED_LEN_VALID;i++)
		{
			/* add user code here ,check key according App Seed */
			if(l_seed[i]!=l_input[i])
			{
				l_compare++;
					//i= gDcmDspSecurityRow[0].DcmDspSecurityKeySize;
			}
			else
			{

			}
		}
		if(l_compare==0)
		{
			DsdInternal_SecurityAccessKeyCompared(l_buf_level[level],KEY_IS_VALID);
			pMsgContext->resDataLen=2;
			DsdInternal_ProcessingDone(pMsgContext);
		}
		else
		{
			DsdInternal_SecurityAccessKeyCompared(l_buf_level[level],KEY_IS_NOT_VALID);
			#if 1
			DsdInternal_SetNegResponse(pMsgContext,DCM_E_INVALIDKEY);  // DCM_E_CONDITIONSNOTCORRECT  // DCM_E_INVALIDKEY
			#else
			pMsgContext->resDataLen=3;
			pMsgContext->resData[0] =0x7f;
			pMsgContext->resData[1] =0x27;
			pMsgContext->resData[2] =DCM_E_INVALIDKEY;
			DsdInternal_ProcessingDone(pMsgContext);
			#endif
		}
	}
	else
	{
		DsdInternal_SecurityAccessKeyCompared(l_buf_level[level],KEY_IS_NOT_VALID);
		#if 1
		DsdInternal_SetNegResponse(pMsgContext,DCM_E_INVALIDKEY);  // DCM_E_CONDITIONSNOTCORRECT  // DCM_E_INVALIDKEY
		#else
		pMsgContext->resDataLen=3;
		pMsgContext->resData[0] =0x7f;
		pMsgContext->resData[1] =0x27;
		pMsgContext->resData[2] =DCM_E_INVALIDKEY;
		DsdInternal_ProcessingDone(pMsgContext);
		#endif
	}
}
#endif

/* 28 */
/******************************************************************************
* Name         :EnableRxAndTx
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_EnableRxAndTx(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	//DsdInternal_SetNegResponse(pMsgContext,DCM_E_CONDITIONSNOTCORRECT);
	(void)CAN_SetControlBy(CAN_CONTROL_BY_28_SERVICE);
	if (gMsgContextType.reqData[2]==NORMAL_MSG)
	{
		(void)Com_TxStart();
		(void)Com_RxStart();
	}
	else if (gMsgContextType.reqData[2]==NM_MSG)
	{
		(void)CanNm_EnableCommunication(0);
	}
	else if (gMsgContextType.reqData[2]==BOTH_NORMAL_AND_NM_MSG)
	{
		(void)CanNm_EnableCommunication(0);
		(void)Com_TxStart();
		(void)Com_RxStart();
	}
	pMsgContext->resDataLen = 2;
	DsdInternal_ProcessingDone(pMsgContext);
}
/******************************************************************************
* Name         :EnableRxAndDisableTx
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_EnableRxAndDisableTx(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	(void)CAN_SetControlBy(CAN_CONTROL_BY_28_SERVICE);
	if (gMsgContextType.reqData[2]==NORMAL_MSG)
	{
		(void)Com_TxStop();
		(void)Com_RxStart();
	}
	else if (gMsgContextType.reqData[2]==NM_MSG)
	{
		(void)CanNm_DisableCommunication(0);
	}
	else if (gMsgContextType.reqData[2]==BOTH_NORMAL_AND_NM_MSG)
	{
		(void)CanNm_DisableCommunication(0);
		(void)Com_TxStop();
		(void)Com_RxStart();
	}
	pMsgContext->resDataLen = 2;
	DsdInternal_ProcessingDone(pMsgContext);
}
/******************************************************************************
* Name         :DisableRxAndTx
* Called by    :Dcm
* Preconditions:Dcm_MsgContextType* pMsgContext
* Parameters   :N/A
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_DisableRxAndTx(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	(void)CAN_SetControlBy(CAN_CONTROL_BY_28_SERVICE);
	if (gMsgContextType.reqData[2]==NORMAL_MSG)
	{
		(void)Com_TxStop();
		(void)Com_RxStop();
	}
	else if (gMsgContextType.reqData[2]==NM_MSG)
	{
		(void)CanNm_DisableCommunication(0);

	}
	else if (gMsgContextType.reqData[2]==BOTH_NORMAL_AND_NM_MSG)
	{
		(void)CanNm_DisableCommunication(0);
		(void)Com_TxStop();
		(void)Com_RxStop();
	}
	pMsgContext->resDataLen = 2;
	DsdInternal_ProcessingDone(pMsgContext);
}

/* 31 */
#if(DCM_SERVICE_31_ENABLED==STD_ON)
#define DCM_NO_USE_NES_RESPONSE_FOR_31  DCM_E_REQUESTOUTOFRANGE
 /******************************************************************************
* Name         :AppStartRoutine0x0206
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0x0206(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	pMsgContext->resData[4]=0x00;
	//set_fast_sleep_status();
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x0206].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0x0207
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0x01b0(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	u8 l_cmd;
	u8 l_level;
	u8 l_buf[SYSDID_SECURITY_KEY_CK_LEN];
	u8 j;
	#ifdef APP_DCM_DEBUG_EN
	u8 i;
	g_app_decm_debug.len = pMsgContext->reqDataLen;
	for(i=0;i<10;i++)
	{
		g_app_decm_debug.buf[i]=pMsgContext->reqData[i];
	}
	#endif
	for(j=0;j<SYSDID_SECURITY_KEY_LEN;j++)
	{
		l_buf[j] = pMsgContext->reqData[4+j];
	}
	cal_write_did(0x01A0u,(u8*)&l_buf[0],SYSDID_SECURITY_KEY_CK_LEN);
	//(void)nvm_write_bytes(NVM_TYPE_EEPROM,SYSDID_SECURITY_KEY_ADDR,l_buf,SYSDID_SECURITY_KEY_LEN);
	pMsgContext->resData[4]=0x00;
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	app_dcm_io_ctrl_led_set_state(APP_DCM_IO_CTRL_STATE_RUN_LED);
	if(pMsgContext->reqData[4]==1)
	{
		l_cmd = LED_DRIVER_CMD_ON;
	}
	else
	{
		l_cmd = LED_DRIVER_CMD_OFF;
	}
	l_level =pMsgContext->reqData[5] ;
	output_app_ctrl(OUTPUT_TYPE_LED,LED_ID_ILL,l_level,l_cmd);
	pMsgContext->resData[4]=0x00;
	//escl_drive_cmd_req(ESCL_CMD_READ_STATUS);
	#endif
	//储存key
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x0207].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStopRoutine0x0207
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StopRoutine0x0207(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStopped();
	//add you code here
	pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x0207].DcmDspRoutineInfoRef.DcmDspRoutineStopOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0x0207
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0x01b0(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
//	DsdInternal_RequestRoutineResults();
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resData[4] = led_driver_get_cmd(LED_ID_ILL);  //unsigned
	pMsgContext->resData[5] = led_driver_get_level(LED_ID_ILL);  //unsigned
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x0207].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0x0208
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0x04FE(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	app_dcm_io_ctrl_motor_set_state(APP_DCM_IO_CTRL_STATE_RUN_MOTOR);
	motor_driver_reactive(MOTOR_DRIVER_CHANNEL_ID_M);
	output_app_ctrl(OUTPUT_TYPE_MOTOR,MOTOR_DRIVER_CHANNEL_ID_M,MOTOR_DRIVER_LEVEL_DEFAULT,pMsgContext->reqData[4]);
	pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x0208].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0x0208
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0x04FE(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
//	DsdInternal_RequestRoutineResults();

	//add you code here
	pMsgContext->resData[4]=0x00;
	pMsgContext->resData[4] = motor_driver_get_state(MOTOR_DRIVER_CHANNEL_ID_M);  //unsigned
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x0208].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}


 /******************************************************************************
* Name         :AppStartRoutine0x5901
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0x0203(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 1
	DsdInternal_RoutineStarted();
	//add you code here
	pMsgContext->resData[4]=0x00;
	//SetEvent(EOL_APP_TASK_ID, EVENT_EOL_APP_LEARN_PKE_START);
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x0206].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_E_SERVICENOTSUPPORTEDINACTIVESESSION);
	#endif
}

 /******************************************************************************
* Name         :AppStopRoutine0x5901
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StopRoutine0x0203(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 1
	DsdInternal_RoutineStopped();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	//SetEvent(EOL_APP_TASK_ID, EVENT_EOL_APP_LEARN_PKE_STOP);
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x0206].DcmDspRoutineInfoRef.DcmDspRoutineStopOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_E_SERVICENOTSUPPORTEDINACTIVESESSION);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0x5901
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0x0203(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 1
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resData[4] =  0x00;//get_pke_register_status();
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x0206].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0x5902
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0x5902(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	//SetEvent(EOL_TASK, EVENT_EOL_APP_ESCL_LEARN_START);
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x5902].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
}

 /******************************************************************************
* Name         :AppStopRoutine0x5902
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StopRoutine0x5902(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStopped();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x5902].DcmDspRoutineInfoRef.DcmDspRoutineStopOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0x5902
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0x5902(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resData[4] = 0x15;//get_escl_drive_learning_result();
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x5902].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0x5903
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0x5903(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x5903].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStopRoutine0x5903
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StopRoutine0x5903(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStopped();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x5903].DcmDspRoutineInfoRef.DcmDspRoutineStopOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0x5903
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0x5903(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x5903].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0x5904
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0x5904(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x5904].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStopRoutine0x5904
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StopRoutine0x5904(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStopped();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x5904].DcmDspRoutineInfoRef.DcmDspRoutineStopOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0x5904
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0x5904(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0x5904].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}
#if  0
 u8 ant_id_test = 0;
u8 get_ant_dcm_to_peps(u8 ant_id)
{
	u8 ret_ant_id=0u;
	//ant_id = ant_id >> 5;
	ant_id_test = ant_id;

	#ifdef LF_APP_CFG_EN

	#else

	switch(ant_id_test)
	{
		case 6:
			ret_ant_id = 0x01;
		break;
		case 1:
			ret_ant_id = 0x02;
		break;
		case 3:
			ret_ant_id = 0x03;
		break;
		case 4:
			ret_ant_id = 0x04;
		break;
		case 2:
			ret_ant_id = 0x5;
		break;
		default :
			/*code*/
		break;

	}
	ant_id =(((u8)0x01<<5) |1);
	#endif
	return ret_ant_id;
}
#endif
/******************************************************************************
* Name         :AppStartRoutine0xDF30
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0xDF30(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->reqData[4] = get_ant_dcm_to_peps(pMsgContext->reqData[4]);
		if(1)//(rf_dcm_app_routine_start(RF_CMD_ANT_CAL, &pMsgContext->reqData[4],  pMsgContext->reqDataLen - 4) == TRUE)
	{
			pMsgContext->resData[4]=0x00;
	}
	else
	{
			pMsgContext->resData[4]=0x01;
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF30].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStopRoutine0xDF30
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StopRoutine0xDF30(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStopped();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF30].DcmDspRoutineInfoRef.DcmDspRoutineStopOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0xDF30
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0xDF30(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
		//LfReadAntCalType l_data;
	uint8_t l_lenght;
		u8 l_data;

	if(0)//(sizeof(l_data) >= DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF30].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength)
	{
		l_lenght = DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF30].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	}
	else
	{
		l_lenght = sizeof(l_data);
	}

	if(1)//(TRUE == rf_dcm_app_read_routine_data(RF_CMD_ANT_CAL, (uint8_t *)&l_data, sizeof(l_data)))
	{
		/*succussed */
		pMsgContext->resData[4]=0x02;
		//memory_copys(&(pMsgContext->resData[5]), (uint8_t *)&l_data,  l_lenght);
	}
	else
	{
		/*ÕýÔÚ´¦Àí*/
		pMsgContext->resData[4]=0x01;
		//memory_clear(&pMsgContext->resData[5],  l_lenght);
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF30].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0xDF31
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0xDF31(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->reqData[4] = get_ant_dcm_to_peps(pMsgContext->reqData[4]);
		if(0)//(rf_dcm_app_routine_start(RF_CMD_RSSI, &pMsgContext->reqData[4],  pMsgContext->reqDataLen - 4) == TRUE)
	{
		pMsgContext->resData[4]=0x00;
	}
	else
	{
		pMsgContext->resData[4]=0x01;
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF31].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStopRoutine0xDF31
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StopRoutine0xDF31(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStopped();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF31].DcmDspRoutineInfoRef.DcmDspRoutineStopOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0xDF31
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0xDF31(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
		//LfReadRssiType l_data;
	uint8_t l_lenght;
		u8 l_data;
	if(0)//(sizeof(l_data) >= DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF31].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength)
	{
		l_lenght = DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF31].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	}
	else
	{
		l_lenght = sizeof(l_data);
	}

	if(0)//(TRUE == rf_dcm_app_read_routine_data(RF_CMD_RSSI, (uint8_t *)&l_data, sizeof(l_data)))
	{
		/*succussed */
		pMsgContext->resData[4]=0x02;
		//memory_copys(&(pMsgContext->resData[5]), (uint8_t *)&l_data,  l_lenght);
	}
	else
	{
		/*ÕýÔÚ´¦Àí*/
		pMsgContext->resData[4]=0x01;
		//memory_clear(&pMsgContext->resData[5],  l_lenght);
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF31].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0xDF32
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0xDF32(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->reqData[4] = get_ant_dcm_to_peps(pMsgContext->reqData[4]);
		if(0)//(rf_dcm_app_routine_start(RF_CMD_RSSI_SINGLE, &pMsgContext->reqData[4],  pMsgContext->reqDataLen - 4) == TRUE)
	{
		pMsgContext->resData[4]=0x00;
	}
	else
	{
		pMsgContext->resData[4]=0x01;
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF32].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStopRoutine0xDF32
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StopRoutine0xDF32(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStopped();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF32].DcmDspRoutineInfoRef.DcmDspRoutineStopOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0xDF32
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0xDF32(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
		//LfReadRssiSingleType l_data;
	uint8_t l_lenght;
		u8 l_data;
	if(sizeof(l_data) >= DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF32].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength)
	{
		l_lenght = DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF32].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	}
	else
	{
		l_lenght = sizeof(l_data);
	}

	if(0)//(TRUE == rf_dcm_app_read_routine_data(RF_CMD_RSSI_SINGLE, (uint8_t *)&l_data, sizeof(l_data)))
	{
		/*succussed */
		pMsgContext->resData[4]=0x02;
		//memory_copys(&(pMsgContext->resData[5]), (uint8_t *)&l_data,  l_lenght);
	}
	else
	{
		/*ÕýÔÚ´¦Àí*/
		pMsgContext->resData[4]=0x01;
		//memory_clear(&pMsgContext->resData[5],  l_lenght);
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF32].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0xDF33
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0xDF33(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
		//rf_dcm_app_clr_sn_read_result();

	if(0)//(lf_tin_app_cmd(LF_TIN_TYPE_TIN,TIN_APP_CMD_READ_SN,(void*)0,0) == TRUE)
	{
		pMsgContext->resData[4]=0x00;
	}
	else
	{
		pMsgContext->resData[4]=0x01;
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF33].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0xDF33
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0xDF33(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
		//eol_fob_sn_t l_eol_fob_sn;
	uint16_t l_lenght;
		u8 l_eol_fob_sn;
	u8 l_sn_read_result;

	//ReceiveMessage(MSG_FOB_SN, l_eol_fob_sn);

	if(0)//(sizeof(l_eol_fob_sn) >= DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF30].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength)
	{
		l_lenght = DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF30].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	}
	else
	{
		l_lenght = sizeof(l_eol_fob_sn);
	}

	l_sn_read_result = 0x03;//rf_dcm_app_get_sn_read_result();

	if(0)//(l_sn_read_result == SN_READ_RESULT_FAILED)
	{
		pMsgContext->resData[4] = 0x03;

	}
		/*
	else if(l_sn_read_result == SN_READ_RESULT_SUCCESSED)
	{
		pMsgContext->resData[4] = 0x02;

		memory_copys((uint8_t *)&(pMsgContext->resData[5]), l_eol_fob_sn, l_lenght);
	}
		*/
	else
	{
		pMsgContext->resData[4] = 0x01;
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF33].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0xDF34
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0xDF34(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->reqData[4] = get_ant_dcm_to_peps(pMsgContext->reqData[4]);
		if(0)//(rf_dcm_app_routine_start(RF_CMD_READ_VBAT, &pMsgContext->reqData[4],  pMsgContext->reqDataLen - 4) == TRUE)
	{
		pMsgContext->resData[4]=0x00;
	}
	else
	{
		pMsgContext->resData[4]=0x01;
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF34].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStopRoutine0xDF34
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StopRoutine0xDF34(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStopped();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF34].DcmDspRoutineInfoRef.DcmDspRoutineStopOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0xDF34
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0xDF34(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
		//LfReadVbatType l_data;
	uint8_t l_lenght;
		u8 l_data;
	if(sizeof(l_data) >= DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF34].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength)
	{
		l_lenght = DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF34].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	}
	else
	{
		l_lenght = sizeof(l_data);
	}

	if(0)//(TRUE == rf_dcm_app_read_routine_data(RF_CMD_READ_VBAT, (uint8_t *)&l_data, sizeof(l_data)))
	{
		/*succussed */
		pMsgContext->resData[4]=0x02;
		//memory_copys(&(pMsgContext->resData[5]), (uint8_t *)&l_data,  l_lenght);
	}
	else
	{
		/*ÕýÔÚ´¦Àí*/
		pMsgContext->resData[4]=0x01;
		//memory_clear(&pMsgContext->resData[5],  l_lenght);
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF34].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0xDF35
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0xDF35(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->reqData[4] = get_ant_dcm_to_peps(pMsgContext->reqData[4]);
		if(0)//(rf_dcm_app_routine_start(RF_CMD_UHF_POW, &pMsgContext->reqData[4],  pMsgContext->reqDataLen - 4) == TRUE)
	{
		pMsgContext->resData[4]=0x00;
	}
	else
	{
		pMsgContext->resData[4]=0x01;
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF35].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0xDF35
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0xDF35(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
		//LfReadUhfPowType l_data;
	uint8_t l_lenght;
		u8 l_data;
	if(sizeof(l_data) >= DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF35].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength)
	{
		l_lenght = DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF35].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	}
	else
	{
		l_lenght = sizeof(l_data);
	}

	if(0)//(TRUE == rf_dcm_app_read_routine_data(RF_CMD_UHF_POW, (uint8_t *)&l_data, sizeof(l_data)))
	{
		/*succussed */
		pMsgContext->resData[4]=0x02;
		//memory_copys(&(pMsgContext->resData[5]), (uint8_t *)&l_data,  l_lenght);
	}
	else
	{
		/*ÕýÔÚ´¦Àí*/
		pMsgContext->resData[4]=0x01;
		//memory_clear(&pMsgContext->resData[5],  l_lenght);
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF35].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0xDF36
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0xDF36(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->reqData[4] = get_ant_dcm_to_peps(pMsgContext->reqData[4]);
		if(0)//(rf_dcm_app_routine_start(RF_CMD_EE_READ, &pMsgContext->reqData[4],  pMsgContext->reqDataLen - 4) == TRUE)
	{
		pMsgContext->resData[4]=0x00;
	}
	else
	{
		pMsgContext->resData[4]=0x01;
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF36].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0xDF36
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0xDF36(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
		//LfReadEeReadType l_data;
	uint8_t l_lenght;
		u8 l_data;
	if(sizeof(l_data) >= DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF36].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength)
	{
		l_lenght = DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF36].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	}
	else
	{
		l_lenght = sizeof(l_data);
	}

	if(0)//(TRUE == rf_dcm_app_read_routine_data(RF_CMD_EE_READ, (uint8_t *)&l_data, sizeof(l_data)))
	{
		/*succussed */
		pMsgContext->resData[4]=0x02;
		//memory_copys(&(pMsgContext->resData[5]), (uint8_t *)&l_data,  l_lenght);
	}
	else
	{
		/*ÕýÔÚ´¦Àí*/
		pMsgContext->resData[4]=0x01;
		//memory_clear(&pMsgContext->resData[5],  l_lenght);
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF36].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0xDF37
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0xDF37(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->reqData[4] = get_ant_dcm_to_peps(pMsgContext->reqData[4]);
		if(0)//(rf_dcm_app_routine_start(RF_CMD_EE_WRITE, &pMsgContext->reqData[4],  pMsgContext->reqDataLen - 4) == TRUE)
	{
		pMsgContext->resData[4]=0x00;
	}
	else
	{
		pMsgContext->resData[4]=0x01;
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF37].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0xDF37
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0xDF37(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
		//LfReadEeWriteType l_data;
	uint8_t l_lenght;
		u8 l_data;
	//add you code here
	//pMsgContext->resData[4]=0x00;
	if(0)//(TRUE == rf_dcm_app_read_routine_data(RF_CMD_EE_WRITE, (uint8_t *)&l_data, sizeof(l_data)))
	{
		/*succussed */
		pMsgContext->resData[4]=0x02;
		//memory_copys(&(pMsgContext->resData[5]), (uint8_t *)&l_data,  l_lenght);
	}
	else
	{
		/*ÕýÔÚ´¦Àí*/
		pMsgContext->resData[4]=0x01;
		//memory_clear(&pMsgContext->resData[5],  l_lenght);
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF37].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0xDF38
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0xDF38(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF38].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0xDF38
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0xDF38(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF38].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0xDF39
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0xDF39(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->reqData[4] = get_ant_dcm_to_peps(pMsgContext->reqData[4]);
		if(0)//(rf_dcm_app_routine_start(RF_CMD_DURABILITY_TEST, &pMsgContext->reqData[4],  pMsgContext->reqDataLen - 4) == TRUE)
	{
		pMsgContext->resData[4]=0x00;
	}
	else
	{
		pMsgContext->resData[4]=0x01;
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF39].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStopRoutine0xDF39
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StopRoutine0xDF39(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStopped();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF39].DcmDspRoutineInfoRef.DcmDspRoutineStopOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0xDF39
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0xDF39(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
		//LfReadDurabilityType l_data;
	uint8_t l_lenght;
		u8 l_data;
	if(sizeof(l_data) >= DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF39].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength)
	{
		l_lenght = DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF39].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	}
	else
	{
		l_lenght = sizeof(l_data);
	}

	if(0)//(TRUE == rf_dcm_app_read_routine_data(RF_CMD_DURABILITY_TEST, (uint8_t *)&l_data, sizeof(l_data)))
	{
		/*succussed */
		pMsgContext->resData[4]=0x02;
		//memory_copys(&(pMsgContext->resData[5]), (uint8_t *)&l_data,  l_lenght);
	}
	else
	{
		/*ÕýÔÚ´¦Àí*/
		pMsgContext->resData[4]=0x01;
		//memory_clear(&pMsgContext->resData[5],  l_lenght);
	}
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF39].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}
 /******************************************************************************
* Name         :AppStartRoutine0xDF3A
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0xDF3A(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF3A].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppStopRoutine0xDF3A
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StopRoutine0xDF3A(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStopped();
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF3A].DcmDspRoutineInfoRef.DcmDspRoutineStopOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}

 /******************************************************************************
* Name         :AppRequestRoutineResults0xDF3A
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_RequestRoutineResults0xDF3A(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	//add you code here
	//pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xDF3A].DcmDspRoutineInfoRef.DcmDspRoutineRequestResOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_E_SERVICENOTSUPPORTEDINACTIVESESSION);
	#endif
}

 /******************************************************************************
* Name         :AppStartRoutine0xFF02
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :Start RKE Learning
*
******************************************************************************/
FUNC(void,DCM_CODE) App_StartRoutine0xFF02(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{
	#if 0
	DsdInternal_RoutineStarted();
	//add you code here
	pMsgContext->resData[4]=0x00;
	pMsgContext->resDataLen=4+DcmDspRoutineIdentifierTable_31[RoutineHandle_0xFF02].DcmDspRoutineInfoRef.DcmDspStartRoutineOut.DcmDspRoutineSignalLength;
	DsdInternal_ProcessingDone(pMsgContext);
	#else
	DsdInternal_SetNegResponse(pMsgContext,DCM_NO_USE_NES_RESPONSE_FOR_31);
	#endif
}
#endif
/* 3D */
/*******************************************************************************
* Name         :App_WriteAddress
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
#if(DCM_SERVICE_3D_ENABLED==STD_ON)
uint8  App_WriteAddressCounter=0;
uint32 startAddress=0;
uint16 memorySize=0;

void App_WriteAddress(Dcm_MsgContextType* pMsgContext)
{
		uint32 i;

		(void)pMsgContext;

		if(App_WriteAddressCounter==0)
		{
				/* Calculate start address */
				for(i=0;i<gMemoryAddressFormat;i++)
				{
						startAddress|=(uint32)(pMsgContext->reqData[2+i])<<(uint8)(8*(gMemoryAddressFormat-1-i));
				}
				/* Calculate size */
				for(i=0;i<gMemorySizeFormat;i++)
				{
						memorySize|=(uint32)(pMsgContext->reqData[2+gMemoryAddressFormat+i])<<(uint8)(8*(gMemorySizeFormat-1-i));
				}
		}
		else
		{
		}
		if(App_WriteAddressCounter<memorySize)
		{
				/* the follow function is used to write data to the certain address */
				#if 0
				W8(startAddress+App_WriteAddressCounter, pMsgContext->resData[2+gMemoryAddressFormat+gMemorySizeFormat+App_WriteAddressCounter]);
				#endif
				/* If the address to be written is in Flash or EEPROM, call related Driver */
				App_WriteAddressCounter++;
		}
		else
		{
				App_WriteAddressCounter=0;
				startAddress=0;
				memorySize=0;
				pMsgContext->resDataLen=2+gMemoryAddressFormat+gMemorySizeFormat;
				DsdInternal_ProcessingDone(pMsgContext);
		}
}
#endif
/* 85 */
/******************************************************************************
* Name         :App_DTCRecordOn
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_DTCRecordOn(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

	//(void)pMsgContext;
	g_dtc_timecount=0u;
	gDTCSwitch=1;
	dem_enable_dtc_setting();
	pMsgContext->resDataLen=2;
	DsdInternal_ProcessingDone(pMsgContext);

}
/******************************************************************************
* Name         :App_DTCRecordOff
* Called by    :Dcm
* Preconditions:N/A
* Parameters   :Dcm_MsgContextType* pMsgContext
* Return code  :N/A
* Description  :N/A
*
******************************************************************************/
FUNC(void,DCM_CODE) App_DTCRecordOff(P2VAR(Dcm_MsgContextType,AUTOMATIC,DCM_APPL_DATA) pMsgContext)
{

	(void)pMsgContext;
	g_dtc_timecount=0u;
	gDTCSwitch=0;

	//error = dem_clear_dtc(dtc);

	dem_disable_dtc_setting();

	pMsgContext->resDataLen=2;
	DsdInternal_ProcessingDone(pMsgContext);

}

//预留
void dtc_on_delay_valid_task(void)
{
	if(gDTCSwitch!=0u)
	{
		g_dtc_timecount++;
		if(g_dtc_timecount>=3000/5u)
		{
			g_dtc_timecount=0u;
			gDTCSwitch=0u;
			dem_enable_dtc_setting();

		}
	}
}

#if 0
//將DATA——F110的數組緩存 返回
u8 *app_dtc_f110_read(void)
{
	u8 *p_data;
		//(void)cal_read_did(0xf110,DATA_0xF188,sizeof(DATA_0xF188));
	p_data = DATA_0xF188;
	return p_data;

}
#endif

bool check_date_valid(u8 *p_date)
{
	u16 l_year;
	bool l_result = TRUE;
	u8 l_data[4];
	u16 l_temp;

	#if 1

	l_data[0] = p_date[0];
	l_data[1] = p_date[1];
	l_data[2] = p_date[2];
	l_data[3] = p_date[3];

	/*日期合法的判斷*/
	if( (l_data[0]>0x99) || (l_data[1]>0x99) || (l_data[0]==0x00) || (l_data[2]==0x00) || (l_data[3]==0x00) || (l_data[2]>0x12) || (l_data[3]>0x31) )
	{
		l_result = FALSE;
	}
	else if( ( (l_data[2]==0x04) || (l_data[2]==0x06)  || (l_data[2]==0x09) || (l_data[2]==0x11 ) ) && (l_data[3]>0x30) )
	{
		l_result = FALSE;
	}
	else if( ( (l_data[2]==0x01) || (l_data[2]==0x03)  || (l_data[2]==0x05) || (l_data[2]==0x07 ) || (l_data[2]==0x08 )|| (l_data[2]==0x10 ) || (l_data[2]==0x12 )) && (l_data[3]>0x31) )
	{
		l_result = FALSE;
	}
	else if( l_data[2]==0x02)
	{

		l_temp = (u16)(l_data[0] >> 4) ;
		l_temp *= 1000;
		l_year = l_temp;
		l_temp =(u16)(l_data[0] & 0x0f);
		l_temp *= 100;
		l_year += l_temp;
		l_temp =(u16)(l_data[1] >> 4);
		l_temp *= 10;
		l_year += l_temp;
		l_temp =(u16)(l_data[1] & 0x0f) ;
		l_year += l_temp;

		//l_year = (u16)(l_data[0] >> 4) * 1000 +  (u16)(l_data[0] & 0x0f) * 100 + (u16)(l_data[1] >> 4) * 10 +  (u16)(l_data[1] & 0x0f) ;
		if( ( (l_year%4) ==0) && ( (l_year%100) != 0) || ( (l_year%400) ==0) )
		{
			l_temp = 0x29;
		}
		else
		{
			l_temp = 0x28;
		}

		if(l_data[3]>l_temp)
		{
			l_result = FALSE;
		}
		else
		{
			l_result = TRUE;
		}


	}
	else
	{
		//code
	}
	#endif

	return l_result;
}









/*PRQA S 2980,2981,2983,2995,2996--*/
