Selaa lähdekoodia

2021-12-03 / Wendell

Actions
1. [add] DC input ovp function
2. [add] query psu input voltage
3. [fix] 042267 can not recovery when dispenser change state too fast

Files
1. As follow commit history

Image version : V1.06.XX.XXXX.XX
Wendell 3 vuotta sitten
vanhempi
commit
9fd61a46df

+ 266 - 809
EVSE/Projects/DO360/Apps/Module_InternalComm.c

@@ -74,6 +74,9 @@ Connector_GFD                   *LocaltionGfd[MAX_GROUP_QUANTITY];
 #define VIN_MIN_VOLTAGE_UL          210	// 小於該值 : UVP
 #define VIN_MIN_REV_VOLTAGE_UL      220 // 大於賦歸 UVP
 
+#define DCIN_OVP_THRESHOLD_VOL      825 // dc input ovp threshold voltage
+#define DCIN_OVP_RECOVERY_VOL       815 // dc input ovp recovery voltage
+
 #define VIN_DROP_VOLTAGE	150	// 小於該值 : ac drop
 
 #define VOUT_MAX_VOLTAGE	995
@@ -128,6 +131,7 @@ struct timespec _checkOutputNoneMatchTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_
 bool _isRelayWelding[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 struct timespec _checkRelayWeldingTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
+byte _dcOvpCnt = 0;
 byte _threePhaseOvp[3] = {0, 0, 0};
 byte _threePhaseUvp[3] = {0, 0, 0};
 
@@ -137,16 +141,9 @@ int Uart5Fd;
 char *relayRs485PortName = "/dev/ttyS5";
 unsigned short fanSpeedSmoothValue = 500;
 
-//struct timeval _close_ac_contactor;
-
 struct timespec _priority_time;
 struct timespec _led_priority_time;
 
-//struct timeval	_ac_charging_comp;
-//struct timeval	_ac_preparing;
-//struct timeb 	_ac_startChargingTime;
-//struct timeb 	_ac_endChargingTime;
-
 unsigned short _setFanSpeed = 0;
 float _beforeChargingTotalEnergy = 0.0;
 byte _checkLedChanged = 3;
@@ -155,6 +152,7 @@ bool _isGfdEnable = false;
 
 Ver ver;
 PresentInputVoltage inputVoltage;
+DCInputVoltage dcInputVoltage;
 PresentOutputVoltage outputVoltage;
 FanSpeed fanSpeed;
 Temperature temperature;
@@ -170,12 +168,6 @@ Rtc rtc;
 Led_Color cur_led_color;
 Led_Color led_color;
 
-Ac_Status acStatus;
-Ac_Led_Status ledStatus;
-Ac_Alarm_code acAlarmCode;
-Ac_Charging_energy acChargingEnergy;
-Ac_Charging_current acChargingCurrent;
-
 #define AC_OVP						1
 #define AC_UVP						2
 #define AC_OCP						4
@@ -417,274 +409,300 @@ void GetPresentInputVol()
 {
     if(ShmChargerInfo->Control.RelayCtrl.bits.AcInputDisable == YES)
     {
-        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
-        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
-        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
-        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
-        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
-        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
-        return;
+        if(Query_DC_InputVoltage(Uart5Fd, Addr.DO360_RC1, &dcInputVoltage) == PASS)
+        {
+            ShmSysConfigAndInfo->SysInfo.InputVoltageDc = dcInputVoltage.DC_Input_1;
+
+            if(ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DcInputOVP == NO)
+            {
+                if(dcInputVoltage.DC_Input_1 > DCIN_OVP_THRESHOLD_VOL)
+                {
+                    _dcOvpCnt++;
+                    if(_dcOvpCnt >= OVP_UVP_CHK_COUNT)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DcInputOVP = YES;
+                        LOG_INFO("Dc Input OVP: %.1f V", dcInputVoltage.DC_Input_1);
+                    }
+                }
+                else
+                {
+                    _dcOvpCnt = 0;
+                }
+            }
+            else
+            {
+                if(dcInputVoltage.DC_Input_1 < DCIN_OVP_RECOVERY_VOL)
+                {
+                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DcInputOVP = NO;
+                    LOG_INFO("Dc Input OVP Recovery: %.1f V", dcInputVoltage.DC_Input_1);
+                }
+                _dcOvpCnt = 0;
+            }
+        }
     }
-	if (Query_Present_InputVoltage(Uart5Fd, Addr.DO360_RC1, &inputVoltage) == PASS)
-	{
-		// resolution : 0.1
-		ShmSysConfigAndInfo->SysInfo.InputVoltageR = ShmRelayModuleData[0]->InputL1Volt = inputVoltage.L1N_L12;
-		ShmSysConfigAndInfo->SysInfo.InputVoltageS = ShmRelayModuleData[0]->InputL2Volt = inputVoltage.L2N_L23;
-		ShmSysConfigAndInfo->SysInfo.InputVoltageT = ShmRelayModuleData[0]->InputL3Volt = inputVoltage.L3N_L31;
-
-		//********************************************************************************************************//
-		// Vin (UVP)
-		if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
-		{
-		    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == NO)
-		    {
-                if (inputVoltage.L1N_L12 <= VIN_MIN_VOLTAGE_IEC)
+    else
+    {
+        if (Query_Present_InputVoltage(Uart5Fd, Addr.DO360_RC1, &inputVoltage) == PASS)
+        {
+            // resolution : 0.1
+            ShmSysConfigAndInfo->SysInfo.InputVoltageR = ShmRelayModuleData[0]->InputL1Volt = inputVoltage.L1N_L12;
+            ShmSysConfigAndInfo->SysInfo.InputVoltageS = ShmRelayModuleData[0]->InputL2Volt = inputVoltage.L2N_L23;
+            ShmSysConfigAndInfo->SysInfo.InputVoltageT = ShmRelayModuleData[0]->InputL3Volt = inputVoltage.L3N_L31;
+
+            //********************************************************************************************************//
+            // Vin (UVP)
+            if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
+            {
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == NO)
                 {
-                    LOG_INFO("In Uvp L1N_L12 = %f", inputVoltage.L1N_L12);
-                    if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT)
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
-                    else
-                        _threePhaseUvp[0] += 1;
+                    if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_IEC)
+                    {
+                        LOG_INFO("In Uvp L1N_L12 = %f", inputVoltage.L1N_L12);
+                        if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT)
+                            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
+                        else
+                            _threePhaseUvp[0] += 1;
+                    }
+                }
+                else
+                {
+                    if (inputVoltage.L1N_L12 > VIN_MIN_REV_VOLTAGE_IEC)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
+                        _threePhaseUvp[0] = 0;
+                    }
                 }
-		    }
-			else
-			{
-			    if (inputVoltage.L1N_L12 >= VIN_MIN_REV_VOLTAGE_IEC)
-			    {
-                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
-                    _threePhaseUvp[0] = 0;
-			    }
-			}
 
-		    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == NO)
-		    {
-                if (inputVoltage.L2N_L23 <= VIN_MIN_VOLTAGE_IEC)
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == NO)
                 {
-                    LOG_INFO("In Uvp L2N_L23 = %f", inputVoltage.L2N_L23);
-                    if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT)
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
-                    else
-                        _threePhaseUvp[1] += 1;
+                    if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_IEC)
+                    {
+                        LOG_INFO("In Uvp L2N_L23 = %f", inputVoltage.L2N_L23);
+                        if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT)
+                            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
+                        else
+                            _threePhaseUvp[1] += 1;
+                    }
+                }
+                else
+                {
+                    if (inputVoltage.L2N_L23 > VIN_MIN_REV_VOLTAGE_IEC)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
+                        _threePhaseUvp[1] = 0;
+                    }
                 }
-		    }
-			else
-			{
-			    if (inputVoltage.L2N_L23 >= VIN_MIN_REV_VOLTAGE_IEC)
-			    {
-                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
-                    _threePhaseUvp[1] = 0;
-			    }
-			}
 
-		    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == NO)
-		    {
-                if (inputVoltage.L3N_L31 <= VIN_MIN_VOLTAGE_IEC)
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == NO)
                 {
-                    LOG_INFO("In Uvp L3N_L31 = %f", inputVoltage.L3N_L31);
-                    if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT)
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
-                    else
-                        _threePhaseUvp[2] += 1;
+                    if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_IEC)
+                    {
+                        LOG_INFO("In Uvp L3N_L31 = %f", inputVoltage.L3N_L31);
+                        if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT)
+                            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
+                        else
+                            _threePhaseUvp[2] += 1;
+                    }
                 }
-		    }
-			else
-			{
-			    if (inputVoltage.L3N_L31 >= VIN_MIN_REV_VOLTAGE_IEC)
-			    {
-                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
-                    _threePhaseUvp[2] = 0;
-			    }
-			}
-		}
-		else if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_UL)
-		{
-		    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == NO)
-		    {
-                if (inputVoltage.L1N_L12 <= VIN_MIN_VOLTAGE_UL)
+                else
                 {
-                    LOG_INFO("In Uvp L1N_L12 = %f", inputVoltage.L1N_L12);
-                    if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT)
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
-                    else
-                        _threePhaseUvp[0] += 1;
+                    if (inputVoltage.L3N_L31 > VIN_MIN_REV_VOLTAGE_IEC)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
+                        _threePhaseUvp[2] = 0;
+                    }
+                }
+            }
+            else if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_UL)
+            {
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == NO)
+                {
+                    if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_UL)
+                    {
+                        LOG_INFO("In Uvp L1N_L12 = %f", inputVoltage.L1N_L12);
+                        if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT)
+                            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = YES;
+                        else
+                            _threePhaseUvp[0] += 1;
+                    }
+                }
+                else
+                {
+                    if (inputVoltage.L1N_L12 > VIN_MIN_REV_VOLTAGE_UL)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
+                        _threePhaseUvp[0] = 0;
+                    }
                 }
-		    }
-			else
-			{
-			    if (inputVoltage.L1N_L12 >= VIN_MIN_REV_VOLTAGE_UL)
-			    {
-                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP = NO;
-                    _threePhaseUvp[0] = 0;
-			    }
-			}
 
-		    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == NO)
-		    {
-                if (inputVoltage.L2N_L23 <= VIN_MIN_VOLTAGE_UL)
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == NO)
                 {
-                    LOG_INFO("In Uvp L2N_L23 = %f", inputVoltage.L2N_L23);
-                    if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT)
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
-                    else
-                        _threePhaseUvp[1] += 1;
+                    if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_UL)
+                    {
+                        LOG_INFO("In Uvp L2N_L23 = %f", inputVoltage.L2N_L23);
+                        if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT)
+                            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = YES;
+                        else
+                            _threePhaseUvp[1] += 1;
+                    }
+                }
+                else
+                {
+                    if (inputVoltage.L2N_L23 > VIN_MIN_REV_VOLTAGE_UL)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
+                        _threePhaseUvp[1] = 0;
+                    }
                 }
-		    }
-			else
-			{
-			    if (inputVoltage.L2N_L23 >= VIN_MIN_REV_VOLTAGE_UL)
-			    {
-                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP = NO;
-                    _threePhaseUvp[1] = 0;
-			    }
-			}
 
-		    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == NO)
-		    {
-                if (inputVoltage.L3N_L31 <= VIN_MIN_VOLTAGE_UL)
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == NO)
                 {
-                    LOG_INFO("In Uvp L3N_L31 = %f", inputVoltage.L3N_L31);
-                    if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT)
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
-                    else
-                        _threePhaseUvp[2] += 1;
+                    if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_UL)
+                    {
+                        LOG_INFO("In Uvp L3N_L31 = %f", inputVoltage.L3N_L31);
+                        if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT)
+                            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = YES;
+                        else
+                            _threePhaseUvp[2] += 1;
+                    }
                 }
-		    }
-			else
-			{
-			    if (inputVoltage.L3N_L31 >= VIN_MIN_REV_VOLTAGE_UL)
-			    {
-                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
-                    _threePhaseUvp[2] = 0;
-			    }
-			}
-		}
-		//********************************************************************************************************//
-		// Vin (OVP)
-		if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
-		{
-		    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == NO)
-		    {
-                if (inputVoltage.L1N_L12 >= VIN_MAX_VOLTAGE_IEC)
+                else
                 {
-                    LOG_INFO("In Ovp L1N_L12 = %f", inputVoltage.L1N_L12);
-                    if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT)
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
-                    else
-                        _threePhaseOvp[0] += 1;
+                    if (inputVoltage.L3N_L31 > VIN_MIN_REV_VOLTAGE_UL)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
+                        _threePhaseUvp[2] = 0;
+                    }
+                }
+            }
+            //********************************************************************************************************//
+            // Vin (OVP)
+            if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC)
+            {
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == NO)
+                {
+                    if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_IEC)
+                    {
+                        LOG_INFO("In Ovp L1N_L12 = %f", inputVoltage.L1N_L12);
+                        if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT)
+                            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
+                        else
+                            _threePhaseOvp[0] += 1;
+                    }
+                }
+                else
+                {
+                    if (inputVoltage.L1N_L12 < VIN_MAX_REV_VOLTAGE_IEC)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
+                        _threePhaseOvp[0] = 0;
+                    }
                 }
-		    }
-			else
-			{
-			    if (inputVoltage.L1N_L12 <= VIN_MAX_REV_VOLTAGE_IEC)
-			    {
-                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
-                    _threePhaseOvp[0] = 0;
-			    }
-			}
 
-		    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == NO)
-		    {
-                if (inputVoltage.L2N_L23 >= VIN_MAX_VOLTAGE_IEC)
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == NO)
                 {
-                    LOG_INFO("In Ovp L2N_L23 = %f", inputVoltage.L2N_L23);
-                    if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT)
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
-                    else
-                        _threePhaseOvp[1] += 1;
+                    if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_IEC)
+                    {
+                        LOG_INFO("In Ovp L2N_L23 = %f", inputVoltage.L2N_L23);
+                        if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT)
+                            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
+                        else
+                            _threePhaseOvp[1] += 1;
+                    }
+                }
+                else
+                {
+                    if (inputVoltage.L2N_L23 < VIN_MAX_REV_VOLTAGE_IEC)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
+                        _threePhaseOvp[1] = 0;
+                    }
                 }
-		    }
-			else
-			{
-			    if (inputVoltage.L2N_L23 <= VIN_MAX_REV_VOLTAGE_IEC)
-			    {
-                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
-                    _threePhaseOvp[1] = 0;
-			    }
-			}
 
-		    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == NO)
-		    {
-                if (inputVoltage.L3N_L31 >= VIN_MAX_VOLTAGE_IEC)
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == NO)
                 {
-                    LOG_INFO("In Ovp L3N_L31 = %f", inputVoltage.L3N_L31);
-                    if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT)
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = YES;
-                    else
-                        _threePhaseOvp[2] += 1;
+                    if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_IEC)
+                    {
+                        LOG_INFO("In Ovp L3N_L31 = %f", inputVoltage.L3N_L31);
+                        if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT)
+                            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = YES;
+                        else
+                            _threePhaseOvp[2] += 1;
+                    }
                 }
-		    }
-			else
-			{
-			    if (inputVoltage.L3N_L31 <= VIN_MAX_REV_VOLTAGE_IEC)
-			    {
-                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
-                    _threePhaseOvp[2] = 0;
-			    }
-			}
-		}
-		else if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_UL)
-		{
-		    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == NO)
-		    {
-                if (inputVoltage.L1N_L12 >= VIN_MAX_VOLTAGE_UL)
+                else
                 {
-                    LOG_INFO("In Ovp L1N_L12 = %f", inputVoltage.L1N_L12);
-                    if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT)
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
-                    else
-                        _threePhaseOvp[0] += 0;
+                    if (inputVoltage.L3N_L31 < VIN_MAX_REV_VOLTAGE_IEC)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
+                        _threePhaseOvp[2] = 0;
+                    }
+                }
+            }
+            else if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_UL)
+            {
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == NO)
+                {
+                    if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_UL)
+                    {
+                        LOG_INFO("In Ovp L1N_L12 = %f", inputVoltage.L1N_L12);
+                        if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT)
+                            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = YES;
+                        else
+                            _threePhaseOvp[0] += 0;
+                    }
+                }
+                else
+                {
+                    if (inputVoltage.L1N_L12 < VIN_MAX_REV_VOLTAGE_UL)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
+                        _threePhaseOvp[0] = 0;
+                    }
                 }
-		    }
-			else
-			{
-			    if (inputVoltage.L1N_L12 <= VIN_MAX_REV_VOLTAGE_UL)
-			    {
-                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP = NO;
-                    _threePhaseOvp[0] = 0;
-			    }
-			}
 
-		    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == NO)
-		    {
-                if (inputVoltage.L2N_L23 >= VIN_MAX_VOLTAGE_UL)
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == NO)
                 {
-                    LOG_INFO("In Ovp L2N_L23 = %f", inputVoltage.L2N_L23);
-                    if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT)
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
-                    else
-                        _threePhaseOvp[1] += 0;
+                    if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_UL)
+                    {
+                        LOG_INFO("In Ovp L2N_L23 = %f", inputVoltage.L2N_L23);
+                        if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT)
+                            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = YES;
+                        else
+                            _threePhaseOvp[1] += 0;
+                    }
+                }
+                else
+                {
+                    if (inputVoltage.L2N_L23 < VIN_MAX_REV_VOLTAGE_UL)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
+                        _threePhaseOvp[1] = 0;
+                    }
                 }
-		    }
-			else
-			{
-			    if (inputVoltage.L2N_L23 <= VIN_MAX_REV_VOLTAGE_UL)
-			    {
-                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP = NO;
-                    _threePhaseOvp[1] = 0;
-			    }
-			}
 
-		    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == NO)
-		    {
-                if (inputVoltage.L3N_L31 >= VIN_MAX_VOLTAGE_UL)
+                if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == NO)
                 {
-                    LOG_INFO("In Ovp L3N_L31 = %f", inputVoltage.L3N_L31);
-                    if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT)
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = YES;
-                    else
-                        _threePhaseOvp[2] += 1;
+                    if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_UL)
+                    {
+                        LOG_INFO("In Ovp L3N_L31 = %f", inputVoltage.L3N_L31);
+                        if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT)
+                            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = YES;
+                        else
+                            _threePhaseOvp[2] += 1;
+                    }
                 }
-		    }
-			else
-			{
-			    if (inputVoltage.L3N_L31 <= VIN_MAX_REV_VOLTAGE_UL)
-			    {
-                    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
-                    _threePhaseOvp[2] = 0;
-			    }
-			}
-		}
-	}
+                else
+                {
+                    if (inputVoltage.L3N_L31 < VIN_MAX_REV_VOLTAGE_UL)
+                    {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
+                        _threePhaseOvp[2] = 0;
+                    }
+                }
+            }
+        }
+    }
 }
 
 // 左右槍的 Relay 前後的輸出電壓
@@ -847,58 +865,6 @@ void CheckK1K2RelayOutput(byte index)
             _chargingData[index]->RelayK1K2Status = LocationRelayCtrl[location]->bits.Gun_N ? YES : NO;
         }
     }
-#if 0
-    if(ShmChargerInfo->Control.SysCtrl.bits.SecondRelayBoardEnable)
-    {
-        // two relay board
-        if (index == 0)
-        {
-            if (regRelay[0].relay_event.bits.Gun1_N == YES && regRelay[0].relay_event.bits.Gun1_P == YES)
-                _chargingData[index]->RelayK1K2Status = YES;
-            else
-                _chargingData[index]->RelayK1K2Status = NO;
-        }
-        else if (index == 1)
-        {
-            if (regRelay[1].relay_event.bits.Gun2_N == YES && regRelay[1].relay_event.bits.Gun2_P == YES)
-                _chargingData[index]->RelayK1K2Status = YES;
-            else
-                _chargingData[index]->RelayK1K2Status = NO;
-        }
-
-        if (regRelay[0].relay_event.bits.Gun1_Parallel_N == YES && regRelay[0].relay_event.bits.Gun1_Parallel_P == YES &&
-            regRelay[0].relay_event.bits.Gun2_Parallel_N == YES && regRelay[0].relay_event.bits.Gun2_Parallel_P == YES &&
-            regRelay[1].relay_event.bits.Gun1_Parallel_N == YES && regRelay[1].relay_event.bits.Gun1_Parallel_P == YES)
-            ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = YES;
-        else
-            ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = NO;
-    }
-    else
-    {
-        // only one relay board
-        if (index == 0)
-        {
-            if (regRelay[0].relay_event.bits.Gun1_N == YES && regRelay[0].relay_event.bits.Gun1_P == YES)
-                _chargingData[index]->RelayK1K2Status = YES;
-            else
-                _chargingData[index]->RelayK1K2Status = NO;
-        }
-        else if (index == 1)
-        {
-            if (regRelay[0].relay_event.bits.Gun2_N == YES && regRelay[0].relay_event.bits.Gun2_P == YES)
-                _chargingData[index]->RelayK1K2Status = YES;
-            else
-                _chargingData[index]->RelayK1K2Status = NO;
-        }
-
-        if (regRelay[0].relay_event.bits.Gun1_Parallel_N == YES && regRelay[0].relay_event.bits.Gun2_Parallel_N == YES)
-            ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = YES;
-        else
-            ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = NO;
-    }
-//	LOG_INFO("Check Relay Output. index = %d, RelayKPK2Status = %d, BridgeRelayStatus = %d",
-//			index, _chargingData[index]->RelayKPK2Status, ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus);
-#endif
 }
 
 void GetGfdAdc(void)
@@ -974,103 +940,6 @@ void GetGfdAdc(void)
     }
 }
 
-void GetGpioInput()
-{
-	if (Query_Gpio_Input(Uart5Fd, Addr.Aux, &gpio_in) == PASS)
-	{
-		// AC Contactor Status
-		if (gpio_in.AC_MainBreaker == 1)
-		{
-			// AC Main Breaker ON
-			LOG_INFO("RB AC Main Breaker.");
-		}
-
-		if (gpio_in.SPD == 1)
-		{
-			// SPD (雷擊保護) ON
-			LOG_INFO("RB SPD.");
-		}
-
-		if (gpio_in.Door_Open == 1)
-		{
-			// Door Open
-			LOG_INFO("RB Door Open.");
-		}
-
-		if (gpio_in.GFD[0] == 1)
-		{
-			// GFD_1 Trigger
-		}
-
-		if (gpio_in.GFD[1] == 1)
-		{
-			// GFD_2 Trigger
-		}
-
-		if (gpio_in.AC_Drop == 1)
-		{
-			// AC Drop
-			LOG_INFO("RB AC Drop.");
-		}
-
-		if (gpio_in.Emergency_IO == 1)
-		{
-			// Emergency IO ON
-			LOG_INFO("RB Emergency IO ON.");
-		}
-
-		if (gpio_in.Button_Emergency_Press == 1)
-		{
-			// Emergency button Press
-		}
-
-		if (gpio_in.Button_On_Press == 1)
-		{
-			// On button Press
-		}
-
-		if (gpio_in.Button_Off_Press == 1)
-		{
-			// Off button Press
-		}
-
-		if (gpio_in.Key_1_Press == 1)
-		{
-			// key 1 press
-		}
-
-		if (gpio_in.Key_2_Press == 1)
-		{
-			// key 2 press
-		}
-
-		if (gpio_in.Key_3_Press == 1)
-		{
-			// key 3 press
-		}
-
-		if (gpio_in.Key_4_Press == 1)
-		{
-			// key 4 press
-		}
-	}
-}
-
-// 5V 12V 24V 48V
-void GetAuxPower()
-{
-	if (Query_Aux_PowerVoltage(Uart5Fd, Addr.Fan, &auxPower) == PASS)
-	{
-		ShmSysConfigAndInfo->SysInfo.AuxPower48V = auxPower.voltage[0];
-		ShmSysConfigAndInfo->SysInfo.AuxPower24V = auxPower.voltage[1];
-		//ShmSysConfigAndInfo->SysInfo.AuxPower12V = auxPower.voltage[4];
-		//ShmSysConfigAndInfo->SysInfo.AuxPower5V = auxPower.voltage[6];
-		// aux power voltage
-		//LOG_INFO("aux1 = %x,", auxPower.voltage[0]);
-		//LOG_INFO("aux2 = %x,", auxPower.voltage[1]);
-	}
-}
-
 void SetFanModuleSpeed()
 {
 	{
@@ -1327,67 +1196,6 @@ void SetAcContactorStatus(void)
     }
 }
 
-void CheckAlarmOccur()
-{
-	bool isErr = false;
-	for(byte count = 0; count < sizeof(_alarm_code)/sizeof(_alarm_code[0]); count++)
-	{
-		if (acAlarmCode.AcAlarmCode & _alarm_code[count])
-		{
-			isErr = true;
-			switch(_alarm_code[count])
-			{
-			case AC_OVP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcSystemInputOVP = YES; break;
-			case AC_UVP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcSystemInputUVP = YES; break;
-			case AC_OCP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP = YES; break;
-			case AC_OTP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP = YES; break;
-			case AC_GMI_FAULT: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail = YES; break;
-			case AC_CP_ERROR: ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = YES; break;
-			case AC_AC_LEAKAGE: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = YES; break;
-			case AC_DC_LEAKAGE: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = YES; break;
-			case AC_SYSTEM_SELFTEST_FAULT: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail = YES; break;
-			case AC_HANDSHAKE_TIMEOUT: break;
-			//case AC_EMC_STOP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = YES; break;
-			case AC_RELAY_WELDING: ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding = YES; break;
-			case AC_GF_MODULE_FAULT: ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = YES; break;
-			case AC_SHUTTER_FAULT: break;
-			case AC_LOCKER_FAULT: ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = YES; break;
-			case AC_POWER_DROP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = YES; break;
-			case AC_CIRCUIT_SHORT: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort = YES; break;
-			case AC_ROTARY_SWITCH_FAULT: break;
-			case AC_RELAY_DRIVE_FAULT: ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault = YES; break;
-			}
-		}
-		else
-		{
-			switch(_alarm_code[count])
-			{
-			case AC_OVP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcSystemInputOVP = NO; break;
-			case AC_UVP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcSystemInputUVP = NO; break;
-			case AC_OCP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAcOutputOCP = NO; break;
-			case AC_OTP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemAmbientOTP = NO; break;
-			case AC_GMI_FAULT: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.AcGroundfaultFail = NO; break;
-			case AC_CP_ERROR: ShmStatusCodeData->InfoCode.InfoEvents.bits.PilotFault = NO; break;
-			case AC_AC_LEAKAGE: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = NO; break;
-			case AC_DC_LEAKAGE: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.RcdTrip = NO; break;
-			case AC_SYSTEM_SELFTEST_FAULT: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.McuSelftestFail = NO; break;
-			case AC_HANDSHAKE_TIMEOUT: break;
-			//case AC_EMC_STOP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip = NO; break;
-			case AC_RELAY_WELDING: ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayWelding = NO; break;
-			case AC_GF_MODULE_FAULT: ShmStatusCodeData->FaultCode.FaultEvents.bits.RcdSelfTestFail = NO; break;
-			case AC_SHUTTER_FAULT: break;
-			case AC_LOCKER_FAULT: ShmStatusCodeData->FaultCode.FaultEvents.bits.AcConnectorLockFail = NO; break;
-			case AC_POWER_DROP: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputDrop = NO; break;
-			case AC_CIRCUIT_SHORT: ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CircuitShort = NO; break;
-			case AC_ROTARY_SWITCH_FAULT:  break;
-			case AC_RELAY_DRIVE_FAULT: ShmStatusCodeData->FaultCode.FaultEvents.bits.AcOutputRelayDrivingFault = NO; break;
-			}
-		}
-	}
-
-	ac_chargingInfo[0]->IsErrorOccur = isErr;
-}
-
 bool IsNoneMatchLedColor()
 {
 	bool result = false;
@@ -1550,7 +1358,6 @@ int InitShareMemory()
 		#endif
 		result = FAIL;
 	}
-	//memset(ShmFanModuleData,0,sizeof(struct FanModuleData));
 
 	if ((MeterSMId = shmget(ShmRelayBdKey, sizeof(struct RelayModuleData), 0777)) < 0)
 	{
@@ -1566,7 +1373,6 @@ int InitShareMemory()
 		#endif
 		result = FAIL;
 	}
-	//memset(ShmRelayModuleData[0],0,sizeof(struct RelayModuleData));
 
 	// DO360 RC2
 	if ((MeterSMId = shmget(ShmRelay2BdKey, sizeof(struct RelayModuleData), 0777)) < 0)
@@ -1583,8 +1389,6 @@ int InitShareMemory()
 		#endif
 		result = FAIL;
 	}
-	//memset(ShmRelayModuleData[1],0,sizeof(struct RelayModuleData));
-
 
 	if ((MeterSMId = shmget(ShmLedBdKey, sizeof(struct LedModuleData), 0777)) < 0)
 	{
@@ -1600,7 +1404,6 @@ int InitShareMemory()
 		#endif
 		result = FAIL;
 	}
-	//memset(ShmLedModuleData,0,sizeof(struct LedModuleData));
 
 	if ((MeterSMId = shmget(ShmPsuKey, sizeof(struct PsuData), 0777)) < 0)
 	{
@@ -2185,352 +1988,6 @@ void GetFanSpeedByFunction()
 //	printf("ShmFanModuleData->TestFanSpeed = %d \n", ShmFanModuleData->TestFanSpeed);
 }
 
-void GetAcStatus()
-{
-	if (Query_AC_Status(Uart5Fd, Addr.AcPlug, &acStatus) == PASS)
-	{
-		ShmSysConfigAndInfo->SysConfig.AcRatingCurrent = acStatus.MaxCurrent;
-
-		if(ShmSysConfigAndInfo->SysConfig.AcMaxChargingCurrent == 0)
-			ShmSysConfigAndInfo->SysConfig.AcMaxChargingCurrent = ShmSysConfigAndInfo->SysConfig.AcRatingCurrent;
-
-		ac_chargingInfo[0]->ConnectorPlugIn = acStatus.CpStatus;
-	//	LOG_INFO("CpStatus = %d \n", acStatus.CpStatus);
-	//				printf("CurLimit = %d \n", acStatus.CurLimit);
-	//				printf("PilotVol_P = %d \n", acStatus.PilotVol_P);
-	//				printf("PilotVol_N = %d \n", acStatus.PilotVol_N);
-	//				printf("LockStatus = %d \n", acStatus.LockStatus);
-	//				printf("RelayStatus = %d \n", acStatus.RelayStatus);
-	//				printf("ShutterStatus = %d \n", acStatus.ShutterStatus);
-	//				printf("MeterStatus = %d \n", acStatus.MeterStatus);
-	//				printf("PpStatus = %d \n", acStatus.PpStatus);
-	//				printf("MaxCurrent = %d \n", acStatus.MaxCurrent);
-	//				printf("RotateSwitchStatus = %d \n", acStatus.RelayStatus);
-	//				printf("============================== \n");
-	//
-	//				ac_chargingInfo[0]->SystemStatus = acStatus.CpStatus;
-	}
-//	else
-//		LOG_INFO("GetAcStatus return fail. \n");
-}
-
-void GetAcAlarmCode()
-{
-	if (Query_AC_Alarm_Code(Uart5Fd, Addr.AcPlug, &acAlarmCode) == PASS)
-	{
-		CheckAlarmOccur();
-	}
-}
-
-unsigned char GetChargingEnergy()
-{
-	return Query_Charging_Energy(Uart5Fd, Addr.AcPlug, &acChargingEnergy);
-}
-
-unsigned char GetChargingCurrent()
-{
-	return Query_Charging_Current(Uart5Fd, Addr.AcPlug, &acChargingCurrent);
-}
-
-void ChangeLedStatus()
-{
-	if (ac_chargingInfo[0]->SystemStatus == S_IDLE)
-		ledStatus.ActionMode = 1;
-	else if (ac_chargingInfo[0]->SystemStatus == S_PREPARNING)
-		ledStatus.ActionMode = 3;
-	else if (ac_chargingInfo[0]->SystemStatus == S_CHARGING)
-		ledStatus.ActionMode = 4;
-
-	Config_LED_Status(Uart5Fd, Addr.AcPlug, &ledStatus);
-}
-
-void SetLegacyReq(byte _switch)
-{
-	Config_Legacy_Req(Uart5Fd, Addr.AcPlug, _switch);
-}
-
-void SetCpDuty(byte _value)
-{
-	Config_Ac_Duty(Uart5Fd, Addr.AcPlug, _value);
-}
-
-void ChangeToCsuMode()
-{
-	ac_chargingInfo[0]->IsModeChagned = Config_CSU_Mode(Uart5Fd, Addr.AcPlug);
-
-//	if (ac_chargingInfo[0]->IsModeChagned == PASS)
-//	{
-//		Config_Reset_MCU(Uart5Fd, Addr.AcPlug);
-//	}
-}
-
-void ChangeStartOrStopDateTime(byte isStart)
-{
-	char cmdBuf[32];
-	struct timeb csuTime;
-	struct tm *tmCSU;
-
-	ftime(&csuTime);
-	tmCSU = localtime(&csuTime.time);
-
-	sprintf(cmdBuf, "%04d-%02d-%02d %02d:%02d:%02d", tmCSU->tm_year + 1900,
-			tmCSU->tm_mon + 1, tmCSU->tm_mday, tmCSU->tm_hour, tmCSU->tm_min,
-			tmCSU->tm_sec);
-	if (isStart)
-		strcpy((char *)ac_chargingInfo[0]->StartDateTime, cmdBuf);
-	else
-		strcpy((char *)ac_chargingInfo[0]->StopDateTime, cmdBuf);
-}
-
-void OcppStartTransation(byte gunIndex)
-{
-	if(strcmp((char *)ac_chargingInfo[0]->StartUserId, "") == EQUAL)
-		strcpy((char *)ShmOCPP16Data->StartTransaction[gunIndex].IdTag, (char *)ShmOCPP16Data->StartTransaction[gunIndex].IdTag);
-	else
-		strcpy((char *)ShmOCPP16Data->StartTransaction[gunIndex].IdTag, (char *)ac_chargingInfo[0]->StartUserId);
-
-	LOG_INFO("AC IdTag = %s", ShmOCPP16Data->StartTransaction[gunIndex].IdTag);
-	ShmOCPP16Data->CpMsg.bits[gunIndex].StartTransactionReq = YES;
-}
-
-void OcppStopTransation(byte gunIndex)
-{
-	if(strcmp((char *)ac_chargingInfo[0]->StartUserId, "") == EQUAL)
-		strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].IdTag, (char *)ShmOCPP16Data->StopTransaction[gunIndex].IdTag);
-	else
-		strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].IdTag, (char *)ac_chargingInfo[0]->StartUserId);
-
-	LOG_INFO("AC IdTag = %s", ShmOCPP16Data->StopTransaction[gunIndex].IdTag);
-	ShmOCPP16Data->CpMsg.bits[gunIndex].StopTransactionReq = YES;
-}
-
-bool OcppRemoteStop(byte gunIndex)
-{
-	bool result = ShmOCPP16Data->CsMsg.bits[gunIndex].RemoteStopTransactionReq;
-
-	if (ShmOCPP16Data->CsMsg.bits[gunIndex].RemoteStopTransactionReq == YES)
-	{
-		strcpy((char *)ShmOCPP16Data->StopTransaction[gunIndex].StopReason, "Remote");
-		ShmOCPP16Data->CsMsg.bits[gunIndex].RemoteStopTransactionReq = NO;
-	}
-
-	return result;
-}
-
-unsigned char isModeChange()
-{
-	unsigned char result = NO;
-
-	if(ac_chargingInfo[0]->SystemStatus != ac_chargingInfo[0]->PreviousSystemStatus)
-	{
-		result = YES;
-		ac_chargingInfo[0]->PreviousSystemStatus = ac_chargingInfo[0]->SystemStatus;
-	}
-
-	return result;
-}
-#if 0
-void AcChargeTypeProcess()
-{
-	if (acgunCount > 0)
-	{
-		//ac_chargingInfo[0]->SelfTest_Comp = YES;
-		//ac_chargingInfo[0]->IsModeChagned = PASS;
-		//---------------------------------------------
-		if (ac_chargingInfo[0]->SelfTest_Comp == NO)
-		{
-			ac_chargingInfo[0]->IsModeChagned = NO;
-			GetFwVersion_AC();
-			GetAcModelName();
-		}
-		else if (ac_chargingInfo[0]->SelfTest_Comp == YES)
-		{
-			if (ac_chargingInfo[0]->IsModeChagned != PASS)
-			{
-				ChangeToCsuMode();
-				return;
-			}
-			GetAcStatus();
-			GetAcAlarmCode();
-
-			byte _status = S_NONE;
-
-			if (ac_chargingInfo[0]->SystemStatus == S_IDLE && ac_chargingInfo[0]->IsErrorOccur)
-			{
-				_status = S_ALARM;
-			}
-			else if (acStatus.CpStatus == AC_SYS_A || ac_chargingInfo[0]->IsErrorOccur)
-			{
-				if (ac_chargingInfo[0]->SystemStatus == S_CHARGING)
-					_status = S_TERMINATING;
-				else if (ac_chargingInfo[0]->SystemStatus >= S_TERMINATING)
-				{
-					if (GetTimeoutValue(_ac_charging_comp) >= 10000000 && acStatus.CpStatus == AC_SYS_A)
-						_status = S_IDLE;
-				}
-				else
-					_status = S_IDLE;
-			}
-			else if (ac_chargingInfo[0]->SystemStatus >= S_PREPARNING &&
-					ac_chargingInfo[0]->SystemStatus < S_CHARGING)
-			{
-				if (acStatus.CpStatus == AC_SYS_C && acStatus.RelayStatus == YES)
-					_status = S_CHARGING;
-				else if (GetTimeoutValue(_ac_preparing) >= 30000000)
-					_status = S_IDLE;
-			}
-			else if ((acStatus.CpStatus == AC_SYS_B || ac_chargingInfo[0]->ConnectorPlugIn == AC_SYS_B) &&
-					ac_chargingInfo[0]->IsAvailable &&
-					!ac_chargingInfo[0]->IsErrorOccur &&
-					(ShmSysConfigAndInfo->SysInfo.WaitForPlugit == YES ||
-						ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE))
-			{
-				if (ac_chargingInfo[0]->RemoteStartFlag == YES)
-				{
-					LOG_INFO("** AC Remote");
-					ac_chargingInfo[0]->RemoteStartFlag = NO;
-					strcpy((char *)ac_chargingInfo[0]->StartUserId, "");
-					ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
-					_status = S_PREPARNING;
-				}
-				else if (ShmSysConfigAndInfo->SysInfo.OrderCharging == NO_DEFINE)
-				{
-					LOG_INFO("** UserId = %s", ShmSysConfigAndInfo->SysConfig.UserId);
-					strcpy((char *)ac_chargingInfo[0]->StartUserId, (char *)ShmSysConfigAndInfo->SysConfig.UserId);
-					LOG_INFO("** CardNumber = %s", ac_chargingInfo[0]->StartUserId);
-					strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
-					ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
-					_status = S_PREPARNING;
-				}
-			}
-			else if (ac_chargingInfo[0]->SystemStatus == S_CHARGING)
-			{
-				if (OcppRemoteStop(1))
-					_status = S_TERMINATING;
-			}
-
-			//printf("_status = %d \n", _status);
-
-			if (_status != S_NONE && ac_chargingInfo[0]->SystemStatus != _status)
-			{
-				ac_chargingInfo[0]->SystemStatus = _status;
-			}
-
-			// 設定限制最大充電電流 >= 6 ~ <= 32
-			switch(ac_chargingInfo[0]->SystemStatus)
-			{
-				case S_IDLE:
-				case S_ALARM:
-				{
-					if (isModeChange())
-					{
-						ac_chargingInfo[0]->PresentChargedEnergy = 0.0;
-						ac_chargingInfo[0]->PresentChargingVoltage = 0;
-						ac_chargingInfo[0]->ChargingFee = 0.0;
-						strcpy((char *)ac_chargingInfo[0]->StartDateTime, "");
-						strcpy((char *)ac_chargingInfo[0]->StopDateTime, "");
-						_beforeChargingTotalEnergy = 0.0;
-					}
-
-					ChangeLedStatus();
-				}
-					break;
-				case S_PREPARNING:
-				{
-					if (isModeChange())
-					{
-						//ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
-						ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
-						if (ShmSysConfigAndInfo->SysInfo.OrderCharging != NO_DEFINE)
-							ShmSysConfigAndInfo->SysInfo.OrderCharging = NO_DEFINE;
-						gettimeofday(&_ac_preparing, NULL);
-					}
-
-					if (GetChargingEnergy() == PASS)
-					{
-						//ac_chargingInfo[0]->PresentChargedEnergy = acChargingEnergy.Energy / 100;
-						_beforeChargingTotalEnergy = acChargingEnergy.Energy;
-					}
-
-					SetLegacyReq(YES);
-					ChangeLedStatus();
-				}
-					break;
-				case S_CHARGING:
-				{
-					if (isModeChange())
-					{
-						ftime(&_ac_startChargingTime);
-						OcppStartTransation(1);
-						ChangeStartOrStopDateTime(YES);
-						ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
-					}
-
-					if (GetChargingEnergy() == PASS)
-					{
-						if ((acChargingEnergy.Energy - _beforeChargingTotalEnergy) > 0)
-						{
-							ac_chargingInfo[0]->PresentChargedEnergy += (acChargingEnergy.Energy - _beforeChargingTotalEnergy) / 100;
-							if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
-							{
-								ac_chargingInfo[0]->ChargingFee += ac_chargingInfo[0]->PresentChargedEnergy * ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee;
-							}
-						}
-
-						_beforeChargingTotalEnergy = acChargingEnergy.Energy;
-					}
-
-					if (GetChargingCurrent() == PASS)
-						ac_chargingInfo[0]->PresentChargingPower = (((float)(AC_DEFAULT_VOL * acChargingCurrent.OuputCurrentL1) / 10) / 1000);
-
-					ftime(&_ac_endChargingTime);
-					ac_chargingInfo[0]->PresentChargedDuration = DiffTimeb(_ac_startChargingTime, _ac_endChargingTime);
-					ac_chargingInfo[0]->PresentChargingVoltage = AC_DEFAULT_VOL;
-					ac_chargingInfo[0]->PresentChargingCurrent = ((float)acChargingCurrent.OuputCurrentL1 / 10);
-
-					// 用以判斷是否有在輸出
-					ac_chargingInfo[0]->IsCharging = acStatus.RelayStatus;
-
-					SetCpDuty(ShmSysConfigAndInfo->SysConfig.AcMaxChargingCurrent);
-					ChangeLedStatus();
-				}
-					break;
-				case S_TERMINATING:
-				{
-					if (isModeChange())
-					{
-						ChangeStartOrStopDateTime(NO);
-						gettimeofday(&_ac_charging_comp, NULL);
-					}
-
-					SetLegacyReq(NO);
-					if (acStatus.RelayStatus == NO)
-						ac_chargingInfo[0]->SystemStatus = S_COMPLETE;
-				}
-					break;
-				case S_COMPLETE:
-				{
-					if (isModeChange())
-					{
-						gettimeofday(&_ac_charging_comp, NULL);
-						ftime(&_ac_endChargingTime);
-						if (strcmp((char *)ac_chargingInfo[0]->StartDateTime, "") != EQUAL)
-						{
-							// AC 固定為第2把槍
-							OcppStopTransation(1);
-						}
-
-						ChangeStartOrStopDateTime(NO);
-						ac_chargingInfo[0]->PresentChargedDuration = DiffTimeb(_ac_startChargingTime, _ac_endChargingTime);
-					}
-				}
-					break;
-			}
-		}
-	}
-}
-#endif
-
 int main(void)
 {
 	if(InitShareMemory() == FAIL)

+ 8 - 1
EVSE/Projects/DO360/Apps/Module_PsuComm.c

@@ -4415,7 +4415,6 @@ int main(void)
 				{
 					//PreCheckSmartChargingStep();
 					startModuleFlag = true;
-					GetClockTime(&_cmdSubPriority_time);
 
 				    for(byte group = 0; group < GENERAL_GUN_QUANTITY; group++)
 				    {
@@ -4424,6 +4423,14 @@ int main(void)
 				            GetStatus(group);
 				        }
 				    }
+                    for(byte group = 0; group < GENERAL_GUN_QUANTITY; group++)
+                    {
+                        if(ShmPsuData->PsuGroup[group].GroupPresentPsuQuantity > 0)
+                        {
+                            GetModuleInput(group);
+                        }
+                    }
+				    GetClockTime(&_cmdSubPriority_time);
 				}
 
 				PsuGroupRoutineQuery();

+ 184 - 49
EVSE/Projects/DO360/Apps/ReadCmdline.c

@@ -269,6 +269,122 @@ int InitShareMemory()
     return result;
 }
 
+static void get_char(char *word)
+{
+    fd_set rfds;
+    struct timeval tv;
+
+    FD_ZERO(&rfds);
+    FD_SET(0, &rfds);
+    tv.tv_sec = 0;
+    tv.tv_usec = 10; //wait input timout time
+
+    //if input
+    if (select(1, &rfds, NULL, NULL, &tv) > 0)
+    {
+        fgets(word, 128, stdin);
+    }
+}
+
+// return string length
+int ParsingCmd(char *inputString, char *outputString)
+{
+    bool valid = false, done = false;
+    int len = 0, start = 0;
+
+    for(int i = 0; i < strlen(inputString); i++)
+    {
+        if(!valid)
+        {
+            if(inputString[i] != ' ' && inputString[i] != '\0' && inputString[i] != '\r' && inputString[i] != '\n')
+            {
+                valid = true;
+                start = i;
+            }
+        }
+        else
+        {
+            if(inputString[i] == ' ' || inputString[i] == '\0' || inputString[i] == '\r' || inputString[i] == '\n' || len >= 10)
+            {
+                done = true;
+                break;
+            }
+        }
+
+        len = (valid && !done) ? len + 1 : len;
+    }
+
+    if(valid)
+    {
+        memcpy(outputString, &inputString[start], len);
+        outputString[len] = '\0';
+    }
+
+    return len;
+}
+
+int GetCommandSring(char *outputCmdString)
+{
+    int len = 0, cnt = 0;
+    int cmdLen = 0, totalLen = 0;
+    char word[128];
+
+    memset(word, 0x00, sizeof(word));
+    get_char(word);
+
+    len = strlen(word);
+    if(len == 0)
+    {
+        return -1;
+    }
+
+    int start = 0;
+    while(start < len - 1)
+    {
+        if(word[start] != ' ' && word[start] != '\0')
+        {
+            cmdLen = ParsingCmd(&word[start], &outputCmdString[totalLen]);
+
+            char newCmd[32];
+            memset(newCmd, 0x00, 32);
+            memcpy(newCmd, &outputCmdString[totalLen], cmdLen);
+
+            cnt = cmdLen > 0 ? cnt + 1 : cnt;
+            totalLen += cmdLen + 1;
+            start += cmdLen;
+        }
+        else
+        {
+            start++;
+        }
+    }
+
+    return cnt;
+}
+
+bool IsLoopStopCmd(void)
+{
+    bool stop = false;
+    int cnt = 0;
+    char cmd[256];
+    char totalCmd[256];
+
+    memset(cmd, 0x00, 256);
+    memset(totalCmd, 0x00, 256);
+
+    cnt = GetCommandSring(totalCmd);
+    if(cnt > 0)
+    {
+        strcpy(&cmd[0], totalCmd);
+
+        if(strcmp(&cmd[0], "c") == 0)
+        {
+            stop = true;
+        }
+    }
+    return stop;
+}
+
 void RunStatusProc(char *v1, char *v2)
 {
 	printf("OrderCharging = %d \n", ShmSysConfigAndInfo->SysInfo.OrderCharging);
@@ -711,56 +827,92 @@ void SetGFDMode(char *v1)
 //  1    XXX    XXX    XXX/XXX/XXX  XXX/XXX/XXX  XXX/XXX/XXX  XXX/XXX/XXX
 void GetTemperature(char *v1)
 {
-    bool show = false;
+    bool loop = false;
+    int time = 0;
+    struct timespec _Loop_time;
     char strGunTemp[16], strChillerTemp[16];
 
     if(strcmp(v1, "c") == 0)
     {
-        printf("\r\n Get c Parameter");
-        show = true;
+        loop = true;
     }
+
     do
     {
-        printf("\r\n                        PSU 0        PSU 1        PSU 2        .....");
-        printf("\r\n Gun  Temp  Chiller   DD/PFC/Amb   DD/PFC/Amb   DD/PFC/Amb   DD/PFC/Amb");
-        for(int i = 0; i < CONNECTOR_QUANTITY; i++)
+        time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
+        if(time >= 1000)
         {
-            sprintf(strGunTemp, "N/A");
-            sprintf(strChillerTemp, "N/A");
+            printf("                        PSU 0        PSU 1        PSU 2        .....\r\n");
+            printf(" Gun  Temp  Chiller   DD/PFC/Amb   DD/PFC/Amb   DD/PFC/Amb   DD/PFC/Amb\r\n");
 
-            if(_chargingData[i]->ConnectorTemp != 0 && _chargingData[i]->ConnectorTemp != 0xFF)
+            for(int i = 0; i < CONNECTOR_QUANTITY; i++)
             {
-                sprintf(strGunTemp, "%3d", _chargingData[i]->ConnectorTemp - 60);
-            }
-            if(_chargingData[i]->ChillerTemp != 0 && _chargingData[i]->ChillerTemp != 0xFF)
-            {
-                sprintf(strChillerTemp, "%3d", _chargingData[i]->ChillerTemp - 60);
-            }
-            printf("\r\n  %d    %s    %s  ", i + 1, strGunTemp, strChillerTemp);
+                sprintf(strGunTemp, "N/A");
+                sprintf(strChillerTemp, "N/A");
 
-            for(int j = 0; j < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; j++)
-            {
-                printf("  %3d/%3d/%3d",
-                    ShmPsuData->PsuGroup[i].PsuModule[j].ExletTemp,
-                    ShmPsuData->PsuGroup[i].PsuModule[j].InletTemp,
-                    ShmPsuData->PsuGroup[i].PsuModule[j].CriticalTemp1);
+                if(_chargingData[i]->ConnectorTemp != 0 && _chargingData[i]->ConnectorTemp != 0xFF)
+                {
+                    sprintf(strGunTemp, "%3d", _chargingData[i]->ConnectorTemp - 60);
+                }
+                if(_chargingData[i]->ChillerTemp != 0 && _chargingData[i]->ChillerTemp != 0xFF)
+                {
+                    sprintf(strChillerTemp, "%3d", _chargingData[i]->ChillerTemp - 60);
+                }
+                printf("  %d    %s    %s  ", i + 1, strGunTemp, strChillerTemp);
+
+                for(int j = 0; j < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; j++)
+                {
+                    printf("  %3d/%3d/%3d",
+                        ShmPsuData->PsuGroup[i].PsuModule[j].ExletTemp,
+                        ShmPsuData->PsuGroup[i].PsuModule[j].InletTemp,
+                        ShmPsuData->PsuGroup[i].PsuModule[j].CriticalTemp1);
+                }
+                printf("\r\n");
             }
+            printf("\r\n");
+            GetClockTime(&_Loop_time);
         }
-        printf("\r\n\r\n");
 
-        if(show)
+        if(loop)
         {
-            sleep(1);
+            loop = IsLoopStopCmd() ? false : true;
+            usleep(10000);
         }
-    }while(show);
+    }while(loop);
 }
 
-void GetAcInputVol()
+void GetInputVol(char *v1)
 {
-	printf("L1N_L12 = %f, L2N_L23 = %f, L3N_L31 = %f \n",
-			ShmSysConfigAndInfo->SysInfo.InputVoltageR,
-			ShmSysConfigAndInfo->SysInfo.InputVoltageS,
-			ShmSysConfigAndInfo->SysInfo.InputVoltageT);
+    bool loop = false;
+    int time = 0;
+    struct timespec _Loop_time;
+
+    if(strcmp(v1, "c") == 0)
+    {
+        loop = true;
+    }
+
+    do
+    {
+        time = GetTimeoutValue(_Loop_time) / mSEC_VAL;
+        if(time >= 1000)
+        {
+            printf("L1N_L12 = %4.1f V, L2N_L23 = %4.1f V, L3N_L31 = %4.1f V, DC Input: %4.1f V\r\n",
+                    ShmSysConfigAndInfo->SysInfo.InputVoltageR,
+                    ShmSysConfigAndInfo->SysInfo.InputVoltageS,
+                    ShmSysConfigAndInfo->SysInfo.InputVoltageT,
+                    ShmSysConfigAndInfo->SysInfo.InputVoltageDc);
+
+            GetClockTime(&_Loop_time);
+        }
+
+        if(loop)
+        {
+            loop = IsLoopStopCmd() ? false : true;
+            usleep(10000);
+        }
+    }while(loop);
+    printf("\r\n");
 }
 
 void GetPsuInformation(char *v1, char *v2, char *v3)
@@ -869,23 +1021,6 @@ void GetConnectorCapInfo(char *v1)
 			_chargingData[_GunIndex]->RealMaxCurrent);
 }
 
-static void get_char(char *word)
-{
-    fd_set rfds;
-    struct timeval tv;
-
-    FD_ZERO(&rfds);
-    FD_SET(0, &rfds);
-    tv.tv_sec = 0;
-    tv.tv_usec = 10; //wait input timout time
-
-    //if input
-    if (select(1, &rfds, NULL, NULL, &tv) > 0)
-    {
-    	fgets(word, 128, stdin);
-    }
-}
-
 void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
 {
 	int _GunIndex = atoi(v1);
@@ -3151,7 +3286,7 @@ int main(void)
 		else if(strcmp(newString[0], "acin") == 0)
 		{
 		    // 取得三向輸入電壓
-			GetAcInputVol();
+			GetInputVol(newString[1]);
 		}
 		else if(strcmp(newString[0], "psu") == 0)
 		{

+ 151 - 6
EVSE/Projects/DO360/Apps/internalComm.c

@@ -35,12 +35,55 @@
 #include 	<math.h>
 #include 	"internalComm.h"
 
-#define PASS				1
-#define FAIL				-1
-
-struct Address Addr={0x01,0x02,0x03,0x05,0x06,0x07,0x08,0x09,0xFF};
-struct Command Cmd={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x24,0x27,0x28,0x29,0x2C,0x81,0x83,
-		0x85,0x86,0x87,0x88,0x089,0x8A,0x8B,0x8C,0x90,0x93,0xe0,0xe1,0xe2,0xe3};
+#define PASS                1
+#define FAIL                -1
+
+struct Address Addr = {
+    AUX_ADD,
+    FAN_ADD,
+    RELAY_ADD,
+    ACPLUG_ADD,
+    LED_ADD,
+    RC1_ADD,
+    RC2_ADD,
+    RD_ADD,
+    BROADCAST_ADD
+};
+
+struct Command Cmd = {
+    MSGID_G_FW_VERSION,
+    MSGID_G_HW_VERSION,
+    MSGID_G_AC_INPUT_VOLTAGE,
+    MSGID_G_DC_OUTPUT_VOLTAGE,
+    MSGID_G_FAN_SPEED,
+    MSGID_G_TEMPERATURE,
+    MSGID_G_AUX_VOLTAGE,
+    MSGID_G_RELAY_STATE,
+    MSGID_G_GFD,
+    MSGID_G_GPIO_INPUT,
+    MSGID_G_MODEL_NAME,
+    MSGID_G_AC_OUTPUT_CURRENT,
+    MSGID_G_AC_STATUS,
+    MSGID_G_AC_ALARM,
+    MSGID_G_AC_OUTPUT_POWER,
+    MSGID_G_DC_INPUT_VOLTAGE,
+    MSGID_S_FAN_SPEED,
+    MSGID_S_MODEL_NAME,
+    MSGID_S_RELAY_STATE,
+    MSGID_S_GPIO_OUTPUT,
+    MSGID_S_RTC,
+    MSGID_S_AC_LED_STATE,
+    MSGID_S_AC_CP_DUTY,
+    MSGID_S_AC_LEGACY_REQ,
+    MSGID_S_GFD,
+    MSGID_S_AC_RESET_MCU,
+    MSGID_S_MCU_OPERATION,
+    MSGID_S_LED_COLOR,
+    MSGID_S_FW_CHECKSUM,
+    MSGID_S_FW_ABORT,
+    MSGID_S_FW_PACKET,
+    MSGID_S_FW_FINISH
+};
 
 int tranceiveRelDelayTime(int fd, unsigned char* cmd, unsigned char cmd_len, unsigned char* rx, unsigned short _delay)
 {
@@ -84,6 +127,88 @@ int tranceive(int fd, unsigned char* cmd, unsigned char cmd_len, unsigned char*
 	return len;
 }
 
+int Internal_Comm_Request(unsigned char fd, unsigned char targetAddr, unsigned char msg, unsigned char *data, unsigned short dataLen, unsigned char *response)
+{
+    int resLen = 0, rxLen = 0;
+
+    unsigned char tx[512], rx[512];
+    unsigned char txChksum = 0x00, rxChksum = 0;
+
+    tx[0] = FRAME_ID;
+    tx[1] = CSU_ADD;
+    tx[2] = targetAddr;
+    tx[3] = msg;
+    tx[4] = dataLen & 0xFF;
+    tx[5] = (dataLen >> 8) & 0xFF;
+
+    if(dataLen > 0)
+    {
+        memcpy(&tx[6], &data[0], dataLen);
+
+        for(int i = 0; i < dataLen; i++)
+        {
+            txChksum ^= tx[6 + i];
+        }
+    }
+
+    tx[6 + dataLen] = txChksum;
+
+    rxLen = tranceive(fd, &tx[0], INTERNAL_PACKET_MIN_LEN + dataLen, &rx[0]);
+
+    if(rxLen >= INTERNAL_PACKET_MIN_LEN)
+    {
+        resLen = (rx[4] | (rx[5] << 8));
+
+        if(rxLen == (INTERNAL_PACKET_MIN_LEN + resLen))
+        {
+            for(int i = 0; i < resLen; i++)
+            {
+                rxChksum ^= rx[6 + i];
+            }
+
+            if(rxChksum == rx[INTERNAL_PACKET_MIN_LEN - 1 + resLen])
+            {
+                if(rx[2] == tx[1] && rx[1] == tx[2] && rx[3] == tx[3])
+                {
+                    if(resLen > 0)
+                    {
+                        memcpy(response, &rx[6], resLen);
+                    }
+#if 0
+                    printf("\r\n");
+                    for(int i = 0; i < rxLen; i++)
+                    {
+                        printf(" %02X", rx[i]);
+                    }
+#endif
+                }
+                else
+                {
+                    // response packet(address or message) is not match
+                    resLen = -1;
+                }
+            }
+            else
+            {
+                // checksum is not match
+                resLen = -1;
+            }
+        }
+        else
+        {
+            // rx packet length and data length is not match
+            resLen = -1;
+        }
+    }
+    else
+    {
+        // rx packet length is less than  INTERNAL_PACKET_MIN_LEN
+        resLen = -1;
+    }
+
+    return resLen;
+}
+
 unsigned char Query_FW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf)
 {
 	unsigned char result = FAIL;
@@ -195,6 +320,26 @@ unsigned char Query_Present_InputVoltage(unsigned char fd, unsigned char targetA
 	return result;
 }
 
+unsigned char Query_DC_InputVoltage(unsigned char fd, unsigned char targetAddr, DCInputVoltage *Ret_Buf)
+{
+    unsigned char result = FAIL;
+    unsigned char resLen = 0;
+    unsigned char response[512];
+
+    memset(response, 0x00, 512);
+    resLen = Internal_Comm_Request(fd, targetAddr, Cmd.query_DC_InputVoltage, 0, 0, &response[0]);
+
+    if(resLen >= 0)
+    {
+        Ret_Buf->DC_Input_1 =(response[0] | (response[1] << 8)) / 10;
+        Ret_Buf->DC_Input_2 =(response[2] | (response[3] << 8)) / 10;
+
+        result = PASS;
+    }
+
+    return result;
+}
+
 unsigned char Query_Present_OutputVoltage(unsigned char fd, unsigned char targetAddr, PresentOutputVoltage *Ret_Buf)
 {
 	unsigned char result = FAIL;

+ 131 - 47
EVSE/Projects/DO360/Apps/internalComm.h

@@ -8,59 +8,136 @@
 #ifndef INTERNALCOMM_H_
 #define INTERNALCOMM_H_
 
+#define FRAME_ID                                0xAA
+#define CSU_ADD                                 0x00
+#define AUX_ADD                                 0x01
+#define FAN_ADD                                 0x02
+#define RELAY_ADD                               0x03
+#define ACPLUG_ADD                              0x05
+#define LED_ADD                                 0x06
+#define RC1_ADD                                 0x07        // relay 1 in power cabinet
+#define RC2_ADD                                 0x08        // relay 2 in power cabinet
+#define RD_ADD                                  0x09        // relay in dispenser
+#define BROADCAST_ADD                           0xFF
+
+#define INTERNAL_PACKET_MIN_LEN                 7
+
+#define MSGID_G_FW_VERSION                      0x01
+#define MSGID_G_HW_VERSION                      0x02
+#define MSGID_G_AC_INPUT_VOLTAGE                0x03
+#define MSGID_G_DC_OUTPUT_VOLTAGE               0x04
+#define MSGID_G_FAN_SPEED                       0x05
+#define MSGID_G_TEMPERATURE                     0x06
+#define MSGID_G_AUX_VOLTAGE                     0x07
+#define MSGID_G_RELAY_STATE                     0x08
+#define MSGID_G_GFD                             0x09
+#define MSGID_G_GPIO_INPUT                      0x0A
+#define MSGID_G_ALARM                           0x22        // no use
+#define MSGID_G_SERIAL_NUMBER                   0x23        // no use
+#define MSGID_G_MODEL_NAME                      0x24
+#define MSGID_G_CORRECTION                      0x25        // no use
+#define MSGID_G_RTC                             0x26        // no use
+#define MSGID_G_AC_OUTPUT_CURRENT               0x27
+#define MSGID_G_AC_STATUS                       0x28
+#define MSGID_G_AC_ALARM                        0x29
+#define MSGID_G_BLE_CONFIG                      0x2A        // no use
+#define MSGID_G_BLE_CENTRAL_ID                  0x2B        // no use
+#define MSGID_G_AC_OUTPUT_POWER                 0x2C
+#define MSGID_G_AC_GUN_PLUGIN                   0x2D        // no use
+#define MSGID_G_AC_AUTHMODE                     0x2E        // no use
+#define MSGID_G_LEAK_CURRENT                    0x2F        // no use
+#define MSGID_G_MCU_OPERATION                   0x30        // no use
+#define MSGID_G_4G_MODULE_REVISION              0x31        // no use
+#define MSGID_G_SELFTEST_STATUS                 0x32        // no use
+#define MSGID_G_AC_FREQUENCY                    0x33        // no use
+#define MSGID_G_4G_SIM_INFO                     0x34        // no use
+#define MSGID_G_METER_MEASUREMENT               0x35        // no use
+#define MSGID_G_METER_CORRECTION                0x36        // no use
+#define MSGID_G_METER_HISTORY                   0x37        // no use
+#define MSGID_G_DC_INPUT_VOLTAGE                0x38
+
+#define MSGID_S_FAN_SPEED                       0x81
+#define MSGID_S_SERIAL_NUMBER                   0x82        // no use
+#define MSGID_S_MODEL_NAME                      0x83
+#define MSGID_S_CORRECTION                      0x84        // no use
+#define MSGID_S_RELAY_STATE                     0x85
+#define MSGID_S_GPIO_OUTPUT                     0x86
+#define MSGID_S_RTC                             0x87
+#define MSGID_S_AC_LED_STATE                    0x88
+#define MSGID_S_AC_CP_DUTY                      0x89
+#define MSGID_S_AC_LEGACY_REQ                   0x8A
+#define MSGID_S_GFD                             0x8B
+#define MSGID_S_AC_RESET_MCU                    0x8C
+#define MSGID_S_AC_BREATH_LED                   0x8D        // no use
+#define MSGID_S_AC_LED BRIGHTNESS               0x8E        // no use
+#define MSGID_S_AC_AUTHMODE                     0x8F        // no use
+#define MSGID_S_MCU_OPERATION                   0x90
+#define MSGID_S_SAVE_CONFIG                     0x91        // no use
+#define MSGID_S_RUN_SELFTEST                    0x92        // no use
+#define MSGID_S_LED_COLOR                       0x93
+#define MSGID_S_MCU_ERASE                       0x94        // no use
+#define MSGID_S_AUX_SWITCH                      0x95        // no use
+#define MSGID_S_METER_CORRECTION                0x96        // no use
+
+#define MSGID_S_FW_CHECKSUM                     0xE0
+#define MSGID_S_FW_ABORT                        0xE1
+#define MSGID_S_FW_PACKET                       0xE2
+#define MSGID_S_FW_FINISH                       0xE3
+
 extern struct Address
 {
-	unsigned char Aux;
-	unsigned char Fan;
-	unsigned char Relay;
-	unsigned char AcPlug;
-	unsigned char Led;
-	unsigned char DO360_RC1;
-	unsigned char DO360_RC2;
-	unsigned char DD360_Relay;
-	unsigned char Broadcast;
+    unsigned char Aux;
+    unsigned char Fan;
+    unsigned char Relay;
+    unsigned char AcPlug;
+    unsigned char Led;
+    unsigned char DO360_RC1;
+    unsigned char DO360_RC2;
+    unsigned char DD360_Relay;
+    unsigned char Broadcast;
 }Addr;
 
 extern struct Command
 {
-	unsigned char query_FW_Ver; 				//0x01
-	unsigned char query_HW_Ver; 				//0x02
-	unsigned char query_Present_InputVoltage;	//0x03
-	unsigned char query_Present_OutputVoltage;	//0x04
-	unsigned char query_Fan_Speed;				//0x05
-	unsigned char query_Temperature;			//0x06
-	unsigned char query_Aux_PowerVoltage;		//0x07
-	unsigned char query_Relay_Output;			//0x08
-	unsigned char query_Gfd_Adc;				//0x09
-	unsigned char query_Gpio_In;				//0x0a
-
-	unsigned char query_Model_Name;				//0x24
-	unsigned char query_ac_output_current;		//0x27
-	unsigned char query_ac_status;				//0x28
-	unsigned char query_ac_alarm_code;			//0x29
-
-	unsigned char query_ac_output_energy;		//0x2C
-
-	unsigned char config_Fan_Speed;			//0x81
-	unsigned char config_Model_Name;			//0x83
-	unsigned char config_Relay_Output;			//0x85
-	unsigned char config_Gpio_Output;			//0x86
-	unsigned char config_Rtc_Data;				//0x87
-	unsigned char config_ac_led_status;			//0x88
-
-	unsigned char config_ac_duty;			//0x89
-	unsigned char config_Legacy_Req;		//0x8A
-	unsigned char config_Gfd_Value;			//0x8B
-	unsigned char config_reset_mcu;			//0x8C
-
-	unsigned char config_csu_mode;			//0x90
-
-	unsigned char config_led_color;			//0x93
-
-	unsigned char update_Start;				//0xe0
-	unsigned char update_Abort;				//0xe1
-	unsigned char update_Transfer;				//0xe2
-	unsigned char update_Finish;				//0xe3
+    unsigned char query_FW_Ver;                 //0x01
+    unsigned char query_HW_Ver;                 //0x02
+    unsigned char query_Present_InputVoltage;   //0x03
+    unsigned char query_Present_OutputVoltage;  //0x04
+    unsigned char query_Fan_Speed;              //0x05
+    unsigned char query_Temperature;            //0x06
+    unsigned char query_Aux_PowerVoltage;       //0x07
+    unsigned char query_Relay_Output;           //0x08
+    unsigned char query_Gfd_Adc;                //0x09
+    unsigned char query_Gpio_In;                //0x0a
+
+    unsigned char query_Model_Name;             //0x24
+    unsigned char query_ac_output_current;      //0x27
+    unsigned char query_ac_status;              //0x28
+    unsigned char query_ac_alarm_code;          //0x29
+
+    unsigned char query_ac_output_energy;       //0x2C
+    unsigned char query_DC_InputVoltage;        //0x38
+
+    unsigned char config_Fan_Speed;             //0x81
+    unsigned char config_Model_Name;            //0x83
+    unsigned char config_Relay_Output;          //0x85
+    unsigned char config_Gpio_Output;           //0x86
+    unsigned char config_Rtc_Data;              //0x87
+    unsigned char config_ac_led_status;         //0x88
+
+    unsigned char config_ac_duty;               //0x89
+    unsigned char config_Legacy_Req;            //0x8A
+    unsigned char config_Gfd_Value;             //0x8B
+    unsigned char config_reset_mcu;             //0x8C
+
+    unsigned char config_csu_mode;              //0x90
+
+    unsigned char config_led_color;             //0x93
+
+    unsigned char update_Start;                 //0xe0
+    unsigned char update_Abort;                 //0xe1
+    unsigned char update_Transfer;              //0xe2
+    unsigned char update_Finish;                //0xe3
 
 }Cmd;
 
@@ -78,6 +155,12 @@ typedef struct PRESENTINPUTVOLTAGE
 	double L3N_L31;
 }PresentInputVoltage;
 
+typedef struct
+{
+    float DC_Input_1;
+    float DC_Input_2;
+}DCInputVoltage;
+
 typedef struct PRESENTOUTPUTVOLTAGE
 {
 	double behindFuse_Voltage_C1;
@@ -270,6 +353,7 @@ Ac_Charging_current;
 extern unsigned char Query_FW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf);
 extern unsigned char Query_HW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf);
 extern unsigned char Query_Present_InputVoltage(unsigned char fd, unsigned char targetAddr, PresentInputVoltage *Ret_Buf);
+extern unsigned char Query_DC_InputVoltage(unsigned char fd, unsigned char targetAddr, DCInputVoltage *Ret_Buf);
 extern unsigned char Query_Present_OutputVoltage(unsigned char fd, unsigned char targetAddr, PresentOutputVoltage *Ret_Buf);
 extern unsigned char Query_Fan_Speed(unsigned char fd, unsigned char targetAddr, FanSpeed *Ret_Buf);
 extern unsigned char Query_Temperature(unsigned char fd, unsigned char targetAddr, Temperature *Ret_Buf);

+ 8 - 3
EVSE/Projects/DO360/Apps/main.c

@@ -263,7 +263,7 @@ bool isModelNameMatch = true;
 
 //int rfidFd = -1;
 //char* rfidPortName = "/dev/ttyS2";
-char* fwVersion = "V1.05.00.0000.00";
+char* fwVersion = "V1.06.00.0000.00";
 
 sqlite3 *localDb;
 bool isDb_ready;
@@ -3189,7 +3189,8 @@ void CheckErrorOccurStatus(byte index)
 
 	if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputOVP == YES ||
 			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputOVP == YES ||
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == YES)
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == YES ||
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DcInputOVP)
 	{
 		if (ShmSysConfigAndInfo->SysWarningInfo.ExtraErrProcess == _EXTRA_ERR_PROCESS_NONE)
 		{
@@ -3205,6 +3206,8 @@ void CheckErrorOccurStatus(byte index)
                 memcpy(chargingInfo[index]->ConnectorAlarmCode, "042201", 6);
             else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP == YES)
                 memcpy(chargingInfo[index]->ConnectorAlarmCode, "042202", 6);
+            else if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DcInputOVP == YES)
+                memcpy(chargingInfo[index]->ConnectorAlarmCode, "042327", 6);
         }
         if(!chargingInfo[index]->ChargingStopFlag.bits.AlarmStop)
         {
@@ -7861,7 +7864,9 @@ int main(void)
                             }
                         }
 
-                        if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].RemoteStatus == _CRS_Idle || ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Enable == false) &&
+                        if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].RemoteStatus == _CRS_Idle ||
+                            ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Enable == false ||
+                            (!chargingInfo[gun_index]->ConnectorPlugIn && ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFailureAlarm)) &&
                             ShmSysConfigAndInfo->SysInfo.ConnectorInfo[gun_index].Parameter.bits.PsuReleasable)
                         {
                             setChargerMode(gun_index, MODE_IDLE);

BIN
EVSE/Projects/DO360/Images/FactoryDefaultConfig.bin


BIN
EVSE/Projects/DO360/Images/ramdisk.gz