Эх сурвалжийг харах

2021.06.10 / Jerry Wang

Actions:
1. Add Chiller temperature OTP and chiller sensor broken status code 012323 and 011038.

Files:
1. As follow as commit history.
Jerry_Wang 3 жил өмнө
parent
commit
26f5467667
62 өөрчлөгдсөн 1986 нэмэгдсэн , 1104 устгасан
  1. 34 5
      EVSE/Projects/DD360/Apps/CSU/Primary.c
  2. 1 8
      EVSE/Projects/DD360/Apps/CSU/UpgradeFW.c
  3. 159 65
      EVSE/Projects/DD360/Apps/CSU/main.c
  4. 24 0
      EVSE/Projects/DD360/Apps/Config.h
  5. 5 5
      EVSE/Projects/DD360/Apps/Define/define.c
  6. 202 165
      EVSE/Projects/DD360/Apps/Define/define.h
  7. 14 13
      EVSE/Projects/DD360/Apps/Makefile
  8. 4 3
      EVSE/Projects/DD360/Apps/ModuleDoComm/DoComm.c
  9. 0 0
      EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvCommOrg.c
  10. 49 53
      EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvRxComm.c
  11. 6 8
      EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvTxComm.c
  12. 2 1
      EVSE/Projects/DD360/Apps/ModuleInternalComm/RelayBoard.c
  13. 71 1
      EVSE/Projects/DD360/Apps/ReadCmdline.c
  14. 91 41
      EVSE/Projects/DD360/Apps/mainOrg.c
  15. 34 5
      EVSE/Projects/DD360Audi/Apps/CSU/Primary.c
  16. 1 8
      EVSE/Projects/DD360Audi/Apps/CSU/UpgradeFW.c
  17. 159 65
      EVSE/Projects/DD360Audi/Apps/CSU/main.c
  18. 24 0
      EVSE/Projects/DD360Audi/Apps/Config.h
  19. 5 5
      EVSE/Projects/DD360Audi/Apps/Define/define.c
  20. 202 165
      EVSE/Projects/DD360Audi/Apps/Define/define.h
  21. 14 13
      EVSE/Projects/DD360Audi/Apps/Makefile
  22. 4 3
      EVSE/Projects/DD360Audi/Apps/ModuleDoComm/DoComm.c
  23. 0 0
      EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvCommOrg.c
  24. 49 53
      EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvRxComm.c
  25. 6 8
      EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvTxComm.c
  26. 2 1
      EVSE/Projects/DD360Audi/Apps/ModuleInternalComm/RelayBoard.c
  27. 71 1
      EVSE/Projects/DD360Audi/Apps/ReadCmdline.c
  28. 91 41
      EVSE/Projects/DD360Audi/Apps/mainOrg.c
  29. BIN
      EVSE/Projects/DD360Audi/Images/ramdisk.gz
  30. BIN
      EVSE/Projects/DD360Audi/output/FactoryConfig
  31. BIN
      EVSE/Projects/DD360Audi/output/Module_DoComm
  32. BIN
      EVSE/Projects/DD360Audi/output/Module_EvComm
  33. BIN
      EVSE/Projects/DD360Audi/output/Module_EventLogging
  34. BIN
      EVSE/Projects/DD360Audi/output/Module_InternalComm
  35. BIN
      EVSE/Projects/DD360Audi/output/Module_LcmControl
  36. BIN
      EVSE/Projects/DD360Audi/output/Module_PrimaryComm
  37. BIN
      EVSE/Projects/DD360Audi/output/ReadCmdline
  38. BIN
      EVSE/Projects/DD360Audi/output/main
  39. 34 5
      EVSE/Projects/DD360ComBox/Apps/CSU/Primary.c
  40. 1 8
      EVSE/Projects/DD360ComBox/Apps/CSU/UpgradeFW.c
  41. 159 65
      EVSE/Projects/DD360ComBox/Apps/CSU/main.c
  42. 24 0
      EVSE/Projects/DD360ComBox/Apps/Config.h
  43. 5 5
      EVSE/Projects/DD360ComBox/Apps/Define/define.c
  44. 202 165
      EVSE/Projects/DD360ComBox/Apps/Define/define.h
  45. 14 13
      EVSE/Projects/DD360ComBox/Apps/Makefile
  46. 4 3
      EVSE/Projects/DD360ComBox/Apps/ModuleDoComm/DoComm.c
  47. 0 0
      EVSE/Projects/DD360ComBox/Apps/ModuleEvComm/Module_EvCommOrg.c
  48. 49 53
      EVSE/Projects/DD360ComBox/Apps/ModuleEvComm/Module_EvRxComm.c
  49. 6 8
      EVSE/Projects/DD360ComBox/Apps/ModuleEvComm/Module_EvTxComm.c
  50. 2 1
      EVSE/Projects/DD360ComBox/Apps/ModuleInternalComm/RelayBoard.c
  51. 71 1
      EVSE/Projects/DD360ComBox/Apps/ReadCmdline.c
  52. 91 41
      EVSE/Projects/DD360ComBox/Apps/mainOrg.c
  53. BIN
      EVSE/Projects/DD360ComBox/Images/ramdisk.gz
  54. BIN
      EVSE/Projects/DD360ComBox/output/FactoryConfig
  55. BIN
      EVSE/Projects/DD360ComBox/output/Module_DoComm
  56. BIN
      EVSE/Projects/DD360ComBox/output/Module_EvComm
  57. BIN
      EVSE/Projects/DD360ComBox/output/Module_EventLogging
  58. BIN
      EVSE/Projects/DD360ComBox/output/Module_InternalComm
  59. BIN
      EVSE/Projects/DD360ComBox/output/Module_LcmControl
  60. BIN
      EVSE/Projects/DD360ComBox/output/Module_PrimaryComm
  61. BIN
      EVSE/Projects/DD360ComBox/output/ReadCmdline
  62. BIN
      EVSE/Projects/DD360ComBox/output/main

+ 34 - 5
EVSE/Projects/DD360/Apps/CSU/Primary.c

@@ -54,6 +54,7 @@ void PrimaryLedIndicatorCtrlFork(void)
         struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
         struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
         struct ChargingInfoData *pDcChargingInfo = NULL;
+        DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
 
         LedConfig *pLedConfig = (LedConfig *)&ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0];
 
@@ -63,12 +64,15 @@ void PrimaryLedIndicatorCtrlFork(void)
 
                 if (pSysWarning->Level == 2) {
                     if (checkCabinetEthConnectState(pLedConfig) == YES) {
+                        usleep(500000);
                         continue;
                     }
 
                     pLedConfig->YellowLED = NO;
                     pLedConfig->GreenLED = NO;
                     pLedConfig->RedLED = YES;
+                    usleep(500000);
+                    continue;
                 }
 
                 //printf("led indicator status = %d\r\n", chargingInfo[gunIndex]->SystemStatus);
@@ -175,11 +179,11 @@ void PrimaryLedIndicatorCtrlFork(void)
                 case S_UPDATE:
                 case S_NONE:
                     break;
-                }
-            }//switch
-        }//for
-        usleep(500000);
-    }//while
+                }//switch
+            }//for
+            usleep(500000);
+        }//while
+    }//fork
 }
 
 //------------------------------------------------------------------------------
@@ -195,44 +199,69 @@ void ChkPrimaryStatus(void)
     struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
     struct ChargingInfoData *pDcChargingInfo = NULL;
     struct ChargingInfoData *pAcChargingInfo = NULL;
+    DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
 
     if (pSysWarning->WarningCount > 0) {
         Rtn = 0;
         for (uint8_t i = 0; i < pSysWarning->WarningCount; i++) {
             if (memcmp(&pSysWarning->WarningCode[i][0], "042251", 6) == 0) {
                 EmcOccureByString("042251");
+                ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = YES;
                 Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "042252", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = YES;
                 EmcOccureByString("042252");
                 Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "042200", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = YES;
                 EmcOccureByString("042200");
                 Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "042201", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = YES;
                 EmcOccureByString("042201");
                 Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "042202", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = YES;
                 EmcOccureByString("042202");
                 Rtn = 1;
+            } else if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = YES;
+                EmcOccureByString("042267");
+                Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
                 EmcOccureByString("012304");
                 Rtn = 1;
             }
         }
+
         if (Rtn == 0) {
+            ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
             ReleaseEmsOccureByString(0, "042251");
             ReleaseEmsOccureByString(0, "042252");
             ReleaseEmsOccureByString(0, "042200");
             ReleaseEmsOccureByString(0, "042201");
             ReleaseEmsOccureByString(0, "042202");
+            ReleaseEmsOccureByString(0, "042267");
             ReleaseEmsOccureByString(0, "012304");
         }
     } else {
+        ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
         ReleaseEmsOccureByString(0, "042251");
         ReleaseEmsOccureByString(0, "042252");
         ReleaseEmsOccureByString(0, "042200");
         ReleaseEmsOccureByString(0, "042201");
         ReleaseEmsOccureByString(0, "042202");
+        ReleaseEmsOccureByString(0, "042267");
         ReleaseEmsOccureByString(0, "012304");
     }
 

+ 1 - 8
EVSE/Projects/DD360/Apps/CSU/UpgradeFW.c

@@ -30,11 +30,10 @@ static int InitComPort(uint8_t target)
     }
 
     if (fd <= 0) {
-#ifdef SystemLogMessage
         log_error("open 407 Communication port NG \n");
-#endif
         return -1;
     }
+
     ioctl (fd, TCGETS, &tios);
     tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
     tios.c_lflag = 0;
@@ -66,21 +65,15 @@ static int InitCanBus(void)
     tv.tv_sec = 0;
     tv.tv_usec = 10000;
     if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct  timeval)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_RCVTIMEO NG");
-#endif
     }
     nbytes = 40960;
     if (setsockopt(fd, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_RCVBUF NG");
-#endif
     }
     nbytes = 40960;
     if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_SNDBUF NG");
-#endif
     }
 
     strcpy(ifr0.ifr_name, "can0");

+ 159 - 65
EVSE/Projects/DD360/Apps/CSU/main.c

@@ -330,58 +330,79 @@ void confirmSelGun(uint8_t selGun)
     StartGunInfoTimeoutDet(selGun, Timeout_SelectGun);
 }
 
-static void checkGunOTPState(uint8_t _index)
+static void checkGunOTPState(uint8_t gunIndex)
 {
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
+
+    if ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
+            (strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
+            (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0) ||
+            (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0)
+       ) {
+        if (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP) {
+            //ResetChargerAlarmCode(gunIndex, "011038"); //清除溫度檢測異常status code
+
+            if (pDcChargingInfo->ChillerTemp >= GUN_OTP_VALUE) {
+                RecordAlarmCode(gunIndex, "012323");
+            } else if (pDcChargingInfo->ChillerTemp != 0 &&
+                       pDcChargingInfo->ChillerTemp < GUN_OTP_RECOVERY) {
+                ResetChargerAlarmCode(gunIndex, "012323");
+            }
+        } else {
+            // 沒接上 Sensor or 異常
+            RecordAlarmCode(gunIndex, "011038");
+            ResetChargerAlarmCode(gunIndex, "012323");
+        }
+    }
 
     switch (pDcChargingInfo->Type) {
     case _Type_Chademo:
         if (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP) {
             if (pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) {
-                RecordAlarmCode(_index, "012229");
+                RecordAlarmCode(gunIndex, "012229");
             } else if (pDcChargingInfo->ConnectorTemp != 0 &&
                        pDcChargingInfo->ConnectorTemp < GUN_OTP_RECOVERY) {
-                ResetChargerAlarmCode(_index, "012229");
+                ResetChargerAlarmCode(gunIndex, "012229");
             }
         } else {
             // 沒接上 Sensor or 異常
-            //RecordAlarmCode(_index, "011018");
-            ResetChargerAlarmCode(_index, "012229");
+            //RecordAlarmCode(gunIndex, "011018");
+            ResetChargerAlarmCode(gunIndex, "012229");
         }
         break;
 
     case _Type_CCS_2:
         // CCS 不管甚麼輸出都會有槍溫偵測!!~
         if (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP) {
-            ResetChargerAlarmCode(_index, "011019");
+            //ResetChargerAlarmCode(gunIndex, "011019");
 
             if (pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) {
-                RecordAlarmCode(_index, "012230");
+                RecordAlarmCode(gunIndex, "012230");
             } else if (pDcChargingInfo->ConnectorTemp != 0 &&
                        pDcChargingInfo->ConnectorTemp < GUN_OTP_RECOVERY) {
-                ResetChargerAlarmCode(_index, "012230");
+                ResetChargerAlarmCode(gunIndex, "012230");
             }
 
-            //ResetChargerAlarmCode(_index, "011019");
+            //ResetChargerAlarmCode(gunIndex, "011019");
         } else {
             // 沒接上 Sensor or 異常
-            RecordAlarmCode(_index, "011019");
-            ResetChargerAlarmCode(_index, "012230");
+            RecordAlarmCode(gunIndex, "011019");
+            ResetChargerAlarmCode(gunIndex, "012230");
         }
         break;
 
     case _Type_GB:
         if (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP) {
             if (pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) {
-                RecordAlarmCode(_index, "012231");
+                RecordAlarmCode(gunIndex, "012231");
             } else if (pDcChargingInfo->ConnectorTemp != 0 &&
                        pDcChargingInfo->ConnectorTemp < GUN_OTP_RECOVERY) {
-                ResetChargerAlarmCode(_index, "012231");
+                ResetChargerAlarmCode(gunIndex, "012231");
             }
         } else {
             // 沒接上 Sensor or 異常
-            RecordAlarmCode(_index, "011020");
-            ResetChargerAlarmCode(_index, "012231");
+            RecordAlarmCode(gunIndex, "011020");
+            ResetChargerAlarmCode(gunIndex, "012231");
         }
         break;
     }
@@ -569,6 +590,28 @@ static void checkChaDeMoAlarmState(uint8_t gunType)
     }
 }
 
+static void checkChillerAlarmState(void)
+{
+    uint8_t gunIndex = 0;
+    struct ChargingInfoData *pDcChargingInfo = NULL;
+
+    for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+        pDcChargingInfo =  (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
+
+        if (ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP == YES) {
+            pAlarmCode->AlarmEvents.bits.SystemChillerOTP = YES;
+        } else {
+            pAlarmCode->AlarmEvents.bits.SystemChillerOTP = NO;
+        }
+
+        if (ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerTempSensorFail == YES) {
+            pFaultCode->FaultEvents.bits.ChillerTempSensorBroken = YES;
+        } else {
+            pFaultCode->FaultEvents.bits.ChillerTempSensorBroken = NO;
+        }
+    }
+}
+
 static void checkEvBoardAlarmState(uint8_t gunType)
 {
     switch (gunType) {
@@ -584,6 +627,8 @@ static void checkEvBoardAlarmState(uint8_t gunType)
         checkGBTAlarmState(gunType);
         break;
     }
+
+    checkChillerAlarmState();
 }
 
 #if 0
@@ -897,13 +942,14 @@ long long DiffTimebWithNow(struct timeb ST)
     ftime(&ET);
     StartTime = (long long)ST.time;
     StopTime = (long long)ET.time;
+
     return ((StopTime - StartTime) * 1000) + (ET.millitm - ST.millitm);
 }
 
 //==========================================
 // Log
 //==========================================
-void CheckFwSlotStatusLog()
+void CheckFwSlotStatusLog(void)
 {
     if (bd0_1_status == 0 && bd0_2_status == 1) {
         log_info("Connector 1 : Chademo");
@@ -2245,7 +2291,10 @@ int SpawnTask()
 
 #if defined DD360 ||defined DD360Audi || defined DD360ComBox
     system("/root/Module_DoComm &");
-#else
+
+    return PASS;
+#endif defined DD360 ||defined DD360Audi || defined DD360ComBox
+
     system("/root/Module_PsuComm &");
 
     if (strcmp((char *)pSysConfig->OcppServerURL, "") != EQUAL &&
@@ -2265,7 +2314,6 @@ int SpawnTask()
         system("/root/Module_4g &");
         system("/root/Module_Wifi &");
     }
-#endif //defined DD360 || defined DD360Audi
 
     return PASS;
 }
@@ -2346,13 +2394,14 @@ bool isEvBoardNormalStopChargeFlag(uint8_t gunIndex)
 //===============================================
 // 掃描插槍狀況
 //===============================================
-void ClearDetectPluginFlag()
+void ClearDetectPluginFlag(void)
 {
+    uint8_t gunIndex = 0;
     pSysInfo->WaitForPlugit = NO;
 
     //DS60-120 add
-    for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gun_index);
+    for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
 
         if (pDcChargingInfo->RemoteStartFlag == YES) {
             pDcChargingInfo->RemoteStartFlag = NO;
@@ -2422,6 +2471,7 @@ uint8_t isPrechargeStatus_chademo(uint8_t gunIndex)
 
     return result;
 }
+
 //===============================================
 // Common Detect Chk - GB
 //===============================================
@@ -2491,8 +2541,10 @@ bool isEvStopCharging_ccs(uint8_t gunIndex)
 //===============================================
 void DisplayChargingInfo()
 {
+    uint8_t i = 0;
+
     log_info("*********** DisplayChargingInfo *********** \n");
-    for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) {
+    for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
         pAcChargingInfo =  (struct ChargingInfoData *)GetAcChargingInfoData(i);
 
         if (pAcChargingInfo->SystemStatus != S_IDLE &&
@@ -2512,6 +2564,7 @@ void DisplayChargingInfo()
     }
 
     usleep(50000);
+
 #if defined DD360Audi
     pSysInfo->SystemPage = _LCM_SELECT_GUN;
 #else
@@ -2519,7 +2572,7 @@ void DisplayChargingInfo()
 #endif //defined DD360Audi
 }
 
-void _AutoReturnTimeout()
+void _AutoReturnTimeout(void)
 {
     log_info("*********** _AutoReturnTimeout %d*********** \n", pSysInfo->PageIndex);
     if (pSysInfo->PageIndex == _LCM_WAIT_FOR_PLUG) {
@@ -2527,7 +2580,9 @@ void _AutoReturnTimeout()
     } else if (pSysInfo->PageIndex == _LCM_AUTHORIZ_COMP) {
         DetectPluginStart();
     }
+
     usleep(50000);
+
 #if defined DD360Audi
     pSysInfo->SystemPage = _LCM_SELECT_GUN;
 #else
@@ -2535,7 +2590,7 @@ void _AutoReturnTimeout()
 #endif //defined DD360Audi
 }
 
-void _SelfTestTimeout()
+void _SelfTestTimeout(void)
 {
     if (pSysInfo->BootingStatus != BOOT_COMPLETE) {
         for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
@@ -2547,7 +2602,7 @@ void _SelfTestTimeout()
     log_info("Self test timeout. \n");
 }
 
-void _AuthorizedTimeout()
+void _AuthorizedTimeout(void)
 {
     if (IsAuthorizingMode()) {
         log_info("*********** _AuthorizedTimeout *********** \n");
@@ -2562,13 +2617,14 @@ void _AuthorizedTimeout()
     }
 }
 
-void _DetectPlugInTimeout()
+void _DetectPlugInTimeout(void)
 {
     log_info("*********** _DetectPlugInTimeout *********** \n");
     strcpy((char *)pSysConfig->UserId, "");
     ClearDetectPluginFlag();
-    //usleep(50000);
-    sleep(1); //Jerry add
+
+    sleep(1); //等待DoComm回報插槍訊號給主櫃
+
 #if defined DD360Audi
     pSysInfo->SystemPage = _LCM_SELECT_GUN;
 #else
@@ -2646,19 +2702,19 @@ bool canStartCharging()
 }
 #endif //0
 
-void AuthorizingStart()
+void AuthorizingStart(void)
 {
     ShmOCPP16Data->SpMsg.bits.AuthorizeReq = YES;
     pSysInfo->AuthorizeFlag = YES;
 }
 
-void ClearAuthorizedFlag()
+void ClearAuthorizedFlag(void)
 {
     ShmOCPP16Data->SpMsg.bits.AuthorizeConf = NO;
     pSysInfo->AuthorizeFlag = NO;
 }
 
-bool isAuthorizedComplete()
+bool isAuthorizedComplete(void)
 {
     if (pSysInfo->AuthorizeFlag == YES) {
         return false;
@@ -2694,22 +2750,43 @@ void ResetChargerAlarmCode(uint8_t gunIndex, char *code)
     else if (strcmp(code, "011018") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail = NO; }
     else if (strcmp(code, "011019") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail = NO; }
     else if (strcmp(code, "011020") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail = NO; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP = NO; }
+    else if (strcmp(code, "011038") == EQUAL) { ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerTempSensorFail = NO; }
 
     if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "", 6) != EQUAL) {
-        if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012229", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012230", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012231", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011011", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011013", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011015", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011012", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011014", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011016", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011018", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011019", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011020", 6) == EQUAL) {
+        if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectOTP == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectOTP == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectOTP == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaRelayWeldingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSRelayWeldingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTRelayWeldingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaRelayDrivingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSRelayDrivingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTRelayDrivingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail == NO &&
+                ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP == NO &&
+                ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerTempSensorFail == NO
+           ) {
             strncpy((char *)pDcChargingInfo->ConnectorAlarmCode, "", 6);
         }
+        //if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012229", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012230", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012231", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011011", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011013", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011015", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011012", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011014", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011016", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011018", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011019", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011020", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012323", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011038", 6) == EQUAL) {
+        //    strncpy((char *)pDcChargingInfo->ConnectorAlarmCode, "", 6);
+        //}
     }
 }
 
@@ -2750,6 +2827,8 @@ void RecordAlarmCode(uint8_t gunIndex, char *code)
     else if (strcmp(code, "011018") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail = YES; }
     else if (strcmp(code, "011019") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail = YES; }
     else if (strcmp(code, "011020") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail = YES; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP = YES; }
+    else if (strcmp(code, "011038") == EQUAL) { ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerTempSensorFail = YES; }
 }
 
 void RecordWarningCode(uint8_t gunIndex, char *code)
@@ -2903,7 +2982,9 @@ void ReleaseAlarmCode(uint8_t gunIndex)
     if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012251", 6) == EQUAL ||
             strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012252", 6) == EQUAL ||
             strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012238", 6) == EQUAL ||
-            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012304", 6) == EQUAL
+            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012304", 6) == EQUAL ||
+            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012323", 6) == EQUAL ||
+            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011038", 6) == EQUAL
        ) {
         memset(pDcChargingInfo->ConnectorAlarmCode, 0, sizeof(pDcChargingInfo->ConnectorAlarmCode));
     }
@@ -3463,6 +3544,12 @@ void CheckErrorOccurStatus(uint8_t index)
         } else if (pAlarmCode->AlarmEvents.bits.DisconnectedFromDo == YES) {
             memcpy(pDcChargingInfo->ConnectorAlarmCode, "012304", 6);
         }
+        //Chiller temperature
+        else if (pAlarmCode->AlarmEvents.bits.SystemChillerOTP == YES) {
+            memcpy(pDcChargingInfo->ConnectorAlarmCode, "012323", 6);
+        } else if (pFaultCode->FaultEvents.bits.ChillerTempSensorBroken == YES) {
+            memcpy(pDcChargingInfo->ConnectorAlarmCode, "011038", 6);
+        }
     }
 }
 
@@ -6136,20 +6223,20 @@ void ResetDetAlarmStatus(uint8_t gun)
     }
 }
 
-static void powerCabinetPsuAlarmStatus(void)
-{
-    uint8_t i = 0;
-
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-    return;
-#endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
-
-    for (i = 0; i < pSysWarning->WarningCount; i++) {
-        if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
-            EmcOccureByString("042267");
-        }
-    }
-}
+//static void powerCabinetPsuAlarmStatus(void)
+//{
+//    uint8_t i = 0;
+//
+//#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+//    return;
+//#endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
+//
+//    for (i = 0; i < pSysWarning->WarningCount; i++) {
+//        if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
+//            EmcOccureByString("042267");
+//        }
+//    }
+//}
 
 static void autoStartChargingForComBox(uint8_t gunIndex)
 {
@@ -6183,12 +6270,19 @@ static void ReviewCriticalAlarm(void)
             ShmDcCommonData->GunRelayDrivingOccur[1] == YES ||
             ShmDcCommonData->GunRelayWeldingOccur[0] == YES ||
             ShmDcCommonData->GunRelayWeldingOccur[1] == YES ||
-            pAlarmCode->AlarmEvents.bits.EmergencyStopTrip ||
-            pAlarmCode->AlarmEvents.bits.MainPowerBreakerTrip ||
-            pAlarmCode->AlarmEvents.bits.DoorOpen ||
+            pAlarmCode->AlarmEvents.bits.EmergencyStopTrip == YES ||
+            pAlarmCode->AlarmEvents.bits.MainPowerBreakerTrip == YES ||
+            pAlarmCode->AlarmEvents.bits.DoorOpen == YES ||
             pSysWarning->ExtraErrProcess != _EXTRA_ERR_PROCESS_NONE ||
-            pAlarmCode->AlarmEvents.bits.PsuFailureAlarm ||
-            pAlarmCode->AlarmEvents.bits.DisconnectedFromDo
+            pAlarmCode->AlarmEvents.bits.PsuFailureAlarm == YES ||
+            pAlarmCode->AlarmEvents.bits.DisconnectedFromDo == YES ||
+            //Power cabinet alarm status
+            ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure == YES
        ) {
         pSysWarning->Level = 2;
     } else {
@@ -6436,7 +6530,7 @@ int main(void)
         CheckReturnToChargingConn();
 
         //確認Power cabinet PSU Status
-        powerCabinetPsuAlarmStatus();
+        //powerCabinetPsuAlarmStatus();
 
         if (pGunIndexInfo->AcGunIndex > 0 && isDetectPlugin() && !GetIsCardScan()) {
             pSysInfo->SystemPage = _LCM_WAIT_FOR_PLUG;

+ 24 - 0
EVSE/Projects/DD360/Apps/Config.h

@@ -310,6 +310,28 @@ typedef union {
     } GunBits;
 } EvBoardErrMsg;
 
+typedef union {
+    uint8_t AlarmState;
+    struct {
+        uint8_t EmergencyStop: 1;    //Power cabinet emergency stop
+        uint8_t DoorOpen: 1;         //Power cabinet emergency door open
+        uint8_t SystemL1InputOVP: 1; //Power cabinet system L1 input OVP
+        uint8_t SystemL2InputOVP: 1; //Power cabinet System L2 input OVP
+        uint8_t SystemL3InputOVP: 1; //Power cabinet System L3 input OVP
+        uint8_t PsuFailure: 1;       //Power cabinet PSU Failure Alarm
+        uint8_t Reserved: 2;
+    } StatusBit;
+} PowerAlarmState;
+
+typedef union {
+    uint8_t ChillerState;
+    struct {
+        uint8_t ChillerOTP: 1;            //chiller Temperature OVP
+        uint8_t ChillerTempSensorFail: 1; //Chiller temperature sensor failure
+        uint8_t Reserved: 6;
+    } StatusBit;
+} ChillerTempState;
+
 typedef struct StDcCommonInfo {
     uint8_t RebootCount;
     uint8_t CcsVersion;
@@ -319,6 +341,8 @@ typedef struct StDcCommonInfo {
     uint8_t GunRelayDrivingOccur[2];
     uint8_t SystemModeChange;
     uint8_t Reserved[3];
+    PowerAlarmState PowerAlarmState;
+    ChillerTempState ChillerTempState[2];
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 5 - 5
EVSE/Projects/DD360/Apps/Define/define.c

@@ -102,7 +102,7 @@ char FaultStatusCode[40][6]=
 "011035", //Ble module broken
 "011036", //Rotary switch fault
 "011037", //CCS liquid chiller water level fault
-"011038", //Reserved
+"011038", //Chiller temperature sensor broken
 "011039", //Reserved
 "011040" //Reserved
 };
@@ -229,10 +229,10 @@ char AlarmStatusCode[128][6]=
 "012317", // Psu Dcdc Eeprom Fault
 "012318", // Psu Pfc Eeprom Fault
 "012319", // Psu Dcdc Over Voltage
-"012320", // reserved
-"012321", // reserved
-"012322", // reserved
-"012323", // reserved
+"012320", // System CHAdeMO output UCP
+"012321", // System CCS output UCP
+"012322", // System GBT output UCP
+"012323", // System Chiller output OTP
 "012324", // reserved
 "012325", // reserved
 "012326", // reserved

+ 202 - 165
EVSE/Projects/DD360/Apps/Define/define.h

@@ -169,6 +169,10 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
 #define ShmOcpp20ModuleKey		1012
 #define ShmRelay2BdKey			1013
 
+#define FaultCodeLength         5
+#define AlarmCodeLength         16
+#define InfoCodeLength          41
+
 /**************************************************************************************/
 /****************** Share memory configuration value constant define ******************/
 /**************************************************************************************/
@@ -289,7 +293,7 @@ enum CoreProfile {
      DefaultPrice,
      CustomDisplayCostAndPrice,
      CustomIdleFeeAfterStop,
-	 ConfigurationVersion,
+     ConfigurationVersion,
 	 _CoreProfile_CNT
 };
 
@@ -401,10 +405,19 @@ typedef union
         unsigned int NormalStop:1;                  // 0: no effect,    1: normal stop
         unsigned int AlarmStop:1;                   // 0: no effect,    1: alarm stop
         unsigned int BackendStop:1;                 // 0: no effect,    1: backend stop
-        unsigned int res:29;
+        unsigned int ManualStop:1;                  // 0: no effect,    1: manual stop
+        unsigned int res:28;
     }bits;
 }ChargingStop;
 
+typedef struct
+{
+    unsigned char DispenserSequence;                    // dispenser sequence
+    unsigned char MaxConnectorQuantity;                 // max connector quantity
+    unsigned char WiringSetting[8];                     // record connector quantity of dispenser
+    unsigned char PowerCabinetReserved[32];
+}WiringInfoData;
+
 struct SysConfigData
 {
 	/**************System***************/
@@ -465,7 +478,10 @@ struct SysConfigData
 	unsigned char			ShowInformation;
 	unsigned char           isReqFirstUpgrade;          //EVSE is request first upgrade from PH server
 	unsigned char           isEnableLocalPowerSharging; //0: Disable power sharing  1: Enable power sharing
-	unsigned char			StopChargingByButton;		//0: Disable  1: Enable
+	unsigned char           StopChargingByButton;       //0: Disable  1: Enable
+
+    /************PowerCabinet************/
+    WiringInfoData          WiringInfo;
 };
 
 struct ChargingInfoData
@@ -510,6 +526,8 @@ struct ChargingInfoData
 	float					ChargingFee;
 	// Connector Temp
 	unsigned char 		ConnectorTemp;			//0x00: -60¢XC  ~  0xFE: 194
+	//Chiller Temp
+	unsigned char 		ChillerTemp;			//0x00: -60¢XC  ~  0xFE: 194
 	// Charging Status
 	unsigned char 		GroundFaultStatus;		// for GFD result => 0x00 : None, 0x01 : Can Start Charging, 0x02 : Stop Charging
 	unsigned short		RealRatingPower;
@@ -580,7 +598,9 @@ typedef union
         unsigned int EthernetStatusRequest:1;           // 0: no request,   1: ethernet connection status has changed           ( cabinet -> dispenser)
         unsigned int WiFiStatusRequest:1;               // 0: no request,   1: wifi connection status has changed               ( cabinet -> dispenser)
         unsigned int TelcomModemStatusRequest:1;        // 0: no request,   1: 4g connection status has changed                 ( cabinet -> dispenser)
-        unsigned int res:11;
+        unsigned int BillingStatusRequest:1;            // 0: no request,   1: billing status has changed                       ( cabinet -> dispenser)
+        unsigned int StopButtonStatusRequest:1;         // 0: no request,   1: stop charging button status has changed          ( cabinet -> dispenser)
+        unsigned int res:9;
     }bits;
 }DispenserSettingFlag;
 
@@ -636,10 +656,13 @@ struct ConnectionInfoData
 
 struct DispenserInfoData
 {
-    unsigned char               DispenserQuantity;
-    unsigned char               TotalConnectorQuantity;
+    unsigned char               DispenserQuantity;                  // record max dispenser quantity
+    unsigned char               TotalConnectorQuantity;             // record max connector quantity
     struct DispenserModule      Dispenser[GENERAL_GUN_QUANTITY];
 
+    unsigned char               PresentDispenserQuantity;
+    unsigned char               PresentConnectorQuantity;
+
     union
     {
         unsigned char Status;
@@ -747,7 +770,10 @@ typedef union
         unsigned int AuthorizingCompleted:1;    // 0: not yet, 1: authorizing completed
         unsigned int DispenserDisconnection:1;  // 0: no connection,  1: dispenser connected
         unsigned int BackendAuthorized:1;       // 0: local authorized, 1: backend authorized
-        unsigned int res:28;
+        unsigned int WiringInfoChanged:1;       // 0: no effect, 1: wiring info has changed
+        unsigned int EnableWriteWiringInfo:1;   // 0: no effect, 1: enable write wiring info after timeout
+        unsigned int CleanWiringInfo:1;         // 0: no effect, 1: clean wiring info
+        unsigned int res:25;
     }bits;
 }CabinetSettingFlag;
 
@@ -760,6 +786,8 @@ typedef struct
     unsigned int EthernetStatus;                // 0: disable, 1: connected, 2: disconnected
     unsigned int WiFiStatus;                    // 0: disable, 1: connected, 2: disconnected
     unsigned int TelcomModemStatus;             // 0: disable, 1: connected, 2: disconnected
+    unsigned int BillingStatus;                 // 0: disable, 1: enable
+    unsigned int StopChargingButton;            // 0: disable, 1: enable
     unsigned int HardwareReboot;                // 1: HardwareReboot, Other value: no effect
     unsigned int SoftwareRestart;               // 1: SoftwareRestart, Other value: no effect
 }CabinetMiscCommand;
@@ -978,7 +1006,7 @@ char FaultStatusCode[40][6]=
 	"011035",	//Ble module broken
 	"011036",	//Rotary switch fault
 	"011037",	//CCS liquid chiller water level fault
-	"011038",	//Reserved
+	"011038",	//Chiller temperature sensor broken
 	"011039",	//Reserved
 	"011040"	//Reserved
 };
@@ -986,10 +1014,10 @@ char FaultStatusCode[40][6]=
 
 struct FaultCodeData
 {
-	unsigned char PreviousFaultVal[5];
+	unsigned char PreviousFaultVal[FaultCodeLength];
 	union
 	{
-		unsigned char FaultVal[5];
+		unsigned char FaultVal[FaultCodeLength];
 		struct
 		{
 			//FaultVal[0]
@@ -1034,7 +1062,8 @@ struct FaultCodeData
 			unsigned char BleModuleBroken:1;					//bit 2
 			unsigned char RotarySwitchFault:1;					//bit 3 
 			unsigned char CcsLiquidChillerWaterLevelFault:1;    //bit 4
-			unsigned char :3;									//bit 5 ~ 7	reserved
+			unsigned char ChillerTempSensorBroken:1;            //bit 5
+			unsigned char :2;									//bit 6 ~ 7	reserved
 		}bits;
 	}FaultEvents;
 };
@@ -1162,10 +1191,10 @@ char AlarmStatusCode[128][6]=
     "012317",   // Psu Dcdc Eeprom Fault
     "012318",   // Psu Pfc Eeprom Fault
     "012319",   // Psu Dcdc Over Voltage
-    "012320",   // reserved
-    "012321",   // reserved
-    "012322",   // reserved
-    "012323",   // reserved
+    "012320",   // System CHAdeMO output UCP
+    "012321",   // System CCS output UCP
+    "012322",   // System GBT output UCP
+    "012323",   // System Chiller output OTP
     "012324",   // reserved
     "012325",   // reserved
     "012326",   // reserved
@@ -1174,10 +1203,10 @@ char AlarmStatusCode[128][6]=
 */
 struct AlarmCodeData
 {
-	unsigned char PreviousAlarmVal[16];
+	unsigned char PreviousAlarmVal[AlarmCodeLength];
 	union
 	{
-		unsigned char AlarmVal[16];
+		unsigned char AlarmVal[AlarmCodeLength];
 		struct
 		{
 			//AlarmVal[0]
@@ -1316,7 +1345,11 @@ struct AlarmCodeData
             unsigned char PsuPfcEepromFault:1;                      //bit 6
             unsigned char PsuDcdcOverVoltage:1;                     //bit 7
             //AlarmVal[15]
-            unsigned char Reserved:8;                               //bit 0~7
+            unsigned char SystemChademoOutputUCP:1;				    //bit 0
+            unsigned char SystemCCSOutputUCP:1;				        //bit 1
+            unsigned char SystemGBTOutputUCP:1;				        //bit 2
+            unsigned char SystemChillerOTP:1;                       //bit 3
+            unsigned char Reserved:4;                               //bit 4~7
 		}bits;
 	}AlarmEvents;
 };
@@ -1658,10 +1691,10 @@ char InfoStatusCode[384][6]=
 */
 struct InfoCodeData
 {
-	unsigned char PreviousInfoVal[41];
+	unsigned char PreviousInfoVal[InfoCodeLength];
 	union
 	{
-		unsigned char InfoVal[41];
+		unsigned char InfoVal[InfoCodeLength];
 		struct
 		{
 			//InfoVal[0]
@@ -2083,6 +2116,10 @@ struct PsuGroupData
 	unsigned int            GroupPresentOutputPower;        //Watt
 	struct PsuModuleData 	PsuModule[MAX_PSU_QUANTITY];
 	PsuGroupError           GroupErrorFlag;
+    unsigned short          TotalIAvailableCurrent;         // unit: 0.1A
+    unsigned short          TempIAvailableCurrent;          // unit: 0.1A
+    unsigned short          StableIAvailableCurrent;        // unit: 0.1A
+    unsigned short          StableCurrentCounter;           // stable current counter
 };
 
 /*Following is the information for system all PSU*/
@@ -4230,104 +4267,104 @@ struct StructCost
 
 struct CertificateHashDataType
 {
-	unsigned char hashAlgorithm[8];								// Required. Used algorithms for the hashes provided.
-	unsigned char issuerNameHash[129];							// Required. hashed value of the IssuerName.
-	unsigned char issuerKeyHash[129];							// Required. Hashed value of the issuers public key
-	unsigned char serialNumber[41];								// Required. The serial number of the certificate.
+    unsigned char hashAlgorithm[8];                             // Required. Used algorithms for the hashes provided.
+    unsigned char issuerNameHash[129];                          // Required. hashed value of the IssuerName.
+    unsigned char issuerKeyHash[129];                           // Required. Hashed value of the issuers public key
+    unsigned char serialNumber[41];                             // Required. The serial number of the certificate.
 };
 
 struct LogParametersType
 {
-	unsigned char remoteLocation[513];								// Required. The URL of the location at the remote system where the log should be stored.
-	unsigned char oldestTimestamp[36];								// Optional. This contains the date and time of the oldest logging information to include in the diagnostics.
-	unsigned char latestTimestamp[36];								// Optional. This contains the date and time of the latest logging information to include in the diagnostics.
+    unsigned char remoteLocation[513];                              // Required. The URL of the location at the remote system where the log should be stored.
+    unsigned char oldestTimestamp[36];                              // Optional. This contains the date and time of the oldest logging information to include in the diagnostics.
+    unsigned char latestTimestamp[36];                              // Optional. This contains the date and time of the latest logging information to include in the diagnostics.
 };
 
 struct FirmwareType
 {
-	unsigned char location[513];									// Required. URI defining the origin of the firmware.
-	unsigned char retrieveDateTime[36];								// Required. Date and time at which the firmware shall be retrieved.
-	unsigned char installDateTime[36];								// Optional. Date and time at which the firmware shall be installed.
-	unsigned char signingCertificate[5501];							// Optional. Certificate with which the firmware was signed. X.509 certificate, first DER encoded into binary, and then Base64 encoded.
-	unsigned char signature[801];									// Optional. Base64 encoded firmware signature.
+    unsigned char location[513];                                    // Required. URI defining the origin of the firmware.
+    unsigned char retrieveDateTime[36];                             // Required. Date and time at which the firmware shall be retrieved.
+    unsigned char installDateTime[36];                              // Optional. Date and time at which the firmware shall be installed.
+    unsigned char signingCertificate[5501];                         // Optional. Certificate with which the firmware was signed. X.509 certificate, first DER encoded into binary, and then Base64 encoded.
+    unsigned char signature[801];                                   // Optional. Base64 encoded firmware signature.
 };
 
 struct StructCertificateSigned
 {
-	unsigned char certificateChain[10001];
-	unsigned char Response_status[16];
+    unsigned char certificateChain[10001];
+    unsigned char Response_status[16];
 };
 
 struct StructDeleteCertificate
 {
-	struct CertificateHashDataType certificateHashData;
-	unsigned char Response_status[16];
+    struct CertificateHashDataType certificateHashData;
+    unsigned char Response_status[16];
 };
 
 struct StructExtendedTrigger
 {
-	unsigned char requestedMessage[32];
-	int connectorId;
-	unsigned char Response_status[16];
+    unsigned char requestedMessage[32];
+    int connectorId;
+    unsigned char Response_status[16];
 };
 
 struct StructGetInstalledCertificateIds
 {
-	unsigned char certificateType[32];
-	unsigned char Response_status[16];
-	struct CertificateHashDataType Response_certificateHashData[3];
+    unsigned char certificateType[32];
+    unsigned char Response_status[16];
+    struct CertificateHashDataType Response_certificateHashData[3];
 };
 
 struct StructGetLog
 {
-	unsigned char logType[16];
-	int requestId;
-	int retries;
-	int retryInterval;
-	struct LogParametersType log;
-	unsigned char Response_status[16];
-	unsigned char Response_filename[256];
+    unsigned char logType[16];
+    int requestId;
+    int retries;
+    int retryInterval;
+    struct LogParametersType log;
+    unsigned char Response_status[16];
+    unsigned char Response_filename[256];
 };
 
 struct StructInstallCertificate
 {
-	unsigned char certificateType[32];
-	unsigned char certificate[5501];
-	unsigned char Response_status[16];
+    unsigned char certificateType[32];
+    unsigned char certificate[5501];
+    unsigned char Response_status[16];
 };
 
 struct StructSignedUpdateFirmware
 {
-	int retries;
-	int retryInterval;
-	int requestId;
-	struct FirmwareType firmware;
-	unsigned char Response_status[16];
+    int retries;
+    int retryInterval;
+    int requestId;
+    struct FirmwareType firmware;
+    unsigned char Response_status[16];
 };
 
 struct StructLogStatusNotification
 {
-	unsigned char status[32];
-	int requestId;
+    unsigned char status[32];
+    int requestId;
 };
 
 struct StructSecurityEventNotification
 {
-	unsigned char type[51];
-	unsigned char timestamp[28];
-	unsigned char techInfo[256];
+    unsigned char type[51];
+    unsigned char timestamp[28];
+    unsigned char techInfo[256];
 };
 
 struct StructSignCertificate
 {
-	unsigned char csr[5501];
-	unsigned char Response_status[16];
+    unsigned char csr[5501];
+    unsigned char Response_status[16];
 };
 
 struct StructSignedFirmwareStatusNotification
 {
-	unsigned char status[32];
-	int requestId;
+    unsigned char status[32];
+    int requestId;
 };
 
 struct OCPP16Data
@@ -4362,23 +4399,23 @@ struct OCPP16Data
         struct
         {
             //SpMsgValue[0]
-            unsigned char BootNotificationReq :1;               	//bit 0,
-            unsigned char BootNotificationConf :1;              	//bit 1,
-            unsigned char AuthorizeReq :1;                      	//bit 2,
-            unsigned char AuthorizeConf :1;                     	//bit 3,
-            unsigned char DiagnosticsStatusNotificationReq :1;  	//bit 4,
-            unsigned char DiagnosticsStatusNotificationConf :1; 	//bit 5,
-            unsigned char FirmwareStatusNotificationReq :1;     	//bit 6,
-            unsigned char FirmwareStatusNotificationConf :1;   	 	//bit 7,
+            unsigned char BootNotificationReq :1;                   //bit 0,
+            unsigned char BootNotificationConf :1;                  //bit 1,
+            unsigned char AuthorizeReq :1;                          //bit 2,
+            unsigned char AuthorizeConf :1;                         //bit 3,
+            unsigned char DiagnosticsStatusNotificationReq :1;      //bit 4,
+            unsigned char DiagnosticsStatusNotificationConf :1;     //bit 5,
+            unsigned char FirmwareStatusNotificationReq :1;         //bit 6,
+            unsigned char FirmwareStatusNotificationConf :1;        //bit 7,
             //SpMsgValue[1]
             unsigned char LogStatusNotificationReq :1;              //bit 0,
-			unsigned char LogStatusNotificationConf :1;             //bit 1,
-			unsigned char SecurityEventNotificationReq :1;          //bit 2,
-			unsigned char SecurityEventNotificationConf :1;         //bit 3,
-			unsigned char SignCertificateReq :1;  					//bit 4,
-			unsigned char SignCertificateConf :1; 					//bit 5,
-			unsigned char SignedFirmwareStatusNotificationReq :1;   //bit 6,
-			unsigned char SignedFirmwareStatusNotificationConf :1;	//bit 7,
+            unsigned char LogStatusNotificationConf :1;             //bit 1,
+            unsigned char SecurityEventNotificationReq :1;          //bit 2,
+            unsigned char SecurityEventNotificationConf :1;         //bit 3,
+            unsigned char SignCertificateReq :1;                    //bit 4,
+            unsigned char SignCertificateConf :1;                   //bit 5,
+            unsigned char SignedFirmwareStatusNotificationReq :1;   //bit 6,
+            unsigned char SignedFirmwareStatusNotificationConf :1;  //bit 7,
         } bits;
     } SpMsg;
 
@@ -4424,40 +4461,40 @@ struct OCPP16Data
         struct
         {
             //CsMsgValue[0]
-            unsigned char ChangeConfigurationReq :1;    			//bit 0,
-            unsigned char ChangeConfigurationConf :1;   			//bit 1,
-            unsigned char ClearCacheReq :1;             			//bit 2,
-            unsigned char ClearCacheConf :1;            			//bit 3,
-            unsigned char GetConfigurationReq :1;       			//bit 4,
-            unsigned char GetConfigurationConf :1;      			//bit 5,
-            unsigned char UpdateFirmwareReq :1;         			//bit 6,
-            unsigned char UpdateFirmwareConf :1;        			//bit 7,
+            unsigned char ChangeConfigurationReq :1;                //bit 0,
+            unsigned char ChangeConfigurationConf :1;               //bit 1,
+            unsigned char ClearCacheReq :1;                         //bit 2,
+            unsigned char ClearCacheConf :1;                        //bit 3,
+            unsigned char GetConfigurationReq :1;                   //bit 4,
+            unsigned char GetConfigurationConf :1;                  //bit 5,
+            unsigned char UpdateFirmwareReq :1;                     //bit 6,
+            unsigned char UpdateFirmwareConf :1;                    //bit 7,
             //CsMsgValue[1]
-            unsigned char GetDiagnosticsReq :1;         			//bit 0,
-            unsigned char GetDiagnosticsConf :1;        			//bit 1,
-            unsigned char GetLocalListVersionReq :1;   				//bit 2,
-            unsigned char GetLocalListVersionConf :1;   			//bit 3,
-            unsigned char ResetReq :1;                  			//bit 4,
-            unsigned char ResetConf :1;                 			//bit 5,
-            unsigned char SendLocalListReq :1;         				//bit 6,
-            unsigned char SendLocalListConf :1;         			//bit 7,
+            unsigned char GetDiagnosticsReq :1;                     //bit 0,
+            unsigned char GetDiagnosticsConf :1;                    //bit 1,
+            unsigned char GetLocalListVersionReq :1;                //bit 2,
+            unsigned char GetLocalListVersionConf :1;               //bit 3,
+            unsigned char ResetReq :1;                              //bit 4,
+            unsigned char ResetConf :1;                             //bit 5,
+            unsigned char SendLocalListReq :1;                      //bit 6,
+            unsigned char SendLocalListConf :1;                     //bit 7,
             //CsMsgValue[2]
-            unsigned char CertificateSignedReq :1;					//bit 0
-            unsigned char CertificateSignedConf :1;					//bit 1
-            unsigned char DeleteCertificateReq :1;					//bit 2
-            unsigned char DeleteCertificateConf :1;					//bit 3
-            unsigned char ExtendedTriggerMessageReq :1;				//bit 4
-            unsigned char ExtendedTriggerMessageConf :1;			//bit 5
-            unsigned char GetInstalledCertificateIdsReq :1;			//bit 6
-            unsigned char GetInstalledCertificateIdsConf :1;		//bit 7
+            unsigned char CertificateSignedReq :1;                  //bit 0
+            unsigned char CertificateSignedConf :1;                 //bit 1
+            unsigned char DeleteCertificateReq :1;                  //bit 2
+            unsigned char DeleteCertificateConf :1;                 //bit 3
+            unsigned char ExtendedTriggerMessageReq :1;             //bit 4
+            unsigned char ExtendedTriggerMessageConf :1;            //bit 5
+            unsigned char GetInstalledCertificateIdsReq :1;         //bit 6
+            unsigned char GetInstalledCertificateIdsConf :1;        //bit 7
             //CsMsgValue[3]
-            unsigned char GetLogReq :1;								//bit 0
-            unsigned char GetLogConf :1;							//bit 1
-            unsigned char InstallCertificateReq :1;					//bit 2
-            unsigned char InstallCertificateConf :1;				//bit 3
-            unsigned char SignedUpdateFirmwareReq :1;				//bit 4
-            unsigned char SignedUpdateFirmwareConf :1;				//bit 5
-            unsigned char :2;										//bit 6 & 7
+            unsigned char GetLogReq :1;                             //bit 0
+            unsigned char GetLogConf :1;                            //bit 1
+            unsigned char InstallCertificateReq :1;                 //bit 2
+            unsigned char InstallCertificateConf :1;                //bit 3
+            unsigned char SignedUpdateFirmwareReq :1;               //bit 4
+            unsigned char SignedUpdateFirmwareConf :1;              //bit 5
+            unsigned char :2;                                       //bit 6 & 7
         } bits;
     } MsMsg;
 
@@ -4474,48 +4511,48 @@ struct OCPP16Data
         } bits[CONNECTOR_QUANTITY];
     }CSUMsg;
 
-    struct StructBootNotification               	BootNotification;
-    struct StructHeartbeat                     	 	Heartbeat;
-    struct StructAuthorize                      	Authorize;
-    struct StructStartTransaction               	StartTransaction[CONNECTOR_QUANTITY];
-    struct StructStopTransaction                	StopTransaction[CONNECTOR_QUANTITY];
-    struct StructStatusNotification             	StatusNotification[CONNECTOR_QUANTITY];
-    struct StructCancelReservation              	CancelReservation[CONNECTOR_QUANTITY];
-    struct StructChangeAvailability             	ChangeAvailability[CONNECTOR_QUANTITY];
-    struct StructChangeConfiguration            	ChangeConfiguration;
-    struct StructClearCache                     	ClearCache;
-    struct StructClearChargingProfile           	ClearChargingProfile[CONNECTOR_QUANTITY];
-    struct StructDataTransfer                   	DataTransfer[CONNECTOR_QUANTITY];
-    struct StructDiagnosticsStatusNotification  	DiagnosticsStatusNotification;
-    struct StructFirmwareStatusNotification     	FirmwareStatusNotification;
-    struct StructGetCompositeSchedule           	GetCompositeSchedule[CONNECTOR_QUANTITY];
-    struct StructGetConfiguration               	GetConfiguration;
-    struct StructGetDiagnostics                 	GetDiagnostics;
-    struct StructGetLocalListVersion            	GetLocalListVersion;
-    struct StructMeterValues                    	MeterValues[CONNECTOR_QUANTITY];
-    struct StructRemoteStartTransaction         	RemoteStartTransaction[CONNECTOR_QUANTITY];
-    struct StructRemoteStopTransaction          	RemoteStopTransaction[CONNECTOR_QUANTITY];
-    struct StructReserveNow                     	ReserveNow[CONNECTOR_QUANTITY];
-    struct StructReset                          	Reset;
-    struct StructSendLocalList                  	SendLocalList;
-    struct StructSetChargingProfile            		SetChargingProfile[CONNECTOR_QUANTITY];
-    struct StructTriggerMessage                 	TriggerMessage[CONNECTOR_QUANTITY];
-    struct StructUnlockConnector                	UnlockConnector[CONNECTOR_QUANTITY];
-    struct StructUpdateFirmware                 	UpdateFirmware;
-    struct OCPP16ConfigurationTable             	ConfigurationTable;
-    struct StructChargingProfile                	SmartChargingProfile[CONNECTOR_QUANTITY];
-    struct StructCost                           	Cost;
-    struct StructCertificateSigned					CertificateSigned;
-    struct StructDeleteCertificate					DeleteCertificate;
-    struct StructExtendedTrigger					ExtendedTriggerMessage;
-    struct StructGetInstalledCertificateIds			GetInstalledCertificateIds;
-    struct StructGetLog								GetLog;
-    struct StructInstallCertificate					InstallCertificate;
-    struct StructSignedUpdateFirmware				SignedUpdateFirmware;
-    struct StructLogStatusNotification				LogStatusNotification;
-    struct StructSecurityEventNotification			SecurityEventNotification;
-    struct StructSignCertificate					SignCertificate;
-    struct StructSignedFirmwareStatusNotification 	SignedFirmwareStatusNotification;
+    struct StructBootNotification                   BootNotification;
+    struct StructHeartbeat                          Heartbeat;
+    struct StructAuthorize                          Authorize;
+    struct StructStartTransaction                   StartTransaction[CONNECTOR_QUANTITY];
+    struct StructStopTransaction                    StopTransaction[CONNECTOR_QUANTITY];
+    struct StructStatusNotification                 StatusNotification[CONNECTOR_QUANTITY];
+    struct StructCancelReservation                  CancelReservation[CONNECTOR_QUANTITY];
+    struct StructChangeAvailability                 ChangeAvailability[CONNECTOR_QUANTITY];
+    struct StructChangeConfiguration                ChangeConfiguration;
+    struct StructClearCache                         ClearCache;
+    struct StructClearChargingProfile               ClearChargingProfile[CONNECTOR_QUANTITY];
+    struct StructDataTransfer                       DataTransfer[CONNECTOR_QUANTITY];
+    struct StructDiagnosticsStatusNotification      DiagnosticsStatusNotification;
+    struct StructFirmwareStatusNotification         FirmwareStatusNotification;
+    struct StructGetCompositeSchedule               GetCompositeSchedule[CONNECTOR_QUANTITY];
+    struct StructGetConfiguration                   GetConfiguration;
+    struct StructGetDiagnostics                     GetDiagnostics;
+    struct StructGetLocalListVersion                GetLocalListVersion;
+    struct StructMeterValues                        MeterValues[CONNECTOR_QUANTITY];
+    struct StructRemoteStartTransaction             RemoteStartTransaction[CONNECTOR_QUANTITY];
+    struct StructRemoteStopTransaction              RemoteStopTransaction[CONNECTOR_QUANTITY];
+    struct StructReserveNow                         ReserveNow[CONNECTOR_QUANTITY];
+    struct StructReset                              Reset;
+    struct StructSendLocalList                      SendLocalList;
+    struct StructSetChargingProfile                 SetChargingProfile[CONNECTOR_QUANTITY];
+    struct StructTriggerMessage                     TriggerMessage[CONNECTOR_QUANTITY];
+    struct StructUnlockConnector                    UnlockConnector[CONNECTOR_QUANTITY];
+    struct StructUpdateFirmware                     UpdateFirmware;
+    struct OCPP16ConfigurationTable                 ConfigurationTable;
+    struct StructChargingProfile                    SmartChargingProfile[CONNECTOR_QUANTITY];
+    struct StructCost                               Cost;
+    struct StructCertificateSigned                  CertificateSigned;
+    struct StructDeleteCertificate                  DeleteCertificate;
+    struct StructExtendedTrigger                    ExtendedTriggerMessage;
+    struct StructGetInstalledCertificateIds         GetInstalledCertificateIds;
+    struct StructGetLog                             GetLog;
+    struct StructInstallCertificate                 InstallCertificate;
+    struct StructSignedUpdateFirmware               SignedUpdateFirmware;
+    struct StructLogStatusNotification              LogStatusNotification;
+    struct StructSecurityEventNotification          SecurityEventNotification;
+    struct StructSignCertificate                    SignCertificate;
+    struct StructSignedFirmwareStatusNotification   SignedFirmwareStatusNotification;
 };
 
 
@@ -5082,8 +5119,8 @@ struct TransactionType
 
 struct StatusInfoType
 {
-	unsigned char reasonCode[21];									// Required. A predefined code for the reason why thestatus is returned in this response. The string is case-insensitive.
-	unsigned char additionalInfo[513];								// Optional. Additional text to provide detailed information.
+    unsigned char reasonCode[21];                                   // Required. A predefined code for the reason why thestatus is returned in this response. The string is case-insensitive.
+    unsigned char additionalInfo[513];                              // Optional. Additional text to provide detailed information.
 };
 /*
  * =============== Message ===============
@@ -5114,11 +5151,11 @@ struct CancelReservation_20
 
 struct CertificateSigned_20
 {
-	unsigned char certificateChain[10001];							// Required. Required. The signed PEM encoded X.509 certificate.This can also contain the necessary sub CA certificates.In that case, the order of the bundle should follow thecertificate chain, starting from the leaf certificate.The Configuration Variable MaxCertificateChainSize canbe used to limit the maximum size of this field.
-	unsigned char certificateType[32];								// Optional. Indicates the type of the signed certificate that is returned.
-	unsigned char Response_status[16];								// Required. Returns whether certificate signing has been accepted, otherwise rejected.
-	struct StatusInfoType Response_statusInfo;						// Optional. Detailed status information.
-	unsigned char guid[37];											// Save guid from server request
+    unsigned char certificateChain[10001];                          // Required. Required. The signed PEM encoded X.509 certificate.This can also contain the necessary sub CA certificates.In that case, the order of the bundle should follow thecertificate chain, starting from the leaf certificate.The Configuration Variable MaxCertificateChainSize canbe used to limit the maximum size of this field.
+    unsigned char certificateType[32];                              // Optional. Indicates the type of the signed certificate that is returned.
+    unsigned char Response_status[16];                              // Required. Returns whether certificate signing has been accepted, otherwise rejected.
+    struct StatusInfoType Response_statusInfo;                      // Optional. Detailed status information.
+    unsigned char guid[37];                                         // Save guid from server request
 };
 
 struct ChangeAvailability_20
@@ -5548,10 +5585,10 @@ struct SetVariables_20
 
 struct SignCertificate_20
 {
-	unsigned char csr[5501];										// Required. The Charging Station SHALL send the public key in form of a Certificate Signing Request (CSR) as described in RFC 2986 [22] using the SignCertificateRequest message.
-	unsigned char certificateType[32];								// Optional. Indicates the type of certificate that is to be signed. When omitted the certificate is to be used for both the 15118 connection (if implemented) and the Charging Station to CSMS connection.
-	unsigned char Response_status[16];								// Required. Specifies whether the CSMS can process the request.
-	struct StatusInfoType Response_statusInfo;						// Optional. Detailed status information.
+    unsigned char csr[5501];                                        // Required. The Charging Station SHALL send the public key in form of a Certificate Signing Request (CSR) as described in RFC 2986 [22] using the SignCertificateRequest message.
+    unsigned char certificateType[32];                              // Optional. Indicates the type of certificate that is to be signed. When omitted the certificate is to be used for both the 15118 connection (if implemented) and the Charging Station to CSMS connection.
+    unsigned char Response_status[16];                              // Required. Specifies whether the CSMS can process the request.
+    struct StatusInfoType Response_statusInfo;                      // Optional. Detailed status information.
 };
 
 struct StatusNotification_20

+ 14 - 13
EVSE/Projects/DD360/Apps/Makefile

@@ -76,9 +76,10 @@ MAIN_SRC_FILES = $(patsubst %.o, %.c, $(MAIN_OBJ_FILES))
 	$(CC) $(CFLAGS) -c $<
 
 #internal comm lib
-INTERNALCOMM_OBJ_FILES = $(COMMON_OBJ_FILES) $(InternalCommLib)/internalComm.o $(InternalCommLib)/Module_InternalComm.o \
-							$(InternalCommLib)/FanBoard.o $(InternalCommLib)/LEDlight.o $(InternalCommLib)/RelayBoard.o \
-								$(InternalCommLib)/AcPlug.o
+INTERNALCOMM_OBJ_FILES = $(COMMON_OBJ_FILES) $(InternalCommLib)/internalComm.o \
+							$(InternalCommLib)/Module_InternalComm.o $(InternalCommLib)/FanBoard.o \
+								$(InternalCommLib)/LEDlight.o $(InternalCommLib)/RelayBoard.o \
+									$(InternalCommLib)/AcPlug.o
 INTERNALCOMM_SRC_FILES = $(patsubst %.o, %.c, $(INTERNALCOMM_OBJ_FILES))
 %.o: %.c
 	$(CC) $(CFLAGS) -c $<
@@ -100,12 +101,12 @@ apps: MainTask DoCommTask EvCommTask \
 				FactoryConfigApp OtherTools CleanExec
 
 MainTask:
-	#$(CC) $(DEFINE) $(MAIN_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(SQLite3_H) $(ModuleUpgrade_H) $(RateCurrent_H) \
-	#	$(RFID_H) $(Lib_Module_RFID) $(Lib_Module_Upgrade) $(Lib_SQLite3) $(Lib_Module_RateCurrent) -o main
-	$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -c -o main.o main.c
-	$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -c -o timeout.o timeout.c
-	$(CC) $(DEFINE) $(CFLAGS) -c -o common.o common.c
-	$(CC) $(TFLAGS) -o main main.o timeout.o common.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3} $(Lib_Module_RatedCurrent)
+	$(CC) $(DEFINE) $(MAIN_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(SQLite3_H) $(ModuleUpgrade_H) $(RateCurrent_H) \
+		$(RFID_H) $(Lib_Module_RFID) $(Lib_Module_Upgrade) $(Lib_SQLite3) $(Lib_Module_RateCurrent) -o main
+	#$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -c -o main.o main.c
+	#$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -c -o timeout.o timeout.c
+	#$(CC) $(DEFINE) $(CFLAGS) -c -o common.o common.c
+	#$(CC) $(TFLAGS) -o main main.o timeout.o common.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3} $(Lib_Module_RatedCurrent)
 
 DoCommTask:
 	$(CC) $(DEFINE) $(CFLAGS) -c -o define.o $(DefineLib)/define.c
@@ -113,10 +114,10 @@ DoCommTask:
 	$(CC) -o Module_DoComm DoComm.o define.o
 
 EvCommTask:
-	#$(CC) $(DEFINE) $(EVCOMM_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(Lib_Module_RatedCurrent) -o Module_EvComm
-	$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Ev_Comm.o $(EvCommLib)/Ev_Comm.c
-	$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Module_EvComm.o $(EvCommLib)/Module_EvComm.c
-	$(CC) -o Module_EvComm Ev_Comm.o Module_EvComm.o $(Lib_Module_RatedCurrent)
+	$(CC) $(DEFINE) $(EVCOMM_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(Lib_Module_RatedCurrent) -o Module_EvComm
+	#$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Ev_Comm.o $(EvCommLib)/Ev_Comm.c
+	#$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Module_EvComm.o $(EvCommLib)/Module_EvComm.c
+	#$(CC) -o Module_EvComm Ev_Comm.o Module_EvComm.o $(Lib_Module_RatedCurrent)
 
 EventLoggingTask:
 	$(CC) $(DEFINE) $(CFLAGS) -c -o define.o $(DefineLib)/define.c

+ 4 - 3
EVSE/Projects/DD360/Apps/ModuleDoComm/DoComm.c

@@ -439,7 +439,7 @@ static void clearMiscCommand(void)
 
 static int qrCodeUrlInfoHandle(uint8_t *data)
 {
-    int len = 0;
+    //int len = 0;
     //char cmdBuf[128] = {0};
     char localTime[128] = {0};
     uint16_t timeLen = 0;
@@ -466,7 +466,8 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
         memset(ShmSysConfigAndInfo->SysConfig.SystemId, '\0', sizeof(ShmSysConfigAndInfo->SysConfig.SystemId));
         //printf("data =  %s\r\n", data);
-        len = string2ByteArray((char *)data, (uint8_t *)ShmSysConfigAndInfo->SysConfig.SystemId);
+        //len =
+        string2ByteArray((char *)data, (uint8_t *)ShmSysConfigAndInfo->SysConfig.SystemId);
         //printf("SystemId =  %s\r\n", ShmSysConfigAndInfo->SysConfig.SystemId);
     }
 
@@ -914,7 +915,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     uint8_t EventCodeTmp[7] = {0};
     uint8_t StatusArray[MAX_REGISTER_NUM][WARNING_CODE_SIZE] = {0};
     uint8_t remaindLen = 0;
-    uint8_t statusCodeError = 0;
+    //uint8_t statusCodeError = 0;
 
     if (dataLen > 0) {
         Hexdump((uint8_t *)data, dataLen);

+ 0 - 0
EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvComm.c → EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvCommOrg.c


+ 49 - 53
EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -31,7 +31,7 @@ static DcCommonInfo *ShmDcCommonData = NULL;
 extern bool AbnormalStopAnalysis(uint8_t gun_index, uint8_t *errCode);
 
 //------------------------------------------------------------------------------
-static uint8_t getMaxConnectTempAndChiller(uint8_t headTemp1, uint8_t headTemp2,
+/*static uint8_t getMaxConnectTempAndChiller(uint8_t headTemp1, uint8_t headTemp2,
         uint8_t chillerTemp1, uint8_t chillerTemp2)
 {
     uint8_t i = 0;
@@ -64,6 +64,7 @@ static uint8_t getMaxConnectTempAndChiller(uint8_t headTemp1, uint8_t headTemp2,
 
     return maxTemp;
 }
+*/
 
 static uint8_t getMaxConnectTemp(uint8_t headTemp1, uint8_t headTemp2)
 {
@@ -98,7 +99,6 @@ static float ReadAdcVolt(uint8_t AdcChannel)
     int fd = -1;
     uint8_t str[64] = {0};
     uint8_t AdcValue[8] = {'\0'};
-    //uint32_t AdcValue = 0;
 
     if (AdcChannel > 7) {
         return -1;
@@ -188,6 +188,12 @@ void CANReceiver(int fd)
 
     canRecPid = fork();
 
+
+    if (canRecPid < 0) {
+        log_error("Create CAN Bus receive task failed\r\n");
+        return;
+    }
+
     if (canRecPid == 0) {
         int isContinue = 1;
         int nbytes;
@@ -212,6 +218,8 @@ void CANReceiver(int fd)
         ShmCcsData = (struct CcsData *)GetShmCcsData();
         ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
 
+        log_info("Child's PID is %d\r\n", getpid());
+
         while (isContinue) {
             memset(&frame, 0, sizeof(struct can_frame));
             nbytes = read(fd, &frame, sizeof(struct can_frame));
@@ -448,70 +456,58 @@ void CANReceiver(int fd)
                     //ShmCcsData->V2GMessage_DIN70121[gunTypeIndex]. .ConnectorTemperatureN = frame.data[2];
                 }
                 }*/
-#if 1
+
                 //memset((uint8_t)&chiilerTemp, 0, sizeof(ChillerTemp));
-                if (targetGun == 0 &&
-                        ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
-                         (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0))
+                //if (targetGun == 0 &&
+                //        ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
+                //         (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0))
+                //   ) {
+                //    getChillerTemperature(&chiilerTemp);
+                //    pDcChargingInfo->ChillerTemp = getMaxConnectTemp(chiilerTemp.Temp[0], chiilerTemp.Temp[1]);
+                //    //pDcChargingInfo->ConnectorTemp = getMaxConnectTempAndChiller(
+                //    //                                     frame.data[1],
+                //    //                                     frame.data[2],
+                //    //                                     chiilerTemp.Temp[0],
+                //    //                                     chiilerTemp.Temp[1]);
+                //} else if (targetGun == 1 &&
+                //           ((strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
+                //            (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0))
+                //          ) {
+                //    getChillerTemperature(&chiilerTemp);
+                //    pDcChargingInfo->ChillerTemp = getMaxConnectTemp(chiilerTemp.Temp[0], chiilerTemp.Temp[1]);
+                //}
+#if 1
+                if ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
+                        (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0) ||
+                        (strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
+                        (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0)
                    ) {
                     getChillerTemperature(&chiilerTemp);
+                    pDcChargingInfo->ChillerTemp = getMaxConnectTemp(chiilerTemp.Temp[0], chiilerTemp.Temp[1]);
+                }
 
-                    pDcChargingInfo->ConnectorTemp = getMaxConnectTempAndChiller(
-                                                         frame.data[1],
-                                                         frame.data[2],
-                                                         chiilerTemp.Temp[0],
-                                                         chiilerTemp.Temp[1]);
-
-                    //log_info("%d chiller Temp1 = %d, temp2 = %d, head Temp1 = %d, Temp2 = %d\r\n",
-                    //         targetGun,
-                    //         chiilerTemp.Temp[0],
-                    //         chiilerTemp.Temp[1],
-                    //         frame.data[1],
-                    //         frame.data[2]);
-                } else if (targetGun == 1 &&
-                           ((strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
-                            (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0))
-                          ) {
-                    getChillerTemperature(&chiilerTemp);
+                pDcChargingInfo->ConnectorTemp = getMaxConnectTemp(frame.data[1], frame.data[2]);
 
-                    pDcChargingInfo->ConnectorTemp = getMaxConnectTempAndChiller(
-                                                         frame.data[1],
-                                                         frame.data[2],
-                                                         chiilerTemp.Temp[0],
-                                                         chiilerTemp.Temp[1]);
-
-                    //log_info("%d chillerTemp1 = %d, temp2 = %d, head Temp1 = %d, Temp2 = %d\r\n",
-                    //         targetGun,
-                    //         chiilerTemp.Temp[0],
-                    //         chiilerTemp.Temp[1],
-                    //         frame.data[1],
-                    //         frame.data[2]);
-                } else {
-                    pDcChargingInfo->ConnectorTemp = getMaxConnectTemp(frame.data[1], frame.data[2]);
-                    //log_info("connector temperature = %d\r\n",
-                    //         pDcChargingInfo->ConnectorTemp);
-                }
-#endif //0
-                if (ShmDcCommonData->SystemModeChange == YES) {
+                if ((ShmDcCommonData->SystemModeChange == YES) ||
+                        (((pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) &&
+                          (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP)) ||
+                         ((pDcChargingInfo->ChillerTemp >= GUN_OTP_VALUE) &&
+                          (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP)))
+                   ) {
                     ShmDcCommonData->SystemModeChange = NO;
-                    //log_info("EvboardStatus = %x \n",
-                    //         ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus);
-                    //log_info("ConnectorPlug locked = %x \n",
-                    //         frame.data[0]);
-
-                    //if (frame.data[1] >= GUN_OTP_VALUE ||
-                    //        frame.data[2] >= GUN_OTP_VALUE ||
-                    //        chiilerTemp.Temp[0] >= GUN_OTP_VALUE ||
-                    //        chiilerTemp.Temp[1] >= GUN_OTP_VALUE) {
                     log_info("Conn %d Temp 0= %d, Temp 1 = %d, chillerTemp1 = %d, chillerTemp2 = %d\r\n",
                              targetGun,
                              frame.data[1],
                              frame.data[2],
                              chiilerTemp.Temp[0],
                              chiilerTemp.Temp[1]);
-                    //}
-                    //log_info("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
                 }
+#endif //0
+                //log_info("EvboardStatus = %x \n",
+                //         ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus);
+                //log_info("ConnectorPlug locked = %x \n",
+                //         frame.data[0]);
+                //log_info("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
                 break;
 
             case ACK_EVSE_ISOLATION_STATUS:

+ 6 - 8
EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -88,23 +88,17 @@ int InitCanBus(void)
     tv.tv_usec = 10000;
 
     if (setsockopt(s0, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct  timeval)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_RCVTIMEO NG");
-#endif
     }
 
     nbytes = 40960;
     if (setsockopt(s0, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_RCVBUF NG");
-#endif
     }
 
     nbytes = 40960;
     if (setsockopt(s0, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_SNDBUF NG");
-#endif
     }
 
     rxfilter[0].can_id = 0x01;
@@ -115,10 +109,10 @@ int InitCanBus(void)
     rxfilter[2].can_mask = 0x00000FFF;
     if (setsockopt(s0, SOL_CAN_RAW, CAN_RAW_FILTER,
                    &rxfilter, sizeof(struct can_filter) * 3) < 0) {
-        log_error("RX setsockopt CAN_RAW_FILTER failed");
+        log_error("RX setsockopt CAN_RAW_FILTER failed\r\n");
     }
 
-    strcpy(ifr0.ifr_name, "can0" );
+    strcpy(ifr0.ifr_name, "can0");
     ioctl(s0, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
     addr0.can_family = AF_CAN;
     addr0.can_ifindex = ifr0.ifr_ifindex;
@@ -507,6 +501,10 @@ static void checkConnectorOVPState(uint8_t gunIndex)
         break;
     }
 
+    if (ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP == YES) {
+        isOTP = true;
+    }
+
     if (isOTP) {
         if (gunTempAllowCount[gunIndex] >= 2) {
             pDcChargingInfo->StopChargeFlag = YES;

+ 2 - 1
EVSE/Projects/DD360/Apps/ModuleInternalComm/RelayBoard.c

@@ -112,7 +112,7 @@ static uint8_t getCommTargetID(uint8_t index)
     return targetID;
 }
 
-static void MatchRelayStatus(void)
+/*static void MatchRelayStatus(void)
 {
     // 因為 AC Contactor 沒有 Feedback,所以暫時先這樣處理
     //regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
@@ -127,6 +127,7 @@ static void MatchRelayStatus(void)
     regRelay.relay_event.bits.Gun1_Parallel_P = outputRelay.relay_event.bits.Gun1_Parallel_P;
     regRelay.relay_event.bits.Gun1_Parallel_N = outputRelay.relay_event.bits.Gun1_Parallel_N;
 }
+*/
 
 static bool IsNoneMatchRelayStatus(void)
 {

+ 71 - 1
EVSE/Projects/DD360/Apps/ReadCmdline.c

@@ -940,7 +940,37 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
             }
         }
 
-        if (strcmp(newString[0], "chg") == 0) {
+        if (strcmp(newString[0], "strchg") == 0) {
+            if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
+                    strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0) {
+                printf ("Input cmd fail ------  strchg [vol 150-1000] [cru 2-100]\n");
+                continue;
+            }
+
+            if (atoi(newString[1]) == ShmSysConfigAndInfo->SysInfo.CurGunSelected) {
+                continue;
+            }
+
+            _GunIndex = atoi((char *)newString[1]);
+            _Voltage = atof((char *)newString[2]);
+            _Current = atof((char *)newString[3]);
+
+            uint8_t PreviousSystemStatus = 0xff;
+            if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                printf ("FindChargingInfoData error\n");
+                continue;
+            }
+
+            printf ("Power = %d, ReqVoltage = %f, ReqCurrent = %f\n",
+                    ShmSysConfigAndInfo->SysConfig.MaxChargingPower, _Voltage, _Current);
+
+            if (_Voltage > 1000 || _Voltage < 50) {
+                _Voltage = 200;
+                printf ("Input Voltage over range\n");
+                continue;
+            }
+
+        } else if (strcmp(newString[0], "chg") == 0) {
             if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
                 continue;
             }
@@ -959,6 +989,9 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
             _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = _vol;
             _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = _cur;
         } else if (strcmp(newString[0], "c") == 0) {
+            if (atoi((char *)newString[1]) != -1) {
+                ShmSysConfigAndInfo->SysInfo.CurGunSelected = atoi((char *)newString[1]);
+            }
             printf("stop \n\r");
             ShmSysConfigAndInfo->SysInfo.StartToChargingFlag = 0x00;
             _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
@@ -1138,6 +1171,43 @@ int main(void)
                 _chargingData[1]->ConnectorTemp = atoi(newString[2]);
                 printf("ReadCmdline temp 1 = %d\r\n", _chargingData[1]->ConnectorTemp);
             }
+        } else if (strcmp(newString[0], "tempC") == 0) {
+            if (strcmp(newString[1], "0") == 0) {
+                uint8_t _GunIndex = 0;
+                if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                    printf ("FindChargingInfoData error\n");
+                    return 0;
+                }
+
+                _chargingData[0]->ChillerTemp = atoi(newString[2]);
+                printf("ReadCmdline temp 0 = %d\r\n", _chargingData[0]->ChillerTemp);
+            } else if (strcmp(newString[1], "1") == 0) {
+                uint8_t _GunIndex = 1;
+                if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                    printf ("FindChargingInfoData error\n");
+                    return 0;
+                }
+
+                _chargingData[1]->ChillerTemp = atoi(newString[2]);
+                printf("ReadCmdline temp 1 = %d\r\n", _chargingData[1]->ChillerTemp);
+            }
+        } else if (strcmp(newString[0], "TempCR") == 0) {
+            if (strcmp(newString[1], "0") == 0) {
+                uint8_t _GunIndex = 0;
+                if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                    printf ("FindChargingInfoData error\n");
+                    return 0;
+                }
+                printf("ReadCmdline temp 0 = %d\r\n", _chargingData[0]->ChillerTemp);
+            } else if (strcmp(newString[1], "1") == 0) {
+                uint8_t _GunIndex = 1;
+                if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                    printf ("FindChargingInfoData error\n");
+                    return 0;
+                }
+
+                printf("ReadCmdline temp 1 = %d\r\n", _chargingData[1]->ChillerTemp);
+            }
         } else {
             printf ("%s\n", msg);
         }

+ 91 - 41
EVSE/Projects/DD360/Apps/main.c → EVSE/Projects/DD360/Apps/mainOrg.c

@@ -343,6 +343,30 @@ static void confirmSelGun(uint8_t selGun)
 
 static void checkGunOTPState(uint8_t _index)
 {
+
+    if ((strncmp((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[7], "V", 1) == 0) ||
+            (strncmp((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[9], "V", 1) == 0) ||
+            (strncmp((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[7], "F", 1) == 0) ||
+            (strncmp((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[9], "F", 1) == 0)
+       ) {
+        if (chargingInfo[_index]->ChillerTemp != UNDEFINED_TEMP) {
+            ResetChargerAlarmCode(_index, "011038"); //清除溫度檢測異常status code
+
+            if (chargingInfo[_index]->ChillerTemp >= GUN_OTP_VALUE) {
+                RecordAlarmCode(_index, "012323");
+            } else if (chargingInfo[_index]->ChillerTemp != 0 &&
+                       chargingInfo[_index]->ChillerTemp < GUN_OTP_RECOVERY) {
+                ResetChargerAlarmCode(_index, "012323");
+            }
+
+            //ResetChargerAlarmCode(_index, "011019");
+        } else {
+            // 沒接上 Sensor or 異常
+            RecordAlarmCode(_index, "011038");
+            ResetChargerAlarmCode(_index, "012323");
+        }
+    }
+
     switch (chargingInfo[_index]->Type) {
     case _Type_Chademo:
         if (chargingInfo[_index]->ConnectorTemp != UNDEFINED_TEMP) {
@@ -597,25 +621,25 @@ static void checkEvBoardAlarmState(uint8_t gunType)
 
 static uint8_t checkCabinetEthConnectState(LedConfig *ledConfig)
 {
-    uint8_t ret = NO;
     LedConfig *pLedConfig = (LedConfig *)ledConfig;
 
-    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DisconnectedFromDo == YES) {
-        ret = YES;
-        if (pLedConfig->RedLED == YES ||
-                pLedConfig->YellowLED == YES ||
-                pLedConfig->GreenLED == YES) {
-            pLedConfig->YellowLED = NO;
-            pLedConfig->GreenLED = NO;
-            pLedConfig->RedLED = NO;
-        } else {
-            pLedConfig->YellowLED = YES;
-            pLedConfig->GreenLED = YES;
-            pLedConfig->RedLED = YES;
-        }
+    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DisconnectedFromDo == NO) {
+        return NO;
+    }
+
+    if (pLedConfig->RedLED == YES ||
+            pLedConfig->YellowLED == YES ||
+            pLedConfig->GreenLED == YES) {
+        pLedConfig->YellowLED = NO;
+        pLedConfig->GreenLED = NO;
+        pLedConfig->RedLED = NO;
+    } else {
+        pLedConfig->YellowLED = YES;
+        pLedConfig->GreenLED = YES;
+        pLedConfig->RedLED = YES;
     }
 
-    return ret;
+    return YES;
 }
 
 static void PrimaryLedIndicatorCtrlFork(void)
@@ -634,14 +658,15 @@ static void PrimaryLedIndicatorCtrlFork(void)
 
         while (isContinue) {
             for (gunIndex = 0; gunIndex < totalGun; gunIndex++) {
-                if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
+                if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2 &&
+                        chargingInfo[gunIndex]->SystemStatus != S_BOOTING) {
                     if (checkCabinetEthConnectState(pLedConfig) == YES) {
                         continue;
                     }
-
                     pLedConfig->YellowLED = NO;
                     pLedConfig->GreenLED = NO;
                     pLedConfig->RedLED = YES;
+                    continue;
                 }
 
                 //printf("led indicator status = %d\r\n", chargingInfo[gunIndex]->SystemStatus);
@@ -670,10 +695,19 @@ static void PrimaryLedIndicatorCtrlFork(void)
                     break;
 
                 case S_IDLE:
+                    //if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
+                    //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
+                    //        break;
+                    //    }
+                    //    pLedConfig->YellowLED = NO;
+                    //    pLedConfig->GreenLED = NO;
+                    //    pLedConfig->RedLED = YES;
+                    //} else {
                     //Module_DoComm connected and system idle
                     pLedConfig->RedLED = NO;
                     pLedConfig->YellowLED = NO;
                     pLedConfig->GreenLED = YES;
+                    //}
                     break;
 
                 case S_RESERVATION:
@@ -685,12 +719,21 @@ static void PrimaryLedIndicatorCtrlFork(void)
                 case S_PREPARING_FOR_EVSE:
                 case S_CCS_PRECHARGE_ST0:
                 case S_CCS_PRECHARGE_ST1:
+                    //if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
+                    //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
+                    //        break;
+                    //    }
+                    //    pLedConfig->YellowLED = NO;
+                    //    pLedConfig->GreenLED = NO;
+                    //    pLedConfig->RedLED = YES;
+                    //} else {
                     //precharging status
                     if (pLedConfig->GreenLED == YES) {
                         pLedConfig->GreenLED = NO;
                     } else {
                         pLedConfig->GreenLED = YES;
                     }
+                    //}
                     break;
 
                 case S_CHARGING:
@@ -704,24 +747,23 @@ static void PrimaryLedIndicatorCtrlFork(void)
                     break;
 
                 case S_ALARM:
+                    //if (checkCabinetEthConnectState(pLedConfig) == YES) {
+                    //    break;
+                    //}
+
                     pLedConfig->YellowLED = NO;
                     pLedConfig->GreenLED = NO;
-
-                    if (checkCabinetEthConnectState(pLedConfig) == YES) {
-                        break;
-                    }
-
                     pLedConfig->RedLED = YES;
                     break;
 
                 case S_TERMINATING:
                 case S_COMPLETE:
-                    //if (pSysWarning->Level == 2) {
-                    //    pLedConfig->YellowLED = NO;
-                    //    pLedConfig->GreenLED = NO;
+                    //if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
                     //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
                     //        break;
                     //    }
+                    //    pLedConfig->YellowLED = NO;
+                    //    pLedConfig->GreenLED = NO;
                     //    pLedConfig->RedLED = YES;
                     //} else {
                     pLedConfig->RedLED = NO;
@@ -732,15 +774,16 @@ static void PrimaryLedIndicatorCtrlFork(void)
 
                 case S_MAINTAIN:
                 case S_FAULT:
-                    pLedConfig->YellowLED = NO;
-                    pLedConfig->GreenLED = NO;
-                    pLedConfig->RedLED = YES;
-                    //if (pSysWarning->Level == 2) {
+                    //if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
                     //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
                     //        break;
                     //    }
-                    //    pLedConfig->RedLED = YES;
+                    //    //pLedConfig->RedLED = YES;
                     //}
+
+                    pLedConfig->YellowLED = NO;
+                    pLedConfig->GreenLED = NO;
+                    pLedConfig->RedLED = YES;
                     break;
 
                 case S_BOOKING:
@@ -748,11 +791,11 @@ static void PrimaryLedIndicatorCtrlFork(void)
                 case S_UPDATE:
                 case S_NONE:
                     break;
-                }
-            }//switch
-        }//for
-        usleep(500000);
-    }//while
+                }//switch
+            }//for
+            usleep(500000);
+        }//while
+    }//fork
 }
 
 //================================================
@@ -2659,6 +2702,8 @@ void ResetChargerAlarmCode(uint8_t gunIndex, char *code)
     else if (strcmp(code, "011018") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail = NO; }
     else if (strcmp(code, "011019") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail = NO; }
     else if (strcmp(code, "011020") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail = NO; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChillerOTP = NO; }
+    else if (strcmp(code, "011038") == EQUAL) {  ShmStatusCodeData->FaultCode.FaultEvents.bits.ChillerTempSensorBroken = NO; }
 
     if (strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "", 6) != EQUAL) {
         if (strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "012229", 6) == EQUAL ||
@@ -2672,7 +2717,10 @@ void ResetChargerAlarmCode(uint8_t gunIndex, char *code)
                 strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011016", 6) == EQUAL ||
                 strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011018", 6) == EQUAL ||
                 strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011019", 6) == EQUAL ||
-                strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011020", 6) == EQUAL) {
+                strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011020", 6) == EQUAL ||
+                strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "012323", 6) == EQUAL ||
+                strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011038", 6) == EQUAL
+           ) {
             strncpy((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "", 6);
         }
     }
@@ -2713,6 +2761,8 @@ void RecordAlarmCode(uint8_t gunIndex, char *code)
     else if (strcmp(code, "011018") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail = YES; }
     else if (strcmp(code, "011019") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail = YES; }
     else if (strcmp(code, "011020") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail = YES; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChillerOTP = YES; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmStatusCodeData->FaultCode.FaultEvents.bits.ChillerTempSensorBroken = YES; }
 }
 
 void RecordWarningCode(uint8_t gunIndex, char *code)
@@ -5912,11 +5962,11 @@ static void ReviewCriticalAlarm(void)
             ShmDcCommonData->GunRelayDrivingOccur[1] == YES ||
             ShmDcCommonData->GunRelayWeldingOccur[0] == YES ||
             ShmDcCommonData->GunRelayWeldingOccur[1] == YES ||
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip ||
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MainPowerBreakerTrip ||
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DoorOpen ||
-            ShmSysConfigAndInfo->SysWarningInfo.ExtraErrProcess != _EXTRA_ERR_PROCESS_NONE ||
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFailureAlarm ||
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == YES ||
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MainPowerBreakerTrip == YES ||
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DoorOpen == YES ||
+            ShmSysConfigAndInfo->SysWarningInfo.ExtraErrProcess != _EXTRA_ERR_PROCESS_NONE == YES ||
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFailureAlarm == YES ||
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DisconnectedFromDo
        ) {
         ShmSysConfigAndInfo->SysWarningInfo.Level = 2;

+ 34 - 5
EVSE/Projects/DD360Audi/Apps/CSU/Primary.c

@@ -54,6 +54,7 @@ void PrimaryLedIndicatorCtrlFork(void)
         struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
         struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
         struct ChargingInfoData *pDcChargingInfo = NULL;
+        DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
 
         LedConfig *pLedConfig = (LedConfig *)&ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0];
 
@@ -63,12 +64,15 @@ void PrimaryLedIndicatorCtrlFork(void)
 
                 if (pSysWarning->Level == 2) {
                     if (checkCabinetEthConnectState(pLedConfig) == YES) {
+                        usleep(500000);
                         continue;
                     }
 
                     pLedConfig->YellowLED = NO;
                     pLedConfig->GreenLED = NO;
                     pLedConfig->RedLED = YES;
+                    usleep(500000);
+                    continue;
                 }
 
                 //printf("led indicator status = %d\r\n", chargingInfo[gunIndex]->SystemStatus);
@@ -175,11 +179,11 @@ void PrimaryLedIndicatorCtrlFork(void)
                 case S_UPDATE:
                 case S_NONE:
                     break;
-                }
-            }//switch
-        }//for
-        usleep(500000);
-    }//while
+                }//switch
+            }//for
+            usleep(500000);
+        }//while
+    }//fork
 }
 
 //------------------------------------------------------------------------------
@@ -195,44 +199,69 @@ void ChkPrimaryStatus(void)
     struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
     struct ChargingInfoData *pDcChargingInfo = NULL;
     struct ChargingInfoData *pAcChargingInfo = NULL;
+    DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
 
     if (pSysWarning->WarningCount > 0) {
         Rtn = 0;
         for (uint8_t i = 0; i < pSysWarning->WarningCount; i++) {
             if (memcmp(&pSysWarning->WarningCode[i][0], "042251", 6) == 0) {
                 EmcOccureByString("042251");
+                ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = YES;
                 Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "042252", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = YES;
                 EmcOccureByString("042252");
                 Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "042200", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = YES;
                 EmcOccureByString("042200");
                 Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "042201", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = YES;
                 EmcOccureByString("042201");
                 Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "042202", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = YES;
                 EmcOccureByString("042202");
                 Rtn = 1;
+            } else if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = YES;
+                EmcOccureByString("042267");
+                Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
                 EmcOccureByString("012304");
                 Rtn = 1;
             }
         }
+
         if (Rtn == 0) {
+            ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
             ReleaseEmsOccureByString(0, "042251");
             ReleaseEmsOccureByString(0, "042252");
             ReleaseEmsOccureByString(0, "042200");
             ReleaseEmsOccureByString(0, "042201");
             ReleaseEmsOccureByString(0, "042202");
+            ReleaseEmsOccureByString(0, "042267");
             ReleaseEmsOccureByString(0, "012304");
         }
     } else {
+        ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
         ReleaseEmsOccureByString(0, "042251");
         ReleaseEmsOccureByString(0, "042252");
         ReleaseEmsOccureByString(0, "042200");
         ReleaseEmsOccureByString(0, "042201");
         ReleaseEmsOccureByString(0, "042202");
+        ReleaseEmsOccureByString(0, "042267");
         ReleaseEmsOccureByString(0, "012304");
     }
 

+ 1 - 8
EVSE/Projects/DD360Audi/Apps/CSU/UpgradeFW.c

@@ -30,11 +30,10 @@ static int InitComPort(uint8_t target)
     }
 
     if (fd <= 0) {
-#ifdef SystemLogMessage
         log_error("open 407 Communication port NG \n");
-#endif
         return -1;
     }
+
     ioctl (fd, TCGETS, &tios);
     tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
     tios.c_lflag = 0;
@@ -66,21 +65,15 @@ static int InitCanBus(void)
     tv.tv_sec = 0;
     tv.tv_usec = 10000;
     if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct  timeval)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_RCVTIMEO NG");
-#endif
     }
     nbytes = 40960;
     if (setsockopt(fd, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_RCVBUF NG");
-#endif
     }
     nbytes = 40960;
     if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_SNDBUF NG");
-#endif
     }
 
     strcpy(ifr0.ifr_name, "can0");

+ 159 - 65
EVSE/Projects/DD360Audi/Apps/CSU/main.c

@@ -330,58 +330,79 @@ void confirmSelGun(uint8_t selGun)
     StartGunInfoTimeoutDet(selGun, Timeout_SelectGun);
 }
 
-static void checkGunOTPState(uint8_t _index)
+static void checkGunOTPState(uint8_t gunIndex)
 {
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
+
+    if ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
+            (strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
+            (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0) ||
+            (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0)
+       ) {
+        if (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP) {
+            //ResetChargerAlarmCode(gunIndex, "011038"); //清除溫度檢測異常status code
+
+            if (pDcChargingInfo->ChillerTemp >= GUN_OTP_VALUE) {
+                RecordAlarmCode(gunIndex, "012323");
+            } else if (pDcChargingInfo->ChillerTemp != 0 &&
+                       pDcChargingInfo->ChillerTemp < GUN_OTP_RECOVERY) {
+                ResetChargerAlarmCode(gunIndex, "012323");
+            }
+        } else {
+            // 沒接上 Sensor or 異常
+            RecordAlarmCode(gunIndex, "011038");
+            ResetChargerAlarmCode(gunIndex, "012323");
+        }
+    }
 
     switch (pDcChargingInfo->Type) {
     case _Type_Chademo:
         if (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP) {
             if (pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) {
-                RecordAlarmCode(_index, "012229");
+                RecordAlarmCode(gunIndex, "012229");
             } else if (pDcChargingInfo->ConnectorTemp != 0 &&
                        pDcChargingInfo->ConnectorTemp < GUN_OTP_RECOVERY) {
-                ResetChargerAlarmCode(_index, "012229");
+                ResetChargerAlarmCode(gunIndex, "012229");
             }
         } else {
             // 沒接上 Sensor or 異常
-            //RecordAlarmCode(_index, "011018");
-            ResetChargerAlarmCode(_index, "012229");
+            //RecordAlarmCode(gunIndex, "011018");
+            ResetChargerAlarmCode(gunIndex, "012229");
         }
         break;
 
     case _Type_CCS_2:
         // CCS 不管甚麼輸出都會有槍溫偵測!!~
         if (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP) {
-            ResetChargerAlarmCode(_index, "011019");
+            //ResetChargerAlarmCode(gunIndex, "011019");
 
             if (pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) {
-                RecordAlarmCode(_index, "012230");
+                RecordAlarmCode(gunIndex, "012230");
             } else if (pDcChargingInfo->ConnectorTemp != 0 &&
                        pDcChargingInfo->ConnectorTemp < GUN_OTP_RECOVERY) {
-                ResetChargerAlarmCode(_index, "012230");
+                ResetChargerAlarmCode(gunIndex, "012230");
             }
 
-            //ResetChargerAlarmCode(_index, "011019");
+            //ResetChargerAlarmCode(gunIndex, "011019");
         } else {
             // 沒接上 Sensor or 異常
-            RecordAlarmCode(_index, "011019");
-            ResetChargerAlarmCode(_index, "012230");
+            RecordAlarmCode(gunIndex, "011019");
+            ResetChargerAlarmCode(gunIndex, "012230");
         }
         break;
 
     case _Type_GB:
         if (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP) {
             if (pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) {
-                RecordAlarmCode(_index, "012231");
+                RecordAlarmCode(gunIndex, "012231");
             } else if (pDcChargingInfo->ConnectorTemp != 0 &&
                        pDcChargingInfo->ConnectorTemp < GUN_OTP_RECOVERY) {
-                ResetChargerAlarmCode(_index, "012231");
+                ResetChargerAlarmCode(gunIndex, "012231");
             }
         } else {
             // 沒接上 Sensor or 異常
-            RecordAlarmCode(_index, "011020");
-            ResetChargerAlarmCode(_index, "012231");
+            RecordAlarmCode(gunIndex, "011020");
+            ResetChargerAlarmCode(gunIndex, "012231");
         }
         break;
     }
@@ -569,6 +590,28 @@ static void checkChaDeMoAlarmState(uint8_t gunType)
     }
 }
 
+static void checkChillerAlarmState(void)
+{
+    uint8_t gunIndex = 0;
+    struct ChargingInfoData *pDcChargingInfo = NULL;
+
+    for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+        pDcChargingInfo =  (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
+
+        if (ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP == YES) {
+            pAlarmCode->AlarmEvents.bits.SystemChillerOTP = YES;
+        } else {
+            pAlarmCode->AlarmEvents.bits.SystemChillerOTP = NO;
+        }
+
+        if (ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerTempSensorFail == YES) {
+            pFaultCode->FaultEvents.bits.ChillerTempSensorBroken = YES;
+        } else {
+            pFaultCode->FaultEvents.bits.ChillerTempSensorBroken = NO;
+        }
+    }
+}
+
 static void checkEvBoardAlarmState(uint8_t gunType)
 {
     switch (gunType) {
@@ -584,6 +627,8 @@ static void checkEvBoardAlarmState(uint8_t gunType)
         checkGBTAlarmState(gunType);
         break;
     }
+
+    checkChillerAlarmState();
 }
 
 #if 0
@@ -897,13 +942,14 @@ long long DiffTimebWithNow(struct timeb ST)
     ftime(&ET);
     StartTime = (long long)ST.time;
     StopTime = (long long)ET.time;
+
     return ((StopTime - StartTime) * 1000) + (ET.millitm - ST.millitm);
 }
 
 //==========================================
 // Log
 //==========================================
-void CheckFwSlotStatusLog()
+void CheckFwSlotStatusLog(void)
 {
     if (bd0_1_status == 0 && bd0_2_status == 1) {
         log_info("Connector 1 : Chademo");
@@ -2245,7 +2291,10 @@ int SpawnTask()
 
 #if defined DD360 ||defined DD360Audi || defined DD360ComBox
     system("/root/Module_DoComm &");
-#else
+
+    return PASS;
+#endif defined DD360 ||defined DD360Audi || defined DD360ComBox
+
     system("/root/Module_PsuComm &");
 
     if (strcmp((char *)pSysConfig->OcppServerURL, "") != EQUAL &&
@@ -2265,7 +2314,6 @@ int SpawnTask()
         system("/root/Module_4g &");
         system("/root/Module_Wifi &");
     }
-#endif //defined DD360 || defined DD360Audi
 
     return PASS;
 }
@@ -2346,13 +2394,14 @@ bool isEvBoardNormalStopChargeFlag(uint8_t gunIndex)
 //===============================================
 // 掃描插槍狀況
 //===============================================
-void ClearDetectPluginFlag()
+void ClearDetectPluginFlag(void)
 {
+    uint8_t gunIndex = 0;
     pSysInfo->WaitForPlugit = NO;
 
     //DS60-120 add
-    for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gun_index);
+    for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
 
         if (pDcChargingInfo->RemoteStartFlag == YES) {
             pDcChargingInfo->RemoteStartFlag = NO;
@@ -2422,6 +2471,7 @@ uint8_t isPrechargeStatus_chademo(uint8_t gunIndex)
 
     return result;
 }
+
 //===============================================
 // Common Detect Chk - GB
 //===============================================
@@ -2491,8 +2541,10 @@ bool isEvStopCharging_ccs(uint8_t gunIndex)
 //===============================================
 void DisplayChargingInfo()
 {
+    uint8_t i = 0;
+
     log_info("*********** DisplayChargingInfo *********** \n");
-    for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) {
+    for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
         pAcChargingInfo =  (struct ChargingInfoData *)GetAcChargingInfoData(i);
 
         if (pAcChargingInfo->SystemStatus != S_IDLE &&
@@ -2512,6 +2564,7 @@ void DisplayChargingInfo()
     }
 
     usleep(50000);
+
 #if defined DD360Audi
     pSysInfo->SystemPage = _LCM_SELECT_GUN;
 #else
@@ -2519,7 +2572,7 @@ void DisplayChargingInfo()
 #endif //defined DD360Audi
 }
 
-void _AutoReturnTimeout()
+void _AutoReturnTimeout(void)
 {
     log_info("*********** _AutoReturnTimeout %d*********** \n", pSysInfo->PageIndex);
     if (pSysInfo->PageIndex == _LCM_WAIT_FOR_PLUG) {
@@ -2527,7 +2580,9 @@ void _AutoReturnTimeout()
     } else if (pSysInfo->PageIndex == _LCM_AUTHORIZ_COMP) {
         DetectPluginStart();
     }
+
     usleep(50000);
+
 #if defined DD360Audi
     pSysInfo->SystemPage = _LCM_SELECT_GUN;
 #else
@@ -2535,7 +2590,7 @@ void _AutoReturnTimeout()
 #endif //defined DD360Audi
 }
 
-void _SelfTestTimeout()
+void _SelfTestTimeout(void)
 {
     if (pSysInfo->BootingStatus != BOOT_COMPLETE) {
         for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
@@ -2547,7 +2602,7 @@ void _SelfTestTimeout()
     log_info("Self test timeout. \n");
 }
 
-void _AuthorizedTimeout()
+void _AuthorizedTimeout(void)
 {
     if (IsAuthorizingMode()) {
         log_info("*********** _AuthorizedTimeout *********** \n");
@@ -2562,13 +2617,14 @@ void _AuthorizedTimeout()
     }
 }
 
-void _DetectPlugInTimeout()
+void _DetectPlugInTimeout(void)
 {
     log_info("*********** _DetectPlugInTimeout *********** \n");
     strcpy((char *)pSysConfig->UserId, "");
     ClearDetectPluginFlag();
-    //usleep(50000);
-    sleep(1); //Jerry add
+
+    sleep(1); //等待DoComm回報插槍訊號給主櫃
+
 #if defined DD360Audi
     pSysInfo->SystemPage = _LCM_SELECT_GUN;
 #else
@@ -2646,19 +2702,19 @@ bool canStartCharging()
 }
 #endif //0
 
-void AuthorizingStart()
+void AuthorizingStart(void)
 {
     ShmOCPP16Data->SpMsg.bits.AuthorizeReq = YES;
     pSysInfo->AuthorizeFlag = YES;
 }
 
-void ClearAuthorizedFlag()
+void ClearAuthorizedFlag(void)
 {
     ShmOCPP16Data->SpMsg.bits.AuthorizeConf = NO;
     pSysInfo->AuthorizeFlag = NO;
 }
 
-bool isAuthorizedComplete()
+bool isAuthorizedComplete(void)
 {
     if (pSysInfo->AuthorizeFlag == YES) {
         return false;
@@ -2694,22 +2750,43 @@ void ResetChargerAlarmCode(uint8_t gunIndex, char *code)
     else if (strcmp(code, "011018") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail = NO; }
     else if (strcmp(code, "011019") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail = NO; }
     else if (strcmp(code, "011020") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail = NO; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP = NO; }
+    else if (strcmp(code, "011038") == EQUAL) { ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerTempSensorFail = NO; }
 
     if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "", 6) != EQUAL) {
-        if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012229", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012230", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012231", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011011", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011013", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011015", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011012", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011014", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011016", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011018", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011019", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011020", 6) == EQUAL) {
+        if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectOTP == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectOTP == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectOTP == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaRelayWeldingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSRelayWeldingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTRelayWeldingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaRelayDrivingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSRelayDrivingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTRelayDrivingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail == NO &&
+                ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP == NO &&
+                ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerTempSensorFail == NO
+           ) {
             strncpy((char *)pDcChargingInfo->ConnectorAlarmCode, "", 6);
         }
+        //if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012229", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012230", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012231", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011011", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011013", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011015", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011012", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011014", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011016", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011018", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011019", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011020", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012323", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011038", 6) == EQUAL) {
+        //    strncpy((char *)pDcChargingInfo->ConnectorAlarmCode, "", 6);
+        //}
     }
 }
 
@@ -2750,6 +2827,8 @@ void RecordAlarmCode(uint8_t gunIndex, char *code)
     else if (strcmp(code, "011018") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail = YES; }
     else if (strcmp(code, "011019") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail = YES; }
     else if (strcmp(code, "011020") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail = YES; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP = YES; }
+    else if (strcmp(code, "011038") == EQUAL) { ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerTempSensorFail = YES; }
 }
 
 void RecordWarningCode(uint8_t gunIndex, char *code)
@@ -2903,7 +2982,9 @@ void ReleaseAlarmCode(uint8_t gunIndex)
     if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012251", 6) == EQUAL ||
             strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012252", 6) == EQUAL ||
             strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012238", 6) == EQUAL ||
-            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012304", 6) == EQUAL
+            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012304", 6) == EQUAL ||
+            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012323", 6) == EQUAL ||
+            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011038", 6) == EQUAL
        ) {
         memset(pDcChargingInfo->ConnectorAlarmCode, 0, sizeof(pDcChargingInfo->ConnectorAlarmCode));
     }
@@ -3463,6 +3544,12 @@ void CheckErrorOccurStatus(uint8_t index)
         } else if (pAlarmCode->AlarmEvents.bits.DisconnectedFromDo == YES) {
             memcpy(pDcChargingInfo->ConnectorAlarmCode, "012304", 6);
         }
+        //Chiller temperature
+        else if (pAlarmCode->AlarmEvents.bits.SystemChillerOTP == YES) {
+            memcpy(pDcChargingInfo->ConnectorAlarmCode, "012323", 6);
+        } else if (pFaultCode->FaultEvents.bits.ChillerTempSensorBroken == YES) {
+            memcpy(pDcChargingInfo->ConnectorAlarmCode, "011038", 6);
+        }
     }
 }
 
@@ -6136,20 +6223,20 @@ void ResetDetAlarmStatus(uint8_t gun)
     }
 }
 
-static void powerCabinetPsuAlarmStatus(void)
-{
-    uint8_t i = 0;
-
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-    return;
-#endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
-
-    for (i = 0; i < pSysWarning->WarningCount; i++) {
-        if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
-            EmcOccureByString("042267");
-        }
-    }
-}
+//static void powerCabinetPsuAlarmStatus(void)
+//{
+//    uint8_t i = 0;
+//
+//#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+//    return;
+//#endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
+//
+//    for (i = 0; i < pSysWarning->WarningCount; i++) {
+//        if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
+//            EmcOccureByString("042267");
+//        }
+//    }
+//}
 
 static void autoStartChargingForComBox(uint8_t gunIndex)
 {
@@ -6183,12 +6270,19 @@ static void ReviewCriticalAlarm(void)
             ShmDcCommonData->GunRelayDrivingOccur[1] == YES ||
             ShmDcCommonData->GunRelayWeldingOccur[0] == YES ||
             ShmDcCommonData->GunRelayWeldingOccur[1] == YES ||
-            pAlarmCode->AlarmEvents.bits.EmergencyStopTrip ||
-            pAlarmCode->AlarmEvents.bits.MainPowerBreakerTrip ||
-            pAlarmCode->AlarmEvents.bits.DoorOpen ||
+            pAlarmCode->AlarmEvents.bits.EmergencyStopTrip == YES ||
+            pAlarmCode->AlarmEvents.bits.MainPowerBreakerTrip == YES ||
+            pAlarmCode->AlarmEvents.bits.DoorOpen == YES ||
             pSysWarning->ExtraErrProcess != _EXTRA_ERR_PROCESS_NONE ||
-            pAlarmCode->AlarmEvents.bits.PsuFailureAlarm ||
-            pAlarmCode->AlarmEvents.bits.DisconnectedFromDo
+            pAlarmCode->AlarmEvents.bits.PsuFailureAlarm == YES ||
+            pAlarmCode->AlarmEvents.bits.DisconnectedFromDo == YES ||
+            //Power cabinet alarm status
+            ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure == YES
        ) {
         pSysWarning->Level = 2;
     } else {
@@ -6436,7 +6530,7 @@ int main(void)
         CheckReturnToChargingConn();
 
         //確認Power cabinet PSU Status
-        powerCabinetPsuAlarmStatus();
+        //powerCabinetPsuAlarmStatus();
 
         if (pGunIndexInfo->AcGunIndex > 0 && isDetectPlugin() && !GetIsCardScan()) {
             pSysInfo->SystemPage = _LCM_WAIT_FOR_PLUG;

+ 24 - 0
EVSE/Projects/DD360Audi/Apps/Config.h

@@ -310,6 +310,28 @@ typedef union {
     } GunBits;
 } EvBoardErrMsg;
 
+typedef union {
+    uint8_t AlarmState;
+    struct {
+        uint8_t EmergencyStop: 1;    //Power cabinet emergency stop
+        uint8_t DoorOpen: 1;         //Power cabinet emergency door open
+        uint8_t SystemL1InputOVP: 1; //Power cabinet system L1 input OVP
+        uint8_t SystemL2InputOVP: 1; //Power cabinet System L2 input OVP
+        uint8_t SystemL3InputOVP: 1; //Power cabinet System L3 input OVP
+        uint8_t PsuFailure: 1;       //Power cabinet PSU Failure Alarm
+        uint8_t Reserved: 2;
+    } StatusBit;
+} PowerAlarmState;
+
+typedef union {
+    uint8_t ChillerState;
+    struct {
+        uint8_t ChillerOTP: 1;            //chiller Temperature OVP
+        uint8_t ChillerTempSensorFail: 1; //Chiller temperature sensor failure
+        uint8_t Reserved: 6;
+    } StatusBit;
+} ChillerTempState;
+
 typedef struct StDcCommonInfo {
     uint8_t RebootCount;
     uint8_t CcsVersion;
@@ -319,6 +341,8 @@ typedef struct StDcCommonInfo {
     uint8_t GunRelayDrivingOccur[2];
     uint8_t SystemModeChange;
     uint8_t Reserved[3];
+    PowerAlarmState PowerAlarmState;
+    ChillerTempState ChillerTempState[2];
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 5 - 5
EVSE/Projects/DD360Audi/Apps/Define/define.c

@@ -102,7 +102,7 @@ char FaultStatusCode[40][6]=
 "011035", //Ble module broken
 "011036", //Rotary switch fault
 "011037", //CCS liquid chiller water level fault
-"011038", //Reserved
+"011038", //Chiller temperature sensor broken
 "011039", //Reserved
 "011040" //Reserved
 };
@@ -229,10 +229,10 @@ char AlarmStatusCode[128][6]=
 "012317", // Psu Dcdc Eeprom Fault
 "012318", // Psu Pfc Eeprom Fault
 "012319", // Psu Dcdc Over Voltage
-"012320", // reserved
-"012321", // reserved
-"012322", // reserved
-"012323", // reserved
+"012320", // System CHAdeMO output UCP
+"012321", // System CCS output UCP
+"012322", // System GBT output UCP
+"012323", // System Chiller output OTP
 "012324", // reserved
 "012325", // reserved
 "012326", // reserved

+ 202 - 165
EVSE/Projects/DD360Audi/Apps/Define/define.h

@@ -169,6 +169,10 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
 #define ShmOcpp20ModuleKey		1012
 #define ShmRelay2BdKey			1013
 
+#define FaultCodeLength         5
+#define AlarmCodeLength         16
+#define InfoCodeLength          41
+
 /**************************************************************************************/
 /****************** Share memory configuration value constant define ******************/
 /**************************************************************************************/
@@ -289,7 +293,7 @@ enum CoreProfile {
      DefaultPrice,
      CustomDisplayCostAndPrice,
      CustomIdleFeeAfterStop,
-	 ConfigurationVersion,
+     ConfigurationVersion,
 	 _CoreProfile_CNT
 };
 
@@ -401,10 +405,19 @@ typedef union
         unsigned int NormalStop:1;                  // 0: no effect,    1: normal stop
         unsigned int AlarmStop:1;                   // 0: no effect,    1: alarm stop
         unsigned int BackendStop:1;                 // 0: no effect,    1: backend stop
-        unsigned int res:29;
+        unsigned int ManualStop:1;                  // 0: no effect,    1: manual stop
+        unsigned int res:28;
     }bits;
 }ChargingStop;
 
+typedef struct
+{
+    unsigned char DispenserSequence;                    // dispenser sequence
+    unsigned char MaxConnectorQuantity;                 // max connector quantity
+    unsigned char WiringSetting[8];                     // record connector quantity of dispenser
+    unsigned char PowerCabinetReserved[32];
+}WiringInfoData;
+
 struct SysConfigData
 {
 	/**************System***************/
@@ -465,7 +478,10 @@ struct SysConfigData
 	unsigned char			ShowInformation;
 	unsigned char           isReqFirstUpgrade;          //EVSE is request first upgrade from PH server
 	unsigned char           isEnableLocalPowerSharging; //0: Disable power sharing  1: Enable power sharing
-	unsigned char			StopChargingByButton;		//0: Disable  1: Enable
+	unsigned char           StopChargingByButton;       //0: Disable  1: Enable
+
+    /************PowerCabinet************/
+    WiringInfoData          WiringInfo;
 };
 
 struct ChargingInfoData
@@ -510,6 +526,8 @@ struct ChargingInfoData
 	float					ChargingFee;
 	// Connector Temp
 	unsigned char 		ConnectorTemp;			//0x00: -60¢XC  ~  0xFE: 194
+	//Chiller Temp
+	unsigned char 		ChillerTemp;			//0x00: -60¢XC  ~  0xFE: 194
 	// Charging Status
 	unsigned char 		GroundFaultStatus;		// for GFD result => 0x00 : None, 0x01 : Can Start Charging, 0x02 : Stop Charging
 	unsigned short		RealRatingPower;
@@ -580,7 +598,9 @@ typedef union
         unsigned int EthernetStatusRequest:1;           // 0: no request,   1: ethernet connection status has changed           ( cabinet -> dispenser)
         unsigned int WiFiStatusRequest:1;               // 0: no request,   1: wifi connection status has changed               ( cabinet -> dispenser)
         unsigned int TelcomModemStatusRequest:1;        // 0: no request,   1: 4g connection status has changed                 ( cabinet -> dispenser)
-        unsigned int res:11;
+        unsigned int BillingStatusRequest:1;            // 0: no request,   1: billing status has changed                       ( cabinet -> dispenser)
+        unsigned int StopButtonStatusRequest:1;         // 0: no request,   1: stop charging button status has changed          ( cabinet -> dispenser)
+        unsigned int res:9;
     }bits;
 }DispenserSettingFlag;
 
@@ -636,10 +656,13 @@ struct ConnectionInfoData
 
 struct DispenserInfoData
 {
-    unsigned char               DispenserQuantity;
-    unsigned char               TotalConnectorQuantity;
+    unsigned char               DispenserQuantity;                  // record max dispenser quantity
+    unsigned char               TotalConnectorQuantity;             // record max connector quantity
     struct DispenserModule      Dispenser[GENERAL_GUN_QUANTITY];
 
+    unsigned char               PresentDispenserQuantity;
+    unsigned char               PresentConnectorQuantity;
+
     union
     {
         unsigned char Status;
@@ -747,7 +770,10 @@ typedef union
         unsigned int AuthorizingCompleted:1;    // 0: not yet, 1: authorizing completed
         unsigned int DispenserDisconnection:1;  // 0: no connection,  1: dispenser connected
         unsigned int BackendAuthorized:1;       // 0: local authorized, 1: backend authorized
-        unsigned int res:28;
+        unsigned int WiringInfoChanged:1;       // 0: no effect, 1: wiring info has changed
+        unsigned int EnableWriteWiringInfo:1;   // 0: no effect, 1: enable write wiring info after timeout
+        unsigned int CleanWiringInfo:1;         // 0: no effect, 1: clean wiring info
+        unsigned int res:25;
     }bits;
 }CabinetSettingFlag;
 
@@ -760,6 +786,8 @@ typedef struct
     unsigned int EthernetStatus;                // 0: disable, 1: connected, 2: disconnected
     unsigned int WiFiStatus;                    // 0: disable, 1: connected, 2: disconnected
     unsigned int TelcomModemStatus;             // 0: disable, 1: connected, 2: disconnected
+    unsigned int BillingStatus;                 // 0: disable, 1: enable
+    unsigned int StopChargingButton;            // 0: disable, 1: enable
     unsigned int HardwareReboot;                // 1: HardwareReboot, Other value: no effect
     unsigned int SoftwareRestart;               // 1: SoftwareRestart, Other value: no effect
 }CabinetMiscCommand;
@@ -978,7 +1006,7 @@ char FaultStatusCode[40][6]=
 	"011035",	//Ble module broken
 	"011036",	//Rotary switch fault
 	"011037",	//CCS liquid chiller water level fault
-	"011038",	//Reserved
+	"011038",	//Chiller temperature sensor broken
 	"011039",	//Reserved
 	"011040"	//Reserved
 };
@@ -986,10 +1014,10 @@ char FaultStatusCode[40][6]=
 
 struct FaultCodeData
 {
-	unsigned char PreviousFaultVal[5];
+	unsigned char PreviousFaultVal[FaultCodeLength];
 	union
 	{
-		unsigned char FaultVal[5];
+		unsigned char FaultVal[FaultCodeLength];
 		struct
 		{
 			//FaultVal[0]
@@ -1034,7 +1062,8 @@ struct FaultCodeData
 			unsigned char BleModuleBroken:1;					//bit 2
 			unsigned char RotarySwitchFault:1;					//bit 3 
 			unsigned char CcsLiquidChillerWaterLevelFault:1;    //bit 4
-			unsigned char :3;									//bit 5 ~ 7	reserved
+			unsigned char ChillerTempSensorBroken:1;            //bit 5
+			unsigned char :2;									//bit 6 ~ 7	reserved
 		}bits;
 	}FaultEvents;
 };
@@ -1162,10 +1191,10 @@ char AlarmStatusCode[128][6]=
     "012317",   // Psu Dcdc Eeprom Fault
     "012318",   // Psu Pfc Eeprom Fault
     "012319",   // Psu Dcdc Over Voltage
-    "012320",   // reserved
-    "012321",   // reserved
-    "012322",   // reserved
-    "012323",   // reserved
+    "012320",   // System CHAdeMO output UCP
+    "012321",   // System CCS output UCP
+    "012322",   // System GBT output UCP
+    "012323",   // System Chiller output OTP
     "012324",   // reserved
     "012325",   // reserved
     "012326",   // reserved
@@ -1174,10 +1203,10 @@ char AlarmStatusCode[128][6]=
 */
 struct AlarmCodeData
 {
-	unsigned char PreviousAlarmVal[16];
+	unsigned char PreviousAlarmVal[AlarmCodeLength];
 	union
 	{
-		unsigned char AlarmVal[16];
+		unsigned char AlarmVal[AlarmCodeLength];
 		struct
 		{
 			//AlarmVal[0]
@@ -1316,7 +1345,11 @@ struct AlarmCodeData
             unsigned char PsuPfcEepromFault:1;                      //bit 6
             unsigned char PsuDcdcOverVoltage:1;                     //bit 7
             //AlarmVal[15]
-            unsigned char Reserved:8;                               //bit 0~7
+            unsigned char SystemChademoOutputUCP:1;				    //bit 0
+            unsigned char SystemCCSOutputUCP:1;				        //bit 1
+            unsigned char SystemGBTOutputUCP:1;				        //bit 2
+            unsigned char SystemChillerOTP:1;                       //bit 3
+            unsigned char Reserved:4;                               //bit 4~7
 		}bits;
 	}AlarmEvents;
 };
@@ -1658,10 +1691,10 @@ char InfoStatusCode[384][6]=
 */
 struct InfoCodeData
 {
-	unsigned char PreviousInfoVal[41];
+	unsigned char PreviousInfoVal[InfoCodeLength];
 	union
 	{
-		unsigned char InfoVal[41];
+		unsigned char InfoVal[InfoCodeLength];
 		struct
 		{
 			//InfoVal[0]
@@ -2083,6 +2116,10 @@ struct PsuGroupData
 	unsigned int            GroupPresentOutputPower;        //Watt
 	struct PsuModuleData 	PsuModule[MAX_PSU_QUANTITY];
 	PsuGroupError           GroupErrorFlag;
+    unsigned short          TotalIAvailableCurrent;         // unit: 0.1A
+    unsigned short          TempIAvailableCurrent;          // unit: 0.1A
+    unsigned short          StableIAvailableCurrent;        // unit: 0.1A
+    unsigned short          StableCurrentCounter;           // stable current counter
 };
 
 /*Following is the information for system all PSU*/
@@ -4230,104 +4267,104 @@ struct StructCost
 
 struct CertificateHashDataType
 {
-	unsigned char hashAlgorithm[8];								// Required. Used algorithms for the hashes provided.
-	unsigned char issuerNameHash[129];							// Required. hashed value of the IssuerName.
-	unsigned char issuerKeyHash[129];							// Required. Hashed value of the issuers public key
-	unsigned char serialNumber[41];								// Required. The serial number of the certificate.
+    unsigned char hashAlgorithm[8];                             // Required. Used algorithms for the hashes provided.
+    unsigned char issuerNameHash[129];                          // Required. hashed value of the IssuerName.
+    unsigned char issuerKeyHash[129];                           // Required. Hashed value of the issuers public key
+    unsigned char serialNumber[41];                             // Required. The serial number of the certificate.
 };
 
 struct LogParametersType
 {
-	unsigned char remoteLocation[513];								// Required. The URL of the location at the remote system where the log should be stored.
-	unsigned char oldestTimestamp[36];								// Optional. This contains the date and time of the oldest logging information to include in the diagnostics.
-	unsigned char latestTimestamp[36];								// Optional. This contains the date and time of the latest logging information to include in the diagnostics.
+    unsigned char remoteLocation[513];                              // Required. The URL of the location at the remote system where the log should be stored.
+    unsigned char oldestTimestamp[36];                              // Optional. This contains the date and time of the oldest logging information to include in the diagnostics.
+    unsigned char latestTimestamp[36];                              // Optional. This contains the date and time of the latest logging information to include in the diagnostics.
 };
 
 struct FirmwareType
 {
-	unsigned char location[513];									// Required. URI defining the origin of the firmware.
-	unsigned char retrieveDateTime[36];								// Required. Date and time at which the firmware shall be retrieved.
-	unsigned char installDateTime[36];								// Optional. Date and time at which the firmware shall be installed.
-	unsigned char signingCertificate[5501];							// Optional. Certificate with which the firmware was signed. X.509 certificate, first DER encoded into binary, and then Base64 encoded.
-	unsigned char signature[801];									// Optional. Base64 encoded firmware signature.
+    unsigned char location[513];                                    // Required. URI defining the origin of the firmware.
+    unsigned char retrieveDateTime[36];                             // Required. Date and time at which the firmware shall be retrieved.
+    unsigned char installDateTime[36];                              // Optional. Date and time at which the firmware shall be installed.
+    unsigned char signingCertificate[5501];                         // Optional. Certificate with which the firmware was signed. X.509 certificate, first DER encoded into binary, and then Base64 encoded.
+    unsigned char signature[801];                                   // Optional. Base64 encoded firmware signature.
 };
 
 struct StructCertificateSigned
 {
-	unsigned char certificateChain[10001];
-	unsigned char Response_status[16];
+    unsigned char certificateChain[10001];
+    unsigned char Response_status[16];
 };
 
 struct StructDeleteCertificate
 {
-	struct CertificateHashDataType certificateHashData;
-	unsigned char Response_status[16];
+    struct CertificateHashDataType certificateHashData;
+    unsigned char Response_status[16];
 };
 
 struct StructExtendedTrigger
 {
-	unsigned char requestedMessage[32];
-	int connectorId;
-	unsigned char Response_status[16];
+    unsigned char requestedMessage[32];
+    int connectorId;
+    unsigned char Response_status[16];
 };
 
 struct StructGetInstalledCertificateIds
 {
-	unsigned char certificateType[32];
-	unsigned char Response_status[16];
-	struct CertificateHashDataType Response_certificateHashData[3];
+    unsigned char certificateType[32];
+    unsigned char Response_status[16];
+    struct CertificateHashDataType Response_certificateHashData[3];
 };
 
 struct StructGetLog
 {
-	unsigned char logType[16];
-	int requestId;
-	int retries;
-	int retryInterval;
-	struct LogParametersType log;
-	unsigned char Response_status[16];
-	unsigned char Response_filename[256];
+    unsigned char logType[16];
+    int requestId;
+    int retries;
+    int retryInterval;
+    struct LogParametersType log;
+    unsigned char Response_status[16];
+    unsigned char Response_filename[256];
 };
 
 struct StructInstallCertificate
 {
-	unsigned char certificateType[32];
-	unsigned char certificate[5501];
-	unsigned char Response_status[16];
+    unsigned char certificateType[32];
+    unsigned char certificate[5501];
+    unsigned char Response_status[16];
 };
 
 struct StructSignedUpdateFirmware
 {
-	int retries;
-	int retryInterval;
-	int requestId;
-	struct FirmwareType firmware;
-	unsigned char Response_status[16];
+    int retries;
+    int retryInterval;
+    int requestId;
+    struct FirmwareType firmware;
+    unsigned char Response_status[16];
 };
 
 struct StructLogStatusNotification
 {
-	unsigned char status[32];
-	int requestId;
+    unsigned char status[32];
+    int requestId;
 };
 
 struct StructSecurityEventNotification
 {
-	unsigned char type[51];
-	unsigned char timestamp[28];
-	unsigned char techInfo[256];
+    unsigned char type[51];
+    unsigned char timestamp[28];
+    unsigned char techInfo[256];
 };
 
 struct StructSignCertificate
 {
-	unsigned char csr[5501];
-	unsigned char Response_status[16];
+    unsigned char csr[5501];
+    unsigned char Response_status[16];
 };
 
 struct StructSignedFirmwareStatusNotification
 {
-	unsigned char status[32];
-	int requestId;
+    unsigned char status[32];
+    int requestId;
 };
 
 struct OCPP16Data
@@ -4362,23 +4399,23 @@ struct OCPP16Data
         struct
         {
             //SpMsgValue[0]
-            unsigned char BootNotificationReq :1;               	//bit 0,
-            unsigned char BootNotificationConf :1;              	//bit 1,
-            unsigned char AuthorizeReq :1;                      	//bit 2,
-            unsigned char AuthorizeConf :1;                     	//bit 3,
-            unsigned char DiagnosticsStatusNotificationReq :1;  	//bit 4,
-            unsigned char DiagnosticsStatusNotificationConf :1; 	//bit 5,
-            unsigned char FirmwareStatusNotificationReq :1;     	//bit 6,
-            unsigned char FirmwareStatusNotificationConf :1;   	 	//bit 7,
+            unsigned char BootNotificationReq :1;                   //bit 0,
+            unsigned char BootNotificationConf :1;                  //bit 1,
+            unsigned char AuthorizeReq :1;                          //bit 2,
+            unsigned char AuthorizeConf :1;                         //bit 3,
+            unsigned char DiagnosticsStatusNotificationReq :1;      //bit 4,
+            unsigned char DiagnosticsStatusNotificationConf :1;     //bit 5,
+            unsigned char FirmwareStatusNotificationReq :1;         //bit 6,
+            unsigned char FirmwareStatusNotificationConf :1;        //bit 7,
             //SpMsgValue[1]
             unsigned char LogStatusNotificationReq :1;              //bit 0,
-			unsigned char LogStatusNotificationConf :1;             //bit 1,
-			unsigned char SecurityEventNotificationReq :1;          //bit 2,
-			unsigned char SecurityEventNotificationConf :1;         //bit 3,
-			unsigned char SignCertificateReq :1;  					//bit 4,
-			unsigned char SignCertificateConf :1; 					//bit 5,
-			unsigned char SignedFirmwareStatusNotificationReq :1;   //bit 6,
-			unsigned char SignedFirmwareStatusNotificationConf :1;	//bit 7,
+            unsigned char LogStatusNotificationConf :1;             //bit 1,
+            unsigned char SecurityEventNotificationReq :1;          //bit 2,
+            unsigned char SecurityEventNotificationConf :1;         //bit 3,
+            unsigned char SignCertificateReq :1;                    //bit 4,
+            unsigned char SignCertificateConf :1;                   //bit 5,
+            unsigned char SignedFirmwareStatusNotificationReq :1;   //bit 6,
+            unsigned char SignedFirmwareStatusNotificationConf :1;  //bit 7,
         } bits;
     } SpMsg;
 
@@ -4424,40 +4461,40 @@ struct OCPP16Data
         struct
         {
             //CsMsgValue[0]
-            unsigned char ChangeConfigurationReq :1;    			//bit 0,
-            unsigned char ChangeConfigurationConf :1;   			//bit 1,
-            unsigned char ClearCacheReq :1;             			//bit 2,
-            unsigned char ClearCacheConf :1;            			//bit 3,
-            unsigned char GetConfigurationReq :1;       			//bit 4,
-            unsigned char GetConfigurationConf :1;      			//bit 5,
-            unsigned char UpdateFirmwareReq :1;         			//bit 6,
-            unsigned char UpdateFirmwareConf :1;        			//bit 7,
+            unsigned char ChangeConfigurationReq :1;                //bit 0,
+            unsigned char ChangeConfigurationConf :1;               //bit 1,
+            unsigned char ClearCacheReq :1;                         //bit 2,
+            unsigned char ClearCacheConf :1;                        //bit 3,
+            unsigned char GetConfigurationReq :1;                   //bit 4,
+            unsigned char GetConfigurationConf :1;                  //bit 5,
+            unsigned char UpdateFirmwareReq :1;                     //bit 6,
+            unsigned char UpdateFirmwareConf :1;                    //bit 7,
             //CsMsgValue[1]
-            unsigned char GetDiagnosticsReq :1;         			//bit 0,
-            unsigned char GetDiagnosticsConf :1;        			//bit 1,
-            unsigned char GetLocalListVersionReq :1;   				//bit 2,
-            unsigned char GetLocalListVersionConf :1;   			//bit 3,
-            unsigned char ResetReq :1;                  			//bit 4,
-            unsigned char ResetConf :1;                 			//bit 5,
-            unsigned char SendLocalListReq :1;         				//bit 6,
-            unsigned char SendLocalListConf :1;         			//bit 7,
+            unsigned char GetDiagnosticsReq :1;                     //bit 0,
+            unsigned char GetDiagnosticsConf :1;                    //bit 1,
+            unsigned char GetLocalListVersionReq :1;                //bit 2,
+            unsigned char GetLocalListVersionConf :1;               //bit 3,
+            unsigned char ResetReq :1;                              //bit 4,
+            unsigned char ResetConf :1;                             //bit 5,
+            unsigned char SendLocalListReq :1;                      //bit 6,
+            unsigned char SendLocalListConf :1;                     //bit 7,
             //CsMsgValue[2]
-            unsigned char CertificateSignedReq :1;					//bit 0
-            unsigned char CertificateSignedConf :1;					//bit 1
-            unsigned char DeleteCertificateReq :1;					//bit 2
-            unsigned char DeleteCertificateConf :1;					//bit 3
-            unsigned char ExtendedTriggerMessageReq :1;				//bit 4
-            unsigned char ExtendedTriggerMessageConf :1;			//bit 5
-            unsigned char GetInstalledCertificateIdsReq :1;			//bit 6
-            unsigned char GetInstalledCertificateIdsConf :1;		//bit 7
+            unsigned char CertificateSignedReq :1;                  //bit 0
+            unsigned char CertificateSignedConf :1;                 //bit 1
+            unsigned char DeleteCertificateReq :1;                  //bit 2
+            unsigned char DeleteCertificateConf :1;                 //bit 3
+            unsigned char ExtendedTriggerMessageReq :1;             //bit 4
+            unsigned char ExtendedTriggerMessageConf :1;            //bit 5
+            unsigned char GetInstalledCertificateIdsReq :1;         //bit 6
+            unsigned char GetInstalledCertificateIdsConf :1;        //bit 7
             //CsMsgValue[3]
-            unsigned char GetLogReq :1;								//bit 0
-            unsigned char GetLogConf :1;							//bit 1
-            unsigned char InstallCertificateReq :1;					//bit 2
-            unsigned char InstallCertificateConf :1;				//bit 3
-            unsigned char SignedUpdateFirmwareReq :1;				//bit 4
-            unsigned char SignedUpdateFirmwareConf :1;				//bit 5
-            unsigned char :2;										//bit 6 & 7
+            unsigned char GetLogReq :1;                             //bit 0
+            unsigned char GetLogConf :1;                            //bit 1
+            unsigned char InstallCertificateReq :1;                 //bit 2
+            unsigned char InstallCertificateConf :1;                //bit 3
+            unsigned char SignedUpdateFirmwareReq :1;               //bit 4
+            unsigned char SignedUpdateFirmwareConf :1;              //bit 5
+            unsigned char :2;                                       //bit 6 & 7
         } bits;
     } MsMsg;
 
@@ -4474,48 +4511,48 @@ struct OCPP16Data
         } bits[CONNECTOR_QUANTITY];
     }CSUMsg;
 
-    struct StructBootNotification               	BootNotification;
-    struct StructHeartbeat                     	 	Heartbeat;
-    struct StructAuthorize                      	Authorize;
-    struct StructStartTransaction               	StartTransaction[CONNECTOR_QUANTITY];
-    struct StructStopTransaction                	StopTransaction[CONNECTOR_QUANTITY];
-    struct StructStatusNotification             	StatusNotification[CONNECTOR_QUANTITY];
-    struct StructCancelReservation              	CancelReservation[CONNECTOR_QUANTITY];
-    struct StructChangeAvailability             	ChangeAvailability[CONNECTOR_QUANTITY];
-    struct StructChangeConfiguration            	ChangeConfiguration;
-    struct StructClearCache                     	ClearCache;
-    struct StructClearChargingProfile           	ClearChargingProfile[CONNECTOR_QUANTITY];
-    struct StructDataTransfer                   	DataTransfer[CONNECTOR_QUANTITY];
-    struct StructDiagnosticsStatusNotification  	DiagnosticsStatusNotification;
-    struct StructFirmwareStatusNotification     	FirmwareStatusNotification;
-    struct StructGetCompositeSchedule           	GetCompositeSchedule[CONNECTOR_QUANTITY];
-    struct StructGetConfiguration               	GetConfiguration;
-    struct StructGetDiagnostics                 	GetDiagnostics;
-    struct StructGetLocalListVersion            	GetLocalListVersion;
-    struct StructMeterValues                    	MeterValues[CONNECTOR_QUANTITY];
-    struct StructRemoteStartTransaction         	RemoteStartTransaction[CONNECTOR_QUANTITY];
-    struct StructRemoteStopTransaction          	RemoteStopTransaction[CONNECTOR_QUANTITY];
-    struct StructReserveNow                     	ReserveNow[CONNECTOR_QUANTITY];
-    struct StructReset                          	Reset;
-    struct StructSendLocalList                  	SendLocalList;
-    struct StructSetChargingProfile            		SetChargingProfile[CONNECTOR_QUANTITY];
-    struct StructTriggerMessage                 	TriggerMessage[CONNECTOR_QUANTITY];
-    struct StructUnlockConnector                	UnlockConnector[CONNECTOR_QUANTITY];
-    struct StructUpdateFirmware                 	UpdateFirmware;
-    struct OCPP16ConfigurationTable             	ConfigurationTable;
-    struct StructChargingProfile                	SmartChargingProfile[CONNECTOR_QUANTITY];
-    struct StructCost                           	Cost;
-    struct StructCertificateSigned					CertificateSigned;
-    struct StructDeleteCertificate					DeleteCertificate;
-    struct StructExtendedTrigger					ExtendedTriggerMessage;
-    struct StructGetInstalledCertificateIds			GetInstalledCertificateIds;
-    struct StructGetLog								GetLog;
-    struct StructInstallCertificate					InstallCertificate;
-    struct StructSignedUpdateFirmware				SignedUpdateFirmware;
-    struct StructLogStatusNotification				LogStatusNotification;
-    struct StructSecurityEventNotification			SecurityEventNotification;
-    struct StructSignCertificate					SignCertificate;
-    struct StructSignedFirmwareStatusNotification 	SignedFirmwareStatusNotification;
+    struct StructBootNotification                   BootNotification;
+    struct StructHeartbeat                          Heartbeat;
+    struct StructAuthorize                          Authorize;
+    struct StructStartTransaction                   StartTransaction[CONNECTOR_QUANTITY];
+    struct StructStopTransaction                    StopTransaction[CONNECTOR_QUANTITY];
+    struct StructStatusNotification                 StatusNotification[CONNECTOR_QUANTITY];
+    struct StructCancelReservation                  CancelReservation[CONNECTOR_QUANTITY];
+    struct StructChangeAvailability                 ChangeAvailability[CONNECTOR_QUANTITY];
+    struct StructChangeConfiguration                ChangeConfiguration;
+    struct StructClearCache                         ClearCache;
+    struct StructClearChargingProfile               ClearChargingProfile[CONNECTOR_QUANTITY];
+    struct StructDataTransfer                       DataTransfer[CONNECTOR_QUANTITY];
+    struct StructDiagnosticsStatusNotification      DiagnosticsStatusNotification;
+    struct StructFirmwareStatusNotification         FirmwareStatusNotification;
+    struct StructGetCompositeSchedule               GetCompositeSchedule[CONNECTOR_QUANTITY];
+    struct StructGetConfiguration                   GetConfiguration;
+    struct StructGetDiagnostics                     GetDiagnostics;
+    struct StructGetLocalListVersion                GetLocalListVersion;
+    struct StructMeterValues                        MeterValues[CONNECTOR_QUANTITY];
+    struct StructRemoteStartTransaction             RemoteStartTransaction[CONNECTOR_QUANTITY];
+    struct StructRemoteStopTransaction              RemoteStopTransaction[CONNECTOR_QUANTITY];
+    struct StructReserveNow                         ReserveNow[CONNECTOR_QUANTITY];
+    struct StructReset                              Reset;
+    struct StructSendLocalList                      SendLocalList;
+    struct StructSetChargingProfile                 SetChargingProfile[CONNECTOR_QUANTITY];
+    struct StructTriggerMessage                     TriggerMessage[CONNECTOR_QUANTITY];
+    struct StructUnlockConnector                    UnlockConnector[CONNECTOR_QUANTITY];
+    struct StructUpdateFirmware                     UpdateFirmware;
+    struct OCPP16ConfigurationTable                 ConfigurationTable;
+    struct StructChargingProfile                    SmartChargingProfile[CONNECTOR_QUANTITY];
+    struct StructCost                               Cost;
+    struct StructCertificateSigned                  CertificateSigned;
+    struct StructDeleteCertificate                  DeleteCertificate;
+    struct StructExtendedTrigger                    ExtendedTriggerMessage;
+    struct StructGetInstalledCertificateIds         GetInstalledCertificateIds;
+    struct StructGetLog                             GetLog;
+    struct StructInstallCertificate                 InstallCertificate;
+    struct StructSignedUpdateFirmware               SignedUpdateFirmware;
+    struct StructLogStatusNotification              LogStatusNotification;
+    struct StructSecurityEventNotification          SecurityEventNotification;
+    struct StructSignCertificate                    SignCertificate;
+    struct StructSignedFirmwareStatusNotification   SignedFirmwareStatusNotification;
 };
 
 
@@ -5082,8 +5119,8 @@ struct TransactionType
 
 struct StatusInfoType
 {
-	unsigned char reasonCode[21];									// Required. A predefined code for the reason why thestatus is returned in this response. The string is case-insensitive.
-	unsigned char additionalInfo[513];								// Optional. Additional text to provide detailed information.
+    unsigned char reasonCode[21];                                   // Required. A predefined code for the reason why thestatus is returned in this response. The string is case-insensitive.
+    unsigned char additionalInfo[513];                              // Optional. Additional text to provide detailed information.
 };
 /*
  * =============== Message ===============
@@ -5114,11 +5151,11 @@ struct CancelReservation_20
 
 struct CertificateSigned_20
 {
-	unsigned char certificateChain[10001];							// Required. Required. The signed PEM encoded X.509 certificate.This can also contain the necessary sub CA certificates.In that case, the order of the bundle should follow thecertificate chain, starting from the leaf certificate.The Configuration Variable MaxCertificateChainSize canbe used to limit the maximum size of this field.
-	unsigned char certificateType[32];								// Optional. Indicates the type of the signed certificate that is returned.
-	unsigned char Response_status[16];								// Required. Returns whether certificate signing has been accepted, otherwise rejected.
-	struct StatusInfoType Response_statusInfo;						// Optional. Detailed status information.
-	unsigned char guid[37];											// Save guid from server request
+    unsigned char certificateChain[10001];                          // Required. Required. The signed PEM encoded X.509 certificate.This can also contain the necessary sub CA certificates.In that case, the order of the bundle should follow thecertificate chain, starting from the leaf certificate.The Configuration Variable MaxCertificateChainSize canbe used to limit the maximum size of this field.
+    unsigned char certificateType[32];                              // Optional. Indicates the type of the signed certificate that is returned.
+    unsigned char Response_status[16];                              // Required. Returns whether certificate signing has been accepted, otherwise rejected.
+    struct StatusInfoType Response_statusInfo;                      // Optional. Detailed status information.
+    unsigned char guid[37];                                         // Save guid from server request
 };
 
 struct ChangeAvailability_20
@@ -5548,10 +5585,10 @@ struct SetVariables_20
 
 struct SignCertificate_20
 {
-	unsigned char csr[5501];										// Required. The Charging Station SHALL send the public key in form of a Certificate Signing Request (CSR) as described in RFC 2986 [22] using the SignCertificateRequest message.
-	unsigned char certificateType[32];								// Optional. Indicates the type of certificate that is to be signed. When omitted the certificate is to be used for both the 15118 connection (if implemented) and the Charging Station to CSMS connection.
-	unsigned char Response_status[16];								// Required. Specifies whether the CSMS can process the request.
-	struct StatusInfoType Response_statusInfo;						// Optional. Detailed status information.
+    unsigned char csr[5501];                                        // Required. The Charging Station SHALL send the public key in form of a Certificate Signing Request (CSR) as described in RFC 2986 [22] using the SignCertificateRequest message.
+    unsigned char certificateType[32];                              // Optional. Indicates the type of certificate that is to be signed. When omitted the certificate is to be used for both the 15118 connection (if implemented) and the Charging Station to CSMS connection.
+    unsigned char Response_status[16];                              // Required. Specifies whether the CSMS can process the request.
+    struct StatusInfoType Response_statusInfo;                      // Optional. Detailed status information.
 };
 
 struct StatusNotification_20

+ 14 - 13
EVSE/Projects/DD360Audi/Apps/Makefile

@@ -76,9 +76,10 @@ MAIN_SRC_FILES = $(patsubst %.o, %.c, $(MAIN_OBJ_FILES))
 	$(CC) $(CFLAGS) -c $<
 
 #internal comm lib
-INTERNALCOMM_OBJ_FILES = $(COMMON_OBJ_FILES) $(InternalCommLib)/internalComm.o $(InternalCommLib)/Module_InternalComm.o \
-							$(InternalCommLib)/FanBoard.o $(InternalCommLib)/LEDlight.o $(InternalCommLib)/RelayBoard.o \
-								$(InternalCommLib)/AcPlug.o
+INTERNALCOMM_OBJ_FILES = $(COMMON_OBJ_FILES) $(InternalCommLib)/internalComm.o \
+							$(InternalCommLib)/Module_InternalComm.o $(InternalCommLib)/FanBoard.o \
+								$(InternalCommLib)/LEDlight.o $(InternalCommLib)/RelayBoard.o \
+									$(InternalCommLib)/AcPlug.o
 INTERNALCOMM_SRC_FILES = $(patsubst %.o, %.c, $(INTERNALCOMM_OBJ_FILES))
 %.o: %.c
 	$(CC) $(CFLAGS) -c $<
@@ -100,12 +101,12 @@ apps: MainTask DoCommTask EvCommTask \
 				FactoryConfigApp OtherTools CleanExec
 
 MainTask:
-	#$(CC) $(DEFINE) $(MAIN_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(SQLite3_H) $(ModuleUpgrade_H) $(RateCurrent_H) \
-	#	$(RFID_H) $(Lib_Module_RFID) $(Lib_Module_Upgrade) $(Lib_SQLite3) $(Lib_Module_RateCurrent) -o main
-	$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -c -o main.o main.c
-	$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -c -o timeout.o timeout.c
-	$(CC) $(DEFINE) $(CFLAGS) -c -o common.o common.c
-	$(CC) $(TFLAGS) -o main main.o timeout.o common.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3} $(Lib_Module_RatedCurrent)
+	$(CC) $(DEFINE) $(MAIN_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(SQLite3_H) $(ModuleUpgrade_H) $(RateCurrent_H) \
+		$(RFID_H) $(Lib_Module_RFID) $(Lib_Module_Upgrade) $(Lib_SQLite3) $(Lib_Module_RateCurrent) -o main
+	#$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -c -o main.o main.c
+	#$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -c -o timeout.o timeout.c
+	#$(CC) $(DEFINE) $(CFLAGS) -c -o common.o common.c
+	#$(CC) $(TFLAGS) -o main main.o timeout.o common.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3} $(Lib_Module_RatedCurrent)
 
 DoCommTask:
 	$(CC) $(DEFINE) $(CFLAGS) -c -o define.o $(DefineLib)/define.c
@@ -113,10 +114,10 @@ DoCommTask:
 	$(CC) -o Module_DoComm DoComm.o define.o
 
 EvCommTask:
-	#$(CC) $(DEFINE) $(EVCOMM_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(Lib_Module_RatedCurrent) -o Module_EvComm
-	$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Ev_Comm.o $(EvCommLib)/Ev_Comm.c
-	$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Module_EvComm.o $(EvCommLib)/Module_EvComm.c
-	$(CC) -o Module_EvComm Ev_Comm.o Module_EvComm.o $(Lib_Module_RatedCurrent)
+	$(CC) $(DEFINE) $(EVCOMM_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(Lib_Module_RatedCurrent) -o Module_EvComm
+	#$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Ev_Comm.o $(EvCommLib)/Ev_Comm.c
+	#$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Module_EvComm.o $(EvCommLib)/Module_EvComm.c
+	#$(CC) -o Module_EvComm Ev_Comm.o Module_EvComm.o $(Lib_Module_RatedCurrent)
 
 EventLoggingTask:
 	$(CC) $(DEFINE) $(CFLAGS) -c -o define.o $(DefineLib)/define.c

+ 4 - 3
EVSE/Projects/DD360Audi/Apps/ModuleDoComm/DoComm.c

@@ -439,7 +439,7 @@ static void clearMiscCommand(void)
 
 static int qrCodeUrlInfoHandle(uint8_t *data)
 {
-    int len = 0;
+    //int len = 0;
     //char cmdBuf[128] = {0};
     char localTime[128] = {0};
     uint16_t timeLen = 0;
@@ -466,7 +466,8 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
         memset(ShmSysConfigAndInfo->SysConfig.SystemId, '\0', sizeof(ShmSysConfigAndInfo->SysConfig.SystemId));
         //printf("data =  %s\r\n", data);
-        len = string2ByteArray((char *)data, (uint8_t *)ShmSysConfigAndInfo->SysConfig.SystemId);
+        //len =
+        string2ByteArray((char *)data, (uint8_t *)ShmSysConfigAndInfo->SysConfig.SystemId);
         //printf("SystemId =  %s\r\n", ShmSysConfigAndInfo->SysConfig.SystemId);
     }
 
@@ -914,7 +915,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     uint8_t EventCodeTmp[7] = {0};
     uint8_t StatusArray[MAX_REGISTER_NUM][WARNING_CODE_SIZE] = {0};
     uint8_t remaindLen = 0;
-    uint8_t statusCodeError = 0;
+    //uint8_t statusCodeError = 0;
 
     if (dataLen > 0) {
         Hexdump((uint8_t *)data, dataLen);

+ 0 - 0
EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvComm.c → EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvCommOrg.c


+ 49 - 53
EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -31,7 +31,7 @@ static DcCommonInfo *ShmDcCommonData = NULL;
 extern bool AbnormalStopAnalysis(uint8_t gun_index, uint8_t *errCode);
 
 //------------------------------------------------------------------------------
-static uint8_t getMaxConnectTempAndChiller(uint8_t headTemp1, uint8_t headTemp2,
+/*static uint8_t getMaxConnectTempAndChiller(uint8_t headTemp1, uint8_t headTemp2,
         uint8_t chillerTemp1, uint8_t chillerTemp2)
 {
     uint8_t i = 0;
@@ -64,6 +64,7 @@ static uint8_t getMaxConnectTempAndChiller(uint8_t headTemp1, uint8_t headTemp2,
 
     return maxTemp;
 }
+*/
 
 static uint8_t getMaxConnectTemp(uint8_t headTemp1, uint8_t headTemp2)
 {
@@ -98,7 +99,6 @@ static float ReadAdcVolt(uint8_t AdcChannel)
     int fd = -1;
     uint8_t str[64] = {0};
     uint8_t AdcValue[8] = {'\0'};
-    //uint32_t AdcValue = 0;
 
     if (AdcChannel > 7) {
         return -1;
@@ -188,6 +188,12 @@ void CANReceiver(int fd)
 
     canRecPid = fork();
 
+
+    if (canRecPid < 0) {
+        log_error("Create CAN Bus receive task failed\r\n");
+        return;
+    }
+
     if (canRecPid == 0) {
         int isContinue = 1;
         int nbytes;
@@ -212,6 +218,8 @@ void CANReceiver(int fd)
         ShmCcsData = (struct CcsData *)GetShmCcsData();
         ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
 
+        log_info("Child's PID is %d\r\n", getpid());
+
         while (isContinue) {
             memset(&frame, 0, sizeof(struct can_frame));
             nbytes = read(fd, &frame, sizeof(struct can_frame));
@@ -448,70 +456,58 @@ void CANReceiver(int fd)
                     //ShmCcsData->V2GMessage_DIN70121[gunTypeIndex]. .ConnectorTemperatureN = frame.data[2];
                 }
                 }*/
-#if 1
+
                 //memset((uint8_t)&chiilerTemp, 0, sizeof(ChillerTemp));
-                if (targetGun == 0 &&
-                        ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
-                         (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0))
+                //if (targetGun == 0 &&
+                //        ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
+                //         (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0))
+                //   ) {
+                //    getChillerTemperature(&chiilerTemp);
+                //    pDcChargingInfo->ChillerTemp = getMaxConnectTemp(chiilerTemp.Temp[0], chiilerTemp.Temp[1]);
+                //    //pDcChargingInfo->ConnectorTemp = getMaxConnectTempAndChiller(
+                //    //                                     frame.data[1],
+                //    //                                     frame.data[2],
+                //    //                                     chiilerTemp.Temp[0],
+                //    //                                     chiilerTemp.Temp[1]);
+                //} else if (targetGun == 1 &&
+                //           ((strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
+                //            (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0))
+                //          ) {
+                //    getChillerTemperature(&chiilerTemp);
+                //    pDcChargingInfo->ChillerTemp = getMaxConnectTemp(chiilerTemp.Temp[0], chiilerTemp.Temp[1]);
+                //}
+#if 1
+                if ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
+                        (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0) ||
+                        (strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
+                        (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0)
                    ) {
                     getChillerTemperature(&chiilerTemp);
+                    pDcChargingInfo->ChillerTemp = getMaxConnectTemp(chiilerTemp.Temp[0], chiilerTemp.Temp[1]);
+                }
 
-                    pDcChargingInfo->ConnectorTemp = getMaxConnectTempAndChiller(
-                                                         frame.data[1],
-                                                         frame.data[2],
-                                                         chiilerTemp.Temp[0],
-                                                         chiilerTemp.Temp[1]);
-
-                    //log_info("%d chiller Temp1 = %d, temp2 = %d, head Temp1 = %d, Temp2 = %d\r\n",
-                    //         targetGun,
-                    //         chiilerTemp.Temp[0],
-                    //         chiilerTemp.Temp[1],
-                    //         frame.data[1],
-                    //         frame.data[2]);
-                } else if (targetGun == 1 &&
-                           ((strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
-                            (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0))
-                          ) {
-                    getChillerTemperature(&chiilerTemp);
+                pDcChargingInfo->ConnectorTemp = getMaxConnectTemp(frame.data[1], frame.data[2]);
 
-                    pDcChargingInfo->ConnectorTemp = getMaxConnectTempAndChiller(
-                                                         frame.data[1],
-                                                         frame.data[2],
-                                                         chiilerTemp.Temp[0],
-                                                         chiilerTemp.Temp[1]);
-
-                    //log_info("%d chillerTemp1 = %d, temp2 = %d, head Temp1 = %d, Temp2 = %d\r\n",
-                    //         targetGun,
-                    //         chiilerTemp.Temp[0],
-                    //         chiilerTemp.Temp[1],
-                    //         frame.data[1],
-                    //         frame.data[2]);
-                } else {
-                    pDcChargingInfo->ConnectorTemp = getMaxConnectTemp(frame.data[1], frame.data[2]);
-                    //log_info("connector temperature = %d\r\n",
-                    //         pDcChargingInfo->ConnectorTemp);
-                }
-#endif //0
-                if (ShmDcCommonData->SystemModeChange == YES) {
+                if ((ShmDcCommonData->SystemModeChange == YES) ||
+                        (((pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) &&
+                          (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP)) ||
+                         ((pDcChargingInfo->ChillerTemp >= GUN_OTP_VALUE) &&
+                          (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP)))
+                   ) {
                     ShmDcCommonData->SystemModeChange = NO;
-                    //log_info("EvboardStatus = %x \n",
-                    //         ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus);
-                    //log_info("ConnectorPlug locked = %x \n",
-                    //         frame.data[0]);
-
-                    //if (frame.data[1] >= GUN_OTP_VALUE ||
-                    //        frame.data[2] >= GUN_OTP_VALUE ||
-                    //        chiilerTemp.Temp[0] >= GUN_OTP_VALUE ||
-                    //        chiilerTemp.Temp[1] >= GUN_OTP_VALUE) {
                     log_info("Conn %d Temp 0= %d, Temp 1 = %d, chillerTemp1 = %d, chillerTemp2 = %d\r\n",
                              targetGun,
                              frame.data[1],
                              frame.data[2],
                              chiilerTemp.Temp[0],
                              chiilerTemp.Temp[1]);
-                    //}
-                    //log_info("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
                 }
+#endif //0
+                //log_info("EvboardStatus = %x \n",
+                //         ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus);
+                //log_info("ConnectorPlug locked = %x \n",
+                //         frame.data[0]);
+                //log_info("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
                 break;
 
             case ACK_EVSE_ISOLATION_STATUS:

+ 6 - 8
EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -88,23 +88,17 @@ int InitCanBus(void)
     tv.tv_usec = 10000;
 
     if (setsockopt(s0, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct  timeval)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_RCVTIMEO NG");
-#endif
     }
 
     nbytes = 40960;
     if (setsockopt(s0, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_RCVBUF NG");
-#endif
     }
 
     nbytes = 40960;
     if (setsockopt(s0, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_SNDBUF NG");
-#endif
     }
 
     rxfilter[0].can_id = 0x01;
@@ -115,10 +109,10 @@ int InitCanBus(void)
     rxfilter[2].can_mask = 0x00000FFF;
     if (setsockopt(s0, SOL_CAN_RAW, CAN_RAW_FILTER,
                    &rxfilter, sizeof(struct can_filter) * 3) < 0) {
-        log_error("RX setsockopt CAN_RAW_FILTER failed");
+        log_error("RX setsockopt CAN_RAW_FILTER failed\r\n");
     }
 
-    strcpy(ifr0.ifr_name, "can0" );
+    strcpy(ifr0.ifr_name, "can0");
     ioctl(s0, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
     addr0.can_family = AF_CAN;
     addr0.can_ifindex = ifr0.ifr_ifindex;
@@ -507,6 +501,10 @@ static void checkConnectorOVPState(uint8_t gunIndex)
         break;
     }
 
+    if (ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP == YES) {
+        isOTP = true;
+    }
+
     if (isOTP) {
         if (gunTempAllowCount[gunIndex] >= 2) {
             pDcChargingInfo->StopChargeFlag = YES;

+ 2 - 1
EVSE/Projects/DD360Audi/Apps/ModuleInternalComm/RelayBoard.c

@@ -112,7 +112,7 @@ static uint8_t getCommTargetID(uint8_t index)
     return targetID;
 }
 
-static void MatchRelayStatus(void)
+/*static void MatchRelayStatus(void)
 {
     // 因為 AC Contactor 沒有 Feedback,所以暫時先這樣處理
     //regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
@@ -127,6 +127,7 @@ static void MatchRelayStatus(void)
     regRelay.relay_event.bits.Gun1_Parallel_P = outputRelay.relay_event.bits.Gun1_Parallel_P;
     regRelay.relay_event.bits.Gun1_Parallel_N = outputRelay.relay_event.bits.Gun1_Parallel_N;
 }
+*/
 
 static bool IsNoneMatchRelayStatus(void)
 {

+ 71 - 1
EVSE/Projects/DD360Audi/Apps/ReadCmdline.c

@@ -940,7 +940,37 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
             }
         }
 
-        if (strcmp(newString[0], "chg") == 0) {
+        if (strcmp(newString[0], "strchg") == 0) {
+            if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
+                    strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0) {
+                printf ("Input cmd fail ------  strchg [vol 150-1000] [cru 2-100]\n");
+                continue;
+            }
+
+            if (atoi(newString[1]) == ShmSysConfigAndInfo->SysInfo.CurGunSelected) {
+                continue;
+            }
+
+            _GunIndex = atoi((char *)newString[1]);
+            _Voltage = atof((char *)newString[2]);
+            _Current = atof((char *)newString[3]);
+
+            uint8_t PreviousSystemStatus = 0xff;
+            if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                printf ("FindChargingInfoData error\n");
+                continue;
+            }
+
+            printf ("Power = %d, ReqVoltage = %f, ReqCurrent = %f\n",
+                    ShmSysConfigAndInfo->SysConfig.MaxChargingPower, _Voltage, _Current);
+
+            if (_Voltage > 1000 || _Voltage < 50) {
+                _Voltage = 200;
+                printf ("Input Voltage over range\n");
+                continue;
+            }
+
+        } else if (strcmp(newString[0], "chg") == 0) {
             if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
                 continue;
             }
@@ -959,6 +989,9 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
             _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = _vol;
             _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = _cur;
         } else if (strcmp(newString[0], "c") == 0) {
+            if (atoi((char *)newString[1]) != -1) {
+                ShmSysConfigAndInfo->SysInfo.CurGunSelected = atoi((char *)newString[1]);
+            }
             printf("stop \n\r");
             ShmSysConfigAndInfo->SysInfo.StartToChargingFlag = 0x00;
             _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
@@ -1138,6 +1171,43 @@ int main(void)
                 _chargingData[1]->ConnectorTemp = atoi(newString[2]);
                 printf("ReadCmdline temp 1 = %d\r\n", _chargingData[1]->ConnectorTemp);
             }
+        } else if (strcmp(newString[0], "tempC") == 0) {
+            if (strcmp(newString[1], "0") == 0) {
+                uint8_t _GunIndex = 0;
+                if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                    printf ("FindChargingInfoData error\n");
+                    return 0;
+                }
+
+                _chargingData[0]->ChillerTemp = atoi(newString[2]);
+                printf("ReadCmdline temp 0 = %d\r\n", _chargingData[0]->ChillerTemp);
+            } else if (strcmp(newString[1], "1") == 0) {
+                uint8_t _GunIndex = 1;
+                if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                    printf ("FindChargingInfoData error\n");
+                    return 0;
+                }
+
+                _chargingData[1]->ChillerTemp = atoi(newString[2]);
+                printf("ReadCmdline temp 1 = %d\r\n", _chargingData[1]->ChillerTemp);
+            }
+        } else if (strcmp(newString[0], "TempCR") == 0) {
+            if (strcmp(newString[1], "0") == 0) {
+                uint8_t _GunIndex = 0;
+                if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                    printf ("FindChargingInfoData error\n");
+                    return 0;
+                }
+                printf("ReadCmdline temp 0 = %d\r\n", _chargingData[0]->ChillerTemp);
+            } else if (strcmp(newString[1], "1") == 0) {
+                uint8_t _GunIndex = 1;
+                if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                    printf ("FindChargingInfoData error\n");
+                    return 0;
+                }
+
+                printf("ReadCmdline temp 1 = %d\r\n", _chargingData[1]->ChillerTemp);
+            }
         } else {
             printf ("%s\n", msg);
         }

+ 91 - 41
EVSE/Projects/DD360Audi/Apps/main.c → EVSE/Projects/DD360Audi/Apps/mainOrg.c

@@ -343,6 +343,30 @@ static void confirmSelGun(uint8_t selGun)
 
 static void checkGunOTPState(uint8_t _index)
 {
+
+    if ((strncmp((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[7], "V", 1) == 0) ||
+            (strncmp((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[9], "V", 1) == 0) ||
+            (strncmp((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[7], "F", 1) == 0) ||
+            (strncmp((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[9], "F", 1) == 0)
+       ) {
+        if (chargingInfo[_index]->ChillerTemp != UNDEFINED_TEMP) {
+            ResetChargerAlarmCode(_index, "011038"); //清除溫度檢測異常status code
+
+            if (chargingInfo[_index]->ChillerTemp >= GUN_OTP_VALUE) {
+                RecordAlarmCode(_index, "012323");
+            } else if (chargingInfo[_index]->ChillerTemp != 0 &&
+                       chargingInfo[_index]->ChillerTemp < GUN_OTP_RECOVERY) {
+                ResetChargerAlarmCode(_index, "012323");
+            }
+
+            //ResetChargerAlarmCode(_index, "011019");
+        } else {
+            // 沒接上 Sensor or 異常
+            RecordAlarmCode(_index, "011038");
+            ResetChargerAlarmCode(_index, "012323");
+        }
+    }
+
     switch (chargingInfo[_index]->Type) {
     case _Type_Chademo:
         if (chargingInfo[_index]->ConnectorTemp != UNDEFINED_TEMP) {
@@ -597,25 +621,25 @@ static void checkEvBoardAlarmState(uint8_t gunType)
 
 static uint8_t checkCabinetEthConnectState(LedConfig *ledConfig)
 {
-    uint8_t ret = NO;
     LedConfig *pLedConfig = (LedConfig *)ledConfig;
 
-    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DisconnectedFromDo == YES) {
-        ret = YES;
-        if (pLedConfig->RedLED == YES ||
-                pLedConfig->YellowLED == YES ||
-                pLedConfig->GreenLED == YES) {
-            pLedConfig->YellowLED = NO;
-            pLedConfig->GreenLED = NO;
-            pLedConfig->RedLED = NO;
-        } else {
-            pLedConfig->YellowLED = YES;
-            pLedConfig->GreenLED = YES;
-            pLedConfig->RedLED = YES;
-        }
+    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DisconnectedFromDo == NO) {
+        return NO;
+    }
+
+    if (pLedConfig->RedLED == YES ||
+            pLedConfig->YellowLED == YES ||
+            pLedConfig->GreenLED == YES) {
+        pLedConfig->YellowLED = NO;
+        pLedConfig->GreenLED = NO;
+        pLedConfig->RedLED = NO;
+    } else {
+        pLedConfig->YellowLED = YES;
+        pLedConfig->GreenLED = YES;
+        pLedConfig->RedLED = YES;
     }
 
-    return ret;
+    return YES;
 }
 
 static void PrimaryLedIndicatorCtrlFork(void)
@@ -634,14 +658,15 @@ static void PrimaryLedIndicatorCtrlFork(void)
 
         while (isContinue) {
             for (gunIndex = 0; gunIndex < totalGun; gunIndex++) {
-                if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
+                if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2 &&
+                        chargingInfo[gunIndex]->SystemStatus != S_BOOTING) {
                     if (checkCabinetEthConnectState(pLedConfig) == YES) {
                         continue;
                     }
-
                     pLedConfig->YellowLED = NO;
                     pLedConfig->GreenLED = NO;
                     pLedConfig->RedLED = YES;
+                    continue;
                 }
 
                 //printf("led indicator status = %d\r\n", chargingInfo[gunIndex]->SystemStatus);
@@ -670,10 +695,19 @@ static void PrimaryLedIndicatorCtrlFork(void)
                     break;
 
                 case S_IDLE:
+                    //if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
+                    //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
+                    //        break;
+                    //    }
+                    //    pLedConfig->YellowLED = NO;
+                    //    pLedConfig->GreenLED = NO;
+                    //    pLedConfig->RedLED = YES;
+                    //} else {
                     //Module_DoComm connected and system idle
                     pLedConfig->RedLED = NO;
                     pLedConfig->YellowLED = NO;
                     pLedConfig->GreenLED = YES;
+                    //}
                     break;
 
                 case S_RESERVATION:
@@ -685,12 +719,21 @@ static void PrimaryLedIndicatorCtrlFork(void)
                 case S_PREPARING_FOR_EVSE:
                 case S_CCS_PRECHARGE_ST0:
                 case S_CCS_PRECHARGE_ST1:
+                    //if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
+                    //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
+                    //        break;
+                    //    }
+                    //    pLedConfig->YellowLED = NO;
+                    //    pLedConfig->GreenLED = NO;
+                    //    pLedConfig->RedLED = YES;
+                    //} else {
                     //precharging status
                     if (pLedConfig->GreenLED == YES) {
                         pLedConfig->GreenLED = NO;
                     } else {
                         pLedConfig->GreenLED = YES;
                     }
+                    //}
                     break;
 
                 case S_CHARGING:
@@ -704,24 +747,23 @@ static void PrimaryLedIndicatorCtrlFork(void)
                     break;
 
                 case S_ALARM:
+                    //if (checkCabinetEthConnectState(pLedConfig) == YES) {
+                    //    break;
+                    //}
+
                     pLedConfig->YellowLED = NO;
                     pLedConfig->GreenLED = NO;
-
-                    if (checkCabinetEthConnectState(pLedConfig) == YES) {
-                        break;
-                    }
-
                     pLedConfig->RedLED = YES;
                     break;
 
                 case S_TERMINATING:
                 case S_COMPLETE:
-                    //if (pSysWarning->Level == 2) {
-                    //    pLedConfig->YellowLED = NO;
-                    //    pLedConfig->GreenLED = NO;
+                    //if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
                     //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
                     //        break;
                     //    }
+                    //    pLedConfig->YellowLED = NO;
+                    //    pLedConfig->GreenLED = NO;
                     //    pLedConfig->RedLED = YES;
                     //} else {
                     pLedConfig->RedLED = NO;
@@ -732,15 +774,16 @@ static void PrimaryLedIndicatorCtrlFork(void)
 
                 case S_MAINTAIN:
                 case S_FAULT:
-                    pLedConfig->YellowLED = NO;
-                    pLedConfig->GreenLED = NO;
-                    pLedConfig->RedLED = YES;
-                    //if (pSysWarning->Level == 2) {
+                    //if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
                     //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
                     //        break;
                     //    }
-                    //    pLedConfig->RedLED = YES;
+                    //    //pLedConfig->RedLED = YES;
                     //}
+
+                    pLedConfig->YellowLED = NO;
+                    pLedConfig->GreenLED = NO;
+                    pLedConfig->RedLED = YES;
                     break;
 
                 case S_BOOKING:
@@ -748,11 +791,11 @@ static void PrimaryLedIndicatorCtrlFork(void)
                 case S_UPDATE:
                 case S_NONE:
                     break;
-                }
-            }//switch
-        }//for
-        usleep(500000);
-    }//while
+                }//switch
+            }//for
+            usleep(500000);
+        }//while
+    }//fork
 }
 
 //================================================
@@ -2659,6 +2702,8 @@ void ResetChargerAlarmCode(uint8_t gunIndex, char *code)
     else if (strcmp(code, "011018") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail = NO; }
     else if (strcmp(code, "011019") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail = NO; }
     else if (strcmp(code, "011020") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail = NO; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChillerOTP = NO; }
+    else if (strcmp(code, "011038") == EQUAL) {  ShmStatusCodeData->FaultCode.FaultEvents.bits.ChillerTempSensorBroken = NO; }
 
     if (strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "", 6) != EQUAL) {
         if (strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "012229", 6) == EQUAL ||
@@ -2672,7 +2717,10 @@ void ResetChargerAlarmCode(uint8_t gunIndex, char *code)
                 strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011016", 6) == EQUAL ||
                 strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011018", 6) == EQUAL ||
                 strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011019", 6) == EQUAL ||
-                strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011020", 6) == EQUAL) {
+                strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011020", 6) == EQUAL ||
+                strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "012323", 6) == EQUAL ||
+                strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011038", 6) == EQUAL
+           ) {
             strncpy((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "", 6);
         }
     }
@@ -2713,6 +2761,8 @@ void RecordAlarmCode(uint8_t gunIndex, char *code)
     else if (strcmp(code, "011018") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail = YES; }
     else if (strcmp(code, "011019") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail = YES; }
     else if (strcmp(code, "011020") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail = YES; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChillerOTP = YES; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmStatusCodeData->FaultCode.FaultEvents.bits.ChillerTempSensorBroken = YES; }
 }
 
 void RecordWarningCode(uint8_t gunIndex, char *code)
@@ -5912,11 +5962,11 @@ static void ReviewCriticalAlarm(void)
             ShmDcCommonData->GunRelayDrivingOccur[1] == YES ||
             ShmDcCommonData->GunRelayWeldingOccur[0] == YES ||
             ShmDcCommonData->GunRelayWeldingOccur[1] == YES ||
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip ||
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MainPowerBreakerTrip ||
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DoorOpen ||
-            ShmSysConfigAndInfo->SysWarningInfo.ExtraErrProcess != _EXTRA_ERR_PROCESS_NONE ||
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFailureAlarm ||
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == YES ||
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MainPowerBreakerTrip == YES ||
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DoorOpen == YES ||
+            ShmSysConfigAndInfo->SysWarningInfo.ExtraErrProcess != _EXTRA_ERR_PROCESS_NONE == YES ||
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFailureAlarm == YES ||
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DisconnectedFromDo
        ) {
         ShmSysConfigAndInfo->SysWarningInfo.Level = 2;

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


BIN
EVSE/Projects/DD360Audi/output/FactoryConfig


BIN
EVSE/Projects/DD360Audi/output/Module_DoComm


BIN
EVSE/Projects/DD360Audi/output/Module_EvComm


BIN
EVSE/Projects/DD360Audi/output/Module_EventLogging


BIN
EVSE/Projects/DD360Audi/output/Module_InternalComm


BIN
EVSE/Projects/DD360Audi/output/Module_LcmControl


BIN
EVSE/Projects/DD360Audi/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360Audi/output/ReadCmdline


BIN
EVSE/Projects/DD360Audi/output/main


+ 34 - 5
EVSE/Projects/DD360ComBox/Apps/CSU/Primary.c

@@ -54,6 +54,7 @@ void PrimaryLedIndicatorCtrlFork(void)
         struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
         struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
         struct ChargingInfoData *pDcChargingInfo = NULL;
+        DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
 
         LedConfig *pLedConfig = (LedConfig *)&ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0];
 
@@ -63,12 +64,15 @@ void PrimaryLedIndicatorCtrlFork(void)
 
                 if (pSysWarning->Level == 2) {
                     if (checkCabinetEthConnectState(pLedConfig) == YES) {
+                        usleep(500000);
                         continue;
                     }
 
                     pLedConfig->YellowLED = NO;
                     pLedConfig->GreenLED = NO;
                     pLedConfig->RedLED = YES;
+                    usleep(500000);
+                    continue;
                 }
 
                 //printf("led indicator status = %d\r\n", chargingInfo[gunIndex]->SystemStatus);
@@ -175,11 +179,11 @@ void PrimaryLedIndicatorCtrlFork(void)
                 case S_UPDATE:
                 case S_NONE:
                     break;
-                }
-            }//switch
-        }//for
-        usleep(500000);
-    }//while
+                }//switch
+            }//for
+            usleep(500000);
+        }//while
+    }//fork
 }
 
 //------------------------------------------------------------------------------
@@ -195,44 +199,69 @@ void ChkPrimaryStatus(void)
     struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
     struct ChargingInfoData *pDcChargingInfo = NULL;
     struct ChargingInfoData *pAcChargingInfo = NULL;
+    DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
 
     if (pSysWarning->WarningCount > 0) {
         Rtn = 0;
         for (uint8_t i = 0; i < pSysWarning->WarningCount; i++) {
             if (memcmp(&pSysWarning->WarningCode[i][0], "042251", 6) == 0) {
                 EmcOccureByString("042251");
+                ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = YES;
                 Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "042252", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = YES;
                 EmcOccureByString("042252");
                 Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "042200", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = YES;
                 EmcOccureByString("042200");
                 Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "042201", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = YES;
                 EmcOccureByString("042201");
                 Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "042202", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = YES;
                 EmcOccureByString("042202");
                 Rtn = 1;
+            } else if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
+                ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = YES;
+                EmcOccureByString("042267");
+                Rtn = 1;
             } else if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
                 EmcOccureByString("012304");
                 Rtn = 1;
             }
         }
+
         if (Rtn == 0) {
+            ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
             ReleaseEmsOccureByString(0, "042251");
             ReleaseEmsOccureByString(0, "042252");
             ReleaseEmsOccureByString(0, "042200");
             ReleaseEmsOccureByString(0, "042201");
             ReleaseEmsOccureByString(0, "042202");
+            ReleaseEmsOccureByString(0, "042267");
             ReleaseEmsOccureByString(0, "012304");
         }
     } else {
+        ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
         ReleaseEmsOccureByString(0, "042251");
         ReleaseEmsOccureByString(0, "042252");
         ReleaseEmsOccureByString(0, "042200");
         ReleaseEmsOccureByString(0, "042201");
         ReleaseEmsOccureByString(0, "042202");
+        ReleaseEmsOccureByString(0, "042267");
         ReleaseEmsOccureByString(0, "012304");
     }
 

+ 1 - 8
EVSE/Projects/DD360ComBox/Apps/CSU/UpgradeFW.c

@@ -30,11 +30,10 @@ static int InitComPort(uint8_t target)
     }
 
     if (fd <= 0) {
-#ifdef SystemLogMessage
         log_error("open 407 Communication port NG \n");
-#endif
         return -1;
     }
+
     ioctl (fd, TCGETS, &tios);
     tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
     tios.c_lflag = 0;
@@ -66,21 +65,15 @@ static int InitCanBus(void)
     tv.tv_sec = 0;
     tv.tv_usec = 10000;
     if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct  timeval)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_RCVTIMEO NG");
-#endif
     }
     nbytes = 40960;
     if (setsockopt(fd, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_RCVBUF NG");
-#endif
     }
     nbytes = 40960;
     if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_SNDBUF NG");
-#endif
     }
 
     strcpy(ifr0.ifr_name, "can0");

+ 159 - 65
EVSE/Projects/DD360ComBox/Apps/CSU/main.c

@@ -330,58 +330,79 @@ void confirmSelGun(uint8_t selGun)
     StartGunInfoTimeoutDet(selGun, Timeout_SelectGun);
 }
 
-static void checkGunOTPState(uint8_t _index)
+static void checkGunOTPState(uint8_t gunIndex)
 {
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
+
+    if ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
+            (strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
+            (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0) ||
+            (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0)
+       ) {
+        if (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP) {
+            //ResetChargerAlarmCode(gunIndex, "011038"); //清除溫度檢測異常status code
+
+            if (pDcChargingInfo->ChillerTemp >= GUN_OTP_VALUE) {
+                RecordAlarmCode(gunIndex, "012323");
+            } else if (pDcChargingInfo->ChillerTemp != 0 &&
+                       pDcChargingInfo->ChillerTemp < GUN_OTP_RECOVERY) {
+                ResetChargerAlarmCode(gunIndex, "012323");
+            }
+        } else {
+            // 沒接上 Sensor or 異常
+            RecordAlarmCode(gunIndex, "011038");
+            ResetChargerAlarmCode(gunIndex, "012323");
+        }
+    }
 
     switch (pDcChargingInfo->Type) {
     case _Type_Chademo:
         if (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP) {
             if (pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) {
-                RecordAlarmCode(_index, "012229");
+                RecordAlarmCode(gunIndex, "012229");
             } else if (pDcChargingInfo->ConnectorTemp != 0 &&
                        pDcChargingInfo->ConnectorTemp < GUN_OTP_RECOVERY) {
-                ResetChargerAlarmCode(_index, "012229");
+                ResetChargerAlarmCode(gunIndex, "012229");
             }
         } else {
             // 沒接上 Sensor or 異常
-            //RecordAlarmCode(_index, "011018");
-            ResetChargerAlarmCode(_index, "012229");
+            //RecordAlarmCode(gunIndex, "011018");
+            ResetChargerAlarmCode(gunIndex, "012229");
         }
         break;
 
     case _Type_CCS_2:
         // CCS 不管甚麼輸出都會有槍溫偵測!!~
         if (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP) {
-            ResetChargerAlarmCode(_index, "011019");
+            //ResetChargerAlarmCode(gunIndex, "011019");
 
             if (pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) {
-                RecordAlarmCode(_index, "012230");
+                RecordAlarmCode(gunIndex, "012230");
             } else if (pDcChargingInfo->ConnectorTemp != 0 &&
                        pDcChargingInfo->ConnectorTemp < GUN_OTP_RECOVERY) {
-                ResetChargerAlarmCode(_index, "012230");
+                ResetChargerAlarmCode(gunIndex, "012230");
             }
 
-            //ResetChargerAlarmCode(_index, "011019");
+            //ResetChargerAlarmCode(gunIndex, "011019");
         } else {
             // 沒接上 Sensor or 異常
-            RecordAlarmCode(_index, "011019");
-            ResetChargerAlarmCode(_index, "012230");
+            RecordAlarmCode(gunIndex, "011019");
+            ResetChargerAlarmCode(gunIndex, "012230");
         }
         break;
 
     case _Type_GB:
         if (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP) {
             if (pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) {
-                RecordAlarmCode(_index, "012231");
+                RecordAlarmCode(gunIndex, "012231");
             } else if (pDcChargingInfo->ConnectorTemp != 0 &&
                        pDcChargingInfo->ConnectorTemp < GUN_OTP_RECOVERY) {
-                ResetChargerAlarmCode(_index, "012231");
+                ResetChargerAlarmCode(gunIndex, "012231");
             }
         } else {
             // 沒接上 Sensor or 異常
-            RecordAlarmCode(_index, "011020");
-            ResetChargerAlarmCode(_index, "012231");
+            RecordAlarmCode(gunIndex, "011020");
+            ResetChargerAlarmCode(gunIndex, "012231");
         }
         break;
     }
@@ -569,6 +590,28 @@ static void checkChaDeMoAlarmState(uint8_t gunType)
     }
 }
 
+static void checkChillerAlarmState(void)
+{
+    uint8_t gunIndex = 0;
+    struct ChargingInfoData *pDcChargingInfo = NULL;
+
+    for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+        pDcChargingInfo =  (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
+
+        if (ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP == YES) {
+            pAlarmCode->AlarmEvents.bits.SystemChillerOTP = YES;
+        } else {
+            pAlarmCode->AlarmEvents.bits.SystemChillerOTP = NO;
+        }
+
+        if (ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerTempSensorFail == YES) {
+            pFaultCode->FaultEvents.bits.ChillerTempSensorBroken = YES;
+        } else {
+            pFaultCode->FaultEvents.bits.ChillerTempSensorBroken = NO;
+        }
+    }
+}
+
 static void checkEvBoardAlarmState(uint8_t gunType)
 {
     switch (gunType) {
@@ -584,6 +627,8 @@ static void checkEvBoardAlarmState(uint8_t gunType)
         checkGBTAlarmState(gunType);
         break;
     }
+
+    checkChillerAlarmState();
 }
 
 #if 0
@@ -897,13 +942,14 @@ long long DiffTimebWithNow(struct timeb ST)
     ftime(&ET);
     StartTime = (long long)ST.time;
     StopTime = (long long)ET.time;
+
     return ((StopTime - StartTime) * 1000) + (ET.millitm - ST.millitm);
 }
 
 //==========================================
 // Log
 //==========================================
-void CheckFwSlotStatusLog()
+void CheckFwSlotStatusLog(void)
 {
     if (bd0_1_status == 0 && bd0_2_status == 1) {
         log_info("Connector 1 : Chademo");
@@ -2245,7 +2291,10 @@ int SpawnTask()
 
 #if defined DD360 ||defined DD360Audi || defined DD360ComBox
     system("/root/Module_DoComm &");
-#else
+
+    return PASS;
+#endif defined DD360 ||defined DD360Audi || defined DD360ComBox
+
     system("/root/Module_PsuComm &");
 
     if (strcmp((char *)pSysConfig->OcppServerURL, "") != EQUAL &&
@@ -2265,7 +2314,6 @@ int SpawnTask()
         system("/root/Module_4g &");
         system("/root/Module_Wifi &");
     }
-#endif //defined DD360 || defined DD360Audi
 
     return PASS;
 }
@@ -2346,13 +2394,14 @@ bool isEvBoardNormalStopChargeFlag(uint8_t gunIndex)
 //===============================================
 // 掃描插槍狀況
 //===============================================
-void ClearDetectPluginFlag()
+void ClearDetectPluginFlag(void)
 {
+    uint8_t gunIndex = 0;
     pSysInfo->WaitForPlugit = NO;
 
     //DS60-120 add
-    for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gun_index);
+    for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
 
         if (pDcChargingInfo->RemoteStartFlag == YES) {
             pDcChargingInfo->RemoteStartFlag = NO;
@@ -2422,6 +2471,7 @@ uint8_t isPrechargeStatus_chademo(uint8_t gunIndex)
 
     return result;
 }
+
 //===============================================
 // Common Detect Chk - GB
 //===============================================
@@ -2491,8 +2541,10 @@ bool isEvStopCharging_ccs(uint8_t gunIndex)
 //===============================================
 void DisplayChargingInfo()
 {
+    uint8_t i = 0;
+
     log_info("*********** DisplayChargingInfo *********** \n");
-    for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) {
+    for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
         pAcChargingInfo =  (struct ChargingInfoData *)GetAcChargingInfoData(i);
 
         if (pAcChargingInfo->SystemStatus != S_IDLE &&
@@ -2512,6 +2564,7 @@ void DisplayChargingInfo()
     }
 
     usleep(50000);
+
 #if defined DD360Audi
     pSysInfo->SystemPage = _LCM_SELECT_GUN;
 #else
@@ -2519,7 +2572,7 @@ void DisplayChargingInfo()
 #endif //defined DD360Audi
 }
 
-void _AutoReturnTimeout()
+void _AutoReturnTimeout(void)
 {
     log_info("*********** _AutoReturnTimeout %d*********** \n", pSysInfo->PageIndex);
     if (pSysInfo->PageIndex == _LCM_WAIT_FOR_PLUG) {
@@ -2527,7 +2580,9 @@ void _AutoReturnTimeout()
     } else if (pSysInfo->PageIndex == _LCM_AUTHORIZ_COMP) {
         DetectPluginStart();
     }
+
     usleep(50000);
+
 #if defined DD360Audi
     pSysInfo->SystemPage = _LCM_SELECT_GUN;
 #else
@@ -2535,7 +2590,7 @@ void _AutoReturnTimeout()
 #endif //defined DD360Audi
 }
 
-void _SelfTestTimeout()
+void _SelfTestTimeout(void)
 {
     if (pSysInfo->BootingStatus != BOOT_COMPLETE) {
         for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
@@ -2547,7 +2602,7 @@ void _SelfTestTimeout()
     log_info("Self test timeout. \n");
 }
 
-void _AuthorizedTimeout()
+void _AuthorizedTimeout(void)
 {
     if (IsAuthorizingMode()) {
         log_info("*********** _AuthorizedTimeout *********** \n");
@@ -2562,13 +2617,14 @@ void _AuthorizedTimeout()
     }
 }
 
-void _DetectPlugInTimeout()
+void _DetectPlugInTimeout(void)
 {
     log_info("*********** _DetectPlugInTimeout *********** \n");
     strcpy((char *)pSysConfig->UserId, "");
     ClearDetectPluginFlag();
-    //usleep(50000);
-    sleep(1); //Jerry add
+
+    sleep(1); //等待DoComm回報插槍訊號給主櫃
+
 #if defined DD360Audi
     pSysInfo->SystemPage = _LCM_SELECT_GUN;
 #else
@@ -2646,19 +2702,19 @@ bool canStartCharging()
 }
 #endif //0
 
-void AuthorizingStart()
+void AuthorizingStart(void)
 {
     ShmOCPP16Data->SpMsg.bits.AuthorizeReq = YES;
     pSysInfo->AuthorizeFlag = YES;
 }
 
-void ClearAuthorizedFlag()
+void ClearAuthorizedFlag(void)
 {
     ShmOCPP16Data->SpMsg.bits.AuthorizeConf = NO;
     pSysInfo->AuthorizeFlag = NO;
 }
 
-bool isAuthorizedComplete()
+bool isAuthorizedComplete(void)
 {
     if (pSysInfo->AuthorizeFlag == YES) {
         return false;
@@ -2694,22 +2750,43 @@ void ResetChargerAlarmCode(uint8_t gunIndex, char *code)
     else if (strcmp(code, "011018") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail = NO; }
     else if (strcmp(code, "011019") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail = NO; }
     else if (strcmp(code, "011020") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail = NO; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP = NO; }
+    else if (strcmp(code, "011038") == EQUAL) { ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerTempSensorFail = NO; }
 
     if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "", 6) != EQUAL) {
-        if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012229", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012230", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012231", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011011", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011013", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011015", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011012", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011014", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011016", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011018", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011019", 6) == EQUAL ||
-                strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011020", 6) == EQUAL) {
+        if (ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectOTP == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectOTP == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectOTP == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaRelayWeldingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSRelayWeldingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTRelayWeldingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaRelayDrivingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSRelayDrivingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTRelayDrivingFault == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail == NO &&
+                ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail == NO &&
+                ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP == NO &&
+                ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerTempSensorFail == NO
+           ) {
             strncpy((char *)pDcChargingInfo->ConnectorAlarmCode, "", 6);
         }
+        //if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012229", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012230", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012231", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011011", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011013", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011015", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011012", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011014", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011016", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011018", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011019", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011020", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012323", 6) == EQUAL ||
+        //        strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011038", 6) == EQUAL) {
+        //    strncpy((char *)pDcChargingInfo->ConnectorAlarmCode, "", 6);
+        //}
     }
 }
 
@@ -2750,6 +2827,8 @@ void RecordAlarmCode(uint8_t gunIndex, char *code)
     else if (strcmp(code, "011018") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail = YES; }
     else if (strcmp(code, "011019") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail = YES; }
     else if (strcmp(code, "011020") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail = YES; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP = YES; }
+    else if (strcmp(code, "011038") == EQUAL) { ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerTempSensorFail = YES; }
 }
 
 void RecordWarningCode(uint8_t gunIndex, char *code)
@@ -2903,7 +2982,9 @@ void ReleaseAlarmCode(uint8_t gunIndex)
     if (strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012251", 6) == EQUAL ||
             strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012252", 6) == EQUAL ||
             strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012238", 6) == EQUAL ||
-            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012304", 6) == EQUAL
+            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012304", 6) == EQUAL ||
+            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "012323", 6) == EQUAL ||
+            strncmp((char *)pDcChargingInfo->ConnectorAlarmCode, "011038", 6) == EQUAL
        ) {
         memset(pDcChargingInfo->ConnectorAlarmCode, 0, sizeof(pDcChargingInfo->ConnectorAlarmCode));
     }
@@ -3463,6 +3544,12 @@ void CheckErrorOccurStatus(uint8_t index)
         } else if (pAlarmCode->AlarmEvents.bits.DisconnectedFromDo == YES) {
             memcpy(pDcChargingInfo->ConnectorAlarmCode, "012304", 6);
         }
+        //Chiller temperature
+        else if (pAlarmCode->AlarmEvents.bits.SystemChillerOTP == YES) {
+            memcpy(pDcChargingInfo->ConnectorAlarmCode, "012323", 6);
+        } else if (pFaultCode->FaultEvents.bits.ChillerTempSensorBroken == YES) {
+            memcpy(pDcChargingInfo->ConnectorAlarmCode, "011038", 6);
+        }
     }
 }
 
@@ -6136,20 +6223,20 @@ void ResetDetAlarmStatus(uint8_t gun)
     }
 }
 
-static void powerCabinetPsuAlarmStatus(void)
-{
-    uint8_t i = 0;
-
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-    return;
-#endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
-
-    for (i = 0; i < pSysWarning->WarningCount; i++) {
-        if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
-            EmcOccureByString("042267");
-        }
-    }
-}
+//static void powerCabinetPsuAlarmStatus(void)
+//{
+//    uint8_t i = 0;
+//
+//#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+//    return;
+//#endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
+//
+//    for (i = 0; i < pSysWarning->WarningCount; i++) {
+//        if (memcmp(&pSysWarning->WarningCode[i][0], "042267", 6) == 0) {
+//            EmcOccureByString("042267");
+//        }
+//    }
+//}
 
 static void autoStartChargingForComBox(uint8_t gunIndex)
 {
@@ -6183,12 +6270,19 @@ static void ReviewCriticalAlarm(void)
             ShmDcCommonData->GunRelayDrivingOccur[1] == YES ||
             ShmDcCommonData->GunRelayWeldingOccur[0] == YES ||
             ShmDcCommonData->GunRelayWeldingOccur[1] == YES ||
-            pAlarmCode->AlarmEvents.bits.EmergencyStopTrip ||
-            pAlarmCode->AlarmEvents.bits.MainPowerBreakerTrip ||
-            pAlarmCode->AlarmEvents.bits.DoorOpen ||
+            pAlarmCode->AlarmEvents.bits.EmergencyStopTrip == YES ||
+            pAlarmCode->AlarmEvents.bits.MainPowerBreakerTrip == YES ||
+            pAlarmCode->AlarmEvents.bits.DoorOpen == YES ||
             pSysWarning->ExtraErrProcess != _EXTRA_ERR_PROCESS_NONE ||
-            pAlarmCode->AlarmEvents.bits.PsuFailureAlarm ||
-            pAlarmCode->AlarmEvents.bits.DisconnectedFromDo
+            pAlarmCode->AlarmEvents.bits.PsuFailureAlarm == YES ||
+            pAlarmCode->AlarmEvents.bits.DisconnectedFromDo == YES ||
+            //Power cabinet alarm status
+            ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP == YES ||
+            ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure == YES
        ) {
         pSysWarning->Level = 2;
     } else {
@@ -6436,7 +6530,7 @@ int main(void)
         CheckReturnToChargingConn();
 
         //確認Power cabinet PSU Status
-        powerCabinetPsuAlarmStatus();
+        //powerCabinetPsuAlarmStatus();
 
         if (pGunIndexInfo->AcGunIndex > 0 && isDetectPlugin() && !GetIsCardScan()) {
             pSysInfo->SystemPage = _LCM_WAIT_FOR_PLUG;

+ 24 - 0
EVSE/Projects/DD360ComBox/Apps/Config.h

@@ -310,6 +310,28 @@ typedef union {
     } GunBits;
 } EvBoardErrMsg;
 
+typedef union {
+    uint8_t AlarmState;
+    struct {
+        uint8_t EmergencyStop: 1;    //Power cabinet emergency stop
+        uint8_t DoorOpen: 1;         //Power cabinet emergency door open
+        uint8_t SystemL1InputOVP: 1; //Power cabinet system L1 input OVP
+        uint8_t SystemL2InputOVP: 1; //Power cabinet System L2 input OVP
+        uint8_t SystemL3InputOVP: 1; //Power cabinet System L3 input OVP
+        uint8_t PsuFailure: 1;       //Power cabinet PSU Failure Alarm
+        uint8_t Reserved: 2;
+    } StatusBit;
+} PowerAlarmState;
+
+typedef union {
+    uint8_t ChillerState;
+    struct {
+        uint8_t ChillerOTP: 1;            //chiller Temperature OVP
+        uint8_t ChillerTempSensorFail: 1; //Chiller temperature sensor failure
+        uint8_t Reserved: 6;
+    } StatusBit;
+} ChillerTempState;
+
 typedef struct StDcCommonInfo {
     uint8_t RebootCount;
     uint8_t CcsVersion;
@@ -319,6 +341,8 @@ typedef struct StDcCommonInfo {
     uint8_t GunRelayDrivingOccur[2];
     uint8_t SystemModeChange;
     uint8_t Reserved[3];
+    PowerAlarmState PowerAlarmState;
+    ChillerTempState ChillerTempState[2];
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 5 - 5
EVSE/Projects/DD360ComBox/Apps/Define/define.c

@@ -102,7 +102,7 @@ char FaultStatusCode[40][6]=
 "011035", //Ble module broken
 "011036", //Rotary switch fault
 "011037", //CCS liquid chiller water level fault
-"011038", //Reserved
+"011038", //Chiller temperature sensor broken
 "011039", //Reserved
 "011040" //Reserved
 };
@@ -229,10 +229,10 @@ char AlarmStatusCode[128][6]=
 "012317", // Psu Dcdc Eeprom Fault
 "012318", // Psu Pfc Eeprom Fault
 "012319", // Psu Dcdc Over Voltage
-"012320", // reserved
-"012321", // reserved
-"012322", // reserved
-"012323", // reserved
+"012320", // System CHAdeMO output UCP
+"012321", // System CCS output UCP
+"012322", // System GBT output UCP
+"012323", // System Chiller output OTP
 "012324", // reserved
 "012325", // reserved
 "012326", // reserved

+ 202 - 165
EVSE/Projects/DD360ComBox/Apps/Define/define.h

@@ -169,6 +169,10 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
 #define ShmOcpp20ModuleKey		1012
 #define ShmRelay2BdKey			1013
 
+#define FaultCodeLength         5
+#define AlarmCodeLength         16
+#define InfoCodeLength          41
+
 /**************************************************************************************/
 /****************** Share memory configuration value constant define ******************/
 /**************************************************************************************/
@@ -289,7 +293,7 @@ enum CoreProfile {
      DefaultPrice,
      CustomDisplayCostAndPrice,
      CustomIdleFeeAfterStop,
-	 ConfigurationVersion,
+     ConfigurationVersion,
 	 _CoreProfile_CNT
 };
 
@@ -401,10 +405,19 @@ typedef union
         unsigned int NormalStop:1;                  // 0: no effect,    1: normal stop
         unsigned int AlarmStop:1;                   // 0: no effect,    1: alarm stop
         unsigned int BackendStop:1;                 // 0: no effect,    1: backend stop
-        unsigned int res:29;
+        unsigned int ManualStop:1;                  // 0: no effect,    1: manual stop
+        unsigned int res:28;
     }bits;
 }ChargingStop;
 
+typedef struct
+{
+    unsigned char DispenserSequence;                    // dispenser sequence
+    unsigned char MaxConnectorQuantity;                 // max connector quantity
+    unsigned char WiringSetting[8];                     // record connector quantity of dispenser
+    unsigned char PowerCabinetReserved[32];
+}WiringInfoData;
+
 struct SysConfigData
 {
 	/**************System***************/
@@ -465,7 +478,10 @@ struct SysConfigData
 	unsigned char			ShowInformation;
 	unsigned char           isReqFirstUpgrade;          //EVSE is request first upgrade from PH server
 	unsigned char           isEnableLocalPowerSharging; //0: Disable power sharing  1: Enable power sharing
-	unsigned char			StopChargingByButton;		//0: Disable  1: Enable
+	unsigned char           StopChargingByButton;       //0: Disable  1: Enable
+
+    /************PowerCabinet************/
+    WiringInfoData          WiringInfo;
 };
 
 struct ChargingInfoData
@@ -510,6 +526,8 @@ struct ChargingInfoData
 	float					ChargingFee;
 	// Connector Temp
 	unsigned char 		ConnectorTemp;			//0x00: -60¢XC  ~  0xFE: 194
+	//Chiller Temp
+	unsigned char 		ChillerTemp;			//0x00: -60¢XC  ~  0xFE: 194
 	// Charging Status
 	unsigned char 		GroundFaultStatus;		// for GFD result => 0x00 : None, 0x01 : Can Start Charging, 0x02 : Stop Charging
 	unsigned short		RealRatingPower;
@@ -580,7 +598,9 @@ typedef union
         unsigned int EthernetStatusRequest:1;           // 0: no request,   1: ethernet connection status has changed           ( cabinet -> dispenser)
         unsigned int WiFiStatusRequest:1;               // 0: no request,   1: wifi connection status has changed               ( cabinet -> dispenser)
         unsigned int TelcomModemStatusRequest:1;        // 0: no request,   1: 4g connection status has changed                 ( cabinet -> dispenser)
-        unsigned int res:11;
+        unsigned int BillingStatusRequest:1;            // 0: no request,   1: billing status has changed                       ( cabinet -> dispenser)
+        unsigned int StopButtonStatusRequest:1;         // 0: no request,   1: stop charging button status has changed          ( cabinet -> dispenser)
+        unsigned int res:9;
     }bits;
 }DispenserSettingFlag;
 
@@ -636,10 +656,13 @@ struct ConnectionInfoData
 
 struct DispenserInfoData
 {
-    unsigned char               DispenserQuantity;
-    unsigned char               TotalConnectorQuantity;
+    unsigned char               DispenserQuantity;                  // record max dispenser quantity
+    unsigned char               TotalConnectorQuantity;             // record max connector quantity
     struct DispenserModule      Dispenser[GENERAL_GUN_QUANTITY];
 
+    unsigned char               PresentDispenserQuantity;
+    unsigned char               PresentConnectorQuantity;
+
     union
     {
         unsigned char Status;
@@ -747,7 +770,10 @@ typedef union
         unsigned int AuthorizingCompleted:1;    // 0: not yet, 1: authorizing completed
         unsigned int DispenserDisconnection:1;  // 0: no connection,  1: dispenser connected
         unsigned int BackendAuthorized:1;       // 0: local authorized, 1: backend authorized
-        unsigned int res:28;
+        unsigned int WiringInfoChanged:1;       // 0: no effect, 1: wiring info has changed
+        unsigned int EnableWriteWiringInfo:1;   // 0: no effect, 1: enable write wiring info after timeout
+        unsigned int CleanWiringInfo:1;         // 0: no effect, 1: clean wiring info
+        unsigned int res:25;
     }bits;
 }CabinetSettingFlag;
 
@@ -760,6 +786,8 @@ typedef struct
     unsigned int EthernetStatus;                // 0: disable, 1: connected, 2: disconnected
     unsigned int WiFiStatus;                    // 0: disable, 1: connected, 2: disconnected
     unsigned int TelcomModemStatus;             // 0: disable, 1: connected, 2: disconnected
+    unsigned int BillingStatus;                 // 0: disable, 1: enable
+    unsigned int StopChargingButton;            // 0: disable, 1: enable
     unsigned int HardwareReboot;                // 1: HardwareReboot, Other value: no effect
     unsigned int SoftwareRestart;               // 1: SoftwareRestart, Other value: no effect
 }CabinetMiscCommand;
@@ -978,7 +1006,7 @@ char FaultStatusCode[40][6]=
 	"011035",	//Ble module broken
 	"011036",	//Rotary switch fault
 	"011037",	//CCS liquid chiller water level fault
-	"011038",	//Reserved
+	"011038",	//Chiller temperature sensor broken
 	"011039",	//Reserved
 	"011040"	//Reserved
 };
@@ -986,10 +1014,10 @@ char FaultStatusCode[40][6]=
 
 struct FaultCodeData
 {
-	unsigned char PreviousFaultVal[5];
+	unsigned char PreviousFaultVal[FaultCodeLength];
 	union
 	{
-		unsigned char FaultVal[5];
+		unsigned char FaultVal[FaultCodeLength];
 		struct
 		{
 			//FaultVal[0]
@@ -1034,7 +1062,8 @@ struct FaultCodeData
 			unsigned char BleModuleBroken:1;					//bit 2
 			unsigned char RotarySwitchFault:1;					//bit 3 
 			unsigned char CcsLiquidChillerWaterLevelFault:1;    //bit 4
-			unsigned char :3;									//bit 5 ~ 7	reserved
+			unsigned char ChillerTempSensorBroken:1;            //bit 5
+			unsigned char :2;									//bit 6 ~ 7	reserved
 		}bits;
 	}FaultEvents;
 };
@@ -1162,10 +1191,10 @@ char AlarmStatusCode[128][6]=
     "012317",   // Psu Dcdc Eeprom Fault
     "012318",   // Psu Pfc Eeprom Fault
     "012319",   // Psu Dcdc Over Voltage
-    "012320",   // reserved
-    "012321",   // reserved
-    "012322",   // reserved
-    "012323",   // reserved
+    "012320",   // System CHAdeMO output UCP
+    "012321",   // System CCS output UCP
+    "012322",   // System GBT output UCP
+    "012323",   // System Chiller output OTP
     "012324",   // reserved
     "012325",   // reserved
     "012326",   // reserved
@@ -1174,10 +1203,10 @@ char AlarmStatusCode[128][6]=
 */
 struct AlarmCodeData
 {
-	unsigned char PreviousAlarmVal[16];
+	unsigned char PreviousAlarmVal[AlarmCodeLength];
 	union
 	{
-		unsigned char AlarmVal[16];
+		unsigned char AlarmVal[AlarmCodeLength];
 		struct
 		{
 			//AlarmVal[0]
@@ -1316,7 +1345,11 @@ struct AlarmCodeData
             unsigned char PsuPfcEepromFault:1;                      //bit 6
             unsigned char PsuDcdcOverVoltage:1;                     //bit 7
             //AlarmVal[15]
-            unsigned char Reserved:8;                               //bit 0~7
+            unsigned char SystemChademoOutputUCP:1;				    //bit 0
+            unsigned char SystemCCSOutputUCP:1;				        //bit 1
+            unsigned char SystemGBTOutputUCP:1;				        //bit 2
+            unsigned char SystemChillerOTP:1;                       //bit 3
+            unsigned char Reserved:4;                               //bit 4~7
 		}bits;
 	}AlarmEvents;
 };
@@ -1658,10 +1691,10 @@ char InfoStatusCode[384][6]=
 */
 struct InfoCodeData
 {
-	unsigned char PreviousInfoVal[41];
+	unsigned char PreviousInfoVal[InfoCodeLength];
 	union
 	{
-		unsigned char InfoVal[41];
+		unsigned char InfoVal[InfoCodeLength];
 		struct
 		{
 			//InfoVal[0]
@@ -2083,6 +2116,10 @@ struct PsuGroupData
 	unsigned int            GroupPresentOutputPower;        //Watt
 	struct PsuModuleData 	PsuModule[MAX_PSU_QUANTITY];
 	PsuGroupError           GroupErrorFlag;
+    unsigned short          TotalIAvailableCurrent;         // unit: 0.1A
+    unsigned short          TempIAvailableCurrent;          // unit: 0.1A
+    unsigned short          StableIAvailableCurrent;        // unit: 0.1A
+    unsigned short          StableCurrentCounter;           // stable current counter
 };
 
 /*Following is the information for system all PSU*/
@@ -4230,104 +4267,104 @@ struct StructCost
 
 struct CertificateHashDataType
 {
-	unsigned char hashAlgorithm[8];								// Required. Used algorithms for the hashes provided.
-	unsigned char issuerNameHash[129];							// Required. hashed value of the IssuerName.
-	unsigned char issuerKeyHash[129];							// Required. Hashed value of the issuers public key
-	unsigned char serialNumber[41];								// Required. The serial number of the certificate.
+    unsigned char hashAlgorithm[8];                             // Required. Used algorithms for the hashes provided.
+    unsigned char issuerNameHash[129];                          // Required. hashed value of the IssuerName.
+    unsigned char issuerKeyHash[129];                           // Required. Hashed value of the issuers public key
+    unsigned char serialNumber[41];                             // Required. The serial number of the certificate.
 };
 
 struct LogParametersType
 {
-	unsigned char remoteLocation[513];								// Required. The URL of the location at the remote system where the log should be stored.
-	unsigned char oldestTimestamp[36];								// Optional. This contains the date and time of the oldest logging information to include in the diagnostics.
-	unsigned char latestTimestamp[36];								// Optional. This contains the date and time of the latest logging information to include in the diagnostics.
+    unsigned char remoteLocation[513];                              // Required. The URL of the location at the remote system where the log should be stored.
+    unsigned char oldestTimestamp[36];                              // Optional. This contains the date and time of the oldest logging information to include in the diagnostics.
+    unsigned char latestTimestamp[36];                              // Optional. This contains the date and time of the latest logging information to include in the diagnostics.
 };
 
 struct FirmwareType
 {
-	unsigned char location[513];									// Required. URI defining the origin of the firmware.
-	unsigned char retrieveDateTime[36];								// Required. Date and time at which the firmware shall be retrieved.
-	unsigned char installDateTime[36];								// Optional. Date and time at which the firmware shall be installed.
-	unsigned char signingCertificate[5501];							// Optional. Certificate with which the firmware was signed. X.509 certificate, first DER encoded into binary, and then Base64 encoded.
-	unsigned char signature[801];									// Optional. Base64 encoded firmware signature.
+    unsigned char location[513];                                    // Required. URI defining the origin of the firmware.
+    unsigned char retrieveDateTime[36];                             // Required. Date and time at which the firmware shall be retrieved.
+    unsigned char installDateTime[36];                              // Optional. Date and time at which the firmware shall be installed.
+    unsigned char signingCertificate[5501];                         // Optional. Certificate with which the firmware was signed. X.509 certificate, first DER encoded into binary, and then Base64 encoded.
+    unsigned char signature[801];                                   // Optional. Base64 encoded firmware signature.
 };
 
 struct StructCertificateSigned
 {
-	unsigned char certificateChain[10001];
-	unsigned char Response_status[16];
+    unsigned char certificateChain[10001];
+    unsigned char Response_status[16];
 };
 
 struct StructDeleteCertificate
 {
-	struct CertificateHashDataType certificateHashData;
-	unsigned char Response_status[16];
+    struct CertificateHashDataType certificateHashData;
+    unsigned char Response_status[16];
 };
 
 struct StructExtendedTrigger
 {
-	unsigned char requestedMessage[32];
-	int connectorId;
-	unsigned char Response_status[16];
+    unsigned char requestedMessage[32];
+    int connectorId;
+    unsigned char Response_status[16];
 };
 
 struct StructGetInstalledCertificateIds
 {
-	unsigned char certificateType[32];
-	unsigned char Response_status[16];
-	struct CertificateHashDataType Response_certificateHashData[3];
+    unsigned char certificateType[32];
+    unsigned char Response_status[16];
+    struct CertificateHashDataType Response_certificateHashData[3];
 };
 
 struct StructGetLog
 {
-	unsigned char logType[16];
-	int requestId;
-	int retries;
-	int retryInterval;
-	struct LogParametersType log;
-	unsigned char Response_status[16];
-	unsigned char Response_filename[256];
+    unsigned char logType[16];
+    int requestId;
+    int retries;
+    int retryInterval;
+    struct LogParametersType log;
+    unsigned char Response_status[16];
+    unsigned char Response_filename[256];
 };
 
 struct StructInstallCertificate
 {
-	unsigned char certificateType[32];
-	unsigned char certificate[5501];
-	unsigned char Response_status[16];
+    unsigned char certificateType[32];
+    unsigned char certificate[5501];
+    unsigned char Response_status[16];
 };
 
 struct StructSignedUpdateFirmware
 {
-	int retries;
-	int retryInterval;
-	int requestId;
-	struct FirmwareType firmware;
-	unsigned char Response_status[16];
+    int retries;
+    int retryInterval;
+    int requestId;
+    struct FirmwareType firmware;
+    unsigned char Response_status[16];
 };
 
 struct StructLogStatusNotification
 {
-	unsigned char status[32];
-	int requestId;
+    unsigned char status[32];
+    int requestId;
 };
 
 struct StructSecurityEventNotification
 {
-	unsigned char type[51];
-	unsigned char timestamp[28];
-	unsigned char techInfo[256];
+    unsigned char type[51];
+    unsigned char timestamp[28];
+    unsigned char techInfo[256];
 };
 
 struct StructSignCertificate
 {
-	unsigned char csr[5501];
-	unsigned char Response_status[16];
+    unsigned char csr[5501];
+    unsigned char Response_status[16];
 };
 
 struct StructSignedFirmwareStatusNotification
 {
-	unsigned char status[32];
-	int requestId;
+    unsigned char status[32];
+    int requestId;
 };
 
 struct OCPP16Data
@@ -4362,23 +4399,23 @@ struct OCPP16Data
         struct
         {
             //SpMsgValue[0]
-            unsigned char BootNotificationReq :1;               	//bit 0,
-            unsigned char BootNotificationConf :1;              	//bit 1,
-            unsigned char AuthorizeReq :1;                      	//bit 2,
-            unsigned char AuthorizeConf :1;                     	//bit 3,
-            unsigned char DiagnosticsStatusNotificationReq :1;  	//bit 4,
-            unsigned char DiagnosticsStatusNotificationConf :1; 	//bit 5,
-            unsigned char FirmwareStatusNotificationReq :1;     	//bit 6,
-            unsigned char FirmwareStatusNotificationConf :1;   	 	//bit 7,
+            unsigned char BootNotificationReq :1;                   //bit 0,
+            unsigned char BootNotificationConf :1;                  //bit 1,
+            unsigned char AuthorizeReq :1;                          //bit 2,
+            unsigned char AuthorizeConf :1;                         //bit 3,
+            unsigned char DiagnosticsStatusNotificationReq :1;      //bit 4,
+            unsigned char DiagnosticsStatusNotificationConf :1;     //bit 5,
+            unsigned char FirmwareStatusNotificationReq :1;         //bit 6,
+            unsigned char FirmwareStatusNotificationConf :1;        //bit 7,
             //SpMsgValue[1]
             unsigned char LogStatusNotificationReq :1;              //bit 0,
-			unsigned char LogStatusNotificationConf :1;             //bit 1,
-			unsigned char SecurityEventNotificationReq :1;          //bit 2,
-			unsigned char SecurityEventNotificationConf :1;         //bit 3,
-			unsigned char SignCertificateReq :1;  					//bit 4,
-			unsigned char SignCertificateConf :1; 					//bit 5,
-			unsigned char SignedFirmwareStatusNotificationReq :1;   //bit 6,
-			unsigned char SignedFirmwareStatusNotificationConf :1;	//bit 7,
+            unsigned char LogStatusNotificationConf :1;             //bit 1,
+            unsigned char SecurityEventNotificationReq :1;          //bit 2,
+            unsigned char SecurityEventNotificationConf :1;         //bit 3,
+            unsigned char SignCertificateReq :1;                    //bit 4,
+            unsigned char SignCertificateConf :1;                   //bit 5,
+            unsigned char SignedFirmwareStatusNotificationReq :1;   //bit 6,
+            unsigned char SignedFirmwareStatusNotificationConf :1;  //bit 7,
         } bits;
     } SpMsg;
 
@@ -4424,40 +4461,40 @@ struct OCPP16Data
         struct
         {
             //CsMsgValue[0]
-            unsigned char ChangeConfigurationReq :1;    			//bit 0,
-            unsigned char ChangeConfigurationConf :1;   			//bit 1,
-            unsigned char ClearCacheReq :1;             			//bit 2,
-            unsigned char ClearCacheConf :1;            			//bit 3,
-            unsigned char GetConfigurationReq :1;       			//bit 4,
-            unsigned char GetConfigurationConf :1;      			//bit 5,
-            unsigned char UpdateFirmwareReq :1;         			//bit 6,
-            unsigned char UpdateFirmwareConf :1;        			//bit 7,
+            unsigned char ChangeConfigurationReq :1;                //bit 0,
+            unsigned char ChangeConfigurationConf :1;               //bit 1,
+            unsigned char ClearCacheReq :1;                         //bit 2,
+            unsigned char ClearCacheConf :1;                        //bit 3,
+            unsigned char GetConfigurationReq :1;                   //bit 4,
+            unsigned char GetConfigurationConf :1;                  //bit 5,
+            unsigned char UpdateFirmwareReq :1;                     //bit 6,
+            unsigned char UpdateFirmwareConf :1;                    //bit 7,
             //CsMsgValue[1]
-            unsigned char GetDiagnosticsReq :1;         			//bit 0,
-            unsigned char GetDiagnosticsConf :1;        			//bit 1,
-            unsigned char GetLocalListVersionReq :1;   				//bit 2,
-            unsigned char GetLocalListVersionConf :1;   			//bit 3,
-            unsigned char ResetReq :1;                  			//bit 4,
-            unsigned char ResetConf :1;                 			//bit 5,
-            unsigned char SendLocalListReq :1;         				//bit 6,
-            unsigned char SendLocalListConf :1;         			//bit 7,
+            unsigned char GetDiagnosticsReq :1;                     //bit 0,
+            unsigned char GetDiagnosticsConf :1;                    //bit 1,
+            unsigned char GetLocalListVersionReq :1;                //bit 2,
+            unsigned char GetLocalListVersionConf :1;               //bit 3,
+            unsigned char ResetReq :1;                              //bit 4,
+            unsigned char ResetConf :1;                             //bit 5,
+            unsigned char SendLocalListReq :1;                      //bit 6,
+            unsigned char SendLocalListConf :1;                     //bit 7,
             //CsMsgValue[2]
-            unsigned char CertificateSignedReq :1;					//bit 0
-            unsigned char CertificateSignedConf :1;					//bit 1
-            unsigned char DeleteCertificateReq :1;					//bit 2
-            unsigned char DeleteCertificateConf :1;					//bit 3
-            unsigned char ExtendedTriggerMessageReq :1;				//bit 4
-            unsigned char ExtendedTriggerMessageConf :1;			//bit 5
-            unsigned char GetInstalledCertificateIdsReq :1;			//bit 6
-            unsigned char GetInstalledCertificateIdsConf :1;		//bit 7
+            unsigned char CertificateSignedReq :1;                  //bit 0
+            unsigned char CertificateSignedConf :1;                 //bit 1
+            unsigned char DeleteCertificateReq :1;                  //bit 2
+            unsigned char DeleteCertificateConf :1;                 //bit 3
+            unsigned char ExtendedTriggerMessageReq :1;             //bit 4
+            unsigned char ExtendedTriggerMessageConf :1;            //bit 5
+            unsigned char GetInstalledCertificateIdsReq :1;         //bit 6
+            unsigned char GetInstalledCertificateIdsConf :1;        //bit 7
             //CsMsgValue[3]
-            unsigned char GetLogReq :1;								//bit 0
-            unsigned char GetLogConf :1;							//bit 1
-            unsigned char InstallCertificateReq :1;					//bit 2
-            unsigned char InstallCertificateConf :1;				//bit 3
-            unsigned char SignedUpdateFirmwareReq :1;				//bit 4
-            unsigned char SignedUpdateFirmwareConf :1;				//bit 5
-            unsigned char :2;										//bit 6 & 7
+            unsigned char GetLogReq :1;                             //bit 0
+            unsigned char GetLogConf :1;                            //bit 1
+            unsigned char InstallCertificateReq :1;                 //bit 2
+            unsigned char InstallCertificateConf :1;                //bit 3
+            unsigned char SignedUpdateFirmwareReq :1;               //bit 4
+            unsigned char SignedUpdateFirmwareConf :1;              //bit 5
+            unsigned char :2;                                       //bit 6 & 7
         } bits;
     } MsMsg;
 
@@ -4474,48 +4511,48 @@ struct OCPP16Data
         } bits[CONNECTOR_QUANTITY];
     }CSUMsg;
 
-    struct StructBootNotification               	BootNotification;
-    struct StructHeartbeat                     	 	Heartbeat;
-    struct StructAuthorize                      	Authorize;
-    struct StructStartTransaction               	StartTransaction[CONNECTOR_QUANTITY];
-    struct StructStopTransaction                	StopTransaction[CONNECTOR_QUANTITY];
-    struct StructStatusNotification             	StatusNotification[CONNECTOR_QUANTITY];
-    struct StructCancelReservation              	CancelReservation[CONNECTOR_QUANTITY];
-    struct StructChangeAvailability             	ChangeAvailability[CONNECTOR_QUANTITY];
-    struct StructChangeConfiguration            	ChangeConfiguration;
-    struct StructClearCache                     	ClearCache;
-    struct StructClearChargingProfile           	ClearChargingProfile[CONNECTOR_QUANTITY];
-    struct StructDataTransfer                   	DataTransfer[CONNECTOR_QUANTITY];
-    struct StructDiagnosticsStatusNotification  	DiagnosticsStatusNotification;
-    struct StructFirmwareStatusNotification     	FirmwareStatusNotification;
-    struct StructGetCompositeSchedule           	GetCompositeSchedule[CONNECTOR_QUANTITY];
-    struct StructGetConfiguration               	GetConfiguration;
-    struct StructGetDiagnostics                 	GetDiagnostics;
-    struct StructGetLocalListVersion            	GetLocalListVersion;
-    struct StructMeterValues                    	MeterValues[CONNECTOR_QUANTITY];
-    struct StructRemoteStartTransaction         	RemoteStartTransaction[CONNECTOR_QUANTITY];
-    struct StructRemoteStopTransaction          	RemoteStopTransaction[CONNECTOR_QUANTITY];
-    struct StructReserveNow                     	ReserveNow[CONNECTOR_QUANTITY];
-    struct StructReset                          	Reset;
-    struct StructSendLocalList                  	SendLocalList;
-    struct StructSetChargingProfile            		SetChargingProfile[CONNECTOR_QUANTITY];
-    struct StructTriggerMessage                 	TriggerMessage[CONNECTOR_QUANTITY];
-    struct StructUnlockConnector                	UnlockConnector[CONNECTOR_QUANTITY];
-    struct StructUpdateFirmware                 	UpdateFirmware;
-    struct OCPP16ConfigurationTable             	ConfigurationTable;
-    struct StructChargingProfile                	SmartChargingProfile[CONNECTOR_QUANTITY];
-    struct StructCost                           	Cost;
-    struct StructCertificateSigned					CertificateSigned;
-    struct StructDeleteCertificate					DeleteCertificate;
-    struct StructExtendedTrigger					ExtendedTriggerMessage;
-    struct StructGetInstalledCertificateIds			GetInstalledCertificateIds;
-    struct StructGetLog								GetLog;
-    struct StructInstallCertificate					InstallCertificate;
-    struct StructSignedUpdateFirmware				SignedUpdateFirmware;
-    struct StructLogStatusNotification				LogStatusNotification;
-    struct StructSecurityEventNotification			SecurityEventNotification;
-    struct StructSignCertificate					SignCertificate;
-    struct StructSignedFirmwareStatusNotification 	SignedFirmwareStatusNotification;
+    struct StructBootNotification                   BootNotification;
+    struct StructHeartbeat                          Heartbeat;
+    struct StructAuthorize                          Authorize;
+    struct StructStartTransaction                   StartTransaction[CONNECTOR_QUANTITY];
+    struct StructStopTransaction                    StopTransaction[CONNECTOR_QUANTITY];
+    struct StructStatusNotification                 StatusNotification[CONNECTOR_QUANTITY];
+    struct StructCancelReservation                  CancelReservation[CONNECTOR_QUANTITY];
+    struct StructChangeAvailability                 ChangeAvailability[CONNECTOR_QUANTITY];
+    struct StructChangeConfiguration                ChangeConfiguration;
+    struct StructClearCache                         ClearCache;
+    struct StructClearChargingProfile               ClearChargingProfile[CONNECTOR_QUANTITY];
+    struct StructDataTransfer                       DataTransfer[CONNECTOR_QUANTITY];
+    struct StructDiagnosticsStatusNotification      DiagnosticsStatusNotification;
+    struct StructFirmwareStatusNotification         FirmwareStatusNotification;
+    struct StructGetCompositeSchedule               GetCompositeSchedule[CONNECTOR_QUANTITY];
+    struct StructGetConfiguration                   GetConfiguration;
+    struct StructGetDiagnostics                     GetDiagnostics;
+    struct StructGetLocalListVersion                GetLocalListVersion;
+    struct StructMeterValues                        MeterValues[CONNECTOR_QUANTITY];
+    struct StructRemoteStartTransaction             RemoteStartTransaction[CONNECTOR_QUANTITY];
+    struct StructRemoteStopTransaction              RemoteStopTransaction[CONNECTOR_QUANTITY];
+    struct StructReserveNow                         ReserveNow[CONNECTOR_QUANTITY];
+    struct StructReset                              Reset;
+    struct StructSendLocalList                      SendLocalList;
+    struct StructSetChargingProfile                 SetChargingProfile[CONNECTOR_QUANTITY];
+    struct StructTriggerMessage                     TriggerMessage[CONNECTOR_QUANTITY];
+    struct StructUnlockConnector                    UnlockConnector[CONNECTOR_QUANTITY];
+    struct StructUpdateFirmware                     UpdateFirmware;
+    struct OCPP16ConfigurationTable                 ConfigurationTable;
+    struct StructChargingProfile                    SmartChargingProfile[CONNECTOR_QUANTITY];
+    struct StructCost                               Cost;
+    struct StructCertificateSigned                  CertificateSigned;
+    struct StructDeleteCertificate                  DeleteCertificate;
+    struct StructExtendedTrigger                    ExtendedTriggerMessage;
+    struct StructGetInstalledCertificateIds         GetInstalledCertificateIds;
+    struct StructGetLog                             GetLog;
+    struct StructInstallCertificate                 InstallCertificate;
+    struct StructSignedUpdateFirmware               SignedUpdateFirmware;
+    struct StructLogStatusNotification              LogStatusNotification;
+    struct StructSecurityEventNotification          SecurityEventNotification;
+    struct StructSignCertificate                    SignCertificate;
+    struct StructSignedFirmwareStatusNotification   SignedFirmwareStatusNotification;
 };
 
 
@@ -5082,8 +5119,8 @@ struct TransactionType
 
 struct StatusInfoType
 {
-	unsigned char reasonCode[21];									// Required. A predefined code for the reason why thestatus is returned in this response. The string is case-insensitive.
-	unsigned char additionalInfo[513];								// Optional. Additional text to provide detailed information.
+    unsigned char reasonCode[21];                                   // Required. A predefined code for the reason why thestatus is returned in this response. The string is case-insensitive.
+    unsigned char additionalInfo[513];                              // Optional. Additional text to provide detailed information.
 };
 /*
  * =============== Message ===============
@@ -5114,11 +5151,11 @@ struct CancelReservation_20
 
 struct CertificateSigned_20
 {
-	unsigned char certificateChain[10001];							// Required. Required. The signed PEM encoded X.509 certificate.This can also contain the necessary sub CA certificates.In that case, the order of the bundle should follow thecertificate chain, starting from the leaf certificate.The Configuration Variable MaxCertificateChainSize canbe used to limit the maximum size of this field.
-	unsigned char certificateType[32];								// Optional. Indicates the type of the signed certificate that is returned.
-	unsigned char Response_status[16];								// Required. Returns whether certificate signing has been accepted, otherwise rejected.
-	struct StatusInfoType Response_statusInfo;						// Optional. Detailed status information.
-	unsigned char guid[37];											// Save guid from server request
+    unsigned char certificateChain[10001];                          // Required. Required. The signed PEM encoded X.509 certificate.This can also contain the necessary sub CA certificates.In that case, the order of the bundle should follow thecertificate chain, starting from the leaf certificate.The Configuration Variable MaxCertificateChainSize canbe used to limit the maximum size of this field.
+    unsigned char certificateType[32];                              // Optional. Indicates the type of the signed certificate that is returned.
+    unsigned char Response_status[16];                              // Required. Returns whether certificate signing has been accepted, otherwise rejected.
+    struct StatusInfoType Response_statusInfo;                      // Optional. Detailed status information.
+    unsigned char guid[37];                                         // Save guid from server request
 };
 
 struct ChangeAvailability_20
@@ -5548,10 +5585,10 @@ struct SetVariables_20
 
 struct SignCertificate_20
 {
-	unsigned char csr[5501];										// Required. The Charging Station SHALL send the public key in form of a Certificate Signing Request (CSR) as described in RFC 2986 [22] using the SignCertificateRequest message.
-	unsigned char certificateType[32];								// Optional. Indicates the type of certificate that is to be signed. When omitted the certificate is to be used for both the 15118 connection (if implemented) and the Charging Station to CSMS connection.
-	unsigned char Response_status[16];								// Required. Specifies whether the CSMS can process the request.
-	struct StatusInfoType Response_statusInfo;						// Optional. Detailed status information.
+    unsigned char csr[5501];                                        // Required. The Charging Station SHALL send the public key in form of a Certificate Signing Request (CSR) as described in RFC 2986 [22] using the SignCertificateRequest message.
+    unsigned char certificateType[32];                              // Optional. Indicates the type of certificate that is to be signed. When omitted the certificate is to be used for both the 15118 connection (if implemented) and the Charging Station to CSMS connection.
+    unsigned char Response_status[16];                              // Required. Specifies whether the CSMS can process the request.
+    struct StatusInfoType Response_statusInfo;                      // Optional. Detailed status information.
 };
 
 struct StatusNotification_20

+ 14 - 13
EVSE/Projects/DD360ComBox/Apps/Makefile

@@ -76,9 +76,10 @@ MAIN_SRC_FILES = $(patsubst %.o, %.c, $(MAIN_OBJ_FILES))
 	$(CC) $(CFLAGS) -c $<
 
 #internal comm lib
-INTERNALCOMM_OBJ_FILES = $(COMMON_OBJ_FILES) $(InternalCommLib)/internalComm.o $(InternalCommLib)/Module_InternalComm.o \
-							$(InternalCommLib)/FanBoard.o $(InternalCommLib)/LEDlight.o $(InternalCommLib)/RelayBoard.o \
-								$(InternalCommLib)/AcPlug.o
+INTERNALCOMM_OBJ_FILES = $(COMMON_OBJ_FILES) $(InternalCommLib)/internalComm.o \
+							$(InternalCommLib)/Module_InternalComm.o $(InternalCommLib)/FanBoard.o \
+								$(InternalCommLib)/LEDlight.o $(InternalCommLib)/RelayBoard.o \
+									$(InternalCommLib)/AcPlug.o
 INTERNALCOMM_SRC_FILES = $(patsubst %.o, %.c, $(INTERNALCOMM_OBJ_FILES))
 %.o: %.c
 	$(CC) $(CFLAGS) -c $<
@@ -100,12 +101,12 @@ apps: MainTask DoCommTask EvCommTask \
 				FactoryConfigApp OtherTools CleanExec
 
 MainTask:
-	#$(CC) $(DEFINE) $(MAIN_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(SQLite3_H) $(ModuleUpgrade_H) $(RateCurrent_H) \
-	#	$(RFID_H) $(Lib_Module_RFID) $(Lib_Module_Upgrade) $(Lib_SQLite3) $(Lib_Module_RateCurrent) -o main
-	$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -c -o main.o main.c
-	$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -c -o timeout.o timeout.c
-	$(CC) $(DEFINE) $(CFLAGS) -c -o common.o common.c
-	$(CC) $(TFLAGS) -o main main.o timeout.o common.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3} $(Lib_Module_RatedCurrent)
+	$(CC) $(DEFINE) $(MAIN_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(SQLite3_H) $(ModuleUpgrade_H) $(RateCurrent_H) \
+		$(RFID_H) $(Lib_Module_RFID) $(Lib_Module_Upgrade) $(Lib_SQLite3) $(Lib_Module_RateCurrent) -o main
+	#$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -c -o main.o main.c
+	#$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -c -o timeout.o timeout.c
+	#$(CC) $(DEFINE) $(CFLAGS) -c -o common.o common.c
+	#$(CC) $(TFLAGS) -o main main.o timeout.o common.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3} $(Lib_Module_RatedCurrent)
 
 DoCommTask:
 	$(CC) $(DEFINE) $(CFLAGS) -c -o define.o $(DefineLib)/define.c
@@ -113,10 +114,10 @@ DoCommTask:
 	$(CC) -o Module_DoComm DoComm.o define.o
 
 EvCommTask:
-	#$(CC) $(DEFINE) $(EVCOMM_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(Lib_Module_RatedCurrent) -o Module_EvComm
-	$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Ev_Comm.o $(EvCommLib)/Ev_Comm.c
-	$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Module_EvComm.o $(EvCommLib)/Module_EvComm.c
-	$(CC) -o Module_EvComm Ev_Comm.o Module_EvComm.o $(Lib_Module_RatedCurrent)
+	$(CC) $(DEFINE) $(EVCOMM_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) $(Lib_Module_RatedCurrent) -o Module_EvComm
+	#$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Ev_Comm.o $(EvCommLib)/Ev_Comm.c
+	#$(CC) $(DEFINE) $(CFLAGS) $(RatedCurrent_H) -c -o Module_EvComm.o $(EvCommLib)/Module_EvComm.c
+	#$(CC) -o Module_EvComm Ev_Comm.o Module_EvComm.o $(Lib_Module_RatedCurrent)
 
 EventLoggingTask:
 	$(CC) $(DEFINE) $(CFLAGS) -c -o define.o $(DefineLib)/define.c

+ 4 - 3
EVSE/Projects/DD360ComBox/Apps/ModuleDoComm/DoComm.c

@@ -439,7 +439,7 @@ static void clearMiscCommand(void)
 
 static int qrCodeUrlInfoHandle(uint8_t *data)
 {
-    int len = 0;
+    //int len = 0;
     //char cmdBuf[128] = {0};
     char localTime[128] = {0};
     uint16_t timeLen = 0;
@@ -466,7 +466,8 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
         memset(ShmSysConfigAndInfo->SysConfig.SystemId, '\0', sizeof(ShmSysConfigAndInfo->SysConfig.SystemId));
         //printf("data =  %s\r\n", data);
-        len = string2ByteArray((char *)data, (uint8_t *)ShmSysConfigAndInfo->SysConfig.SystemId);
+        //len =
+        string2ByteArray((char *)data, (uint8_t *)ShmSysConfigAndInfo->SysConfig.SystemId);
         //printf("SystemId =  %s\r\n", ShmSysConfigAndInfo->SysConfig.SystemId);
     }
 
@@ -914,7 +915,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     uint8_t EventCodeTmp[7] = {0};
     uint8_t StatusArray[MAX_REGISTER_NUM][WARNING_CODE_SIZE] = {0};
     uint8_t remaindLen = 0;
-    uint8_t statusCodeError = 0;
+    //uint8_t statusCodeError = 0;
 
     if (dataLen > 0) {
         Hexdump((uint8_t *)data, dataLen);

+ 0 - 0
EVSE/Projects/DD360ComBox/Apps/ModuleEvComm/Module_EvComm.c → EVSE/Projects/DD360ComBox/Apps/ModuleEvComm/Module_EvCommOrg.c


+ 49 - 53
EVSE/Projects/DD360ComBox/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -31,7 +31,7 @@ static DcCommonInfo *ShmDcCommonData = NULL;
 extern bool AbnormalStopAnalysis(uint8_t gun_index, uint8_t *errCode);
 
 //------------------------------------------------------------------------------
-static uint8_t getMaxConnectTempAndChiller(uint8_t headTemp1, uint8_t headTemp2,
+/*static uint8_t getMaxConnectTempAndChiller(uint8_t headTemp1, uint8_t headTemp2,
         uint8_t chillerTemp1, uint8_t chillerTemp2)
 {
     uint8_t i = 0;
@@ -64,6 +64,7 @@ static uint8_t getMaxConnectTempAndChiller(uint8_t headTemp1, uint8_t headTemp2,
 
     return maxTemp;
 }
+*/
 
 static uint8_t getMaxConnectTemp(uint8_t headTemp1, uint8_t headTemp2)
 {
@@ -98,7 +99,6 @@ static float ReadAdcVolt(uint8_t AdcChannel)
     int fd = -1;
     uint8_t str[64] = {0};
     uint8_t AdcValue[8] = {'\0'};
-    //uint32_t AdcValue = 0;
 
     if (AdcChannel > 7) {
         return -1;
@@ -188,6 +188,12 @@ void CANReceiver(int fd)
 
     canRecPid = fork();
 
+
+    if (canRecPid < 0) {
+        log_error("Create CAN Bus receive task failed\r\n");
+        return;
+    }
+
     if (canRecPid == 0) {
         int isContinue = 1;
         int nbytes;
@@ -212,6 +218,8 @@ void CANReceiver(int fd)
         ShmCcsData = (struct CcsData *)GetShmCcsData();
         ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
 
+        log_info("Child's PID is %d\r\n", getpid());
+
         while (isContinue) {
             memset(&frame, 0, sizeof(struct can_frame));
             nbytes = read(fd, &frame, sizeof(struct can_frame));
@@ -448,70 +456,58 @@ void CANReceiver(int fd)
                     //ShmCcsData->V2GMessage_DIN70121[gunTypeIndex]. .ConnectorTemperatureN = frame.data[2];
                 }
                 }*/
-#if 1
+
                 //memset((uint8_t)&chiilerTemp, 0, sizeof(ChillerTemp));
-                if (targetGun == 0 &&
-                        ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
-                         (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0))
+                //if (targetGun == 0 &&
+                //        ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
+                //         (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0))
+                //   ) {
+                //    getChillerTemperature(&chiilerTemp);
+                //    pDcChargingInfo->ChillerTemp = getMaxConnectTemp(chiilerTemp.Temp[0], chiilerTemp.Temp[1]);
+                //    //pDcChargingInfo->ConnectorTemp = getMaxConnectTempAndChiller(
+                //    //                                     frame.data[1],
+                //    //                                     frame.data[2],
+                //    //                                     chiilerTemp.Temp[0],
+                //    //                                     chiilerTemp.Temp[1]);
+                //} else if (targetGun == 1 &&
+                //           ((strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
+                //            (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0))
+                //          ) {
+                //    getChillerTemperature(&chiilerTemp);
+                //    pDcChargingInfo->ChillerTemp = getMaxConnectTemp(chiilerTemp.Temp[0], chiilerTemp.Temp[1]);
+                //}
+#if 1
+                if ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
+                        (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0) ||
+                        (strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
+                        (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0)
                    ) {
                     getChillerTemperature(&chiilerTemp);
+                    pDcChargingInfo->ChillerTemp = getMaxConnectTemp(chiilerTemp.Temp[0], chiilerTemp.Temp[1]);
+                }
 
-                    pDcChargingInfo->ConnectorTemp = getMaxConnectTempAndChiller(
-                                                         frame.data[1],
-                                                         frame.data[2],
-                                                         chiilerTemp.Temp[0],
-                                                         chiilerTemp.Temp[1]);
-
-                    //log_info("%d chiller Temp1 = %d, temp2 = %d, head Temp1 = %d, Temp2 = %d\r\n",
-                    //         targetGun,
-                    //         chiilerTemp.Temp[0],
-                    //         chiilerTemp.Temp[1],
-                    //         frame.data[1],
-                    //         frame.data[2]);
-                } else if (targetGun == 1 &&
-                           ((strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
-                            (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0))
-                          ) {
-                    getChillerTemperature(&chiilerTemp);
+                pDcChargingInfo->ConnectorTemp = getMaxConnectTemp(frame.data[1], frame.data[2]);
 
-                    pDcChargingInfo->ConnectorTemp = getMaxConnectTempAndChiller(
-                                                         frame.data[1],
-                                                         frame.data[2],
-                                                         chiilerTemp.Temp[0],
-                                                         chiilerTemp.Temp[1]);
-
-                    //log_info("%d chillerTemp1 = %d, temp2 = %d, head Temp1 = %d, Temp2 = %d\r\n",
-                    //         targetGun,
-                    //         chiilerTemp.Temp[0],
-                    //         chiilerTemp.Temp[1],
-                    //         frame.data[1],
-                    //         frame.data[2]);
-                } else {
-                    pDcChargingInfo->ConnectorTemp = getMaxConnectTemp(frame.data[1], frame.data[2]);
-                    //log_info("connector temperature = %d\r\n",
-                    //         pDcChargingInfo->ConnectorTemp);
-                }
-#endif //0
-                if (ShmDcCommonData->SystemModeChange == YES) {
+                if ((ShmDcCommonData->SystemModeChange == YES) ||
+                        (((pDcChargingInfo->ConnectorTemp >= GUN_OTP_VALUE) &&
+                          (pDcChargingInfo->ConnectorTemp != UNDEFINED_TEMP)) ||
+                         ((pDcChargingInfo->ChillerTemp >= GUN_OTP_VALUE) &&
+                          (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP)))
+                   ) {
                     ShmDcCommonData->SystemModeChange = NO;
-                    //log_info("EvboardStatus = %x \n",
-                    //         ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus);
-                    //log_info("ConnectorPlug locked = %x \n",
-                    //         frame.data[0]);
-
-                    //if (frame.data[1] >= GUN_OTP_VALUE ||
-                    //        frame.data[2] >= GUN_OTP_VALUE ||
-                    //        chiilerTemp.Temp[0] >= GUN_OTP_VALUE ||
-                    //        chiilerTemp.Temp[1] >= GUN_OTP_VALUE) {
                     log_info("Conn %d Temp 0= %d, Temp 1 = %d, chillerTemp1 = %d, chillerTemp2 = %d\r\n",
                              targetGun,
                              frame.data[1],
                              frame.data[2],
                              chiilerTemp.Temp[0],
                              chiilerTemp.Temp[1]);
-                    //}
-                    //log_info("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
                 }
+#endif //0
+                //log_info("EvboardStatus = %x \n",
+                //         ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus);
+                //log_info("ConnectorPlug locked = %x \n",
+                //         frame.data[0]);
+                //log_info("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
                 break;
 
             case ACK_EVSE_ISOLATION_STATUS:

+ 6 - 8
EVSE/Projects/DD360ComBox/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -88,23 +88,17 @@ int InitCanBus(void)
     tv.tv_usec = 10000;
 
     if (setsockopt(s0, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct  timeval)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_RCVTIMEO NG");
-#endif
     }
 
     nbytes = 40960;
     if (setsockopt(s0, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_RCVBUF NG");
-#endif
     }
 
     nbytes = 40960;
     if (setsockopt(s0, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0) {
-#ifdef SystemLogMessage
         log_error("Set SO_SNDBUF NG");
-#endif
     }
 
     rxfilter[0].can_id = 0x01;
@@ -115,10 +109,10 @@ int InitCanBus(void)
     rxfilter[2].can_mask = 0x00000FFF;
     if (setsockopt(s0, SOL_CAN_RAW, CAN_RAW_FILTER,
                    &rxfilter, sizeof(struct can_filter) * 3) < 0) {
-        log_error("RX setsockopt CAN_RAW_FILTER failed");
+        log_error("RX setsockopt CAN_RAW_FILTER failed\r\n");
     }
 
-    strcpy(ifr0.ifr_name, "can0" );
+    strcpy(ifr0.ifr_name, "can0");
     ioctl(s0, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
     addr0.can_family = AF_CAN;
     addr0.can_ifindex = ifr0.ifr_ifindex;
@@ -507,6 +501,10 @@ static void checkConnectorOVPState(uint8_t gunIndex)
         break;
     }
 
+    if (ShmDcCommonData->ChillerTempState[gunIndex].StatusBit.ChillerOTP == YES) {
+        isOTP = true;
+    }
+
     if (isOTP) {
         if (gunTempAllowCount[gunIndex] >= 2) {
             pDcChargingInfo->StopChargeFlag = YES;

+ 2 - 1
EVSE/Projects/DD360ComBox/Apps/ModuleInternalComm/RelayBoard.c

@@ -112,7 +112,7 @@ static uint8_t getCommTargetID(uint8_t index)
     return targetID;
 }
 
-static void MatchRelayStatus(void)
+/*static void MatchRelayStatus(void)
 {
     // 因為 AC Contactor 沒有 Feedback,所以暫時先這樣處理
     //regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
@@ -127,6 +127,7 @@ static void MatchRelayStatus(void)
     regRelay.relay_event.bits.Gun1_Parallel_P = outputRelay.relay_event.bits.Gun1_Parallel_P;
     regRelay.relay_event.bits.Gun1_Parallel_N = outputRelay.relay_event.bits.Gun1_Parallel_N;
 }
+*/
 
 static bool IsNoneMatchRelayStatus(void)
 {

+ 71 - 1
EVSE/Projects/DD360ComBox/Apps/ReadCmdline.c

@@ -940,7 +940,37 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
             }
         }
 
-        if (strcmp(newString[0], "chg") == 0) {
+        if (strcmp(newString[0], "strchg") == 0) {
+            if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
+                    strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0) {
+                printf ("Input cmd fail ------  strchg [vol 150-1000] [cru 2-100]\n");
+                continue;
+            }
+
+            if (atoi(newString[1]) == ShmSysConfigAndInfo->SysInfo.CurGunSelected) {
+                continue;
+            }
+
+            _GunIndex = atoi((char *)newString[1]);
+            _Voltage = atof((char *)newString[2]);
+            _Current = atof((char *)newString[3]);
+
+            uint8_t PreviousSystemStatus = 0xff;
+            if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                printf ("FindChargingInfoData error\n");
+                continue;
+            }
+
+            printf ("Power = %d, ReqVoltage = %f, ReqCurrent = %f\n",
+                    ShmSysConfigAndInfo->SysConfig.MaxChargingPower, _Voltage, _Current);
+
+            if (_Voltage > 1000 || _Voltage < 50) {
+                _Voltage = 200;
+                printf ("Input Voltage over range\n");
+                continue;
+            }
+
+        } else if (strcmp(newString[0], "chg") == 0) {
             if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
                 continue;
             }
@@ -959,6 +989,9 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
             _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = _vol;
             _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = _cur;
         } else if (strcmp(newString[0], "c") == 0) {
+            if (atoi((char *)newString[1]) != -1) {
+                ShmSysConfigAndInfo->SysInfo.CurGunSelected = atoi((char *)newString[1]);
+            }
             printf("stop \n\r");
             ShmSysConfigAndInfo->SysInfo.StartToChargingFlag = 0x00;
             _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
@@ -1138,6 +1171,43 @@ int main(void)
                 _chargingData[1]->ConnectorTemp = atoi(newString[2]);
                 printf("ReadCmdline temp 1 = %d\r\n", _chargingData[1]->ConnectorTemp);
             }
+        } else if (strcmp(newString[0], "tempC") == 0) {
+            if (strcmp(newString[1], "0") == 0) {
+                uint8_t _GunIndex = 0;
+                if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                    printf ("FindChargingInfoData error\n");
+                    return 0;
+                }
+
+                _chargingData[0]->ChillerTemp = atoi(newString[2]);
+                printf("ReadCmdline temp 0 = %d\r\n", _chargingData[0]->ChillerTemp);
+            } else if (strcmp(newString[1], "1") == 0) {
+                uint8_t _GunIndex = 1;
+                if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                    printf ("FindChargingInfoData error\n");
+                    return 0;
+                }
+
+                _chargingData[1]->ChillerTemp = atoi(newString[2]);
+                printf("ReadCmdline temp 1 = %d\r\n", _chargingData[1]->ChillerTemp);
+            }
+        } else if (strcmp(newString[0], "TempCR") == 0) {
+            if (strcmp(newString[1], "0") == 0) {
+                uint8_t _GunIndex = 0;
+                if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                    printf ("FindChargingInfoData error\n");
+                    return 0;
+                }
+                printf("ReadCmdline temp 0 = %d\r\n", _chargingData[0]->ChillerTemp);
+            } else if (strcmp(newString[1], "1") == 0) {
+                uint8_t _GunIndex = 1;
+                if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+                    printf ("FindChargingInfoData error\n");
+                    return 0;
+                }
+
+                printf("ReadCmdline temp 1 = %d\r\n", _chargingData[1]->ChillerTemp);
+            }
         } else {
             printf ("%s\n", msg);
         }

+ 91 - 41
EVSE/Projects/DD360ComBox/Apps/main.c → EVSE/Projects/DD360ComBox/Apps/mainOrg.c

@@ -343,6 +343,30 @@ static void confirmSelGun(uint8_t selGun)
 
 static void checkGunOTPState(uint8_t _index)
 {
+
+    if ((strncmp((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[7], "V", 1) == 0) ||
+            (strncmp((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[9], "V", 1) == 0) ||
+            (strncmp((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[7], "F", 1) == 0) ||
+            (strncmp((char *)&ShmSysConfigAndInfo->SysConfig.ModelName[9], "F", 1) == 0)
+       ) {
+        if (chargingInfo[_index]->ChillerTemp != UNDEFINED_TEMP) {
+            ResetChargerAlarmCode(_index, "011038"); //清除溫度檢測異常status code
+
+            if (chargingInfo[_index]->ChillerTemp >= GUN_OTP_VALUE) {
+                RecordAlarmCode(_index, "012323");
+            } else if (chargingInfo[_index]->ChillerTemp != 0 &&
+                       chargingInfo[_index]->ChillerTemp < GUN_OTP_RECOVERY) {
+                ResetChargerAlarmCode(_index, "012323");
+            }
+
+            //ResetChargerAlarmCode(_index, "011019");
+        } else {
+            // 沒接上 Sensor or 異常
+            RecordAlarmCode(_index, "011038");
+            ResetChargerAlarmCode(_index, "012323");
+        }
+    }
+
     switch (chargingInfo[_index]->Type) {
     case _Type_Chademo:
         if (chargingInfo[_index]->ConnectorTemp != UNDEFINED_TEMP) {
@@ -597,25 +621,25 @@ static void checkEvBoardAlarmState(uint8_t gunType)
 
 static uint8_t checkCabinetEthConnectState(LedConfig *ledConfig)
 {
-    uint8_t ret = NO;
     LedConfig *pLedConfig = (LedConfig *)ledConfig;
 
-    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DisconnectedFromDo == YES) {
-        ret = YES;
-        if (pLedConfig->RedLED == YES ||
-                pLedConfig->YellowLED == YES ||
-                pLedConfig->GreenLED == YES) {
-            pLedConfig->YellowLED = NO;
-            pLedConfig->GreenLED = NO;
-            pLedConfig->RedLED = NO;
-        } else {
-            pLedConfig->YellowLED = YES;
-            pLedConfig->GreenLED = YES;
-            pLedConfig->RedLED = YES;
-        }
+    if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DisconnectedFromDo == NO) {
+        return NO;
+    }
+
+    if (pLedConfig->RedLED == YES ||
+            pLedConfig->YellowLED == YES ||
+            pLedConfig->GreenLED == YES) {
+        pLedConfig->YellowLED = NO;
+        pLedConfig->GreenLED = NO;
+        pLedConfig->RedLED = NO;
+    } else {
+        pLedConfig->YellowLED = YES;
+        pLedConfig->GreenLED = YES;
+        pLedConfig->RedLED = YES;
     }
 
-    return ret;
+    return YES;
 }
 
 static void PrimaryLedIndicatorCtrlFork(void)
@@ -634,14 +658,15 @@ static void PrimaryLedIndicatorCtrlFork(void)
 
         while (isContinue) {
             for (gunIndex = 0; gunIndex < totalGun; gunIndex++) {
-                if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
+                if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2 &&
+                        chargingInfo[gunIndex]->SystemStatus != S_BOOTING) {
                     if (checkCabinetEthConnectState(pLedConfig) == YES) {
                         continue;
                     }
-
                     pLedConfig->YellowLED = NO;
                     pLedConfig->GreenLED = NO;
                     pLedConfig->RedLED = YES;
+                    continue;
                 }
 
                 //printf("led indicator status = %d\r\n", chargingInfo[gunIndex]->SystemStatus);
@@ -670,10 +695,19 @@ static void PrimaryLedIndicatorCtrlFork(void)
                     break;
 
                 case S_IDLE:
+                    //if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
+                    //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
+                    //        break;
+                    //    }
+                    //    pLedConfig->YellowLED = NO;
+                    //    pLedConfig->GreenLED = NO;
+                    //    pLedConfig->RedLED = YES;
+                    //} else {
                     //Module_DoComm connected and system idle
                     pLedConfig->RedLED = NO;
                     pLedConfig->YellowLED = NO;
                     pLedConfig->GreenLED = YES;
+                    //}
                     break;
 
                 case S_RESERVATION:
@@ -685,12 +719,21 @@ static void PrimaryLedIndicatorCtrlFork(void)
                 case S_PREPARING_FOR_EVSE:
                 case S_CCS_PRECHARGE_ST0:
                 case S_CCS_PRECHARGE_ST1:
+                    //if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
+                    //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
+                    //        break;
+                    //    }
+                    //    pLedConfig->YellowLED = NO;
+                    //    pLedConfig->GreenLED = NO;
+                    //    pLedConfig->RedLED = YES;
+                    //} else {
                     //precharging status
                     if (pLedConfig->GreenLED == YES) {
                         pLedConfig->GreenLED = NO;
                     } else {
                         pLedConfig->GreenLED = YES;
                     }
+                    //}
                     break;
 
                 case S_CHARGING:
@@ -704,24 +747,23 @@ static void PrimaryLedIndicatorCtrlFork(void)
                     break;
 
                 case S_ALARM:
+                    //if (checkCabinetEthConnectState(pLedConfig) == YES) {
+                    //    break;
+                    //}
+
                     pLedConfig->YellowLED = NO;
                     pLedConfig->GreenLED = NO;
-
-                    if (checkCabinetEthConnectState(pLedConfig) == YES) {
-                        break;
-                    }
-
                     pLedConfig->RedLED = YES;
                     break;
 
                 case S_TERMINATING:
                 case S_COMPLETE:
-                    //if (pSysWarning->Level == 2) {
-                    //    pLedConfig->YellowLED = NO;
-                    //    pLedConfig->GreenLED = NO;
+                    //if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
                     //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
                     //        break;
                     //    }
+                    //    pLedConfig->YellowLED = NO;
+                    //    pLedConfig->GreenLED = NO;
                     //    pLedConfig->RedLED = YES;
                     //} else {
                     pLedConfig->RedLED = NO;
@@ -732,15 +774,16 @@ static void PrimaryLedIndicatorCtrlFork(void)
 
                 case S_MAINTAIN:
                 case S_FAULT:
-                    pLedConfig->YellowLED = NO;
-                    pLedConfig->GreenLED = NO;
-                    pLedConfig->RedLED = YES;
-                    //if (pSysWarning->Level == 2) {
+                    //if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
                     //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
                     //        break;
                     //    }
-                    //    pLedConfig->RedLED = YES;
+                    //    //pLedConfig->RedLED = YES;
                     //}
+
+                    pLedConfig->YellowLED = NO;
+                    pLedConfig->GreenLED = NO;
+                    pLedConfig->RedLED = YES;
                     break;
 
                 case S_BOOKING:
@@ -748,11 +791,11 @@ static void PrimaryLedIndicatorCtrlFork(void)
                 case S_UPDATE:
                 case S_NONE:
                     break;
-                }
-            }//switch
-        }//for
-        usleep(500000);
-    }//while
+                }//switch
+            }//for
+            usleep(500000);
+        }//while
+    }//fork
 }
 
 //================================================
@@ -2659,6 +2702,8 @@ void ResetChargerAlarmCode(uint8_t gunIndex, char *code)
     else if (strcmp(code, "011018") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail = NO; }
     else if (strcmp(code, "011019") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail = NO; }
     else if (strcmp(code, "011020") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail = NO; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChillerOTP = NO; }
+    else if (strcmp(code, "011038") == EQUAL) {  ShmStatusCodeData->FaultCode.FaultEvents.bits.ChillerTempSensorBroken = NO; }
 
     if (strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "", 6) != EQUAL) {
         if (strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "012229", 6) == EQUAL ||
@@ -2672,7 +2717,10 @@ void ResetChargerAlarmCode(uint8_t gunIndex, char *code)
                 strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011016", 6) == EQUAL ||
                 strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011018", 6) == EQUAL ||
                 strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011019", 6) == EQUAL ||
-                strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011020", 6) == EQUAL) {
+                strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011020", 6) == EQUAL ||
+                strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "012323", 6) == EQUAL ||
+                strncmp((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "011038", 6) == EQUAL
+           ) {
             strncpy((char *)chargingInfo[gunIndex]->ConnectorAlarmCode, "", 6);
         }
     }
@@ -2713,6 +2761,8 @@ void RecordAlarmCode(uint8_t gunIndex, char *code)
     else if (strcmp(code, "011018") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.ChaConnectTempSensorFail = YES; }
     else if (strcmp(code, "011019") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.CCSConnectTempSensorFail = YES; }
     else if (strcmp(code, "011020") == EQUAL) { ShmDcCommonData->ConnectErrList[gunIndex].GunBits.GBTConnectTempSensorFail = YES; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChillerOTP = YES; }
+    else if (strcmp(code, "012323") == EQUAL) { ShmStatusCodeData->FaultCode.FaultEvents.bits.ChillerTempSensorBroken = YES; }
 }
 
 void RecordWarningCode(uint8_t gunIndex, char *code)
@@ -5912,11 +5962,11 @@ static void ReviewCriticalAlarm(void)
             ShmDcCommonData->GunRelayDrivingOccur[1] == YES ||
             ShmDcCommonData->GunRelayWeldingOccur[0] == YES ||
             ShmDcCommonData->GunRelayWeldingOccur[1] == YES ||
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip ||
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MainPowerBreakerTrip ||
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DoorOpen ||
-            ShmSysConfigAndInfo->SysWarningInfo.ExtraErrProcess != _EXTRA_ERR_PROCESS_NONE ||
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFailureAlarm ||
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.EmergencyStopTrip == YES ||
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.MainPowerBreakerTrip == YES ||
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DoorOpen == YES ||
+            ShmSysConfigAndInfo->SysWarningInfo.ExtraErrProcess != _EXTRA_ERR_PROCESS_NONE == YES ||
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.PsuFailureAlarm == YES ||
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.DisconnectedFromDo
        ) {
         ShmSysConfigAndInfo->SysWarningInfo.Level = 2;

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


BIN
EVSE/Projects/DD360ComBox/output/FactoryConfig


BIN
EVSE/Projects/DD360ComBox/output/Module_DoComm


BIN
EVSE/Projects/DD360ComBox/output/Module_EvComm


BIN
EVSE/Projects/DD360ComBox/output/Module_EventLogging


BIN
EVSE/Projects/DD360ComBox/output/Module_InternalComm


BIN
EVSE/Projects/DD360ComBox/output/Module_LcmControl


BIN
EVSE/Projects/DD360ComBox/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360ComBox/output/ReadCmdline


BIN
EVSE/Projects/DD360ComBox/output/main