فهرست منبع

[Improve][AX80][Module_LcmControl]

2021.12.21 / Folus Wen

Actions:
1. Module_LcmControl synchronize from AW-CCS.

Files:
1. As follow commit history

Image version: D0.01.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 3 سال پیش
والد
کامیت
a701a7f6ba

+ 61 - 42
EVSE/Projects/AX80/Apps/LCM/Module_LcmControl.c

@@ -2,7 +2,7 @@
  * Module_LcmControl.c
  *
  * Created on : 2020-10-20
- * Update on : 2021-12-14
+ * Update on : 2021-12-20
  * Author : Folus Wen, Eason Yang
  * Version : V0.24
  *
@@ -92,14 +92,14 @@ enum TMR_IDX
 	TMR_IDX_SHOW_AUTH_RESULT
 };
 
-struct timeb					startTime[AC_QUANTITY][10];
+struct timespec					startTime[AC_QUANTITY][TMR_IDX_SHOW_AUTH_RESULT];
 
-#define TIME_ANIMATION_PLUGIN			1000
-#define TIME_ANIMATION_BATTERY			1000
-#define TIME_ANIMATION_CONNECTION		1000
-#define TIME_ANIMATION_ALARM			5000
-#define TIME_REFRESH_TIME				5000
-#define TIME_AUTH_RESULT_TIME			5000
+#define TIME_ANIMATION_PLUGIN			1 // Unit: Second
+#define TIME_ANIMATION_BATTERY			1 // Unit: Second
+#define TIME_ANIMATION_CONNECTION		1 // Unit: Second
+#define TIME_ANIMATION_ALARM			5 // Unit: Second
+#define TIME_REFRESH_TIME				5 // Unit: Second
+#define TIME_AUTH_RESULT_TIME			5 // Unit: Second
 
 //=======================================
 // Declare Variable
@@ -152,6 +152,25 @@ int StoreLogMsg(const char *fmt, ...)
 	return rc;
 }
 
+void refreshStartTimer(struct timespec *timer)
+{
+	clock_gettime(CLOCK_MONOTONIC, timer);
+}
+
+int getDiffSecNow(struct timespec timer)
+{
+	struct timespec timerNow;
+
+	clock_gettime(CLOCK_MONOTONIC, &timerNow);
+
+	return (int)((((unsigned long)(timerNow.tv_sec - timer.tv_sec) * 1000) + ((unsigned long)((timerNow.tv_nsec / 1000000) - (timer.tv_nsec / 1000000))))/1000);
+}
+
+int getDiffSecBetween(struct timespec start, struct timespec end)
+{
+	return (int)((((unsigned long)(end.tv_sec - start.tv_sec) * 1000) + ((unsigned long)((end.tv_nsec / 1000000) - (start.tv_nsec / 1000000))))/1000);
+}
+
 long long DiffTimebWithNow(struct timeb ST)
 {
 	//return milli-second
@@ -680,9 +699,9 @@ void page_header(uint8_t gun_index, uint8_t system_mode)
 	else
 	{
 		// EVERY 5 SECONDS TO UPDATE PRICE
-		if(DiffTimebWithNow(startTime[gun_index][TMR_IDX_PRICE]) > (TIME_REFRESH_TIME))
+		if(getDiffSecNow(startTime[gun_index][TMR_IDX_PRICE]) > (TIME_REFRESH_TIME))
 		{
-			ftime(&startTime[gun_index][TMR_IDX_PRICE]);
+			refreshStartTimer(&startTime[gun_index][TMR_IDX_PRICE]);
 			setBillingFromBackend(gun_index, system_mode);
 		}
 	}
@@ -1364,7 +1383,7 @@ void setFinalCost(uint8_t gun_index, uint8_t type)
 					lcdRegisterWrite(Uart1Fd, REG_TYPE_RAM, TEXT_REMAINING_ACCOUNT_BALANCE, output_data, ARRAY_SIZE(output_data));
 				}
 				else
-				{	
+				{
 					setDisplayValue(ICON_COMPLETE_WALLET, APPEAR);
 
 					strcpy((char*)balance_empty, "-----");
@@ -1690,9 +1709,9 @@ void setWarningStatus(uint8_t gun_index)
 
 		setAlarmCodeAndIcon();
 	}
-	else if(ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 4 && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_ALARM]) > (TIME_ANIMATION_ALARM)))
+	else if(ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 4 && (getDiffSecNow(startTime[gun_index][TMR_IDX_ALARM]) > (TIME_ANIMATION_ALARM)))
 	{
-		ftime(&startTime[gun_index][TMR_IDX_ALARM]);
+		refreshStartTimer(&startTime[gun_index][TMR_IDX_ALARM]);
 		if(ShmSysConfigAndInfo->SysWarningInfo.PageIndex == 0)
 		{
 			ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 1;
@@ -1752,30 +1771,30 @@ void setConnectionAnimation(uint8_t gun_index, uint8_t system_mode)
 		case SYS_MODE_IDLE:
 			if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
 			{
-				if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
+				if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (getDiffSecNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
 				{
 					setDisplayValue(ICON_PRECHARGING_ANIMATION, CONNECTION_FLASHING_1);
 					CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_1;
 				}
-				else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
+				else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (getDiffSecNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
 				{
 					setDisplayValue(ICON_PRECHARGING_ANIMATION, CONNECTION_FLASHING_2);
 					CONNECTION_LEVEL_STATUS =  CONNECTION_LEVEL_0;
-					ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
+					refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
 				}
 			}
 			else
 			{
-				if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
+				if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (getDiffSecNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
 				{
 					setDisplayValue(ICON_PREPARING_ANIMATION, CONNECTION_FLASHING_1);
 					CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_1;
 				}
-				else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
+				else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (getDiffSecNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
 				{
 					setDisplayValue(ICON_PREPARING_ANIMATION, CONNECTION_FLASHING_2);
 					CONNECTION_LEVEL_STATUS =  CONNECTION_LEVEL_0;
-					ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
+					refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
 				}
 			}
 
@@ -1783,45 +1802,45 @@ void setConnectionAnimation(uint8_t gun_index, uint8_t system_mode)
 		case SYS_MODE_PREPARING:
 			if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
 			{
-				if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
+				if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (getDiffSecNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
 				{
 					setDisplayValue(ICON_PRECHARGING_ANIMATION, CONNECTION_FLASHING_1);
 					CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_1;
 				}
-				else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
+				else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (getDiffSecNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
 				{
 					setDisplayValue(ICON_PRECHARGING_ANIMATION, CONNECTION_FLASHING_2);
 					CONNECTION_LEVEL_STATUS =  CONNECTION_LEVEL_0;
-					ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
+					refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
 				}
 			}
 			else
 			{
-				if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
+				if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (getDiffSecNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
 				{
 					setDisplayValue(ICON_PREPARING_ANIMATION, CONNECTION_FLASHING_1);
 					CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_1;
 				}
-				else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
+				else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (getDiffSecNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
 				{
 					setDisplayValue(ICON_PREPARING_ANIMATION, CONNECTION_FLASHING_2);
 					CONNECTION_LEVEL_STATUS =  CONNECTION_LEVEL_0;
-					ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
+					refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
 				}
 			}
 
 			break;
 		case SYS_MODE_CHARGING:
-			if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
+			if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_0) && (getDiffSecNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION)))
 			{
 				setDisplayValue(ICON_CHARGING_ANIMATION, CONNECTION_FLASHING_1);
 				CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_1;
 			}
-			else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
+			else if((CONNECTION_LEVEL_STATUS == CONNECTION_LEVEL_1) && (getDiffSecNow(startTime[gun_index][TMR_IDX_CONNECTION]) > (TIME_ANIMATION_CONNECTION*2)))
 			{
 				setDisplayValue(ICON_CHARGING_ANIMATION, CONNECTION_FLASHING_2);
 				CONNECTION_LEVEL_STATUS =  CONNECTION_LEVEL_0;
-				ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
+				refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
 			}
 			break;
 		case SYS_MODE_TERMINATING:
@@ -1844,16 +1863,16 @@ void setGunPluginAnimation(uint8_t gun_index)
 	}
 	else
 	{
-		if((GUN_PLUGING_LEVEL_STATUS == GUN_PLUGING_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_PLUGIN]) > (TIME_ANIMATION_PLUGIN)))
+		if((GUN_PLUGING_LEVEL_STATUS == GUN_PLUGING_LEVEL_0) && (getDiffSecNow(startTime[gun_index][TMR_IDX_PLUGIN]) > (TIME_ANIMATION_PLUGIN)))
 		{
 			setDisplayValue(ICON_PREPARING_PLUG_ARROW, PLUGIN_ARROW_1);
 			GUN_PLUGING_LEVEL_STATUS = GUN_PLUGING_LEVEL_1;
 		}
-		else if((GUN_PLUGING_LEVEL_STATUS == GUN_PLUGING_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_PLUGIN]) > (TIME_ANIMATION_PLUGIN*2)))
+		else if((GUN_PLUGING_LEVEL_STATUS == GUN_PLUGING_LEVEL_1) && (getDiffSecNow(startTime[gun_index][TMR_IDX_PLUGIN]) > (TIME_ANIMATION_PLUGIN*2)))
 		{
 			setDisplayValue(ICON_PREPARING_PLUG_ARROW, PLUGIN_ARROW_2);
 			GUN_PLUGING_LEVEL_STATUS =  GUN_PLUGING_LEVEL_0;
-			ftime(&startTime[gun_index][TMR_IDX_PLUGIN]);
+			refreshStartTimer(&startTime[gun_index][TMR_IDX_PLUGIN]);
 		}
 	}
 }
@@ -1863,16 +1882,16 @@ void setGunPluginAnimation(uint8_t gun_index)
 //=======================================
 void setPlugAndChargeAnimation(uint8_t gun_index)
 {
-	if((GUN_PLUGING_LEVEL_STATUS == GUN_PLUGING_LEVEL_0) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_PLUGIN]) > (TIME_ANIMATION_PLUGIN)))
+	if((GUN_PLUGING_LEVEL_STATUS == GUN_PLUGING_LEVEL_0) && (getDiffSecNow(startTime[gun_index][TMR_IDX_PLUGIN]) > (TIME_ANIMATION_PLUGIN)))
 	{
 		setDisplayValue(ICON_PLUG_AND_CHARGE_ARROW, PLUGIN_ARROW_1);
 		GUN_PLUGING_LEVEL_STATUS = GUN_PLUGING_LEVEL_1;
 	}
-	else if((GUN_PLUGING_LEVEL_STATUS == GUN_PLUGING_LEVEL_1) && (DiffTimebWithNow(startTime[gun_index][TMR_IDX_PLUGIN]) > (TIME_ANIMATION_PLUGIN*2)))
+	else if((GUN_PLUGING_LEVEL_STATUS == GUN_PLUGING_LEVEL_1) && (getDiffSecNow(startTime[gun_index][TMR_IDX_PLUGIN]) > (TIME_ANIMATION_PLUGIN*2)))
 	{
 		setDisplayValue(ICON_PLUG_AND_CHARGE_ARROW, PLUGIN_ARROW_2);
 		GUN_PLUGING_LEVEL_STATUS =  GUN_PLUGING_LEVEL_0;
-		ftime(&startTime[gun_index][TMR_IDX_PLUGIN]);
+		refreshStartTimer(&startTime[gun_index][TMR_IDX_PLUGIN]);
 	}
 }
 
@@ -2044,13 +2063,13 @@ void setDefaultValue(uint8_t gun_index, uint8_t system_mode)
 			{
 				setDisplayValue(ICON_PRECHARGING_ANIMATION, CONNECTION_FLASHING_1);
 				CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
-				ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
+				refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
 			}
 			else
 			{
 				setDisplayValue(ICON_PREPARING_PLUG_ARROW, PLUGIN_ARROW_1);
 				GUN_PLUGING_LEVEL_STATUS = GUN_PLUGING_LEVEL_0;
-				ftime(&startTime[gun_index][TMR_IDX_PLUGIN]);
+				refreshStartTimer(&startTime[gun_index][TMR_IDX_PLUGIN]);
 			}
 			break;
 		case SYS_MODE_AUTHORIZING:
@@ -2060,18 +2079,18 @@ void setDefaultValue(uint8_t gun_index, uint8_t system_mode)
 			{
 				setDisplayValue(ICON_PRECHARGING_ANIMATION, CONNECTION_FLASHING_1);
 				CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
-				ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
+				refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
 			}
 			else
 			{
 				setDisplayValue(ICON_PREPARING_PLUG_ARROW, PLUGIN_ARROW_1);
 				GUN_PLUGING_LEVEL_STATUS = GUN_PLUGING_LEVEL_0;
-				ftime(&startTime[gun_index][TMR_IDX_PLUGIN]);
+				refreshStartTimer(&startTime[gun_index][TMR_IDX_PLUGIN]);
 			}
 			break;
 		case SYS_MODE_CHARGING:
 			setDisplayValue(ICON_CHARGING_ANIMATION, CONNECTION_FLASHING_1);
-			ftime(&startTime[gun_index][TMR_IDX_CONNECTION]);
+			refreshStartTimer(&startTime[gun_index][TMR_IDX_CONNECTION]);
 			CONNECTION_LEVEL_STATUS = CONNECTION_LEVEL_0;
 			break;
 		case SYS_MODE_TERMINATING:
@@ -2587,10 +2606,10 @@ int main(void)
 
 			if(ShmCharger->isAuthrizing || ShmCharger->isGetAuthResult)
 			{
-				if(DiffTimebWithNow(startTime[ShmCharger->gun_selectd][TMR_IDX_SHOW_AUTH_RESULT]) >= TIME_AUTH_RESULT_TIME)
+				if(getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_SHOW_AUTH_RESULT]) >= TIME_AUTH_RESULT_TIME)
 					ShmCharger->isGetAuthResult = FALSE;
 
-				if(DiffTimebWithNow(startTime[ShmCharger->gun_selectd][TMR_IDX_SHOW_AUTH_RESULT]) < TIME_AUTH_RESULT_TIME)
+				if(getDiffSecNow(startTime[ShmCharger->gun_selectd][TMR_IDX_SHOW_AUTH_RESULT]) < TIME_AUTH_RESULT_TIME)
 				{
 					page_authorizing(ShmCharger->gun_selectd);
 					ShmCharger->gun_info[ShmCharger->gun_selectd].isHandshakeTimerRefresh = YES;
@@ -2603,7 +2622,7 @@ int main(void)
 			}
 			else
 			{
-				ftime(&startTime[ShmCharger->gun_selectd][TMR_IDX_SHOW_AUTH_RESULT]);
+				refreshStartTimer(&startTime[ShmCharger->gun_selectd][TMR_IDX_SHOW_AUTH_RESULT]);
 
 				switch(ShmSysConfigAndInfo->SysInfo.AcChargingData[ShmCharger->gun_selectd].SystemStatus)
 				{

+ 1 - 1
EVSE/Projects/AX80/Apps/Makefile

@@ -129,7 +129,7 @@ Module_CCS_Task:
 Module_LcmControl_Task:
 	@echo "===== Module_LcmControl_Task ==================================="
 	rm -f Module_LcmControl
-	$(CC) -D $(Project) "-I../../../Modularization/ocppfiles/" "-I./" "-I../../" -O0  -Wall -fmessage-length=0 LCM/lcmComm_dgus.c LCM/Module_LcmControl.c LCM/cbmp.c -o Module_LcmControl
+	$(CC) -D $(Project) "-I../../../Modularization/ocppfiles/" "-I./" "-I../../" -O0  -Wall -fmessage-length=0 LCM/lcmComm_dgus.c LCM/Module_LcmControl.c LCM/cbmp.c -lrt -o Module_LcmControl
 	rm -f *.o	
 	mv -f Module_LcmControl ../Images/root
 

+ 28 - 11
EVSE/Projects/AX80/Apps/main.c

@@ -4109,7 +4109,8 @@ void checkConnectionTimeout()
 	}
 	else
 	{
-		ShmCharger->timeoutSpec.Setting_Timeout_Spec = ocpp_get_connection_timeout();
+		ShmCharger->timeoutSpec.Present_Timeout_Spec = ocpp_get_connection_timeout();
+		/*
 		if((ShmCharger->timeoutSpec.Setting_Timeout_Spec) < TIMEOUT_SPEC_BS_HLC_HANDSHAKE)
 		{
 			ShmCharger->timeoutSpec.Present_Timeout_Spec = (TIMEOUT_SPEC_BS_HLC_HANDSHAKE+10);
@@ -4119,7 +4120,7 @@ void checkConnectionTimeout()
 		{
 			ShmCharger->timeoutSpec.Present_Timeout_Spec = (ShmCharger->timeoutSpec.Setting_Timeout_Spec);
 			//DEBUG_INFO("Handshaking timeout specification follow by OCPP Configuration : Pass...\n.");
-		}
+		}*/
 		//DEBUG_INFO("Handshaking timeout specification follow by OCPP Configuration : %s s \n.",ShmOCPP16Data->ConfigurationTable.CoreProfile[ConnectionTimeOut].ItemData);
 	}
 }
@@ -4619,6 +4620,16 @@ void checkRemoteUpgradeStatus()
 	}
 }
 
+void checkHandshakeTime()
+{
+	// Handskake timer needs to refresh
+	if(ShmCharger->gun_info[ShmCharger->gun_selectd].isHandshakeTimerRefresh == YES)
+		refreshStartTimer(&startTime[0][TMR_IDX_GUN_DETECT]);
+
+	// Timer for lcm to shows
+	ShmCharger->timeoutSpec.Handshake_Timeout = (ocpp_get_connection_timeout() - getDiffSecNow(startTime[0][TMR_IDX_GUN_DETECT]));
+}
+
 void checkRfidAuthrize()
 {
 	static uint8_t isCheckdResult = FALSE;
@@ -4757,6 +4768,8 @@ void checkRfidAuthrize()
 
 					if(getDiffSecNow(startTime[0][TMR_IDX_GUN_DETECT]) < ocpp_get_connection_timeout())
 					{
+						checkHandshakeTime();
+
 						if(GetCardSerialNumber() != FAIL)
 						{
 							if(isMatchPresentUser())
@@ -4832,6 +4845,8 @@ void checkRfidAuthrize()
 	}
 }
 
+
+
 //======================================================
 // Main process
 //======================================================
@@ -5007,7 +5022,8 @@ int main(void)
 					}
 					else
 					{
-						if((gpio_get_value(GPIO_IN_WAKEUP) == OFF) ||
+						if((ShmCharger->gun_info[ShmCharger->gun_selectd].isHandshakeTimerRefresh == YES) ||
+						   (gpio_get_value(GPIO_IN_WAKEUP) == OFF) ||
 						   (ShmCharger->gun_info[gun_index].GPIO_Input.Button_Mode_Switch == ON) ||
 						   (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus != ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus) ||
 						   (((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_IDLE) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_PREPARING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].SystemStatus == SYS_MODE_RESERVATION)) &&
@@ -5339,6 +5355,8 @@ int main(void)
 								ShmCharger->gun_info[gun_index].isSleepOn = OFF;
 								setLedMotion(gun_index, LED_ACTION_AUTHED);
 								refreshStartTimer(&startTime[gun_index][TMR_IDX_POWERSAVING_LCD]);
+
+								checkHandshakeTime();
 							}
 							else
 							{
@@ -5488,6 +5506,7 @@ int main(void)
 					case SYS_MODE_PREPARING:
 						if(isModeChange(gun_index))
 						{
+							refreshStartTimer(&startTime[0][TMR_IDX_GUN_DETECT]);
 							refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
 							setLedMotion(gun_index, LED_ACTION_AUTHED);
 							ShmCharger->gun_info[gun_index].resultAuthorization = DEFAULT_RFID;
@@ -5498,11 +5517,12 @@ int main(void)
 						if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_B) ||
 							(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C))
 						{
+							refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
+
 							if(!getRequest(gun_index))
 							{
 								setRequest(gun_index, ON);
 								setLedMotion(gun_index, LED_ACTION_CONNECTED);
-								refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
 								DEBUG_INFO("Set Request On.\n");
 							}
 
@@ -5530,7 +5550,6 @@ int main(void)
 									if((16 < ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus) && (ShmCharger->gun_info[gun_index].acCcsInfo.PresentMsgFlowStatus < 254))
 									{
 										DEBUG_INFO("Enter HLC Mode charging.\n");
-										refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
 									}
 
 									break;
@@ -5543,14 +5562,11 @@ int main(void)
 										ocpp_set_profile_req(gun_index, ON);
 										sleep(1);
 										checkChargingProfileLimit(gun_index);
-
-										refreshStartTimer(&startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]);
 									}
 									break;
 								case HANDSHAKE_SET_MAX_CURRENT:
 								case HANDSHAKE_BS_MODE:
 									DEBUG_INFO("Enter BS Mode charging.\n");
-									refreshStartTimer(&startTime[gun_index][TMR_IDX_HANDSHAKING]);
 									checkChargingProfileLimit(gun_index);
 									if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C)
 										setRelay(gun_index,ON);
@@ -5618,11 +5634,11 @@ int main(void)
 									}
 
 									//120 sec timeout
-									if(getDiffSecNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > TIMEOUT_SPEC_CCS_HANDSHAKE)
+									if(getDiffSecNow(startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]) > TIMEOUT_SPEC_CCS_HANDSHAKE)
 									{
 										setLedMotion(gun_index, LED_ACTION_HANDSHAKE_FAIL);
 
-										if(getDiffSecNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > (TIMEOUT_SPEC_CCS_HANDSHAKE+5))
+										if(getDiffSecNow(startTime[gun_index][TMR_IDX_BS_HLC_HANDSHAKE]) > (TIMEOUT_SPEC_CCS_HANDSHAKE+5))
 										{
 											DEBUG_INFO("CCS 120 secs handshake timeout, change to BS Mode...\n");
 
@@ -5670,13 +5686,14 @@ int main(void)
 							ShmCharger->gun_info[gun_index].rfidReq = OFF;
 						}
 
+						checkHandshakeTime();
 						if(getDiffSecNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > ShmCharger->timeoutSpec.Present_Timeout_Spec)
 						{
 							setLedMotion(gun_index, LED_ACTION_HANDSHAKE_FAIL);
+							DEBUG_INFO("Handshaking timeout...%d\n", ShmCharger->timeoutSpec.Present_Timeout_Spec);
 
 							if(getDiffSecNow(startTime[gun_index][TMR_IDX_HANDSHAKING]) > (ShmCharger->timeoutSpec.Present_Timeout_Spec+5))
 							{
-								DEBUG_INFO("Handshaking timeout...\n");
 								setChargerMode(gun_index, SYS_MODE_IDLE);
 							}
 						}

+ 0 - 1
EVSE/Projects/AX80/Apps/main.h

@@ -540,7 +540,6 @@ typedef struct MCU_RESET_REQUEST
 
 typedef struct TIMEOUT_SPEC
 {
-	int Setting_Timeout_Spec;
 	int Present_Timeout_Spec;
 	int Handshake_Timeout;
 }Timeout_Spec;