Parcourir la source

[Add][AX80][main / Module_InternalComm]

2022.04.20 / Folus Wen

Actions:
1. Module_InternalComm output log logic improve
2. main end charging session if disconnect from EV in alarm mode.

Files:
1. As follow commit history

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

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen il y a 2 ans
Parent
commit
95e949a4d6

+ 340 - 328
EVSE/Projects/AX80/Apps/Module_InternalComm.c

@@ -1860,6 +1860,346 @@ int main(void)
 		DEBUG_INFO("ttyS1 port open success.\n");
 	}
 
+	// Log output thread
+	if(fork() == 0)
+	{
+		for(;;)
+		{
+			//==========================================================
+			// High priority polling log print out
+			//==========================================================
+			if((current_timestamp() - tsPrintLog[PRIORITY_HIGH]) > (ShmDispenser->gun_info.legacyRequest.isLegacyRequest?3000:6000))
+			{
+				tsPrintLog[PRIORITY_HIGH] = current_timestamp();
+
+				//===============================
+				// Config primary MCU LED
+				//===============================
+				if((previousCharger.gun_info.primaryMcuLed.mode != ShmDispenser->gun_info.primaryMcuLed.mode) ||
+				   (previousCharger.gun_info.primaryMcuLed.alarm_code != ShmDispenser->gun_info.primaryMcuLed.alarm_code))
+				{
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("***** High priority polling : Case 1 ******\n");
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("MCU set Led mode : %d\n", ShmDispenser->gun_info.primaryMcuLed.mode);
+					DEBUG_INFO("MCU set Alarm code : %x\n", ShmDispenser->gun_info.primaryMcuLed.alarm_code);
+
+					previousCharger.gun_info.primaryMcuLed.mode = ShmDispenser->gun_info.primaryMcuLed.mode;
+					previousCharger.gun_info.primaryMcuLed.alarm_code = ShmDispenser->gun_info.primaryMcuLed.alarm_code;
+				}
+
+				//===============================
+				// Config primary Legacy request
+				//===============================
+				if(previousCharger.gun_info.legacyRequest.isLegacyRequest != ShmDispenser->gun_info.legacyRequest.isLegacyRequest)
+				{
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("***** High priority polling : Case 2 ******\n");
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("MCU set relay request : %d\n", ShmDispenser->gun_info.legacyRequest.isLegacyRequest);
+
+					previousCharger.gun_info.legacyRequest.isLegacyRequest = ShmDispenser->gun_info.legacyRequest.isLegacyRequest;
+				}
+
+				//===============================
+				// Query primary MCU status
+				//===============================
+				if((previousCharger.gun_info.primaryMcuState.cp_state != ShmDispenser->gun_info.primaryMcuState.cp_state) ||
+				   (previousCharger.gun_info.primaryMcuState.current_limit != ShmDispenser->gun_info.primaryMcuState.current_limit) ||
+				   (previousCharger.gun_info.primaryMcuState.relay_state != ShmDispenser->gun_info.primaryMcuState.relay_state) ||
+				   (previousCharger.gun_info.primaryMcuState.socket_e.isSocketEMode != ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEMode) ||
+				   (previousCharger.gun_info.primaryMcuState.socket_e.isSocketEPinOn != ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEPinOn))
+				{
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("***** High priority polling : Case 3 ******\n");
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("MCU get Pilot State : %d\n", ShmDispenser->gun_info.primaryMcuState.cp_state);
+					DEBUG_INFO("MCU get Pilot Duty : %.2f\n", (float)ShmDispenser->gun_info.primaryMcuState.current_limit);
+					DEBUG_INFO("MCU get Pilot Voltage Positive : %.2f\n", ShmDispenser->gun_info.primaryMcuState.cp_voltage_positive);
+					DEBUG_INFO("MCU get Pilot Voltage Negative : %.2f\n", ShmDispenser->gun_info.primaryMcuState.cp_voltage_negtive);
+
+					if(ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEPinOn == ON)
+						DEBUG_INFO("Relay on mode : CHARGING_MODE_SOCKETE. \n");
+					else
+						DEBUG_INFO("Relay on mode : CHARGING_MODE_BS / CHARGING_MODE_HLC. \n");
+
+					DEBUG_INFO("MCU get Relay State : %d\n", ShmDispenser->gun_info.primaryMcuState.relay_state);
+					DEBUG_INFO("MCU get Rating Current : %.2f\n", (float)ShmDispenser->gun_info.primaryMcuState.rating_current);
+					DEBUG_INFO("MCU get Rotary switch : %d\n", ShmDispenser->gun_info.primaryMcuState.rotatory_switch);
+					DEBUG_INFO("MCU get is on Socket-E mode : %d\n", ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEMode);
+					DEBUG_INFO("MCU get Socket-E detect pin : %d\n", ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEPinOn);
+
+					//===============================
+					// Query primary MCU power consumption
+					//===============================
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("***** High priority polling : Case 10 *****\n");
+					DEBUG_INFO("*******************************************\n");
+					DEBUG_INFO("MCU get total power consumption : %f kWh\n",((float)ShmDispenser->gun_info.powerConsumptionTotal.power_consumption/10000.0));
+					DEBUG_INFO("MCU get L1N_L12 power consumption : %f kWh\n",((float)ShmDispenser->gun_info.powerConsumption[0].power_consumption/10000.0));
+					if(ShmDispenser->ConfigData.AcPhaseCount == 3)
+					{
+						DEBUG_INFO("MCU get L2N_L23 power consumption : %f kWh\n",((float)ShmDispenser->gun_info.powerConsumption[1].power_consumption/10000.0));
+						DEBUG_INFO("MCU get L3N_L31 power consumption : %f kWh\n",((float)ShmDispenser->gun_info.powerConsumption[2].power_consumption/10000.0));
+					}
+
+					/*
+					DEBUG_INFO("MCU get Locker State : %d\n", ShmDispenser->gun_info.primaryMcuState.locker_state);
+					DEBUG_INFO("MCU get Shutter State : %d\n", ShmDispenser->gun_info.primaryMcuState.shutter_state);
+					DEBUG_INFO("MCU get Meter State : %d\n", ShmDispenser->gun_info.primaryMcuState.meter_state);
+					DEBUG_INFO("MCU get PP State : %d\n", ShmDispenser->gun_info.primaryMcuState.pp_state);
+					*/
+
+					previousCharger.gun_info.primaryMcuState.cp_state = ShmDispenser->gun_info.primaryMcuState.cp_state;
+					previousCharger.gun_info.primaryMcuState.current_limit = ShmDispenser->gun_info.primaryMcuState.current_limit;
+					previousCharger.gun_info.primaryMcuState.relay_state = ShmDispenser->gun_info.primaryMcuState.relay_state;
+					previousCharger.gun_info.primaryMcuState.socket_e.isSocketEMode = ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEMode;
+					previousCharger.gun_info.primaryMcuState.socket_e.isSocketEPinOn = ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEPinOn;
+				}
+
+				//===============================
+				// Query primary MCU Alarm code
+				//===============================
+				if((previousCharger.gun_info.primaryMcuAlarm.InputAlarmCode != ShmDispenser->gun_info.primaryMcuAlarm.InputAlarmCode))
+				{
+					if((ShmDispenser->gun_info.primaryMcuAlarm.InputAlarmCode>0))
+					{
+						DEBUG_INFO("*******************************************\n");
+						DEBUG_INFO("***** High priority polling : Case 4 ******\n");
+						DEBUG_INFO("*******************************************\n");
+						DEBUG_INFO("MCU get OVP_L1 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OVP_L1);
+						DEBUG_INFO("MCU get UVP_L1 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.UVP_L1);
+						DEBUG_INFO("MCU get OCP_L1 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OCP_L1);
+						if(ShmDispenser->ConfigData.AcPhaseCount == 3)
+						{
+							DEBUG_INFO("MCU get OVP_L2 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OVP_L2);
+							DEBUG_INFO("MCU get UVP_L2 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.UVP_L2);
+							DEBUG_INFO("MCU get OCP_L2 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OCP_L2);
+							DEBUG_INFO("MCU get OVP_L3 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OVP_L3);
+							DEBUG_INFO("MCU get UVP_L3 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.UVP_L3);
+							DEBUG_INFO("MCU get OCP_L3 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OCP_L3);
+						}
+						DEBUG_INFO("MCU get OTP : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OTP);
+						DEBUG_INFO("MCU get gmi_fault : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.gmi_fault);
+						DEBUG_INFO("MCU get cp_fault : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.cp_fault);
+						DEBUG_INFO("MCU get ac_leak : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.ac_leak);
+						DEBUG_INFO("MCU get dc_leak : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.dc_leak);
+						DEBUG_INFO("MCU get mcu_selftest_fail : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.mcu_selftest_fail);
+						DEBUG_INFO("MCU get handshaking_timeout : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.handshaking_timeout);
+						DEBUG_INFO("MCU get emergency_stop : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.emergency_stop);
+						DEBUG_INFO("MCU get relay_welding : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.relay_welding);
+						DEBUG_INFO("MCU get leak_module_fail : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.leak_module_fail);
+						DEBUG_INFO("MCU get shutter_fault : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.shutter_fault);
+						DEBUG_INFO("MCU get locker_fault : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.locker_fault);
+						DEBUG_INFO("MCU get power_drop : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.power_drop);
+						DEBUG_INFO("MCU get rotate_switch_fault : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.rotate_switch_fault);
+						DEBUG_INFO("MCU get short_circuit_L1 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.short_circuit_L1);
+						if(ShmDispenser->ConfigData.AcPhaseCount == 3)
+						{
+							DEBUG_INFO("MCU get short_circuit_L2 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.short_circuit_L2);
+							DEBUG_INFO("MCU get short_circuit_L3 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.short_circuit_L3);
+						}
+						DEBUG_INFO("MCU get relay_drive_fault : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.relay_drive_fault);
+						DEBUG_INFO("MCU get meter_comm_timeout : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.meter_comm_timeout);
+						DEBUG_INFO("MCU get meter_ic_comm_timeout : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.meter_ic_comm_timeout);
+						DEBUG_INFO("MCU get pilot_negative_error : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.pilot_negative_error);
+						DEBUG_INFO("MCU get InputAlarmCode : %x\n", ShmDispenser->gun_info.primaryMcuAlarm.InputAlarmCode);
+					}
+
+					DEBUG_INFO("===========================================\n");
+					DEBUG_INFO("==== Normal priority polling : Case 1 =====\n");
+					DEBUG_INFO("===========================================\n");
+					DEBUG_INFO("MCU get Input voltage L1: %.2f\n", (float)ShmDispenser->gun_info.inputVoltage.L1N_L12);
+					DEBUG_INFO("MCU get PresentChargingVoltage L1: %.2f\n", (float)ShmDispenser->gun_info.inputVoltage.L1N_L12);
+					if(ShmDispenser->ConfigData.AcPhaseCount == 3)
+					{
+						DEBUG_INFO("MCU get Input voltage L2: %f\n", (float)ShmDispenser->gun_info.inputVoltage.L2N_L23);
+						DEBUG_INFO("MCU get PresentChargingVoltage L2: %.2f\n", (float)ShmDispenser->gun_info.inputVoltage.L2N_L23);
+						DEBUG_INFO("MCU get Input voltage L3: %f\n", (float)ShmDispenser->gun_info.inputVoltage.L3N_L31);
+						DEBUG_INFO("MCU get PresentChargingVoltage L3: %.2f\n", (float)ShmDispenser->gun_info.inputVoltage.L3N_L31);
+					}
+
+					previousCharger.gun_info.primaryMcuAlarm.InputAlarmCode = ShmDispenser->gun_info.primaryMcuAlarm.InputAlarmCode;
+				}
+
+				//===============================
+				// Query primary MCU BLE config
+				//===============================
+				if((previousCharger.gun_info.bleConfigData.isLogin != ShmDispenser->gun_info.bleConfigData.isLogin) ||
+				   (previousCharger.gun_info.bleConfigData.isRequestStart != ShmDispenser->gun_info.bleConfigData.isRequestStart) ||
+				   (previousCharger.gun_info.bleConfigData.isRequestStop != ShmDispenser->gun_info.bleConfigData.isRequestStop))
+				{
+					if(ShmDispenser->gun_info.bleConfigData.isLogin == ON)
+					{
+						DEBUG_INFO("*******************************************\n");
+						DEBUG_INFO("***** High priority polling : Case 5 ******\n");
+						DEBUG_INFO("*******************************************\n");
+						DEBUG_INFO("MCU get isUserLogin : %d\n", ShmDispenser->gun_info.bleConfigData.isLogin);
+						DEBUG_INFO("MCU get isRequestStartCharger : %d\n", ShmDispenser->gun_info.bleConfigData.isRequestStart);
+						DEBUG_INFO("MCU get isRequestStopCharger : %d\n", ShmDispenser->gun_info.bleConfigData.isRequestStop);
+					}
+
+					previousCharger.gun_info.bleConfigData.isLogin = ShmDispenser->gun_info.bleConfigData.isLogin;
+					previousCharger.gun_info.bleConfigData.isRequestStart = ShmDispenser->gun_info.bleConfigData.isRequestStart;
+					previousCharger.gun_info.bleConfigData.isRequestStop = ShmDispenser->gun_info.bleConfigData.isRequestStop;
+				}
+
+				//===============================
+				// Query primary MCU ble login id
+				//===============================
+				if((strcmp((char *)&previousCharger.gun_info.bleLoginCentralId.id,(char *)&ShmDispenser->gun_info.bleLoginCentralId.id) != 0))
+				{
+					if(strcmp((char *)&ShmDispenser->gun_info.bleLoginCentralId.id,"") != 0)
+					{
+						DEBUG_INFO("*******************************************\n");
+						DEBUG_INFO("***** High priority polling : Case 6 ******\n");
+						DEBUG_INFO("*******************************************\n");
+						DEBUG_INFO("MCU get ble central id : %s\n", ShmDispenser->gun_info.bleLoginCentralId.id);
+					}
+
+					memcpy(&previousCharger.gun_info.bleLoginCentralId.id, ShmDispenser->gun_info.bleLoginCentralId.id, ARRAY_SIZE(ShmDispenser->gun_info.bleLoginCentralId.id));
+				}
+
+				//==========================================================
+				// Low priority polling log print out
+				//==========================================================
+				if((current_timestamp() - tsPrintLog[PRIORITY_LOW]) > (ShmDispenser->gun_info.legacyRequest.isLegacyRequest?3000:6000))
+				{
+					tsPrintLog[PRIORITY_LOW] = current_timestamp();
+
+					switch(logIndex)
+					{
+						case 1:
+							if((previousCharger.gun_info.outputCurrent.L1N_L12[0] != ShmDispenser->gun_info.outputCurrent.L1N_L12[0]) ||
+							   (previousCharger.gun_info.outputCurrent.L2N_L23[0] != ShmDispenser->gun_info.outputCurrent.L2N_L23[0]) ||
+							   (previousCharger.gun_info.outputCurrent.L3N_L31[0] != ShmDispenser->gun_info.outputCurrent.L3N_L31[0]))
+							{
+								DEBUG_INFO("===========================================\n");
+								DEBUG_INFO("==== Normal priority polling : Case 3 =====\n");
+								DEBUG_INFO("===========================================\n");
+								DEBUG_INFO("MCU get output current L1: %f\n", (float)ShmDispenser->gun_info.outputCurrent.L1N_L12[0]);
+								if(ShmDispenser->ConfigData.AcPhaseCount == 3)
+								{
+									DEBUG_INFO("MCU get output current L2: %f\n", (float)ShmDispenser->gun_info.outputCurrent.L2N_L23[0]);
+									DEBUG_INFO("MCU get output current L3: %f\n", (float)ShmDispenser->gun_info.outputCurrent.L3N_L31[0]);
+								}
+
+								previousCharger.gun_info.outputCurrent.L1N_L12[0] = ShmDispenser->gun_info.outputCurrent.L1N_L12[0];
+								previousCharger.gun_info.outputCurrent.L2N_L23[0] = ShmDispenser->gun_info.outputCurrent.L2N_L23[0];
+								previousCharger.gun_info.outputCurrent.L3N_L31[0] = ShmDispenser->gun_info.outputCurrent.L3N_L31[0];
+							}
+
+							break;
+						case 2:
+							if(previousCharger.gun_info.gunPluginTimes.GunPluginTimes != ShmDispenser->gun_info.gunPluginTimes.GunPluginTimes)
+							{
+								DEBUG_INFO("===========================================\n");
+								DEBUG_INFO("==== Normal priority polling : Case 5 =====\n");
+								DEBUG_INFO("===========================================\n");
+								DEBUG_INFO("MCU get gun plugin times : %ld\n", (long)ShmDispenser->gun_info.gunPluginTimes.GunPluginTimes);
+
+								previousCharger.gun_info.gunPluginTimes.GunPluginTimes = ShmDispenser->gun_info.gunPluginTimes.GunPluginTimes;
+							}
+
+							break;
+						case 3:
+							if(previousCharger.gun_info.temperature.point[0] != ShmDispenser->gun_info.temperature.point[0])
+							{
+								DEBUG_INFO("===========================================\n");
+								DEBUG_INFO("==== Normal priority polling : Case 7 =====\n");
+								DEBUG_INFO("===========================================\n");
+								DEBUG_INFO("MCU get temperature : %d\n", ShmDispenser->gun_info.temperature.point[0]);
+
+								previousCharger.gun_info.temperature.point[0] = ShmDispenser->gun_info.temperature.point[0];
+							}
+
+							break;
+						case 4:
+							if(previousCharger.gun_info.primaryMcuCp_Pwn_Duty.max_current != ShmDispenser->gun_info.primaryMcuCp_Pwn_Duty.max_current)
+							{
+								DEBUG_INFO("===========================================\n");
+								DEBUG_INFO("==== Normal priority polling : Case 9 =====\n");
+								DEBUG_INFO("===========================================\n");
+								DEBUG_INFO("MCU set cp pwn duty : %d\n", ShmDispenser->gun_info.primaryMcuCp_Pwn_Duty.max_current);
+
+								previousCharger.gun_info.primaryMcuCp_Pwn_Duty.max_current = ShmDispenser->gun_info.primaryMcuCp_Pwn_Duty.max_current;
+							}
+
+							break;
+						case 5:
+							DEBUG_INFO("===========================================\n");
+							DEBUG_INFO("==== Normal priority polling : Case 11 ====\n");
+							DEBUG_INFO("===========================================\n");
+							if(ShmDispenser->gun_info.bleConfigData.isLogin && !ShmDispenser->isConnectedBackend)
+							{
+								DEBUG_INFO("Sync from MCU rtc OK...%04d-%02d-%02d %02d:%02d:%02d\n", ShmDispenser->gun_info.rtc.year,
+																									ShmDispenser->gun_info.rtc.month,
+																									ShmDispenser->gun_info.rtc.day,
+																									ShmDispenser->gun_info.rtc.hour,
+																									ShmDispenser->gun_info.rtc.min,
+																									ShmDispenser->gun_info.rtc.sec);
+							}
+							else
+							{
+								DEBUG_INFO("MCU set rtc OK...%04d-%02d-%02d %02d:%02d:%02d\n", ShmDispenser->gun_info.rtc.year,
+																								ShmDispenser->gun_info.rtc.month,
+																								ShmDispenser->gun_info.rtc.day,
+																								ShmDispenser->gun_info.rtc.hour,
+																								ShmDispenser->gun_info.rtc.min,
+																								ShmDispenser->gun_info.rtc.sec);
+							}
+							break;
+						case 6:
+							break;
+						case 7:
+							if(ShmDispenser->gun_info.isSetBreatheLedTiming == ON)
+							{
+								DEBUG_INFO("===========================================\n");
+								DEBUG_INFO("==== Normal priority polling : Case 17 ====\n");
+								DEBUG_INFO("===========================================\n");
+								DEBUG_INFO("MCU set breathe led timing : Authed Fade in [%ld].\n", (long)ShmDispenser->gun_info.setBreatheLedTiming.set_Led_Action_Authed_Fade_In);
+								DEBUG_INFO("MCU set breathe led timing : Authed Fade out [%ld].\n", (long)ShmDispenser->gun_info.setBreatheLedTiming.set_Led_Action_Authed_Fade_Out);
+								DEBUG_INFO("MCU set breathe led timing : Charging Fade in [%ld].\n", (long)ShmDispenser->gun_info.setBreatheLedTiming.Set_Led_Action_Chaging_Fade_In);
+								DEBUG_INFO("MCU set breathe led timing : Charging Fade out [%ld].\n", (long)ShmDispenser->gun_info.setBreatheLedTiming.set_Led_Action_Chaging_Fade_Out);
+								DEBUG_INFO("MCU set breathe led timing : Connected Fade in [%ld].\n", (long)ShmDispenser->gun_info.setBreatheLedTiming.set_Led_Action_Connected_Fade_In);
+								DEBUG_INFO("MCU set breathe led timing : Connected Fade out [%ld].\n", (long)ShmDispenser->gun_info.setBreatheLedTiming.set_Led_Action_Connected_Fade_Out);
+							}
+							break;
+						case 8:
+							if(ShmDispenser->gun_info.isSetLedBrightness == ON)
+							{
+								DEBUG_INFO("===========================================\n");
+								DEBUG_INFO("==== Normal priority polling : Case 19 ====\n");
+								DEBUG_INFO("===========================================\n");
+								DEBUG_INFO("MCU set led brightness Sector 01 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_1);
+								DEBUG_INFO("MCU set led brightness Sector 02 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_2);
+								DEBUG_INFO("MCU set led brightness Sector 03 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_3);
+								DEBUG_INFO("MCU set led brightness Sector 04 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_4);
+								DEBUG_INFO("MCU set led brightness Sector 05 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_5);
+								DEBUG_INFO("MCU set led brightness Sector 06 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_6);
+								DEBUG_INFO("MCU set led brightness Sector 07 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_7);
+								DEBUG_INFO("MCU set led brightness Sector 08 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_8);
+								DEBUG_INFO("MCU set led brightness Sector 09 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_9);
+								DEBUG_INFO("MCU set led brightness Sector 10 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_10);
+								DEBUG_INFO("MCU set led brightness Sector 11 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_11);
+								DEBUG_INFO("MCU set led brightness Sector 12 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_12);
+							}
+							break;
+						default:
+							logIndex = 0;
+
+							break;
+					}
+
+					logIndex++;
+				}
+			}
+
+			usleep(100000);
+		}
+		exit(0);
+	}
+
 	for(;;)
 	{
 		/*
@@ -2134,201 +2474,7 @@ int main(void)
 					failCount = FAIL_SPEC_COMM;
 			}
 
-			//==========================================================
-			// High priority polling log print out
-			//==========================================================
-			if((current_timestamp() - tsPrintLog[PRIORITY_HIGH]) > (ShmDispenser->gun_info.legacyRequest.isLegacyRequest?3000:6000))
-			{
-				tsPrintLog[PRIORITY_HIGH] = current_timestamp();
-
-				//===============================
-				// Config primary MCU LED
-				//===============================
-				if((previousCharger.gun_info.primaryMcuLed.mode != ShmDispenser->gun_info.primaryMcuLed.mode) ||
-				   (previousCharger.gun_info.primaryMcuLed.alarm_code != ShmDispenser->gun_info.primaryMcuLed.alarm_code))
-				{
-					DEBUG_INFO("*******************************************\n");
-					DEBUG_INFO("***** High priority polling : Case 1 ******\n");
-					DEBUG_INFO("*******************************************\n");
-					DEBUG_INFO("MCU set Led mode : %d\n", ShmDispenser->gun_info.primaryMcuLed.mode);
-					DEBUG_INFO("MCU set Alarm code : %x\n", ShmDispenser->gun_info.primaryMcuLed.alarm_code);
-
-					previousCharger.gun_info.primaryMcuLed.mode = ShmDispenser->gun_info.primaryMcuLed.mode;
-					previousCharger.gun_info.primaryMcuLed.alarm_code = ShmDispenser->gun_info.primaryMcuLed.alarm_code;
-				}
-
-				//===============================
-				// Config primary Legacy request
-				//===============================
-				if(previousCharger.gun_info.legacyRequest.isLegacyRequest != ShmDispenser->gun_info.legacyRequest.isLegacyRequest)
-				{
-					DEBUG_INFO("*******************************************\n");
-					DEBUG_INFO("***** High priority polling : Case 2 ******\n");
-					DEBUG_INFO("*******************************************\n");
-					DEBUG_INFO("MCU set relay request : %d\n", ShmDispenser->gun_info.legacyRequest.isLegacyRequest);
-
-					previousCharger.gun_info.legacyRequest.isLegacyRequest = ShmDispenser->gun_info.legacyRequest.isLegacyRequest;
-				}
-
-				//===============================
-				// Query primary MCU status
-				//===============================
-				if((previousCharger.gun_info.primaryMcuState.cp_state != ShmDispenser->gun_info.primaryMcuState.cp_state) ||
-				   (previousCharger.gun_info.primaryMcuState.current_limit != ShmDispenser->gun_info.primaryMcuState.current_limit) ||
-				   (previousCharger.gun_info.primaryMcuState.relay_state != ShmDispenser->gun_info.primaryMcuState.relay_state) ||
-				   (previousCharger.gun_info.primaryMcuState.socket_e.isSocketEMode != ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEMode) ||
-				   (previousCharger.gun_info.primaryMcuState.socket_e.isSocketEPinOn != ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEPinOn))
-				{
-					DEBUG_INFO("*******************************************\n");
-					DEBUG_INFO("***** High priority polling : Case 3 ******\n");
-					DEBUG_INFO("*******************************************\n");
-					DEBUG_INFO("MCU get Pilot State : %d\n", ShmDispenser->gun_info.primaryMcuState.cp_state);
-					DEBUG_INFO("MCU get Pilot Duty : %.2f\n", (float)ShmDispenser->gun_info.primaryMcuState.current_limit);
-					DEBUG_INFO("MCU get Pilot Voltage Positive : %.2f\n", ShmDispenser->gun_info.primaryMcuState.cp_voltage_positive);
-					DEBUG_INFO("MCU get Pilot Voltage Negative : %.2f\n", ShmDispenser->gun_info.primaryMcuState.cp_voltage_negtive);
-
-					if(ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEPinOn == ON)
-						DEBUG_INFO("Relay on mode : CHARGING_MODE_SOCKETE. \n");
-					else
-						DEBUG_INFO("Relay on mode : CHARGING_MODE_BS / CHARGING_MODE_HLC. \n");
-
-					DEBUG_INFO("MCU get Relay State : %d\n", ShmDispenser->gun_info.primaryMcuState.relay_state);
-					DEBUG_INFO("MCU get Rating Current : %.2f\n", (float)ShmDispenser->gun_info.primaryMcuState.rating_current);
-					DEBUG_INFO("MCU get Rotary switch : %d\n", ShmDispenser->gun_info.primaryMcuState.rotatory_switch);
-					DEBUG_INFO("MCU get is on Socket-E mode : %d\n", ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEMode);
-					DEBUG_INFO("MCU get Socket-E detect pin : %d\n", ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEPinOn);
-
-					//===============================
-					// Query primary MCU power consumption
-					//===============================
-					DEBUG_INFO("*******************************************\n");
-					DEBUG_INFO("***** High priority polling : Case 10 *****\n");
-					DEBUG_INFO("*******************************************\n");
-					DEBUG_INFO("MCU get total power consumption : %f kWh\n",((float)ShmDispenser->gun_info.powerConsumptionTotal.power_consumption/10000.0));
-					DEBUG_INFO("MCU get L1N_L12 power consumption : %f kWh\n",((float)ShmDispenser->gun_info.powerConsumption[0].power_consumption/10000.0));
-					if(ShmDispenser->ConfigData.AcPhaseCount == 3)
-					{
-						DEBUG_INFO("MCU get L2N_L23 power consumption : %f kWh\n",((float)ShmDispenser->gun_info.powerConsumption[1].power_consumption/10000.0));
-						DEBUG_INFO("MCU get L3N_L31 power consumption : %f kWh\n",((float)ShmDispenser->gun_info.powerConsumption[2].power_consumption/10000.0));
-					}
-
-					/*
-					DEBUG_INFO("MCU get Locker State : %d\n", ShmDispenser->gun_info.primaryMcuState.locker_state);
-					DEBUG_INFO("MCU get Shutter State : %d\n", ShmDispenser->gun_info.primaryMcuState.shutter_state);
-					DEBUG_INFO("MCU get Meter State : %d\n", ShmDispenser->gun_info.primaryMcuState.meter_state);
-					DEBUG_INFO("MCU get PP State : %d\n", ShmDispenser->gun_info.primaryMcuState.pp_state);
-					*/
-
-					previousCharger.gun_info.primaryMcuState.cp_state = ShmDispenser->gun_info.primaryMcuState.cp_state;
-					previousCharger.gun_info.primaryMcuState.current_limit = ShmDispenser->gun_info.primaryMcuState.current_limit;
-					previousCharger.gun_info.primaryMcuState.relay_state = ShmDispenser->gun_info.primaryMcuState.relay_state;
-					previousCharger.gun_info.primaryMcuState.socket_e.isSocketEMode = ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEMode;
-					previousCharger.gun_info.primaryMcuState.socket_e.isSocketEPinOn = ShmDispenser->gun_info.primaryMcuState.socket_e.isSocketEPinOn;
-				}
-
-				//===============================
-				// Query primary MCU Alarm code
-				//===============================
-				if((previousCharger.gun_info.primaryMcuAlarm.InputAlarmCode != ShmDispenser->gun_info.primaryMcuAlarm.InputAlarmCode))
-				{
-					if((ShmDispenser->gun_info.primaryMcuAlarm.InputAlarmCode>0))
-					{
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("***** High priority polling : Case 4 ******\n");
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("MCU get OVP_L1 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OVP_L1);
-						DEBUG_INFO("MCU get UVP_L1 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.UVP_L1);
-						DEBUG_INFO("MCU get OCP_L1 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OCP_L1);
-						if(ShmDispenser->ConfigData.AcPhaseCount == 3)
-						{
-							DEBUG_INFO("MCU get OVP_L2 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OVP_L2);
-							DEBUG_INFO("MCU get UVP_L2 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.UVP_L2);
-							DEBUG_INFO("MCU get OCP_L2 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OCP_L2);
-							DEBUG_INFO("MCU get OVP_L3 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OVP_L3);
-							DEBUG_INFO("MCU get UVP_L3 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.UVP_L3);
-							DEBUG_INFO("MCU get OCP_L3 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OCP_L3);
-						}
-						DEBUG_INFO("MCU get OTP : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.OTP);
-						DEBUG_INFO("MCU get gmi_fault : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.gmi_fault);
-						DEBUG_INFO("MCU get cp_fault : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.cp_fault);
-						DEBUG_INFO("MCU get ac_leak : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.ac_leak);
-						DEBUG_INFO("MCU get dc_leak : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.dc_leak);
-						DEBUG_INFO("MCU get mcu_selftest_fail : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.mcu_selftest_fail);
-						DEBUG_INFO("MCU get handshaking_timeout : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.handshaking_timeout);
-						DEBUG_INFO("MCU get emergency_stop : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.emergency_stop);
-						DEBUG_INFO("MCU get relay_welding : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.relay_welding);
-						DEBUG_INFO("MCU get leak_module_fail : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.leak_module_fail);
-						DEBUG_INFO("MCU get shutter_fault : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.shutter_fault);
-						DEBUG_INFO("MCU get locker_fault : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.locker_fault);
-						DEBUG_INFO("MCU get power_drop : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.power_drop);
-						DEBUG_INFO("MCU get rotate_switch_fault : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.rotate_switch_fault);
-						DEBUG_INFO("MCU get short_circuit_L1 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.short_circuit_L1);
-						if(ShmDispenser->ConfigData.AcPhaseCount == 3)
-						{
-							DEBUG_INFO("MCU get short_circuit_L2 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.short_circuit_L2);
-							DEBUG_INFO("MCU get short_circuit_L3 : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.short_circuit_L3);
-						}
-						DEBUG_INFO("MCU get relay_drive_fault : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.relay_drive_fault);
-						DEBUG_INFO("MCU get meter_comm_timeout : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.meter_comm_timeout);
-						DEBUG_INFO("MCU get meter_ic_comm_timeout : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.meter_ic_comm_timeout);
-						DEBUG_INFO("MCU get pilot_negative_error : %d\n", ShmDispenser->gun_info.primaryMcuAlarm.bits.pilot_negative_error);
-						DEBUG_INFO("MCU get InputAlarmCode : %x\n", ShmDispenser->gun_info.primaryMcuAlarm.InputAlarmCode);
-					}
-
-					DEBUG_INFO("===========================================\n");
-					DEBUG_INFO("==== Normal priority polling : Case 1 =====\n");
-					DEBUG_INFO("===========================================\n");
-					DEBUG_INFO("MCU get Input voltage L1: %.2f\n", (float)ShmDispenser->gun_info.inputVoltage.L1N_L12);
-					DEBUG_INFO("MCU get PresentChargingVoltage L1: %.2f\n", (float)ShmDispenser->gun_info.inputVoltage.L1N_L12);
-					if(ShmDispenser->ConfigData.AcPhaseCount == 3)
-					{
-						DEBUG_INFO("MCU get Input voltage L2: %f\n", (float)ShmDispenser->gun_info.inputVoltage.L2N_L23);
-						DEBUG_INFO("MCU get PresentChargingVoltage L2: %.2f\n", (float)ShmDispenser->gun_info.inputVoltage.L2N_L23);
-						DEBUG_INFO("MCU get Input voltage L3: %f\n", (float)ShmDispenser->gun_info.inputVoltage.L3N_L31);
-						DEBUG_INFO("MCU get PresentChargingVoltage L3: %.2f\n", (float)ShmDispenser->gun_info.inputVoltage.L3N_L31);
-					}
-
-					previousCharger.gun_info.primaryMcuAlarm.InputAlarmCode = ShmDispenser->gun_info.primaryMcuAlarm.InputAlarmCode;
-				}
-
-				//===============================
-				// Query primary MCU BLE config
-				//===============================
-				if((previousCharger.gun_info.bleConfigData.isLogin != ShmDispenser->gun_info.bleConfigData.isLogin) ||
-				   (previousCharger.gun_info.bleConfigData.isRequestStart != ShmDispenser->gun_info.bleConfigData.isRequestStart) ||
-				   (previousCharger.gun_info.bleConfigData.isRequestStop != ShmDispenser->gun_info.bleConfigData.isRequestStop))
-				{
-					if(ShmDispenser->gun_info.bleConfigData.isLogin == ON)
-					{
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("***** High priority polling : Case 5 ******\n");
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("MCU get isUserLogin : %d\n", ShmDispenser->gun_info.bleConfigData.isLogin);
-						DEBUG_INFO("MCU get isRequestStartCharger : %d\n", ShmDispenser->gun_info.bleConfigData.isRequestStart);
-						DEBUG_INFO("MCU get isRequestStopCharger : %d\n", ShmDispenser->gun_info.bleConfigData.isRequestStop);
-					}
-
-					previousCharger.gun_info.bleConfigData.isLogin = ShmDispenser->gun_info.bleConfigData.isLogin;
-					previousCharger.gun_info.bleConfigData.isRequestStart = ShmDispenser->gun_info.bleConfigData.isRequestStart;
-					previousCharger.gun_info.bleConfigData.isRequestStop = ShmDispenser->gun_info.bleConfigData.isRequestStop;
-				}
 
-				//===============================
-				// Query primary MCU ble login id
-				//===============================
-				if((strcmp((char *)&previousCharger.gun_info.bleLoginCentralId.id,(char *)&ShmDispenser->gun_info.bleLoginCentralId.id) != 0))
-				{
-					if(strcmp((char *)&ShmDispenser->gun_info.bleLoginCentralId.id,"") != 0)
-					{
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("***** High priority polling : Case 6 ******\n");
-						DEBUG_INFO("*******************************************\n");
-						DEBUG_INFO("MCU get ble central id : %s\n", ShmDispenser->gun_info.bleLoginCentralId.id);
-					}
-
-					memcpy(&previousCharger.gun_info.bleLoginCentralId.id, ShmDispenser->gun_info.bleLoginCentralId.id, ARRAY_SIZE(ShmDispenser->gun_info.bleLoginCentralId.id));
-				}
-			}
 		}
 		else
 		{
@@ -2688,140 +2834,6 @@ int main(void)
 					stepIndex = 0;
 					break;
 			}
-
-			//==========================================================
-			// Low priority polling log print out
-			//==========================================================
-			if((current_timestamp() - tsPrintLog[PRIORITY_LOW]) > (ShmDispenser->gun_info.legacyRequest.isLegacyRequest?3000:6000))
-			{
-				tsPrintLog[PRIORITY_LOW] = current_timestamp();
-
-				switch(logIndex)
-				{
-					case 1:
-						if((previousCharger.gun_info.outputCurrent.L1N_L12[0] != ShmDispenser->gun_info.outputCurrent.L1N_L12[0]) ||
-						   (previousCharger.gun_info.outputCurrent.L2N_L23[0] != ShmDispenser->gun_info.outputCurrent.L2N_L23[0]) ||
-						   (previousCharger.gun_info.outputCurrent.L3N_L31[0] != ShmDispenser->gun_info.outputCurrent.L3N_L31[0]))
-						{
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("==== Normal priority polling : Case 3 =====\n");
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("MCU get output current L1: %f\n", (float)ShmDispenser->gun_info.outputCurrent.L1N_L12[0]);
-							if(ShmDispenser->ConfigData.AcPhaseCount == 3)
-							{
-								DEBUG_INFO("MCU get output current L2: %f\n", (float)ShmDispenser->gun_info.outputCurrent.L2N_L23[0]);
-								DEBUG_INFO("MCU get output current L3: %f\n", (float)ShmDispenser->gun_info.outputCurrent.L3N_L31[0]);
-							}
-
-							previousCharger.gun_info.outputCurrent.L1N_L12[0] = ShmDispenser->gun_info.outputCurrent.L1N_L12[0];
-							previousCharger.gun_info.outputCurrent.L2N_L23[0] = ShmDispenser->gun_info.outputCurrent.L2N_L23[0];
-							previousCharger.gun_info.outputCurrent.L3N_L31[0] = ShmDispenser->gun_info.outputCurrent.L3N_L31[0];
-						}
-
-						break;
-					case 2:
-						if(previousCharger.gun_info.gunPluginTimes.GunPluginTimes != ShmDispenser->gun_info.gunPluginTimes.GunPluginTimes)
-						{
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("==== Normal priority polling : Case 5 =====\n");
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("MCU get gun plugin times : %ld\n", (long)ShmDispenser->gun_info.gunPluginTimes.GunPluginTimes);
-
-							previousCharger.gun_info.gunPluginTimes.GunPluginTimes = ShmDispenser->gun_info.gunPluginTimes.GunPluginTimes;
-						}
-
-						break;
-					case 3:
-						if(previousCharger.gun_info.temperature.point[0] != ShmDispenser->gun_info.temperature.point[0])
-						{
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("==== Normal priority polling : Case 7 =====\n");
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("MCU get temperature : %d\n", ShmDispenser->gun_info.temperature.point[0]);
-
-							previousCharger.gun_info.temperature.point[0] = ShmDispenser->gun_info.temperature.point[0];
-						}
-
-						break;
-					case 4:
-						if(previousCharger.gun_info.primaryMcuCp_Pwn_Duty.max_current != ShmDispenser->gun_info.primaryMcuCp_Pwn_Duty.max_current)
-						{
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("==== Normal priority polling : Case 9 =====\n");
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("MCU set cp pwn duty : %d\n", ShmDispenser->gun_info.primaryMcuCp_Pwn_Duty.max_current);
-
-							previousCharger.gun_info.primaryMcuCp_Pwn_Duty.max_current = ShmDispenser->gun_info.primaryMcuCp_Pwn_Duty.max_current;
-						}
-
-						break;
-					case 5:
-						DEBUG_INFO("===========================================\n");
-						DEBUG_INFO("==== Normal priority polling : Case 11 ====\n");
-						DEBUG_INFO("===========================================\n");
-						if(ShmDispenser->gun_info.bleConfigData.isLogin && !ShmDispenser->isConnectedBackend)
-						{
-							DEBUG_INFO("Sync from MCU rtc OK...%04d-%02d-%02d %02d:%02d:%02d\n", ShmDispenser->gun_info.rtc.year,
-																								ShmDispenser->gun_info.rtc.month,
-																								ShmDispenser->gun_info.rtc.day,
-																								ShmDispenser->gun_info.rtc.hour,
-																								ShmDispenser->gun_info.rtc.min,
-																								ShmDispenser->gun_info.rtc.sec);
-						}
-						else
-						{
-							DEBUG_INFO("MCU set rtc OK...%04d-%02d-%02d %02d:%02d:%02d\n", ShmDispenser->gun_info.rtc.year,
-																							ShmDispenser->gun_info.rtc.month,
-																							ShmDispenser->gun_info.rtc.day,
-																							ShmDispenser->gun_info.rtc.hour,
-																							ShmDispenser->gun_info.rtc.min,
-																							ShmDispenser->gun_info.rtc.sec);
-						}
-						break;
-					case 6:
-						break;
-					case 7:
-						if(ShmDispenser->gun_info.isSetBreatheLedTiming == ON)
-						{
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("==== Normal priority polling : Case 17 ====\n");
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("MCU set breathe led timing : Authed Fade in [%ld].\n", (long)ShmDispenser->gun_info.setBreatheLedTiming.set_Led_Action_Authed_Fade_In);
-							DEBUG_INFO("MCU set breathe led timing : Authed Fade out [%ld].\n", (long)ShmDispenser->gun_info.setBreatheLedTiming.set_Led_Action_Authed_Fade_Out);
-							DEBUG_INFO("MCU set breathe led timing : Charging Fade in [%ld].\n", (long)ShmDispenser->gun_info.setBreatheLedTiming.Set_Led_Action_Chaging_Fade_In);
-							DEBUG_INFO("MCU set breathe led timing : Charging Fade out [%ld].\n", (long)ShmDispenser->gun_info.setBreatheLedTiming.set_Led_Action_Chaging_Fade_Out);
-							DEBUG_INFO("MCU set breathe led timing : Connected Fade in [%ld].\n", (long)ShmDispenser->gun_info.setBreatheLedTiming.set_Led_Action_Connected_Fade_In);
-							DEBUG_INFO("MCU set breathe led timing : Connected Fade out [%ld].\n", (long)ShmDispenser->gun_info.setBreatheLedTiming.set_Led_Action_Connected_Fade_Out);
-						}
-						break;
-					case 8:
-						if(ShmDispenser->gun_info.isSetLedBrightness == ON)
-						{
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("==== Normal priority polling : Case 19 ====\n");
-							DEBUG_INFO("===========================================\n");
-							DEBUG_INFO("MCU set led brightness Sector 01 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_1);
-							DEBUG_INFO("MCU set led brightness Sector 02 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_2);
-							DEBUG_INFO("MCU set led brightness Sector 03 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_3);
-							DEBUG_INFO("MCU set led brightness Sector 04 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_4);
-							DEBUG_INFO("MCU set led brightness Sector 05 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_5);
-							DEBUG_INFO("MCU set led brightness Sector 06 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_6);
-							DEBUG_INFO("MCU set led brightness Sector 07 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_7);
-							DEBUG_INFO("MCU set led brightness Sector 08 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_8);
-							DEBUG_INFO("MCU set led brightness Sector 09 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_9);
-							DEBUG_INFO("MCU set led brightness Sector 10 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_10);
-							DEBUG_INFO("MCU set led brightness Sector 11 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_11);
-							DEBUG_INFO("MCU set led brightness Sector 12 : [%x].\n", ShmDispenser->gun_info.setLedBrightness.sector_12);
-						}
-						break;
-					default:
-						logIndex = 0;
-
-						break;
-				}
-
-				logIndex++;
-			}
 		}
 		stepIndex++;
 

+ 16 - 6
EVSE/Projects/AX80/Apps/main.c

@@ -4706,7 +4706,7 @@ void checkStopReason(uint8_t gun_index)
 		{
 			sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EmergencyStop");
 		}
-		else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
+		else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) || (ShmCharger->gun_info[gun_index].isGunUnpluggedBefore == YES))
 		{
 			sprintf((char*)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
 			memcpy((char*)ShmOCPP16Data->StopTransaction[gun_index].IdTag, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmOCPP16Data->StopTransaction[gun_index].IdTag));
@@ -4764,7 +4764,7 @@ void checkStopReason(uint8_t gun_index)
 		{
 			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "EmergencyStop");
 		}
-		else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)
+		else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A) || (ShmCharger->gun_info[gun_index].isGunUnpluggedBefore == YES))
 		{
 			sprintf((char*)ShmOCPP20Data->TransactionEvent[gun_index].transactionInfo.stoppedReason, "EVDisconnected");
 			memcpy((char*)ShmOCPP20Data->TransactionEvent[gun_index].idToken.idToken, (char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].StartUserId));
@@ -5607,6 +5607,7 @@ int main(void)
 							setLedMotion(gun_index,LED_ACTION_IDLE);
 							setRelay(gun_index, OFF);
 							setRequest(gun_index,OFF);
+							ShmCharger->gun_info[gun_index].isGunUnpluggedBefore = NO;
 							ShmCharger->gun_info[gun_index].rfidReq = OFF;
 							ShmCharger->gun_info[gun_index].bleConfigData.isRequestStart = OFF;
 							ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop = OFF;
@@ -6011,7 +6012,8 @@ int main(void)
 							refreshStartTimer(&startTime[gun_index][TMR_IDX_CCS_HEARTBEAT_COUNT_RESET]);
 						}
 
-						if((ShmCharger->gun_info[gun_index].rfidReq == ON) ||
+						if((ShmCharger->gun_info[gun_index].isGunUnpluggedBefore == YES) |\
+						   (ShmCharger->gun_info[gun_index].rfidReq == ON) ||
 						   (ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop == ON) ||
 						   ocpp_get_remotestop(gun_index) ||
 						   (ocpp_get_connection_status() && !ocpp_get_starttransaction_result(gun_index)) ||
@@ -6204,7 +6206,8 @@ int main(void)
 						}
 
 						// End authorize pass
-						if(((ShmCharger->gun_info[gun_index].rfidReq == ON) &&isMatchStartUser(gun_index)) ||
+						if((ShmCharger->gun_info[gun_index].isGunUnpluggedBefore == YES) ||
+						   ((ShmCharger->gun_info[gun_index].rfidReq == ON) &&isMatchStartUser(gun_index)) ||
 						   ((ShmCharger->gun_info[gun_index].rfidReq == ON) && ocpp_get_auth_result(YES, gun_index)) ||
 						   (!ocpp_get_connection_status() && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_FREE) && (ShmCharger->gun_info[gun_index].rfidReq == ON)) ||
 						   (!ocpp_get_connection_status() && (isValidLocalWhiteCard() == PASS) && (ShmSysConfigAndInfo->SysConfig.OfflinePolicy == OFF_POLICY_LOCALLIST) && (ShmCharger->gun_info[gun_index].rfidReq == ON)) ||
@@ -6268,7 +6271,8 @@ int main(void)
 							if(!ocpp_get_auth_result(YES, gun_index))
 								ShmCharger->gun_info[gun_index].rfidReq = OFF;
 
-							if((((ShmCharger->gun_info[gun_index].chargingMode != CHARGING_MODE_SOCKETE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C)) || ((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_SOCKETE) && ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn)) &&
+							if((ShmCharger->gun_info[gun_index].isGunUnpluggedBefore == NO) &&
+							   (((ShmCharger->gun_info[gun_index].chargingMode != CHARGING_MODE_SOCKETE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_C)) || ((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_SOCKETE) && ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn)) &&
 							   (ShmCharger->gun_info[gun_index].rfidReq != ON) &&
 							   (ShmCharger->gun_info[gun_index].bleConfigData.isRequestStop != ON)  &&
 							   !ocpp_get_remotestop(gun_index) &&
@@ -6326,12 +6330,18 @@ int main(void)
 						setLedMotion(gun_index,LED_ACTION_ALARM);
 						setRelay(gun_index, OFF);
 
+						if(((ShmCharger->gun_info[gun_index].chargingMode != CHARGING_MODE_SOCKETE) && (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PilotState == CP_STATE_A)) ||
+						   ((ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_SOCKETE) && !ShmCharger->gun_info[gun_index].primaryMcuState.socket_e.isSocketEPinOn) )
+						{
+							ShmCharger->gun_info[gun_index].isGunUnpluggedBefore = YES;
+						}
+
 						/*
 						 * 	TODO:
 						 * 	1. Customize emergency stop and report stop transaction then return to idle mode if error recover.
 						 * 	2. Customer: Bambang
 						 */
-						if((ShmSysConfigAndInfo->SysConfig.ModelName[12] == 'B') &&
+						if(((ShmSysConfigAndInfo->SysConfig.ModelName[12] == 'B') && (ShmSysConfigAndInfo->SysConfig.ModelName[13] == 'B')) &&
 						   (ShmCharger->gun_info[gun_index].systemAlarmCode.SystemAlarmCode == ALARM_EMERGENCY_STOP))
 						{
 							if(((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PreviousSystemStatus == SYS_MODE_TERMINATING)) &&

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

@@ -794,6 +794,7 @@ typedef struct GUN_INFO
 	uint32_t										isUpgradeReq:1;
 	uint32_t										isUpgradeEnd:1;
 	uint32_t										isUpgradePASS:1;
+	uint32_t										isGunUnpluggedBefore:1;
 	uint32_t										isEmergencyStopReport:1;
 }Gun_Info;