Browse Source

2021-02-24 / Jerry Wang

Actions:
1. Test ChaDemo charging.
2. DoComo connector status is added to the alarm code of the failure status report.

Files:
1. As follow commit history.
Jerry_Wang 4 years ago
parent
commit
f1c691d860
66 changed files with 6291 additions and 12226 deletions
  1. 3 0
      EVSE/Projects/DD360/Apps/AudiCust.h
  2. 2247 2808
      EVSE/Projects/DD360/Apps/Module_EvComm.c
  3. 2 0
      EVSE/Projects/DD360/Apps/Module_InternalComm.c
  4. 179 136
      EVSE/Projects/DD360/Apps/ReDoComm.c
  5. 19 4
      EVSE/Projects/DD360/Apps/ReDoComm.h
  6. 123 97
      EVSE/Projects/DD360/Apps/ReMain.c
  7. 1 0
      EVSE/Projects/DD360/Apps/ReModule_EvComm.c
  8. 3 1
      EVSE/Projects/DD360/Apps/ReModule_InternalComm.c
  9. 63 50
      EVSE/Projects/DD360/Apps/ReModule_LcmControl.c
  10. 14 3
      EVSE/Projects/DD360/Apps/ReModule_PrimaryComm.c
  11. 2 0
      EVSE/Projects/DD360/Apps/kill.sh
  12. BIN
      EVSE/Projects/DD360/Images/ramdisk.gz
  13. BIN
      EVSE/Projects/DD360/output/DoComm
  14. BIN
      EVSE/Projects/DD360/output/FactoryConfig
  15. BIN
      EVSE/Projects/DD360/output/Module_EvComm
  16. BIN
      EVSE/Projects/DD360/output/Module_EventLogging
  17. BIN
      EVSE/Projects/DD360/output/Module_InternalComm
  18. BIN
      EVSE/Projects/DD360/output/Module_LcmControl
  19. BIN
      EVSE/Projects/DD360/output/Module_PrimaryComm
  20. BIN
      EVSE/Projects/DD360/output/ReadCmdline
  21. 2 0
      EVSE/Projects/DD360/output/kill.sh
  22. BIN
      EVSE/Projects/DD360/output/main
  23. 18 0
      EVSE/Projects/DD360Audi/Apps/AudiCust.h
  24. 148 104
      EVSE/Projects/DD360Audi/Apps/Config.h
  25. 282 266
      EVSE/Projects/DD360Audi/Apps/FactoryConfig.c
  26. 24 31
      EVSE/Projects/DD360Audi/Apps/Makefile
  27. 72 101
      EVSE/Projects/DD360Audi/Apps/Module_EvComm.c
  28. 52 43
      EVSE/Projects/DD360Audi/Apps/Module_EvComm.h
  29. 251 208
      EVSE/Projects/DD360Audi/Apps/Module_EventLogging.c
  30. 197 166
      EVSE/Projects/DD360Audi/Apps/Module_InternalComm.c
  31. 181 217
      EVSE/Projects/DD360Audi/Apps/Module_LcmContro.h
  32. 13 34
      EVSE/Projects/DD360Audi/Apps/Module_LcmControl.c
  33. 448 396
      EVSE/Projects/DD360Audi/Apps/Module_PrimaryComm.c
  34. 283 251
      EVSE/Projects/DD360Audi/Apps/OutputTask.c
  35. 340 321
      EVSE/Projects/DD360Audi/Apps/PrimaryComm.c
  36. 46 49
      EVSE/Projects/DD360Audi/Apps/PrimaryComm.h
  37. 204 135
      EVSE/Projects/DD360Audi/Apps/ReDoComm.c
  38. 22 2
      EVSE/Projects/DD360Audi/Apps/ReDoComm.h
  39. 140 104
      EVSE/Projects/DD360Audi/Apps/ReMain.c
  40. 1 0
      EVSE/Projects/DD360Audi/Apps/ReModule_EvComm.c
  41. 5 2
      EVSE/Projects/DD360Audi/Apps/ReModule_InternalComm.c
  42. 112 42
      EVSE/Projects/DD360Audi/Apps/ReModule_LcmControl.c
  43. 14 3
      EVSE/Projects/DD360Audi/Apps/ReModule_PrimaryComm.c
  44. 590 475
      EVSE/Projects/DD360Audi/Apps/ReadCmdline.c
  45. BIN
      EVSE/Projects/DD360Audi/Apps/UnsafetyOutputTask
  46. 0 5678
      EVSE/Projects/DD360Audi/Apps/define.h
  47. 2 2
      EVSE/Projects/DD360Audi/Apps/init.sh
  48. 2 0
      EVSE/Projects/DD360Audi/Apps/kill.sh
  49. 161 475
      EVSE/Projects/DD360Audi/Apps/main.c
  50. 15 14
      EVSE/Projects/DD360Audi/Apps/timeout.h
  51. 1 1
      EVSE/Projects/DD360Audi/Apps/web.sh
  52. BIN
      EVSE/Projects/DD360Audi/Images/ramdisk.gz
  53. BIN
      EVSE/Projects/DD360Audi/output/DoComm
  54. BIN
      EVSE/Projects/DD360Audi/output/FactoryConfig
  55. BIN
      EVSE/Projects/DD360Audi/output/Module_EvComm
  56. BIN
      EVSE/Projects/DD360Audi/output/Module_EventLogging
  57. BIN
      EVSE/Projects/DD360Audi/output/Module_InternalComm
  58. BIN
      EVSE/Projects/DD360Audi/output/Module_LcmControl
  59. BIN
      EVSE/Projects/DD360Audi/output/Module_PrimaryComm
  60. BIN
      EVSE/Projects/DD360Audi/output/ReadCmdline
  61. BIN
      EVSE/Projects/DD360Audi/output/UnsafetyOutputTask
  62. 2 2
      EVSE/Projects/DD360Audi/output/init.sh
  63. 2 0
      EVSE/Projects/DD360Audi/output/kill.sh
  64. BIN
      EVSE/Projects/DD360Audi/output/main
  65. 1 1
      EVSE/Projects/DD360Audi/output/web.sh
  66. 4 4
      EVSE/Projects/define.h

+ 3 - 0
EVSE/Projects/DD360/Apps/AudiCust.h

@@ -38,6 +38,9 @@
 #define DEV_ST_ENABLE_USE                       0x01
 #define DEV_ST_ENABLE_NO_USE                    0x02
 
+#define EV_BOARD_STOP_CHARGING                  1
+#define POWER_CABINET_STOP_CHARGING             2
+
 //------------------------------------------------------------------------------
 typedef struct StEthDevStatus {
     uint8_t Backend;

File diff suppressed because it is too large
+ 2247 - 2808
EVSE/Projects/DD360/Apps/Module_EvComm.c


+ 2 - 0
EVSE/Projects/DD360/Apps/Module_InternalComm.c

@@ -1012,6 +1012,7 @@ void CheckAcInputOvpStatus(byte index)
 //          }
 //      }
 //      else
+        DEBUG_INFO("CheckAcInputOvpStatus\r\n");
         _chargingData[index]->StopChargeFlag = YES;
     }
 }
@@ -1021,6 +1022,7 @@ void CheckPhaseLossStatus(byte index)
     if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == YES ||
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == YES ||
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == YES) {
+        DEBUG_INFO("CheckPhaseLossStatus\r\n");
         _chargingData[index]->StopChargeFlag = YES;
     }
 }

+ 179 - 136
EVSE/Projects/DD360/Apps/ReDoComm.c

@@ -540,7 +540,7 @@ static int updateFirmwareHandle(uint8_t *imgName)
     return ret;
 }
 
-static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
+static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
 {
     int ret = PASS;
     uint8_t i = 0, j = 0;
@@ -572,21 +572,21 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
 
         case MISC_CMD_OPERATIVE_STATE:
             if ((value > YES) || (value < NO)) {
-                if (id == 2) {
+                if (plugNum == 1) {
                     clearMiscCommand();
                 }
                 break;
             }
 
-            DEBUG_INFO("change availability id = %d, value = %d\r\n", id - 1, value);
-            ShmOCPP16Data->CsMsg.bits[id - 1].ChangeAvailabilityReq = YES;
+            DEBUG_INFO("change availability plugNum = %d, value = %d\r\n", plugNum, value);
+            ShmOCPP16Data->CsMsg.bits[plugNum].ChangeAvailabilityReq = YES;
             if (value == YES) {
-                strcpy((char *)ShmOCPP16Data->ChangeAvailability[id - 1].Type, "Operative");
+                strcpy((char *)ShmOCPP16Data->ChangeAvailability[plugNum].Type, "Operative");
             } else if (value == NO) {
-                strcpy((char *)ShmOCPP16Data->ChangeAvailability[id - 1].Type, "Inoperative");
+                strcpy((char *)ShmOCPP16Data->ChangeAvailability[plugNum].Type, "Inoperative");
             }
 
-            if (id == 2) {
+            if (plugNum == 1) {
                 clearMiscCommand();
             }
             break;
@@ -615,20 +615,20 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
             break;
 
         case MISC_CMD_ACCOUNT_BALANCE:
-#if defined DD360Audi
-            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (id - 1)) {
+            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (plugNum)) {
                 clearMiscCommand();
                 break;
             }
 
-            if (getConfirmSelectedGun(id - 1) == FAIL) {
+#if defined DD360Audi
+            if (getConfirmSelectedGun(plugNum) == FAIL) {
                 DEBUG_INFO("Remote start not select gun\r\n");
                 break;
             }
-#endif //defined DD360Audi
+#endif //DD360Audi
 
-            gAudiCustInfo->PricesInfo[id - 1].Balance = transPricesUnit((int)value);
-            DEBUG_INFO("%d misc balance = %.2f\r\n", id, gAudiCustInfo->PricesInfo[id - 1].Balance);
+            gAudiCustInfo->PricesInfo[plugNum].Balance = transPricesUnit((int)value);
+            DEBUG_INFO("%d misc balance = %.2f\r\n", plugNum, gAudiCustInfo->PricesInfo[plugNum].Balance);
             clearMiscCommand();
             break;
 
@@ -648,7 +648,6 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
             gAudiCustInfo->EthDevStatus.FourG = value;
             break;
 
-
         //--- Control Dispenser ---
         case MISC_CMD_HARDWARE_REBOOT:
             if (value != YES) {
@@ -676,24 +675,24 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
 
         case MISC_CMD_REMOTE_START_CHARGING:
             if (value != YES) {
-                if (id == 2) {
+                if (plugNum == 1) {
                     clearMiscCommand();
                 }
                 break;
             }
-            DEBUG_INFO("Remote start charging id = %d\r\n", id);
+            DEBUG_INFO("Remote start charging plugNum = %d\r\n", plugNum);
 
-            //if (getConfirmSelectedGun(id - 1) == FAIL) {
+            //if (getConfirmSelectedGun(plugNum - 1) == FAIL) {
             //    DEBUG_INFO("Remote start not select gun\r\n");
             //    break;
             //}
 #if defined DD360Audi
-            if (getSelGunWaitToAuthor(id - 1) == FAIL) {
+            if (getSelGunWaitToAuthor(plugNum) == FAIL) {
                 DEBUG_ERROR("Remote start gun already charging\r\n");
                 break;
             }
 
-            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (id - 1)) {
+            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (plugNum)) {
                 if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == LEFT_GUN_NUM &&
                         (gAudiCustInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM ||
                          gAudiCustInfo->SelGunInfo.LeftGun == SEL_GUN_ATHOR)) {
@@ -718,23 +717,23 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
                     ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
                 }
 
-                ShmSysConfigAndInfo->SysInfo.CurGunSelected = (id - 1);
+                ShmSysConfigAndInfo->SysInfo.CurGunSelected = (plugNum);
                 ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
             }
-            setConfirmSelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
 #else
-            ShmSysConfigAndInfo->SysInfo.CurGunSelected = (id - 1);
+            ShmSysConfigAndInfo->SysInfo.CurGunSelected = (plugNum);
             ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
-#endif //defined DD360Audi
+#endif //DD360Audi
+            setConfirmSelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
 
-            ShmOCPP16Data->CsMsg.bits[id - 1].RemoteStartTransactionReq = YES;
-            gAudiCustInfo->PricesInfo[id - 1].Balance = 0.00;
+            ShmOCPP16Data->CsMsg.bits[plugNum].RemoteStartTransactionReq = YES;
+            gAudiCustInfo->PricesInfo[plugNum].Balance = 0.00;
             clearMiscCommand();
             break;
 
         case MISC_CMD_REMOTE_STOP_CHARGING:
             if (value != YES) {
-                if (id == 2) {
+                if (plugNum == 1) {
                     clearMiscCommand();
                 }
                 break;
@@ -745,14 +744,14 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
             ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
             gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
             ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
-            destroySelectGun(id - 1);
+            destroySelectGun(plugNum);
 
             clearMiscCommand();
             break;
 
         case MISC_CMD_REMOTE_UNLOCK:
             if (value != YES) {
-                if (id == 2) {
+                if (plugNum == 1) {
                     clearMiscCommand();
                 }
                 break;
@@ -765,9 +764,9 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
                 ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
                 gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
                 ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
-                destroySelectGun(id - 1);
+                destroySelectGun(plugNum);
             } else {
-                ChargingData[id - 1]->StopChargeFlag = YES;
+                ChargingData[plugNum]->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
             }
             break;
 
@@ -781,7 +780,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
     return ret;
 }
 
-static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
+static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
 {
     uint8_t addr = 0;
     float MaxVolt, MaxCurrent, MaxPower;
@@ -797,7 +796,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
         if (MaxVolt > MAX_VOLTAGE) {
             MaxVolt = MAX_VOLTAGE;
         }
-        ChargingData[gunID]->MaximumChargingVoltage = MaxVolt;
+        ChargingData[plugNum]->MaximumChargingVoltage = MaxVolt;
     }
 
     MaxCurrent = (float)(ntohs(pCapabilityInfo->OutputCurrent));
@@ -805,7 +804,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
         if (MaxCurrent > MAX_CURRENCY) {
             MaxCurrent = MAX_CURRENCY;
         }
-        ChargingData[gunID]->AvailableChargingCurrent = MaxCurrent;
+        ChargingData[plugNum]->AvailableChargingCurrent = MaxCurrent;
     }
 
     MaxPower = (float)(ntohs(pCapabilityInfo->OutputPower));
@@ -813,7 +812,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
         if (MaxPower > MAX_POWER) {
             MaxPower = MAX_POWER;
         }
-        ChargingData[gunID]->AvailableChargingPower = MaxPower;
+        ChargingData[plugNum]->AvailableChargingPower = MaxPower;
     }
     //MaxVolt = (float)(data[0] << 8 |data[1]);
     //MaxCurrent = (float)(data[2] << 8 | data[3]);
@@ -825,20 +824,20 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
     pAccountInfo = (AccountInfo *)&data[addr];
 
     ShmSysConfigAndInfo->SysConfig.BillingData.Currency = pAccountInfo->Currency;
-    gAudiCustInfo->PricesInfo[gunID].UserPrices         = transPricesUnit(ntohl(pAccountInfo->UserPrices));
-    ChargingData[gunID]->ChargingFee                    = transPricesUnit(ntohl(pAccountInfo->TotalCost));
-    gAudiCustInfo->PricesInfo[gunID].Balance            = transPricesUnit(ntohl(pAccountInfo->Balance));
+    gAudiCustInfo->PricesInfo[plugNum].UserPrices         = transPricesUnit(ntohl(pAccountInfo->UserPrices));
+    ChargingData[plugNum]->ChargingFee                    = transPricesUnit(ntohl(pAccountInfo->TotalCost));
+    gAudiCustInfo->PricesInfo[plugNum].Balance            = transPricesUnit(ntohl(pAccountInfo->Balance));
 
-    if ((pricesInfo[gunID].UserPrices != gAudiCustInfo->PricesInfo[gunID].UserPrices) ||
-            (pricesInfo[gunID].Balance != gAudiCustInfo->PricesInfo[gunID].Balance)) {
-        pricesInfo[gunID].UserPrices = gAudiCustInfo->PricesInfo[gunID].UserPrices;
-        pricesInfo[gunID].Balance = gAudiCustInfo->PricesInfo[gunID].Balance;
+    if ((pricesInfo[plugNum].UserPrices != gAudiCustInfo->PricesInfo[plugNum].UserPrices) ||
+            (pricesInfo[plugNum].Balance != gAudiCustInfo->PricesInfo[plugNum].Balance)) {
+        pricesInfo[plugNum].UserPrices = gAudiCustInfo->PricesInfo[plugNum].UserPrices;
+        pricesInfo[plugNum].Balance = gAudiCustInfo->PricesInfo[plugNum].Balance;
 
         DEBUG_INFO("id = %d, user prices = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s\r\n",
-                   gunID,
-                   gAudiCustInfo->PricesInfo[gunID].UserPrices,
-                   ChargingData[gunID]->ChargingFee,
-                   gAudiCustInfo->PricesInfo[gunID].Balance,
+                   plugNum,
+                   gAudiCustInfo->PricesInfo[plugNum].UserPrices,
+                   ChargingData[plugNum]->ChargingFee,
+                   gAudiCustInfo->PricesInfo[plugNum].Balance,
                    (uint8_t *)Currency[ShmSysConfigAndInfo->SysConfig.BillingData.Currency]);
     }
 
@@ -908,74 +907,82 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     uint8_t count = 0;
     uint8_t EventCodeTmp[7] = {0};
     uint8_t StatusArray[MAX_REGISTER_NUM][WARNING_CODE_SIZE] = {0};
-    uint8_t remaindLen = dataLen % dataLen;
+    uint8_t remaindLen = 0;
     uint8_t statusCodeError = 0;
 
-    if (remaindLen != 0) {
-        dataLen -= remaindLen;
-    }
+    //if (dataLen <= 0) {
+    //    return FAIL;
+    //}
 
-    if (dataLen < WARNING_CODE_SIZE) {
-        DEBUG_ERROR("fail status code length = %d\r\n", dataLen);
-        Hexdump(data, dataLen);
-        if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 0) {
-            for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
-                usleep(128);
-                if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '3' ||  //from backend or power cabinet
-                        (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0] >= 'B' &&
-                         ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '4')) {
-                    memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
-                    memcpy(EventCodeTmp,
-                           ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i],
-                           sizeof(EventCodeTmp));
-                    removeFaultCodeToBuf(EventCodeTmp);
+    if (dataLen > 0) {
+        remaindLen = dataLen % WARNING_CODE_SIZE;
+
+        if (remaindLen != 0) {
+            dataLen -= remaindLen;
+        }
+
+        if (dataLen < WARNING_CODE_SIZE) {
+            DEBUG_ERROR("fail status code length = %d\r\n", dataLen);
+            Hexdump(data, dataLen);
+            if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 0) {
+                for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+                    usleep(128);
+                    if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '3' ||  //from backend or power cabinet
+                            (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0] >= 'B' &&
+                             ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '4')) {
+                        memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
+                        memcpy(EventCodeTmp,
+                               ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i],
+                               sizeof(EventCodeTmp));
+                        removeFaultCodeToBuf(EventCodeTmp);
+                    }
                 }
             }
+            return FAIL;
         }
-        return FAIL;
-    }
 
-    for (count = 0; count < dataLen; count += WARNING_CODE_SIZE) {
-        usleep(128);
-        // misc command status code handle
-        if (strncmp((char *)&data[count], MISC_ST_MISC_CMD, WARNING_CODE_SIZE) == 0) {
-            //if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
-            gDoCommGblData.MiscCmd = REG_MISC_CONTROL;
-            //}
-            memset((char *)&data[count], 0, WARNING_CODE_SIZE);
-            continue;
-        } else if (strncmp((char *)&data[count], MISC_ST_VERSION, WARNING_CODE_SIZE) == 0) {
-            //if (gDoCommGblData.MiscCmd != REG_REPORT_CSU_VERSION) {
-            gDoCommGblData.MiscCmd = REG_REPORT_CSU_VERSION;
-            //}
-            memset((char *)&data[count], 0, WARNING_CODE_SIZE);
-            continue;
-        }
+        for (count = 0; count < dataLen; count += WARNING_CODE_SIZE) {
+            usleep(128);
+            // misc command status code handle
+            if (strncmp((char *)&data[count], MISC_ST_MISC_CMD, WARNING_CODE_SIZE) == 0) {
+                //if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
+                gDoCommGblData.MiscCmd = REG_MISC_CONTROL;
+                //}
+                memset((char *)&data[count], 0, WARNING_CODE_SIZE);
+                continue;
+            } else if (strncmp((char *)&data[count], MISC_ST_VERSION, WARNING_CODE_SIZE) == 0) {
+                //if (gDoCommGblData.MiscCmd != REG_REPORT_CSU_VERSION) {
+                gDoCommGblData.MiscCmd = REG_REPORT_CSU_VERSION;
+                //}
+                memset((char *)&data[count], 0, WARNING_CODE_SIZE);
+                continue;
+            }
 
-        if (CompareArrayIsZero((uint8_t *)&data[count], WARNING_CODE_SIZE) == true) {
-            memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
-            memcpy(EventCodeTmp, (char *)&data[count], sizeof(EventCodeTmp));
-            DEBUG_ERROR("error status = %s\r\n", EventCodeTmp);
-            continue;
-        }
+            if (CompareArrayIsZero((uint8_t *)&data[count], WARNING_CODE_SIZE) == true) {
+                memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
+                memcpy(EventCodeTmp, (char *)&data[count], sizeof(EventCodeTmp));
+                DEBUG_ERROR("error status = %s\r\n", EventCodeTmp);
+                continue;
+            }
 
-        strncpy((char *)&StatusArray[count / WARNING_CODE_SIZE], (char *)&data[count], WARNING_CODE_SIZE);
+            strncpy((char *)&StatusArray[count / WARNING_CODE_SIZE], (char *)&data[count], WARNING_CODE_SIZE);
 
-        ret = 0;
-        for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
-            usleep(128);
-            if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0],
-                       StatusArray[count / WARNING_CODE_SIZE],
-                       WARNING_CODE_SIZE) == 0) {
-                ret = 1;
-                break;
+            ret = 0;
+            for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+                usleep(128);
+                if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0],
+                           StatusArray[count / WARNING_CODE_SIZE],
+                           WARNING_CODE_SIZE) == 0) {
+                    ret = 1;
+                    break;
+                }
             }
-        }
 
-        if (ret == 0) {
-            addFaultCodeToBuf(StatusArray[count / WARNING_CODE_SIZE]);
+            if (ret == 0) {
+                addFaultCodeToBuf(StatusArray[count / WARNING_CODE_SIZE]);
+            }
+            //Rtn=StatusCodeProcessing(StatusArray[count/6]);
         }
-        //Rtn=StatusCodeProcessing(StatusArray[count/6]);
     }
 
     for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
@@ -1017,7 +1024,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     return PASS;
 }
 
-static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t id, uint8_t reg)
+static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_t reg)
 {
     int ret = PASS;
     uint8_t rawDataLen = 0;
@@ -1059,7 +1066,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t id, uint8_t reg
         break;
 
     case REG_CHARGING_CAP:
-        chargingcapabilityHandle(pCsuResult->Data.Data, id - 1);
+        chargingcapabilityHandle(pCsuResult->Data.Data, plugNum);
         break;
 
     case REG_CHARGING_TARGET:
@@ -1108,7 +1115,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t id, uint8_t reg
         break;
 
     case REG_MISC_CONTROL:
-        miscCommandHandle(rawDataLen, pCsuResult->Head.ID, pCsuResult->Data.Data);
+        miscCommandHandle(rawDataLen, plugNum, pCsuResult->Data.Data);
         break;
 
     case REG_REPORT_CSU_VERSION:
@@ -1142,6 +1149,8 @@ static int composeSocketData(int fd,
     int ret = PASS;
     int size = 0;
     int sendPktLen = 0;
+    uint8_t i = 0;
+    uint8_t plugNum = 0;
     CsuCmdPkt csuCmdPkt = {0};
     CsuResultPkt csuResult = {0};
 
@@ -1180,7 +1189,14 @@ static int composeSocketData(int fd,
         return FAIL;
     }
 
-    ret = responsePackeHandle(fd, (uint8_t *)&csuResult, id, csuCmdPkt.Data.Register);
+    for (i = 0; i < sizeof(gDoCommGblData.ConnectorID); i++) {
+        if (id == gDoCommGblData.ConnectorID[i]) {
+            plugNum = i;
+            break;
+        }
+    }
+
+    ret = responsePackeHandle(fd, (uint8_t *)&csuResult, plugNum, csuCmdPkt.Data.Register);
 
     return ret;
 }
@@ -1343,29 +1359,33 @@ static int writeUserID(int fd, uint8_t id, uint8_t *pUserID)
 static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
 {
     uint8_t dataBuf[8] = {0};
-    uint8_t alarmCode[WARNING_CODE_SIZE] = {0};
     int ret = PASS;
 
     if (ChargingData[plugNum]->SystemStatus <= S_AUTHORIZING) {
-        dataBuf[0] = 0;    //idle
+        dataBuf[0] = CONN_ST_IDLE;    //idle
+        strcpy((char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode, "");
     } else if ((ChargingData[plugNum]->SystemStatus <= S_PREPARING_FOR_EVSE) ||
                (ChargingData[plugNum]->SystemStatus == S_CCS_PRECHARGE_ST0) ||
                (ChargingData[plugNum]->SystemStatus == S_CCS_PRECHARGE_ST1)) {
-        dataBuf[0] = 1;    //preparing
+        dataBuf[0] = CONN_ST_PREPARING;    //preparing
     } else if (ChargingData[plugNum]->SystemStatus == S_CHARGING) {
-        dataBuf[0] = 2;    //charging
+        dataBuf[0] = CONN_ST_CHARGING;    //charging
     } else if (ChargingData[plugNum]->SystemStatus == S_TERMINATING) {
-        dataBuf[0] = 3;    //terminating
-    } else if (ChargingData[plugNum]->SystemStatus == S_ALARM) {
-        dataBuf[0] = 4;    //Alarm
-        memcpy(&alarmCode[1], ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode, WARNING_CODE_SIZE);
+        dataBuf[0] = CONN_ST_TERMINATING;    //terminating
+    } else if ((ChargingData[plugNum]->SystemStatus == S_ALARM) ||
+               (ChargingData[plugNum]->SystemStatus == S_FAULT)) {
+        dataBuf[0] = CONN_ST_ALARM;
+        if (strcmp((char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode, "") != 0) {
+            strncpy((char *)&dataBuf[1], (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode, WARNING_CODE_SIZE);
+            DEBUG_INFO("ID = %d, VendorErrorCode = %s\r\n", plugNum, (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
+        }
     }
 
     ret = composeSocketData(fd,
                             id,
                             OP_WRITE_DATA,
                             REG_CONNECTOR_STATE,
-                            sizeof(dataBuf),
+                            sizeof(dataBuf) - 1,
                             &dataBuf[0]);
     return ret;
 }
@@ -1384,13 +1404,13 @@ static int writePlugInStatus(int fd, uint8_t plugNum, uint8_t id)
     return ret;
 }
 
-static int readSoftwareUpdate(int fd)
+static int readSoftwareUpdate(int fd, uint8_t gunID)
 {
     int ret = PASS;
     uint8_t dataBuf[2] = {ShmSysConfigAndInfo->SysInfo.FirmwareUpdate, 0};
 
     ret = composeSocketData(fd,
-                            0x01,
+                            gunID,
                             OP_READ_DATA,
                             REG_SOFTWARE_UPDATE,
                             1,
@@ -1439,7 +1459,7 @@ static int readChargingCapability(int fd, uint8_t id)
     return ret;
 }
 
-static int writeDispenserStatus(int fd)
+static int writeDispenserStatus(int fd, uint8_t gunID)
 {
     uint8_t warningCount = 0;
     uint8_t count = 0;
@@ -1467,7 +1487,7 @@ static int writeDispenserStatus(int fd)
     }
 
     ret = composeSocketData(fd,
-                            ID_OF_DISPENSER,
+                            gunID,
                             OP_WRITE_DATA,
                             REG_DISPENSER_STATUS,
                             strlen((char *)CurWarnCodeTmp),
@@ -1476,12 +1496,12 @@ static int writeDispenserStatus(int fd)
     return ret;
 }
 
-static int readPowerCabinetStatus(int fd)
+static int readPowerCabinetStatus(int fd, uint8_t gunID)
 {
     int ret = PASS;
 
     ret = composeSocketData(fd,
-                            ID_OF_DISPENSER,
+                            gunID,
                             OP_READ_DATA,
                             REG_POWER_CABINET_STATUS,
                             0,
@@ -1640,7 +1660,7 @@ static int InitShareMemory(void)
     return result;
 }
 
-static void updateFirmwareProcess(int fd, uint8_t totalConnCount)
+static void updateFirmwareProcess(int fd, uint8_t gunID, uint8_t totalConnCount)
 {
     bool canUpdateFirmware = true;
     uint8_t plugNum = 0;
@@ -1660,7 +1680,7 @@ static void updateFirmwareProcess(int fd, uint8_t totalConnCount)
     if (canUpdateFirmware) {
         ftime(&updateTime);
         if (DiffTimeb(gRegTimeUp[0][REG_SOFTWARE_UPDATE], updateTime) > LOOP_RETRY_TIME * 5) {
-            readSoftwareUpdate(fd);
+            readSoftwareUpdate(fd, gunID);
             ftime(&gRegTimeUp[0][REG_SOFTWARE_UPDATE]);
         }
 
@@ -1668,7 +1688,7 @@ static void updateFirmwareProcess(int fd, uint8_t totalConnCount)
             while (ackCount != 0) {
                 ftime(&updateTime);
                 if (DiffTimeb(gRegTimeUp[0][REG_SOFTWARE_UPDATE], updateTime) > LOOP_RETRY_TIME / 2) {
-                    readSoftwareUpdate(fd);
+                    readSoftwareUpdate(fd, gunID);
                     ftime(&gRegTimeUp[0][REG_SOFTWARE_UPDATE]);
                     if (ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == NO) {
                         ackCount--;
@@ -1683,14 +1703,22 @@ static void updateFirmwareProcess(int fd, uint8_t totalConnCount)
 static void checkAuthorProcess(int fd, uint8_t plugNum)
 {
     int ret = 0;
+    uint8_t gunID = 0;
     struct timeb AuthNowTime;
 
+#if defined DD360Audi
+    gunID = gDoCommGblData.ConnectorID[ShmSysConfigAndInfo->SysInfo.CurGunSelected];
+    //gunID = gDoCommGblData.ConnectorID[plugNum];
+#else
+    gunID = ID_REGISTER;
+#endif // DD360Audi
+
     if ((ShmOCPP16Data->SpMsg.bits.AuthorizeReq == YES) || (ShmSysConfigAndInfo->SysInfo.AuthorizeFlag == YES)) {
         ftime(&AuthNowTime);
 
         if (DiffTimeb(gRegTimeUp[plugNum][REG_USER_ID], AuthNowTime) > LOOP_RETRY_TIME) {
             ret = writeUserID(fd,
-                              ShmSysConfigAndInfo->SysInfo.CurGunSelected + 1,
+                              gunID,
                               ShmSysConfigAndInfo->SysConfig.UserId);
             if (ret >= 0) {
                 memset(ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status,
@@ -1705,7 +1733,14 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
                 //printf("gAudiCustInfo->PricesInfo[plugNum].Balance = %.2f, %.2f\r\n",
                 //       gAudiCustInfo->PricesInfo[plugNum].Balance,
                 //       FAIL_BALANCE_PRICES);
-                if (gAudiCustInfo->PricesInfo[plugNum].Balance != FAIL_BALANCE_PRICES) {
+#if defined DD360Audi
+                if (gAudiCustInfo->PricesInfo[plugNum].Balance != FAIL_BALANCE_PRICES)
+#else
+                if (gAudiCustInfo->PricesInfo[plugNum].Balance == FAIL_BALANCE_PRICES) {
+                    gAudiCustInfo->PricesInfo[plugNum].Balance = 0;
+                }
+#endif //
+                {
                     ShmOCPP16Data->SpMsg.bits.AuthorizeConf    = 1; //isAuthorizedComplete
                     ShmOCPP16Data->SpMsg.bits.AuthorizeReq     = 0;
                     ShmSysConfigAndInfo->SysInfo.AuthorizeFlag = 0;
@@ -1733,6 +1768,8 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
             if (WriteModelName(fd) == PASS) {
                 gDoCommGblData.DisConnCount = 0;
                 curReg = REG_CONNECTOR_ID;
+            } else {
+                sleep(1);
             }
             break;
 
@@ -1740,12 +1777,14 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
             if (readConnectorID(fd) == PASS) {
                 gDoCommGblData.DisConnCount = 0;
                 curReg = REG_REPORT_CSU_VERSION;
+            } else {
+                sleep(1);
             }
             break;
 
         case REG_POWER_CABINET_STATUS:
             if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME) {
-                readPowerCabinetStatus(fd);
+                readPowerCabinetStatus(fd, gunID);
                 ftime(&gRegTimeUp[plugNum][curReg]);
             }
             curReg = REG_DISPENSER_STATUS;
@@ -1753,7 +1792,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
 
         case REG_DISPENSER_STATUS:
             if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME) {
-                writeDispenserStatus(fd);
+                writeDispenserStatus(fd, gunID);
                 ftime(&gRegTimeUp[plugNum][curReg]);
             }
             curReg = REG_PLUG_IN_STATE;
@@ -1884,8 +1923,9 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
 //    return NO;
 //}
 
-static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
+static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8_t gunID)
 {
+    uint8_t i = 0;
     struct timeb AuthNowTime = {0};
 
     switch (ChargingData[plugNum]->SystemStatus) {
@@ -1922,8 +1962,9 @@ static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
         ftime(&AuthNowTime);
         if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME) {
             if (readChargePermission(fd, gunID) && readChargingCapability(fd, gunID)) {
-                ShmPsuData->SystemAvailablePower = (ChargingData[0]->AvailableChargingPower +
-                                                    ChargingData[1]->AvailableChargingPower);
+                for (i = 0; i < totalGun; i++) {
+                    ShmPsuData->SystemAvailablePower += ChargingData[i]->AvailableChargingPower;
+                }
                 ShmPsuData->SystemPresentPsuQuantity = (ShmPsuData->SystemAvailablePower / 30);
             }
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
@@ -1949,7 +1990,7 @@ static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
                 DEBUG_INFO("Stop charging by power cabinet's permission = %d, %d\r\n",
                            plugNum,
                            REG_CHARGING_PERMISSION);
-                ChargingData[plugNum]->StopChargeFlag = 1;
+                ChargingData[plugNum]->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
             }
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
         }
@@ -1978,7 +2019,7 @@ static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
                 DEBUG_INFO("Stop charging by power cabinet's permission = %d, %d\r\n",
                            plugNum,
                            REG_CHARGING_PERMISSION);
-                ChargingData[plugNum]->StopChargeFlag = 1;
+                ChargingData[plugNum]->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
             }
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
         }
@@ -2004,7 +2045,8 @@ static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
                 DEBUG_INFO("Stop charging by power cabinet's permission = %d, %d\r\n",
                            plugNum,
                            REG_CHARGING_PERMISSION);
-                ChargingData[plugNum]->StopChargeFlag = 1;
+                ChargingData[plugNum]->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
+                //printf("%d StopChargeFlag = %d\r\n", plugNum, ChargingData[plugNum]->StopChargeFlag);
             }
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
         }
@@ -2117,14 +2159,15 @@ int main(int argc, char *argv[])
 
             initDone = messageTrigger(fd, 0, 0, REG_MODEL_NAME); //first trigger model name and connector id
         } else {
-            checkAuthorProcess(fd, 0);
+            //checkAuthorProcess(fd, 0);
 
             plugNum = 0;
             gunID = 0;
             for (plugNum = 0; plugNum < totalConnCount; plugNum++) {
                 //plugNum = setup chargingData value for bottom layer
-                gunID = (plugNum  + 1); //connector Id, 1 = left gun, 2 = right gun
-                systemStatusProcess(fd, plugNum, gunID);
+                //gunID = (plugNum  + 1); //connector Id, 1 = left gun, 2 = right gun
+                gunID = gDoCommGblData.ConnectorID[plugNum];
+                systemStatusProcess(fd, totalConnCount, plugNum, gunID);
 
                 initDone = messageTrigger(fd,
                                           plugNum,
@@ -2152,7 +2195,7 @@ int main(int argc, char *argv[])
 
         //update dispenser firmware
         if (initDone != DISPENER_INIT_FAIL) {
-            updateFirmwareProcess(fd, totalConnCount);
+            updateFirmwareProcess(fd, gDoCommGblData.ConnectorID[0], totalConnCount);
         }
 
         usleep(1000);

+ 19 - 4
EVSE/Projects/DD360/Apps/ReDoComm.h

@@ -15,8 +15,8 @@
 
 #define MAX_REGISTER_NUM                        30
 
-#define CHECK_NETWORK_FAIL_COUNT                3
-#define CONNECT_SERVER_FAIL_COUNT               3
+#define CHECK_NETWORK_FAIL_COUNT                10
+#define CONNECT_SERVER_FAIL_COUNT               5
 #define WARNING_CODE_SIZE                       6
 
 #define MAX_VOLTAGE                             10000
@@ -58,6 +58,15 @@
 #define OP_WRITE_DATA                           0x02
 #define OP_WAIT_RESPONSE                        0x03
 
+//------------------------------------------------------------------------------
+//--- connector status ---
+//------------------------------------------------------------------------------
+#define CONN_ST_IDLE                            0x00
+#define CONN_ST_PREPARING                       0x01
+#define CONN_ST_CHARGING                        0x02
+#define CONN_ST_TERMINATING                     0x03
+#define CONN_ST_ALARM                           0x04
+
 //------------------------------------------------------------------------------
 //--- dispenser register ---
 //------------------------------------------------------------------------------
@@ -119,12 +128,18 @@
 #pragma pack(push)
 #pragma pack(1)
 
+typedef struct StConnectorIDTable {
+    uint8_t DcConnID1;
+    uint8_t DcConnID2;
+    uint8_t AcConnID;
+} ConnectorIDTable;
+
 typedef struct StDoCommGlobalVar {
     uint8_t SeqNum;
     uint8_t DisConnCount;
-    uint8_t ConnectorID[2]; //keep from power cabinet
+    uint8_t ConnectorID[3]; //keep from power cabinet
     uint8_t MiscCmd;
-    uint8_t Reserved[3];
+    uint8_t Reserved[2];
 } DoCommGblData;
 
 typedef struct StCommnadHead {

+ 123 - 97
EVSE/Projects/DD360/Apps/ReMain.c

@@ -1271,11 +1271,12 @@ void GetFirmwareVersion()
         if (ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'J') {
             chademo++;
             count++;
-        } else  if (ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'G') {
+        } else if (ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'G') {
             gb++;
             count++;
-        } else  if (ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'U' ||
-                    ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'E') {
+        } else if (ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'U' ||
+                   ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'V' ||
+                   ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'E') {
             ccs++;
             count++;
         }
@@ -1668,7 +1669,7 @@ void SelfTestRun()
                     DEBUG_INFO_MSG("Primary FW Rev = %s", ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev);
                     ShmPrimaryMcuData->SelfTest_Comp = YES;
                 }
-#if 1 //DS60-120 remove
+#if 0 //DS60-120 remove
                 if ((strlen((char *)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev) != 0 ||
                         ShmSysConfigAndInfo->SysInfo.LedModuleFwRev[0] != '\0')
                         && (ShmLedModuleData->SelfTest_Comp != YES)
@@ -1677,13 +1678,16 @@ void SelfTestRun()
                     ShmLedModuleData->SelfTest_Comp = YES;
                 }
 #endif //0
+
                 // EV 小板
                 if (!evInitFlag) {
                     evInitFlag = YES;
                     for (byte index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++) {
+                        //DEBUG_INFO_MSG("index = %d, charging index = %d, type = %d\r\n", index, chargingInfo[index]->type_index, chargingInfo[index]->Type);
                         if (chargingInfo[index]->Type == _Type_Chademo) {
-                            if ((strlen((char *)ShmCHAdeMOData->evse[chargingInfo[index]->type_index].version) != 0 || ShmCHAdeMOData->evse[chargingInfo[index]->type_index].version[0] != '\0')
-                                    && (ShmCHAdeMOData->evse[chargingInfo[index]->type_index].SelfTest_Comp != YES)
+                            if ((strlen((char *)ShmCHAdeMOData->evse[chargingInfo[index]->type_index].version) != 0 ||
+                                    ShmCHAdeMOData->evse[chargingInfo[index]->type_index].version[0] != '\0')
+                                    //&& (ShmCHAdeMOData->evse[chargingInfo[index]->type_index].SelfTest_Comp != YES)
                                ) {
                                 DEBUG_INFO_MSG("CHAdeMO[%d] FW Rev = %s", chargingInfo[index]->type_index, ShmCHAdeMOData->evse[chargingInfo[index]->type_index].version);
                                 ShmCHAdeMOData->evse[chargingInfo[index]->type_index].SelfTest_Comp = YES;
@@ -1692,8 +1696,9 @@ void SelfTestRun()
                                 evInitFlag = NO;
                             }
                         } else if (chargingInfo[index]->Type == _Type_GB) {
-                            if ((strlen((char *)ShmGBTData->evse[chargingInfo[index]->type_index].version) != 0 || ShmGBTData->evse[chargingInfo[index]->type_index].version[0] != '\0')
-                                    && (ShmGBTData->evse[chargingInfo[index]->type_index].SelfTest_Comp != YES)
+                            if ((strlen((char *)ShmGBTData->evse[chargingInfo[index]->type_index].version) != 0 ||
+                                    ShmGBTData->evse[chargingInfo[index]->type_index].version[0] != '\0')
+                                    //&& (ShmGBTData->evse[chargingInfo[index]->type_index].SelfTest_Comp != YES)
                                ) {
                                 DEBUG_INFO_MSG("GBT[%d] FW Rev = %s", chargingInfo[index]->type_index, ShmGBTData->evse[chargingInfo[index]->type_index].version);
                                 ShmGBTData->evse[chargingInfo[index]->type_index].SelfTest_Comp = YES;
@@ -1703,7 +1708,7 @@ void SelfTestRun()
                             }
                         } else if (chargingInfo[index]->Type == _Type_CCS_2) {
                             if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
-                                if ((strlen((char *)ShmCcsData->V2GMessage_DIN70121[chargingInfo[index]->type_index].version) != 0 &&
+                                if ((strlen((char *)ShmCcsData->V2GMessage_DIN70121[chargingInfo[index]->type_index].version) != 0 ||
                                         ShmCcsData->V2GMessage_DIN70121[chargingInfo[index]->type_index].version[0] != '\0')
                                         /*&&(ShmCcsData->V2GMessage_DIN70121[chargingInfo[index]->type_index].SelfTest_Comp != YES)*/
                                    ) {
@@ -1734,7 +1739,7 @@ void SelfTestRun()
                 if ( ShmFanModuleData->SelfTest_Comp &&
                         ShmRelayModuleData->SelfTest_Comp &&
                         ShmPrimaryMcuData->SelfTest_Comp &&
-                        ShmLedModuleData->SelfTest_Comp &&
+                        //ShmLedModuleData->SelfTest_Comp &&
                         evInitFlag
                    ) {
                     ShmSysConfigAndInfo->SysInfo.SelfTestSeq = _STEST_AC_CONTACTOR;
@@ -1886,8 +1891,9 @@ int StoreUsrConfigData(struct SysConfigData *UsrData)
 //===============================================
 // Common Detect Chk - Stop Charging ?
 //===============================================
-bool isEvBoardStopChargeFlag(byte gunIndex)
+int isEvBoardStopChargeFlag(byte gunIndex)
 {
+    //printf("StopChargeFlag = %d\r\n", chargingInfo[gunIndex]->StopChargeFlag);
     return chargingInfo[gunIndex]->StopChargeFlag;
 }
 
@@ -2376,7 +2382,8 @@ void EmcOccureByString(char *code)
     byte level = 2;
     // 嚴重的急停有以下幾種 : EMC 按鈕、Mainbreak、Dooropen
     // 其錯誤等級為 2
-    /*
+
+#if defined DD360 || defined DD360Audi
     //DS60-120 remove
     if (strncmp(code, "012251", 6) == EQUAL ||
             strncmp(code, "012252", 6) == EQUAL ||
@@ -2387,19 +2394,25 @@ void EmcOccureByString(char *code)
             strncmp(code, "042200", 6) == EQUAL ||
             strncmp(code, "042201", 6) == EQUAL ||
             strncmp(code, "042202", 6) == EQUAL ||
-            strncmp(code, "042267", 6) == EQUAL) {
-                */
-    for (byte gun = 0; gun < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun++) {
-        if ((chargingInfo[gun]->SystemStatus > S_IDLE && chargingInfo[gun]->SystemStatus < S_TERMINATING) ||
-                (chargingInfo[gun]->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingInfo[gun]->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
-            //ChargingTerminalProcess(gun);
-            ChargingAlarmProcess(gun);
+            strncmp(code, "042267", 6) == EQUAL)
+#endif //defined DD360 || defined DD360Audi
+    {
+        for (byte gun = 0; gun < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun++) {
+            //strncpy((char *)ShmOCPP16Data->StatusNotification[gun].VendorErrorCode, code, 6);
+
+            if ((chargingInfo[gun]->SystemStatus > S_IDLE &&
+                    chargingInfo[gun]->SystemStatus < S_TERMINATING) ||
+                    (chargingInfo[gun]->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
+                     chargingInfo[gun]->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
+                //ChargingTerminalProcess(gun);
+                ChargingAlarmProcess(gun);
+            }
         }
+#if defined DD360 || defined DD360Audi
+        StopChargingProcessByString(level);
+        InformOcppErrOccur(4);
+#endif //defined DD360 || defined DD360Audi
     }
-
-    StopChargingProcessByString(level);
-    //InformOcppErrOccur(4);
-    //}
 }
 
 void ReleaseBoardErrOccurByString(byte index, char *code)
@@ -2522,12 +2535,12 @@ void ChkPrimaryStatus()
     }
 
     //DS60-120 add
-    if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
-            ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS) {
-        ShmSysConfigAndInfo->SysConfig.ShowInformation = YES;
-    } else {
-        ShmSysConfigAndInfo->SysConfig.ShowInformation = NO;
-    }
+    //if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
+    //        ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS) {
+    //    ShmSysConfigAndInfo->SysConfig.ShowInformation = YES;
+    //} else {
+    //    ShmSysConfigAndInfo->SysConfig.ShowInformation = NO;
+    //}
 
     if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
             !leftBtnPush
@@ -2730,7 +2743,7 @@ void CheckErrorOccurStatus(byte index)
                     memcpy(chargingInfo[index]->ConnectorAlarmCode, "012205", 6);
                 }
             }
-
+            //DEBUG_INFO_MSG("1 CheckErrorOccurStatus\r\n");
             chargingInfo[index]->StopChargeFlag = YES;
             //------------------------------------------------------------------
         } else {
@@ -2767,6 +2780,7 @@ void CheckErrorOccurStatus(byte index)
                 memcpy(chargingInfo[index]->ConnectorAlarmCode, "012202", 6);
             }
         }
+        //DEBUG_INFO_MSG("2 CheckErrorOccurStatus\r\n");
         chargingInfo[index]->StopChargeFlag = YES;
         //----------------------------------------------------------------------
     } else {
@@ -2881,7 +2895,7 @@ void CheckGunTypeFromHw()
         }
     }
 
-#if 0 //DS60-120 remove
+#if 1 //DS60-120 remove
     //BD1(Left-CCS-CND1-SMR2-左槍), BD2(Right-CHADEMO-CND2-SMR1-右槍), CCS: 10 , CHAdeMO: 01 , GBT: 11
     //CcsChargingData [0至1] 分別為 Right至Left
     //model name 槍順序左至右分別為Right至Left
@@ -5140,7 +5154,30 @@ void TheEndCharging(byte gun_index)
 
 void UpdateErrorCodeToOcpp(byte index)
 {
-    //printf("ConnectorAlarmCode = %s \n", chargingInfo[index]->ConnectorAlarmCode);
+    uint8_t i = 0;
+
+    if ((strcmp((char *)chargingInfo[index]->ConnectorAlarmCode, "") == EQUAL) &&
+            (strcmp((char *)chargingInfo[index]->EvConnAlarmCode, "") == EQUAL)
+       ) {
+        for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+            if (strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012251", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012252", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012238", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "042251", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "042252", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012304", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "042200", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "042201", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "042202", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "042267", 6) == EQUAL) {
+
+                strncpy((char *)ShmOCPP16Data->StatusNotification[index].VendorErrorCode, (char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], 6);
+                //DEBUG_INFO_MSG("1 %d = VendorErrorCode = %s\r\n", index, (char *)ShmOCPP16Data->StatusNotification[index].VendorErrorCode);
+                break;
+            }
+        }
+    }
+
     if (strcmp((char *)chargingInfo[index]->ConnectorAlarmCode, "") != EQUAL) {
         strcpy((char *)ShmOCPP16Data->StatusNotification[index].ErrorCode, "InternalError");
         strcpy((char *)ShmOCPP16Data->StatusNotification[index].VendorErrorCode, (char *)chargingInfo[index]->ConnectorAlarmCode);
@@ -5148,6 +5185,8 @@ void UpdateErrorCodeToOcpp(byte index)
         strcpy((char *)ShmOCPP16Data->StatusNotification[index].ErrorCode, "OtherError");
         strcpy((char *)ShmOCPP16Data->StatusNotification[index].VendorErrorCode, (char *)chargingInfo[index]->EvConnAlarmCode);
     }
+
+    //DEBUG_INFO_MSG("2 %d = VendorErrorCode = %s\r\n", index, (char *)ShmOCPP16Data->StatusNotification[index].VendorErrorCode);
 }
 
 void AdjustChargerCurrent()
@@ -5337,6 +5376,8 @@ static void powerCabinetPsuAlarmStatus(void)
 
 int main(void)
 {
+    uint8_t evBoardStopState = 0;
+
     if (CreateShareMemory() == 0) {
         DEBUG_ERROR_MSG("CreatShareMemory NG\r\n");
         if (ShmStatusCodeData != NULL) {
@@ -5495,7 +5536,6 @@ int main(void)
                         ChargingProfileFlat(_index);
                         _ocppProfileChkFlag = 0;
                     } else if (chargingInfo[_index]->SystemStatus != S_CHARGING) {
-
                         ChargingProfileFlat(_index);
                         _ocppProfileChkFlag = 0;
                     } else {
@@ -5514,7 +5554,6 @@ int main(void)
                 }
 #endif //defined METER_ENABLE
             }
-
             gettimeofday(&_cmdMainPriority_time, NULL);
         }
 
@@ -5544,11 +5583,7 @@ int main(void)
             //PRINTF_FUNC("index = %d, ErrorCode = %s \n", gun_index, ShmOCPP16Data->StatusNotification[gun_index].ErrorCode);
             switch (chargingInfo[gun_index]->SystemStatus) {
             case S_IDLE:
-            case S_RESERVATION:
-            case S_MAINTAIN:
-            case S_FAULT: {
-                if (chargingInfo[gun_index]->SystemStatus == S_IDLE &&
-                        isModeChange(gun_index)) {
+                if (isModeChange(gun_index)) {
                     DEBUG_INFO_MSG("S_IDLE================================== %x \n", gun_index);
                     chargingInfo[gun_index]->PresentChargedDuration = 0;
                     chargingInfo[gun_index]->RemainChargingDuration = 0;
@@ -5566,8 +5601,10 @@ int main(void)
                     destroySelGun(gun_index);
 #endif //defined DD360Audi
                     ResetDetAlarmStatus(gun_index); //recovery OVP status code
-                } else if (chargingInfo[gun_index]->SystemStatus == S_RESERVATION &&
-                           isModeChange(gun_index)) {
+                    //strcpy((char *)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode, "");
+                }
+            case S_RESERVATION:
+                if (isModeChange(gun_index)) {
                     DEBUG_INFO_MSG("S_RESERVATION....................%x \n", gun_index);
                     ShmOCPP16Data->CsMsg.bits[gun_index].ReserveNowConf = YES;
                 }
@@ -5576,6 +5613,8 @@ int main(void)
                     setChargerMode(gun_index, MODE_MAINTAIN);
                 }
 
+            case S_MAINTAIN:
+            case S_FAULT: {
                 if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
                     if (gun_index == ShmSysConfigAndInfo->SysInfo.CurGunSelected) {
                         ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_FIX;
@@ -5595,9 +5634,9 @@ int main(void)
                     }
 
                     ClearDetectPluginFlag();
-#if !defined DD360 && !defined DD360Audi
+//#if !defined DD360 && !defined DD360Audi
                     UpdateErrorCodeToOcpp(gun_index);
-#endif //!defined DD360 && !defined DD360Audi
+//#endif //!defined DD360 && !defined DD360Audi
                     setChargerMode(gun_index, MODE_FAULT);
                 } else {
 #if 1
@@ -5667,11 +5706,6 @@ int main(void)
                             // Idle 正常程序起點
                             // 判斷是否有啟用檢查插槍
                             if (isDetectPlugin()) {
-                                //PRINTF_FUNC("----------------ShmSysConfigAndInfo->SysInfo.PageIndex--------------- %d \n", ShmSysConfigAndInfo->SysInfo.PageIndex);
-                                //PRINTF_FUNC("----------------ShmSysConfigAndInfo->SysInfo.SystemPage--------------- %d \n", ShmSysConfigAndInfo->SysInfo.SystemPage);
-                                //PRINTF_FUNC("----------------ShmSysConfigAndInfo->SysInfo.ConnectorPage--------------- %d \n", ShmSysConfigAndInfo->SysInfo.ConnectorPage);
-                                //PRINTF_FUNC("----------------isCardScan--------------- %d \n", isCardScan);
-
                                 // 卡號驗證成功後,等待充電槍插入充電車
                                 if (chargingInfo[gun_index]->RemoteStartFlag == YES) {
                                     if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
@@ -5883,12 +5917,17 @@ int main(void)
                     }
                 }
 
-                if (isEvBoardStopChargeFlag(gun_index) == YES) {
+                if ((evBoardStopState = isEvBoardStopChargeFlag(gun_index)) > 0) {
                     // 板端要求停止 (錯誤)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
                         strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
                     }
-                    ChargingAlarmProcess(gun_index);
+
+                    if (evBoardStopState == EV_BOARD_STOP_CHARGING) {
+                        ChargingAlarmProcess(gun_index);
+                    } else if (evBoardStopState == POWER_CABINET_STOP_CHARGING) {
+                        ChargingTerminalProcess(gun_index);
+                    }
                 } else if (isEvBoardNormalStopChargeFlag(gun_index) == YES) {
                     // 板端要求停止 (正常)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
@@ -5901,11 +5940,6 @@ int main(void)
                     ChargingTerminalProcess(gun_index);
                 }
 
-                //if (isEvBoardStopChargeFlag(gun_index) == YES || OcppRemoteStop(gun_index) == YES) {
-                //    // 板端或後臺要求停止
-                //    ChargingTerminalProcess(gun_index);
-                //}
-
                 if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
                     ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_PRE_CHARGE;
                     ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
@@ -5937,12 +5971,17 @@ int main(void)
                     }
                 }
 
-                if (isEvBoardStopChargeFlag(gun_index) == YES) {
+                if ((evBoardStopState = isEvBoardStopChargeFlag(gun_index)) > 0) {
                     // 板端要求停止 (錯誤)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
                         strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
                     }
-                    ChargingAlarmProcess(gun_index);
+
+                    if (evBoardStopState == EV_BOARD_STOP_CHARGING) {
+                        ChargingAlarmProcess(gun_index);
+                    } else if (evBoardStopState == POWER_CABINET_STOP_CHARGING) {
+                        ChargingTerminalProcess(gun_index);
+                    }
                 } else if (isEvBoardNormalStopChargeFlag(gun_index) == YES) {
                     // 板端要求停止 (正常)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
@@ -5955,12 +5994,6 @@ int main(void)
                     ChargingTerminalProcess(gun_index);
                 }
 
-                //if (isEvBoardStopChargeFlag(gun_index) == YES  ||
-                //        OcppRemoteStop(gun_index) == YES) {
-                //    // 板端或後臺要求停止
-                //    ChargingTerminalProcess(gun_index);
-                //}
-
                 // LCM => Pre-charging
                 if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
                     ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_PRE_CHARGE;
@@ -6018,12 +6051,17 @@ int main(void)
                     }
                 }
 
-                if (isEvBoardStopChargeFlag(gun_index) == YES) {
+                if ((evBoardStopState = isEvBoardStopChargeFlag(gun_index)) > 0) {
                     // 板端要求停止 (錯誤)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
                         strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
                     }
-                    ChargingAlarmProcess(gun_index);
+
+                    if (evBoardStopState == EV_BOARD_STOP_CHARGING) {
+                        ChargingAlarmProcess(gun_index);
+                    } else if (evBoardStopState == POWER_CABINET_STOP_CHARGING) {
+                        ChargingTerminalProcess(gun_index);
+                    }
                 } else if (isEvBoardNormalStopChargeFlag(gun_index) == YES) {
                     // 板端要求停止 (正常)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
@@ -6036,12 +6074,6 @@ int main(void)
                     ChargingTerminalProcess(gun_index);
                 }
 
-                //if (isEvBoardStopChargeFlag(gun_index) == YES ||
-                //        OcppRemoteStop(gun_index) == YES) {
-                //    // 板端或後臺要求停止
-                //    ChargingTerminalProcess(gun_index);
-                //}
-
                 // LCM => Pre-charging
                 if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
                     ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_PRE_CHARGE;
@@ -6115,12 +6147,17 @@ int main(void)
                     }
                 }
 
-                if (isEvBoardStopChargeFlag(gun_index) == YES) {
+                if ((evBoardStopState = isEvBoardStopChargeFlag(gun_index)) > 0) {
                     // 板端要求停止 (錯誤)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
                         strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
                     }
-                    ChargingAlarmProcess(gun_index);
+                    //printf("%d evBoardStopState = %d\r\n", gun_index, evBoardStopState);
+                    if (evBoardStopState == EV_BOARD_STOP_CHARGING) {
+                        ChargingAlarmProcess(gun_index);
+                    } else if (evBoardStopState == POWER_CABINET_STOP_CHARGING) {
+                        ChargingTerminalProcess(gun_index);
+                    }
                 } else if (isEvBoardNormalStopChargeFlag(gun_index) == YES) {
                     // 板端要求停止 (正常)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
@@ -6137,16 +6174,6 @@ int main(void)
                     ChargingTerminalProcess(gun_index);
                 }
 
-                //if (isEvBoardStopChargeFlag(gun_index) ||
-                //        OcppRemoteStop(gun_index) ||
-                //        CheckBackendChargingTimeout(gun_index) ||
-                //        CheckBackendChargingEnergy(gun_index) ||
-                //        strcmp((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Invalid") == EQUAL) {
-                //    DEBUG_INFO_MSG("S_CHARGING=======Stop=========================== %f \n", (chargingInfo[gun_index]->EvBatterytargetVoltage * 10));
-                //    // 板端或後臺要求停止
-                //    ChargingTerminalProcess(gun_index);
-                //}
-
                 // LCM => Charging
                 if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
                     ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_CHARGING;
@@ -6332,9 +6359,13 @@ int main(void)
                     RecordAlarmCode(gun_index, "012235");
                 }
 
-                if (isEvBoardStopChargeFlag(gun_index) == YES) {
+                if ((evBoardStopState = isEvBoardStopChargeFlag(gun_index)) > 0) {
                     // 板端要求停止 (錯誤)
-                    ChargingAlarmProcess(gun_index);
+                    if (evBoardStopState == EV_BOARD_STOP_CHARGING) {
+                        ChargingAlarmProcess(gun_index);
+                    } else if (evBoardStopState == POWER_CABINET_STOP_CHARGING) {
+                        ChargingTerminalProcess(gun_index);
+                    }
                 } else if (isEvBoardNormalStopChargeFlag(gun_index) == YES) {
                     // 板端要求停止 (正常)
                     ChargingTerminalProcess(gun_index);
@@ -6344,11 +6375,6 @@ int main(void)
                     ChargingTerminalProcess(gun_index);
                 }
 
-                //if (isEvBoardStopChargeFlag(gun_index) == YES) {
-                //    // 板端要求停止
-                //    ChargingTerminalProcess(gun_index);
-                //}
-
                 // 等待 EV 小板 (CCS) 通知可以開始 Precharge
                 // 切換 D+ Relay to Precharge Relay
                 if (isPrechargeStatus_ccs(gun_index) == 39 || isPrechargeStatus_ccs(gun_index) == 40) {
@@ -6384,9 +6410,14 @@ int main(void)
                     RecordAlarmCode(gun_index, "012235");
                 }
 
-                if (isEvBoardStopChargeFlag(gun_index) == YES) {
+                if ((evBoardStopState = isEvBoardStopChargeFlag(gun_index)) > 0) {
                     // 板端要求停止 (錯誤)
-                    ChargingAlarmProcess(gun_index);
+                    if (evBoardStopState == EV_BOARD_STOP_CHARGING) {
+                        ChargingAlarmProcess(gun_index);
+                    } else if (evBoardStopState == POWER_CABINET_STOP_CHARGING) {
+                        ChargingTerminalProcess(gun_index);
+                    }
+
                 } else if (isEvBoardNormalStopChargeFlag(gun_index) == YES) {
                     // 板端要求停止 (正常)
                     ChargingTerminalProcess(gun_index);
@@ -6396,11 +6427,6 @@ int main(void)
                     ChargingTerminalProcess(gun_index);
                 }
 
-                //if (isEvBoardStopChargeFlag(gun_index) == YES) {
-                //    // 板端要求停止
-                //    ChargingTerminalProcess(gun_index);
-                //}
-
                 // 等待小板通知進入充電
                 // 切換 D+ Relay to Precharge Relay
                 if (chargingInfo[gun_index]->RelayK1K2Status == YES) {

+ 1 - 0
EVSE/Projects/DD360/Apps/ReModule_EvComm.c

@@ -3338,6 +3338,7 @@ int main(int argc, char *argv[])
                 }
             }
             break;
+            case S_ALARM:
             case S_TERMINATING: {
                 // 設定當前輸出
                 if (gun_count == 1) {

+ 3 - 1
EVSE/Projects/DD360/Apps/ReModule_InternalComm.c

@@ -326,7 +326,7 @@ void GetFwAndHwVersion_Led()
         // SystemInfo
         strcpy((char *) ShmSysConfigAndInfo->SysInfo.LedModuleFwRev, ver.Version_FW);
         //PRINTF_FUNC("GetFwAndHwVersion_Led s1 = %s \n", ver.Version_FW);
-        //ShmLedModuleData->SelfTest_Comp = YES;
+        ShmLedModuleData->SelfTest_Comp = YES;
     } else {
         //PRINTF_FUNC("GetFwAndHwVersion_Led fail \n");
     }
@@ -1166,6 +1166,7 @@ void CheckAcInputOvpStatus(byte index)
 //          }
 //      }
 //      else
+        //DEBUG_INFO("CheckAcInputOvpStatus\r\n");
         _chargingData[index]->StopChargeFlag = YES;
     }
 }
@@ -1175,6 +1176,7 @@ void CheckPhaseLossStatus(byte index)
     if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == YES ||
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == YES ||
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == YES) {
+        //DEBUG_INFO("CheckPhaseLossStatus\r\n");
         _chargingData[index]->StopChargeFlag = YES;
     }
 }

+ 63 - 50
EVSE/Projects/DD360/Apps/ReModule_LcmControl.c

@@ -339,7 +339,7 @@ void ChangeWarningFunc()
     // 最多一次五筆
     //PRINTF_FUNC("LCM PageIndex = %d \n", ShmSysConfigAndInfo->SysWarningInfo.PageIndex);
     //PRINTF_FUNC("WarningCount = %d \n", ShmSysConfigAndInfo->SysWarningInfo.WarningCount);
-#if !defined DD360 && !defined DD360Audi
+//#if !defined DD360 && !defined DD360Audi
     for (i = 0; (i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
         memset(cmd, 0x00, sizeof(cmd));
         if ((i) >= 5) {
@@ -362,48 +362,50 @@ void ChangeWarningFunc()
         DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
         DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
     }
-#else
-    for (i = 0; (i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
-        memset(cmd, 0x00, sizeof(cmd));
-        if ((i - j) >= 5) {
-            break;
-        }
-        if (
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033900", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033901", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033902", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043627", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043628", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043622", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043623", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043624", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043625", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043626", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042241", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042242", 6) == 0)
-        ) {
-            j++;
-            continue;
-        }
-        //error code
-        string2ByteArray(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], cmd);
-        DisplayValueToLcm(0x0010 + ((i - j) * 6), cmd, sizeof(cmd));
-        //警告標示
-        memset(cmd, 0x00, sizeof(cmd));
 
-        cmd[0] = 0x00;
-        cmd[1] = 0x01;
-        DisplayValueToLcm(0x0002 + ((i - j) * 2), cmd, 2);
-    }
+    /*#else
+        for (i = 0; (i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+            memset(cmd, 0x00, sizeof(cmd));
+            if ((i - j) >= 5) {
+                break;
+            }
+            if (
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033900", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033901", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033902", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043627", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043628", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043622", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043623", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043624", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043625", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043626", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042241", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042242", 6) == 0)
+            ) {
+                j++;
+                continue;
+            }
+            //error code
+            string2ByteArray(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], cmd);
+            DisplayValueToLcm(0x0010 + ((i - j) * 6), cmd, sizeof(cmd));
+            //警告標示
+            memset(cmd, 0x00, sizeof(cmd));
+
+            cmd[0] = 0x00;
+            cmd[1] = 0x01;
+            DisplayValueToLcm(0x0002 + ((i - j) * 2), cmd, 2);
+        }
 
-    memset(cmd, 0x00, sizeof(cmd));
-    i = i - j;
-    for (; (i) < 5; i++) {
-        DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
-        DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
-    }
+        memset(cmd, 0x00, sizeof(cmd));
+        i = i - j;
+        for (; (i) < 5; i++) {
+            DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
+            DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
+        }
 
-#endif //!defined DD360 && !defined DD360Audi
+    #endif //!defined DD360 && !defined DD360Audi
+    */
 }
 
 //================================================
@@ -927,13 +929,15 @@ void RefreshConnStatus()
     // Wifi priority is higher than Ethernet
 #if defined DD360 || defined DD360Audi
     uint8_t i = 0;
+    uint8_t ehtStatus = 0;
 
     for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
         if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012304", 6) == 0) {
-            if (gAudiCustInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
-                gAudiCustInfo->EthDevStatus.Ethernet = DEV_ST_ENABLE_NO_USE;
-            }
-            continue;
+            ehtStatus = 1;
+            //if (gAudiCustInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
+            //    gAudiCustInfo->EthDevStatus.Ethernet = DEV_ST_ENABLE_NO_USE;
+            //}
+            break;
         }
     }
 
@@ -945,14 +949,22 @@ void RefreshConnStatus()
         ChangeDisplay2Value(__conn_status, _disconnect);
     }
 
-    if (gAudiCustInfo->EthDevStatus.Ethernet == DEV_ST_DISABLE) {
-    } else if (gAudiCustInfo->EthDevStatus.Ethernet == DEV_ST_ENABLE_USE) {
-        ChangeDisplay2Value(__ethernet_status, _eth_connect);
-    } else if (gAudiCustInfo->EthDevStatus.Ethernet == DEV_ST_ENABLE_NO_USE) {
-        ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
+    if (ehtStatus == 1) {
+        if (gAudiCustInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
+            ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
+        }
+    } else {
+        if (gAudiCustInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
+            ChangeDisplay2Value(__ethernet_status, _eth_connect);
+        }
+        //if (gAudiCustInfo->EthDevStatus.Ethernet == DEV_ST_DISABLE) {
+        //} else if (gAudiCustInfo->EthDevStatus.Ethernet == DEV_ST_ENABLE_USE) {
+        //    ChangeDisplay2Value(__ethernet_status, _eth_connect);
+        //} else if (gAudiCustInfo->EthDevStatus.Ethernet == DEV_ST_ENABLE_NO_USE) {
+        //    ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
+        //}
     }
 
-
     if (gAudiCustInfo->EthDevStatus.Wifi == DEV_ST_DISABLE) {
         ChangeDisplay2Value(__wifi_status, _disappear);
 
@@ -1968,6 +1980,7 @@ int main(void)
     acgunCount = ShmSysConfigAndInfo->SysConfig.AcConnectorCount;
     Initialization();
 
+    //printf("_LCM_COMPLETE \r\n");
     //ChangeToOtherPage(_LCM_COMPLETE);
     //return 0;
 

+ 14 - 3
EVSE/Projects/DD360/Apps/ReModule_PrimaryComm.c

@@ -285,8 +285,18 @@ void GetInputGpioStatus()
         //ShmSysConfigAndInfo->SysInfo.AcContactorStatus = ShmPrimaryMcuData->InputDet.bits.AcContactorDetec = gpio_in.AC_Connector;
         //ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec = gpio_in.AC_MainBreaker;
 #else
-        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning = ~gpio_in.AC_Connector;
-        ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsLiquidChillerWaterLevelFault = ~gpio_in.AC_MainBreaker;
+        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)
+
+           ) {
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning = ~gpio_in.AC_Connector;
+            ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsLiquidChillerWaterLevelFault = ~gpio_in.AC_MainBreaker;
+        } else {
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning = gpio_in.AC_Connector;
+            ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsLiquidChillerWaterLevelFault = gpio_in.AC_MainBreaker;
+        }
 #endif //!defined DD360 && !defined DD360Audi
 
         ShmPrimaryMcuData->InputDet.bits.SpdDetec = gpio_in.SPD;
@@ -300,6 +310,7 @@ void GetInputGpioStatus()
 #else
         ShmPrimaryMcuData->InputDet.bits.DoorOpen = gpio_in.Door_Open;
 #endif //defined DD360 ||defined DD360Audi
+
         ShmPrimaryMcuData->InputDet.bits.Button1 = gpio_in.Button[0];
         ShmPrimaryMcuData->InputDet.bits.Button2 = gpio_in.Button[1];
         ShmPrimaryMcuData->InputDet.bits.EmergencyButton = gpio_in.Emergency_Btn;
@@ -618,7 +629,7 @@ int main(void)
 #endif //defined METER_ENABLE
         }
 
-        usleep(100000);
+        usleep(50000);
     }
 
     return FAIL;

+ 2 - 0
EVSE/Projects/DD360/Apps/kill.sh

@@ -33,5 +33,7 @@ ipcrm -M 0x000003f0
 ipcrm -M 0x000003f3
 ipcrm -M 0x000003f1
 ipcrm -M 0x000003f6
+ipcrm -M 0x000003eb
+ipcrm -M 0x000003f2
 
 ipcs

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


BIN
EVSE/Projects/DD360/output/DoComm


BIN
EVSE/Projects/DD360/output/FactoryConfig


BIN
EVSE/Projects/DD360/output/Module_EvComm


BIN
EVSE/Projects/DD360/output/Module_EventLogging


BIN
EVSE/Projects/DD360/output/Module_InternalComm


BIN
EVSE/Projects/DD360/output/Module_LcmControl


BIN
EVSE/Projects/DD360/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360/output/ReadCmdline


+ 2 - 0
EVSE/Projects/DD360/output/kill.sh

@@ -33,5 +33,7 @@ ipcrm -M 0x000003f0
 ipcrm -M 0x000003f3
 ipcrm -M 0x000003f1
 ipcrm -M 0x000003f6
+ipcrm -M 0x000003eb
+ipcrm -M 0x000003f2
 
 ipcs

BIN
EVSE/Projects/DD360/output/main


+ 18 - 0
EVSE/Projects/DD360Audi/Apps/AudiCust.h

@@ -32,6 +32,23 @@
 //#define RT_SOFTWARE_RESTART                     0x02
 
 //------------------------------------------------------------------------------
+//--- power cabinet Ethernet device status ---
+//------------------------------------------------------------------------------
+#define DEV_ST_DISABLE                          0x00
+#define DEV_ST_ENABLE_USE                       0x01
+#define DEV_ST_ENABLE_NO_USE                    0x02
+
+#define EV_BOARD_STOP_CHARGING                  1
+#define POWER_CABINET_STOP_CHARGING             2
+
+//------------------------------------------------------------------------------
+typedef struct StEthDevStatus {
+    uint8_t Backend;
+    uint8_t Ethernet;
+    uint8_t Wifi;
+    uint8_t FourG;
+} EthDevStatus;
+
 typedef struct StSelGunInfo {
     uint8_t LeftGun;
     uint8_t RightGun;
@@ -73,6 +90,7 @@ typedef struct StAudiCustInfo {
     SelGunInfo SelGunInfo;
     PricesInfo PricesInfo[2];
     RemoteSetup RemoteSetup;
+    EthDevStatus EthDevStatus;
 } AudiCustInfo;
 
 #endif /* _AUDI_CUSTOM_H_ */

+ 148 - 104
EVSE/Projects/DD360Audi/Apps/Config.h

@@ -7,46 +7,49 @@
 #ifndef CONFIG_H_
 #define CONFIG_H_
 
-typedef unsigned char byte;
-
-#define TOTAL_QUANTITY_GUN                      4               //Max Count
-
-#define MODE_BOOT                               0
-#define MODE_IDLE                               1
-#define MODE_AUTHORIZING                        2
-#define MODE_REASSIGN_CHECK                     3
-#define MODE_REASSIGN                           4
-#define MODE_PRECHARGE                          5
-#define MODE_PREPARE_FOR_EV                     6
-#define MODE_PREPARE_FOR_EVSE                   7
-#define MODE_CHARGING                           8
-#define MODE_TERMINATING                        9
-#define MODE_COMPLETE                           10
-#define MODE_ALARM                              11
-#define MODE_FAULT                              12
-#define MODE_RESERVATION                        13
-#define MODE_BOOKING                            14
-#define MODE_MAINTAIN                           15
-#define MODE_DEBUG                              16
-#define MODE_CCS_PRECHARGE_STEP0                17  // ready for ccs precharge processing, For D+ relay to precharge relay
-#define MODE_CCS_PRECHARGE_STEP1                18  // waitting for ev board inform to enter to charging, For precharge relay to D+ relay
-#define MODE_UPDATE                             19
-
-#define GFD_WAIT                                0
-#define GFD_PASS                                1
-#define GFD_FAIL                                2
-#define GFD_WARNING                             3
-
-#define PRECHARGE_WAIT                          0
-#define PRECHARGE_READY                         1
-#define PRECHARGE_PRERELAY_PASS                 2
-#define PRECHARGE_CHARELAY_PASS                 3
-
-#define BOOTTING                                0
-#define BOOT_COMPLETE                           1
+#define ShmCsuMeterKey          2001
+#define ShmCommonKey            2002
+
+typedef unsigned char           byte;
+
+#define TOTAL_QUANTITY_GUN          4               //Max Count
+
+#define MODE_BOOT                   0
+#define MODE_IDLE                   1
+#define MODE_AUTHORIZING            2
+#define MODE_REASSIGN_CHECK         3
+#define MODE_REASSIGN               4
+#define MODE_PRECHARGE              5
+#define MODE_PREPARE_FOR_EV         6
+#define MODE_PREPARE_FOR_EVSE       7
+#define MODE_CHARGING               8
+#define MODE_TERMINATING            9
+#define MODE_COMPLETE               10
+#define MODE_ALARM                  11
+#define MODE_FAULT                  12
+#define MODE_RESERVATION            13
+#define MODE_BOOKING                14
+#define MODE_MAINTAIN               15
+#define MODE_DEBUG                  16
+#define MODE_CCS_PRECHARGE_STEP0    17  // ready for ccs precharge processing, For D+ relay to precharge relay
+#define MODE_CCS_PRECHARGE_STEP1    18  // waitting for ev board inform to enter to charging, For precharge relay to D+ relay
+#define MODE_UPDATE                 19
+
+#define GFD_WAIT            0
+#define GFD_PASS            1
+#define GFD_FAIL            2
+#define GFD_WARNING         3
+
+#define PRECHARGE_WAIT              0
+#define PRECHARGE_READY             1
+#define PRECHARGE_PRERELAY_PASS     2
+#define PRECHARGE_CHARELAY_PASS     3
+
+#define BOOTTING            0
+#define BOOT_COMPLETE       1
 
 enum _SYSTEM_STATUS {
-    S_BOOTING = 0,
+    S_BOOTING =                         0,
     S_IDLE,
     S_AUTHORIZING,
     S_REASSIGN_CHECK,
@@ -70,127 +73,168 @@ enum _SYSTEM_STATUS {
 };
 
 enum _AC_SYSTEM_STATUS {
-    AC_SYS_NONE = 0,
+    AC_SYS_NONE =   0,
     AC_SYS_A,
     AC_SYS_B,
     AC_SYS_C,
     AC_SYS_D,
-    AC_SYS_E,
+    AC_SYS_E
 };
 
 enum _GUN_TYPE {
-    _Type_Chademo = 0,
+    _Type_Chademo =         0,
     _Type_CCS_2,
     _Type_GB,
     _Type_AC,
 };
 
-//enum _LCM_INDEX
-//{
-//  _LCM_INIT =             0x00,
-//  _LCM_IDLE =             0x01,
-//  _LCM_AUTHORIZING =      0x04,
-//  _LCM_AUTHORIZ_COMP =    0x05,
-//  _LCM_AUTHORIZ_FAIL =    0x06,
-//  _LCM_WAIT_FOR_PLUG =    0x07,
-//  _LCM_PRE_CHARGE =       0x08,
-//  _LCM_CHARGING =         0x09,
-//  _LCM_COMPLETE =         0x0A,
-//  _LCM_FIX =              0x0B,
-//  _LCM_NONE =             0xFF,
-//};
-
 enum _LCM_INDEX {
-    _LCM_INIT          = 0x00,
-    _LCM_IDLE          = 0x01,
-    _LCM_AUTHORIZING   = 0x02,
-    _LCM_AUTHORIZ_COMP = 0x03,
-    _LCM_AUTHORIZ_FAIL = 0x04,
-    _LCM_WAIT_FOR_PLUG = 0x05,
-    _LCM_PRE_CHARGE    = 0x06,
-    _LCM_CHARGING      = 0x07,
-    _LCM_COMPLETE      = 0x08,
-    _LCM_FIX           = 0x09,
-    _LCM_SELECT_GUN    = 0x0A,
-    _LCM_NONE          = 0xFF,
+    _LCM_INIT =             0x00,
+    _LCM_IDLE =             0x01,
+    _LCM_AUTHORIZING =      0x02,
+    _LCM_AUTHORIZ_COMP =    0x03,
+    _LCM_AUTHORIZ_FAIL =    0x04,
+    _LCM_WAIT_FOR_PLUG =    0x05,
+    _LCM_PRE_CHARGE =       0x06,
+    _LCM_CHARGING =         0x07,
+    _LCM_COMPLETE =         0x08,
+    _LCM_FIX =              0x09,
+    _LCM_SELECT_GUN =       0x0A,
+    _LCM_NONE =             0xFF,
 };
 
 enum _SELF_TEST_SEQ {
-    _STEST_VERSION      = 0x00,
+    _STEST_VERSION = 0x00,
     _STEST_AC_CONTACTOR = 0x01,
-    _STEST_PSU_DETECT   = 0x02,
-    _STEST_PSU_CAP      = 0x03,
-    _STEST_FAIL         = 0x04,
-    _STEST_COMPLETE     = 0xEE,
+    _STEST_PSU_DETECT = 0x02,
+    _STEST_PSU_CAP = 0x03,
+    _STEST_FAIL = 0x04,
+    _STEST_COMPLETE = 0xEE,
 };
 
 enum _MODULE_PSU_WORK_STEP {
-    INITIAL_START    = 0,
-    GET_PSU_COUNT    = 1,
-    GET_SYS_CAP      = 2,
-    BOOTING_COMPLETE = 3,
+    INITIAL_START       =       0,
+    GET_PSU_COUNT       =       1,
+    GET_SYS_CAP         =       2,
+    BOOTING_COMPLETE    =       3,
 
-    _WORK_CHARGING   = 10,
+    _WORK_CHARGING      =       10,
 
-    _TEST_MODE       = 20,
+    _TEST_MODE          =       20,
 
-    _NO_WORKING      = 254,
-    _INIT_PSU_STATUS = 255,
+    _NO_WORKING         =       254,
+    _INIT_PSU_STATUS    =       255
 };
 
 enum _OFFLINE_POLICY {
-    _OFFLINE_POLICY_LOCAL_LIST       = 0x00,
+    _OFFLINE_POLICY_LOCAL_LIST = 0x00,
     _OFFLINE_POLICY_PHIHONG_RFID_TAG = 0x01,
-    _OFFLINE_POLICY_FREE_CHARGING    = 0x02,
-    _OFFLINE_POLICY_NO_CHARGING      = 0x03,
+    _OFFLINE_POLICY_FREE_CHARGING = 0x02,
+    _OFFLINE_POLICY_NO_CHARGING = 0x03,
 };
 
 enum _REASSIGNED_RESOURCE_STEP {
-    _REASSIGNED_NONE           = 0,  //
-    _REASSIGNED_PREPARE_M_TO_A = 1,  // 系統收到需要降載需求 (輸出總電流降低),PSU Task 收到將狀態切換至下個狀態
-    _REASSIGNED_GET_NEW_CAP    = 2,  // 充電中的重新取得屬於自己火線上的總能量並透過小板通知車端 - 超過10秒直接跳下一步
-    _REASSIGNED_ADJUST_M_TO_A  = 3,  // 模塊重新分配完成
-    _REASSIGNED_RELAY_M_TO_A   = 4,  // 切斷橋接的 Relay
-
-    _REASSIGNED_PREPARE_A_TO_M = 11,
-    _REASSIGNED_ADJUST_A_TO_M  = 12, // 模塊升壓
-    _REASSIGNED_RELAY_A_TO_M   = 13, // 搭接橋接的 Relay
-    _REASSIGNED_WAITING        = 14,
-    _REASSIGNED_COMP           = 15,
+    _REASSIGNED_NONE =              0,  //
+    _REASSIGNED_PREPARE_M_TO_A =    1,  // 系統收到需要降載需求 (輸出總電流降低),PSU Task 收到將狀態切換至下個狀態
+    _REASSIGNED_GET_NEW_CAP =       2,  // 充電中的重新取得屬於自己火線上的總能量並透過小板通知車端 - 超過10秒直接跳下一步
+    _REASSIGNED_ADJUST_M_TO_A =     3,  // 模塊重新分配完成
+    _REASSIGNED_RELAY_M_TO_A =      4,  // 切斷橋接的 Relay
+
+    _REASSIGNED_PREPARE_A_TO_M =    11,
+    _REASSIGNED_ADJUST_A_TO_M =     12, // 模塊升壓
+    _REASSIGNED_RELAY_A_TO_M =      13, // 搭接橋接的 Relay
+    _REASSIGNED_WAITING =           14,
+    _REASSIGNED_COMP =              15
 };
 
 enum _MAIN_CHARGING_MODE {
-    _MAIN_CHARGING_MODE_MAX  = 0,
+    _MAIN_CHARGING_MODE_MAX = 0,
     _MAIN_CHARGING_MODE_AVER = 1,
 };
 
 enum _EXTRA_ERR_PROCESS {
-    _EXTRA_ERR_PROCESS_NONE  = 0,
+    _EXTRA_ERR_PROCESS_NONE = 0,
     _EXTRA_ERR_PROCESS_INUVP = 1,
-    _EXTRA_ERR_PROCESS_INOVP = 2,
+    _EXTRA_ERR_PROCESS_INOVP = 2
 };
 
 enum _CHARGER_TYPE {
     _CHARGER_TYPE_IEC = 0,
-    _CHARGER_TYPE_UL  = 1,
+    _CHARGER_TYPE_UL = 1,
 };
 
 enum _SYS_WIFI_MODE {
     _SYS_WIFI_MODE_DISABLE = 0,
     _SYS_WIFI_MODE_STATION = 1,
-    _SYS_WIFI_MODE_AP      = 2,
+    _SYS_WIFI_MODE_AP = 2
 };
 
 enum _LED_INTENSITY_LV {
     _LED_INTENSITY_DARKEST   = 0,
     _LED_INTENSITY_MEDIUM    = 1,
-    _LED_INTENSITY_BRIGHTEST = 2,
+    _LED_INTENSITY_BRIGHTEST = 2
 };
 
 enum _CCS_COMM_PROTOCOL {
-    _CCS_COMM_V2GMessage_DIN70121      = 0x01,
-    _CCS_COMM_V2GMessage_ISO15118_2014 = 0x02,
-    _CCS_COMM_V2GMessage_ISO15118_2018 = 0x03,
+    _CCS_COMM_V2GMessage_DIN70121       = 0x01,
+    _CCS_COMM_V2GMessage_ISO15118_2014  = 0x02,
+    _CCS_COMM_V2GMessage_ISO15118_2018  = 0x03
+};
+
+enum _ETHERNET_USAGE {
+    _ETHERNET_USAGE_NONE    = 0,
+    _ETHERNET_USAGE_LAN,
+    _ETHERNET_USAGE_WIFI,
+    _ETHERNET_USAGE_3G_4g
+};
+
+enum _PRIMARY_CHECK_TAG {
+    _PRIMARY_CHECK_TAG_AC_CONTACT       = 0,
+    _PRIMARY_CHECK_TAG_MAIN_BREAKER     = 1,
+};
+
+struct StructMeter {
+    float curMeterValue;
+    float newMeterValue;
+    byte isCalculation;
+    float _chargingValue;
+    float _curTotalCharging;
+};
+
+struct MeterInformation {
+    struct StructMeter _meter[2];
+    byte isWorking;
+};
+
+enum _CCS_VERSION_CHECK_TAG {
+    _CCS_VERSION_CHECK_TAG_V015S0       = 0,
+    _CCS_VERSION_CHECK_TAG_V013S0       = 1,
+};
+
+enum RELAY_STATUS_ERROR_INDEX {
+    RELAY_SMR1_P_STATUS =   0,
+    RELAY_SMR1_N_STATUS =   1,
+    RELAY_SMR2_P_STATUS =   2,
+    RELAY_SMR2_N_STATUS =   3,
+    RELAY_PARA_P_STATUS =   4,
+    RELAY_PARA_N_STATUS =   5,
+};
+
+enum RELAY_STATUS_ERROR_TYPE {
+    RELAY_STATUS_ERROR_NONE = 0,
+    RELAY_STATUS_ERROR_WELDING = 10,
+    RELAY_STATUS_ERROR_DRIVING = 11
+};
+
+struct DcCommonInformation {
+    // check if the guns are of the same type
+    byte SysGunAreSameType;
+    // to check the ccs version
+    byte CcsVersion;
+    // for relay welding/driving check
+    char RelayCheckStatus[6];
+    char GunRelayWeldingOccur[2];
+    char GunRelayDrivingOccur[2];
 };
 
 #endif /* CONFIG_H_ */

+ 282 - 266
EVSE/Projects/DD360Audi/Apps/FactoryConfig.c

@@ -1,307 +1,323 @@
-#include    <sys/time.h>
-#include    <sys/timeb.h>
+#include 	<sys/time.h>
+#include 	<sys/timeb.h>
 #include    <sys/types.h>
 #include    <sys/stat.h>
-#include    <sys/types.h>
-#include    <sys/ioctl.h>
-#include    <sys/socket.h>
-#include    <sys/ipc.h>
-#include    <sys/shm.h>
-#include    <sys/shm.h>
-#include    <sys/mman.h>
-#include    <linux/can.h>
-#include    <linux/can/raw.h>
-#include    <linux/wireless.h>
-#include    <arpa/inet.h>
-#include    <netinet/in.h>
+#include 	<sys/types.h>
+#include 	<sys/ioctl.h>
+#include 	<sys/socket.h>
+#include 	<sys/ipc.h>
+#include 	<sys/shm.h>
+#include 	<sys/shm.h>
+#include 	<sys/mman.h>
+#include 	<linux/can.h>
+#include 	<linux/can/raw.h>
+#include 	<linux/wireless.h>
+#include 	<arpa/inet.h>
+#include 	<netinet/in.h>
 
-#include    <unistd.h>
-#include    <stdarg.h>
-#include    <stdio.h>      /*璅蹱�頛詨�頛詨枂摰𡁶儔*/
-#include    <stdlib.h>     /*璅蹱��賣彍摨怠�蝢�*/
-#include    <unistd.h>     /*Unix 璅蹱��賣彍摰𡁶儔*/
-#include    <fcntl.h>      /*瑼娍綉�嗅�蝢�*/
-#include    <termios.h>    /*PPSIX 蝯�垢�批�摰𡁶儔*/
-#include    <errno.h>      /*�航炊�笔�蝢�*/
-#include    <errno.h>
-#include    <string.h>
-#include    <time.h>
-#include    <ctype.h>
-#include    <ifaddrs.h>
-#include    "../../define.h"
-#include    "Config.h"
+#include 	<unistd.h>
+#include 	<stdarg.h>
+#include    <stdio.h>      /*標準輸入輸出定義*/
+#include    <stdlib.h>     /*標準函數庫定義*/
+#include    <unistd.h>     /*Unix 標準函數定義*/
+#include    <fcntl.h>      /*檔控制定義*/
+#include    <termios.h>    /*PPSIX 終端控制定義*/
+#include    <errno.h>      /*錯誤號定義*/
+#include 	<errno.h>
+#include 	<string.h>
+#include	<time.h>
+#include	<ctype.h>
+#include 	<ifaddrs.h>
+#include	"../../define.h"
+#include 	"Config.h"
 
 #define Debug
-#define ARRAY_SIZE(A)       (sizeof(A) / sizeof(A[0]))
-#define PASS                1
-#define FAIL                -1
-#define OUTPUT_FLASH        0x01
-#define OUTPUT_FILE         0x02
+#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
+#define PASS				1
+#define FAIL				-1
+#define OUTPUT_FLASH		0x01
+#define OUTPUT_FILE			0x02
 
-struct SysConfigData            SysConfig;
+struct SysConfigData 			SysConfig;
 
 int StoreLogMsg(const char *fmt, ...);
 
 int StoreLogMsg(const char *fmt, ...)
 {
-    char Buf[4096 + 256];
-    char buffer[4096];
-    va_list args;
-    struct timeb  SeqEndTime;
-    struct tm *tm;
+	char Buf[4096+256];
+	char buffer[4096];
+	va_list args;
+	struct timeb  SeqEndTime;
+	struct tm *tm;
 
-    va_start(args, fmt);
-    int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-    va_end(args);
+	va_start(args, fmt);
+	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
+	va_end(args);
 
-    memset(Buf, 0, sizeof(Buf));
-    ftime(&SeqEndTime);
-    SeqEndTime.time = time(NULL);
-    tm = localtime(&SeqEndTime.time);
+	memset(Buf,0,sizeof(Buf));
+	ftime(&SeqEndTime);
+	SeqEndTime.time = time(NULL);
+	tm=localtime(&SeqEndTime.time);
 
-    sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-            tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
-            buffer,
-            tm->tm_year + 1900, tm->tm_mon + 1);
-    system(Buf);
+	sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
+			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,SeqEndTime.millitm,
+			buffer,
+			tm->tm_year+1900,tm->tm_mon+1);
+	system(Buf);
 
-    return rc;
+	return rc;
 }
 
 void helpOutput(void)
 {
-    printf("Usage: Module_FactoryConfig [OPTION]...\r\n\r\n");
-    printf("Generate factory default configuration value\r\n\r\n");
-    printf("OPTION:\r\n");
-    printf("	-a Write to file(/mnt) & flash\r\n");
-    printf("	-f Write to file(/mnt)\r\n");
-    printf("	-m Write to flash\r\n");
+	printf("Usage: Module_FactoryConfig [OPTION]...\r\n\r\n");
+	printf("Generate factory default configuration value\r\n\r\n");
+	printf("OPTION:\r\n");
+	printf("	-a Write to file(/mnt) & flash\r\n");
+	printf("	-f Write to file(/mnt)\r\n");
+	printf("	-m Write to flash\r\n");
 }
 
 /**************************************************************************************/
 /************This task will create Factory default confgiuration file *****************/
-/***********and store it into mtdblock 10,11,12                               ****************/
+ /***********and store it into mtdblock 10,11,12                               ****************/
 /**************************************************************************************/
-int main(int argc, char *argv[])
+int main(int argc,char *argv[])
 {
-    unsigned char outType = 0;
-    unsigned int i, Chk, MtdBlockSize = 0x600000;
-    unsigned char *ptr;
-    int fd, wrd;
+	unsigned char outType=0;
+	unsigned int i,Chk, MtdBlockSize=0x600000;
+	unsigned char *ptr;
+	int fd,wrd;
 
-    ptr = malloc(MtdBlockSize);
-    if (ptr == NULL) {
-#ifdef SystemLogMessage
-        StoreLogMsg("[FactoryConfig]main: malloc for SysConfigData NG");
-#endif
-        return 0;
-    }
-    memset(ptr, 0, MtdBlockSize);
-    memset(&SysConfig, 0, sizeof(struct SysConfigData));
+	ptr=malloc(MtdBlockSize);
+	if(ptr==NULL)
+	{
+		#ifdef SystemLogMessage
+		StoreLogMsg("[FactoryConfig]main: malloc for SysConfigData NG");
+		#endif
+		return 0;
+	}
+	memset(ptr, 0, MtdBlockSize);
+	memset(&SysConfig, 0, sizeof(struct SysConfigData));
 
-    /*
-     * TODO: Set factory default configuration
-    */
-    //********** System **********// udhcpc -i eth1 -s ./dhcp_script/eth1.script
-    //
-    strcpy((char *)SysConfig.ModelName, "DDYC182V0UE2AD");
-    strcpy((char *)SysConfig.SerialNumber, "SERIALFORRD");
+	/*
+	 * TODO: Set factory default configuration
+	*/
+	//********** System **********// udhcpc -i eth1 -s ./dhcp_script/eth1.script
+	//
+	strcpy((char *)SysConfig.ModelName, "DDYE182V0UD2AU");
+	strcpy((char *)SysConfig.SerialNumber, "SERIALFORRD");
 
-    memset(SysConfig.SystemId, 0x00, sizeof(SysConfig.SystemId));
-    char Dash = '-';
+	memset(SysConfig.SystemId, 0x00, sizeof(SysConfig.SystemId));
+	char Dash = '-';
 
-    strcat((char *)SysConfig.SystemId, (char *)SysConfig.ModelName);
-    strncat((char *)SysConfig.SystemId, &Dash, 1);
-    strcat((char *)SysConfig.SystemId, (char *)SysConfig.SerialNumber);
+	strcat((char *)SysConfig.SystemId, (char *)SysConfig.ModelName);
+	strncat((char *)SysConfig.SystemId, &Dash, 1);
+	strcat((char *)SysConfig.SystemId, (char *)SysConfig.SerialNumber);
 
-    strcpy((char *)SysConfig.SystemDateTime, "");
-    SysConfig.AuthorisationMode = AUTH_MODE_ENABLE;
-    SysConfig.DefaultLanguage = 0;
-    SysConfig.RfidCardNumEndian = 0;
-    SysConfig.AcPlugInTimes = 0;
-    SysConfig.GbPlugInTimes = 0;
-    SysConfig.Ccs1PlugInTime = 0;
-    SysConfig.Ccs2PlugInTimes = 0;
-    SysConfig.ChademoPlugInTimes = 0;
-    SysConfig.BillingData.isBilling = 0;
-    SysConfig.isAPP = 1;
-    SysConfig.isQRCode = 1;
-    SysConfig.isRFID = 1;
-    //********** Charging **********//
-    SysConfig.MaxChargingEnergy = 0;
-    SysConfig.MaxChargingCurrent = 500;     // ��憭批虾頛詨枂�餅� (�湔�)
-    SysConfig.MaxChargingDuration = 0;
-    SysConfig.AcMaxChargingCurrent = 0;
-    SysConfig.PhaseLossPolicy = 0;
-    /*+++ 20200908, vern, modify it +++*/
-    /*for(unsigned char i = 0; i < 10; i++)
-        strcpy((char *)SysConfig.LocalWhiteCard, "");*/
-    memset(SysConfig.LocalWhiteCard, 0, sizeof(SysConfig.LocalWhiteCard));
-    /*--- 20200908, vern, modify it ---*/
-    strcpy((char *)SysConfig.UserId, "");
-    //********** Network **********//
-    strcpy((char *)SysConfig.FtpServer, "");
-    SysConfig.Eth0Interface.EthDhcpClient = 0;
-    strcpy((char *) SysConfig.Eth0Interface.EthIpAddress, "192.168.1.10");
-    strcpy((char *) SysConfig.Eth0Interface.EthSubmaskAddress, "255.255.255.0");
-    strcpy((char *) SysConfig.Eth0Interface.EthGatewayAddress, "192.168.1.254");
-    SysConfig.Eth1Interface.EthDhcpClient = 0;
-    strcpy((char *) SysConfig.Eth1Interface.EthIpAddress, "192.168.0.10");
-    strcpy((char *) SysConfig.Eth1Interface.EthSubmaskAddress, "255.255.255.0");
-    strcpy((char *) SysConfig.Eth1Interface.EthGatewayAddress, "192.168.0.254");
-    if (SysConfig.ModelName[10] == 'W') {
-        SysConfig.AthInterface.WifiMode = 2;
-    } else {
-        SysConfig.AthInterface.WifiMode = 0;
-    }
-    strcpy((char *) SysConfig.AthInterface.WifiSsid, "");
-    strcpy((char *) SysConfig.AthInterface.WifiPassword, "");
-    SysConfig.AthInterface.WifiRssi = 0;
-    SysConfig.AthInterface.WifiDhcpServer = 0;
-    SysConfig.AthInterface.WifiDhcpClient = 0;
-    strcpy((char *) SysConfig.AthInterface.WifiMacAddress, "");
-    strcpy((char *) SysConfig.AthInterface.WifiIpAddress, "");
-    strcpy((char *) SysConfig.AthInterface.WifiSubmaskAddress, "");
-    strcpy((char *) SysConfig.AthInterface.WifiGatewayAddress, "");
-    SysConfig.AthInterface.WifiNetworkConn = 0;
-    strcpy((char *) SysConfig.TelecomInterface.TelcomModelName, "");
-    strcpy((char *) SysConfig.TelecomInterface.TelcomSoftwareVer, "");
-    //strcpy((char *) SysConfig.TelecomInterface.TelcomApn, "Internet");
-    strcpy((char *) SysConfig.TelecomInterface.TelcomApn, "");
-    SysConfig.TelecomInterface.TelcomRssi = 0;
-    strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapId, " ");
-    strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapPwd, " ");
-    strcpy((char *) SysConfig.TelecomInterface.TelcomModemImei, "");
-    strcpy((char *) SysConfig.TelecomInterface.TelcomSimImsi, "");
-    strcpy((char *) SysConfig.TelecomInterface.TelcomSimIccid, "");
-    SysConfig.TelecomInterface.TelcomSimStatus = 0;
-    SysConfig.TelecomInterface.TelcomModemMode = 0;
-    strcpy((char *) SysConfig.TelecomInterface.TelcomIpAddress, "");
-    SysConfig.TelecomInterface.TelcomNetworkConn = 0;
-    strcpy((char *)SysConfig.chargePointVendor, "Phihong Technology");
-    //********** Backend **********//
-    SysConfig.BackendConnTimeout = 300; //300 seconds
-    SysConfig.OfflinePolicy = 2;
-    SysConfig.OfflineMaxChargeEnergy = 0;
-    SysConfig.OfflineMaxChargeDuration = 0;
-    strcpy((char *) SysConfig.OcppServerURL, "");
-    strcpy((char *) SysConfig.ChargeBoxId, "");
-    SysConfig.LedInfo.Intensity = 2;
+	strcpy((char *)SysConfig.SystemDateTime, "");
+	SysConfig.AuthorisationMode = AUTH_MODE_ENABLE;
+	SysConfig.DefaultLanguage = 0;
+	SysConfig.RfidCardNumEndian = 0;
+	SysConfig.AcPlugInTimes = 0;
+	SysConfig.GbPlugInTimes = 0;
+	SysConfig.Ccs1PlugInTime = 0;
+	SysConfig.Ccs2PlugInTimes = 0;
+	SysConfig.ChademoPlugInTimes = 0;
+	SysConfig.BillingData.isBilling = 0;
+	SysConfig.isAPP = 1;
+	SysConfig.isQRCode = 1;
+	SysConfig.isRFID = 1;
+	//********** Charging **********//
+	SysConfig.MaxChargingEnergy = 0;
+	SysConfig.MaxChargingCurrent = 500;		// 最大可輸出電流 (整樁)
+	SysConfig.MaxChargingDuration = 0;
+	SysConfig.AcMaxChargingCurrent = 0;
+	SysConfig.PhaseLossPolicy = 0;
+	/*+++ 20200908, vern, modify it +++*/
+	/*for(unsigned char i = 0; i < 10; i++)
+		strcpy((char *)SysConfig.LocalWhiteCard, "");*/
+	memset(SysConfig.LocalWhiteCard,0,sizeof(SysConfig.LocalWhiteCard));	
+	/*--- 20200908, vern, modify it ---*/
+	strcpy((char *)SysConfig.UserId, "");
+	//********** Network **********//
+	strcpy((char *)SysConfig.FtpServer, "");
+	SysConfig.Eth0Interface.EthDhcpClient = 0;
+	strcpy((char *) SysConfig.Eth0Interface.EthIpAddress, "192.168.1.10");
+	strcpy((char *) SysConfig.Eth0Interface.EthSubmaskAddress, "255.255.255.0");
+	strcpy((char *) SysConfig.Eth0Interface.EthGatewayAddress, "192.168.1.254");
+	SysConfig.Eth1Interface.EthDhcpClient = 0;
+	strcpy((char *) SysConfig.Eth1Interface.EthIpAddress, "192.168.0.10");
+	strcpy((char *) SysConfig.Eth1Interface.EthSubmaskAddress, "255.255.255.0");
+	strcpy((char *) SysConfig.Eth1Interface.EthGatewayAddress, "192.168.0.254");
+	if(SysConfig.ModelName[10] == 'W')
+		SysConfig.AthInterface.WifiMode = 2;
+	else
+		SysConfig.AthInterface.WifiMode = 0;
+	strcpy((char *) SysConfig.AthInterface.WifiSsid, "");
+	strcpy((char *) SysConfig.AthInterface.WifiPassword, "");
+	SysConfig.AthInterface.WifiRssi = 0;
+	SysConfig.AthInterface.WifiDhcpServer = 0;
+	SysConfig.AthInterface.WifiDhcpClient = 0;
+	strcpy((char *) SysConfig.AthInterface.WifiMacAddress, "");
+	strcpy((char *) SysConfig.AthInterface.WifiIpAddress, "");
+	strcpy((char *) SysConfig.AthInterface.WifiSubmaskAddress, "");
+	strcpy((char *) SysConfig.AthInterface.WifiGatewayAddress, "");
+	SysConfig.AthInterface.WifiNetworkConn = 0;
+	strcpy((char *) SysConfig.TelecomInterface.TelcomModelName, "");
+	strcpy((char *) SysConfig.TelecomInterface.TelcomSoftwareVer, "");
+	//strcpy((char *) SysConfig.TelecomInterface.TelcomApn, "Internet");
+	strcpy((char *) SysConfig.TelecomInterface.TelcomApn, "");
+	SysConfig.TelecomInterface.TelcomRssi = 0;
+	strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapId, " ");
+	strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapPwd, " ");
+	strcpy((char *) SysConfig.TelecomInterface.TelcomModemImei, "");
+	strcpy((char *) SysConfig.TelecomInterface.TelcomSimImsi, "");
+	strcpy((char *) SysConfig.TelecomInterface.TelcomSimIccid, "");
+	SysConfig.TelecomInterface.TelcomSimStatus = 0;
+	SysConfig.TelecomInterface.TelcomModemMode = 0;
+	strcpy((char *) SysConfig.TelecomInterface.TelcomIpAddress, "");
+	SysConfig.TelecomInterface.TelcomNetworkConn = 0;
+	strcpy((char *)SysConfig.chargePointVendor, "Phihong Technology");
+	//********** Backend **********//
+	SysConfig.BackendConnTimeout = 300; //300 seconds
+	SysConfig.OfflinePolicy = 2;
+	SysConfig.OfflineMaxChargeEnergy = 0;
+	SysConfig.OfflineMaxChargeDuration = 0;
+	strcpy((char *) SysConfig.OcppServerURL, "");
+	strcpy((char *) SysConfig.ChargeBoxId, "");
+	SysConfig.LedInfo.Intensity = 2;
 
-    //copy default configuration to pointer
-    memcpy(ptr, &SysConfig, sizeof(struct SysConfigData));
+	//copy default configuration to pointer
+	memcpy(ptr,&SysConfig,sizeof(struct SysConfigData));
 
-    //calculate CRC
-    Chk = 0;
-    for (i = 0; i < (MtdBlockSize - 4); i++) {
-        Chk += *(ptr + i);
-    }
-    memcpy( ptr + MtdBlockSize - 4, &Chk, 4);
+	//calculate CRC
+	Chk=0;
+	for(i=0;i<(MtdBlockSize-4);i++)
+	{
+		Chk+=*(ptr+i);
+	}
+	memcpy(	ptr+MtdBlockSize-4,&Chk,4);
 
-    /*
-    * Parameter process
-    */
-    if (argc > 1) {
-        char *arg = argv[1];
-        switch (arg[0]) {
-        case '-':
-            switch (arg[1]) {
-            case 'a':
-                outType |= OUTPUT_FILE;
-                outType |= OUTPUT_FLASH;
-                break;
-            case 'f':
-                outType |= OUTPUT_FILE;
-                break;
-            case 'm':
-                outType |= OUTPUT_FLASH;
-                break;
-            default:
-                helpOutput();
-                break;
-            }
-            break;
-        default:
-            helpOutput();
-            break;
-        }
-    } else {
-        helpOutput();
-    }
+	/*
+	* Parameter process
+	*/
+	if (argc > 1)
+	{
+		char *arg = argv[1];
+		switch (arg[0])
+		{
+		case '-':
+			switch (arg[1])
+			{
+				case 'a':
+					outType |= OUTPUT_FILE;
+					outType |= OUTPUT_FLASH;
+					break;
+				case 'f':
+					outType |= OUTPUT_FILE;
+					break;
+				case 'm':
+					outType |= OUTPUT_FLASH;
+					break;
+				default:
+					helpOutput();
+					break;
+			}
+				break;
+			default:
+				helpOutput();
+				break;
+		}
+	}
+	else
+	{
+		helpOutput();
+	}
 
-    /*
-     * Configuration bin file generate
-    */
-    if ((outType & OUTPUT_FILE) > 0) {
-        fd = open("/mnt/FactoryDefaultConfig.bin", O_RDWR | O_CREAT);
-        if (fd < 0) {
-            StoreLogMsg("[FactoryConfig]main: open /mnt/FactoryDefaultConfig.bin NG");
-            free(ptr);
-            return 0;
-        }
-        wrd = write(fd, ptr, MtdBlockSize);
-        close(fd);
-        if (wrd < MtdBlockSize) {
-            StoreLogMsg("write /mnt/FactoryDefaultConfig.bin NG\r\n");
-            free(ptr);
-            return 0;
-        }
-        StoreLogMsg("FactoryConfig write to file in /mnt OK.\r\n");
-    }
+	/*
+	 * Configuration bin file generate
+	*/
+	if((outType&OUTPUT_FILE)>0)
+	{
+		fd = open("/mnt/FactoryDefaultConfig.bin", O_RDWR | O_CREAT);
+		if (fd < 0)
+		{
+			StoreLogMsg("[FactoryConfig]main: open /mnt/FactoryDefaultConfig.bin NG");
+			free(ptr);
+			return 0;
+		}
+		wrd=write(fd, ptr, MtdBlockSize);
+		close(fd);
+		if(wrd<MtdBlockSize)
+		{
+			StoreLogMsg("write /mnt/FactoryDefaultConfig.bin NG\r\n");
+			free(ptr);
+			return 0;
+		}
+		StoreLogMsg("FactoryConfig write to file in /mnt OK.\r\n");
+	}
 
-    /*
-    * Flash memory write
-    */
-    if ((outType & OUTPUT_FLASH) > 0) {
-        // Save factory default setting value to flash factory default setting block
-        fd = open("/dev/mtdblock12", O_RDWR);
-        if (fd < 0) {
-            StoreLogMsg("open /dev/mtdblock12 NG\r\n");
-            free(ptr);
-            return 0;
-        }
-        wrd = write(fd, ptr, MtdBlockSize);
-        close(fd);
-        if (wrd < MtdBlockSize) {
-            StoreLogMsg("write /dev/mtdblock12 NG\r\n");
-            free(ptr);
-            return 0;
-        }
+	/*
+	* Flash memory write
+	*/
+	if((outType&OUTPUT_FLASH)>0)
+	{
+		// Save factory default setting value to flash factory default setting block
+		fd = open("/dev/mtdblock12", O_RDWR);
+		if (fd < 0)
+		{
+			StoreLogMsg("open /dev/mtdblock12 NG\r\n");
+			free(ptr);
+			return 0;
+		}
+		wrd=write(fd, ptr, MtdBlockSize);
+		close(fd);
+		if(wrd<MtdBlockSize)
+		{
+			StoreLogMsg("write /dev/mtdblock12 NG\r\n");
+			free(ptr);
+			return 0;
+		}
 
-        // Save factory default setting value to flash backup setting block
-        fd = open("/dev/mtdblock11", O_RDWR);
-        if (fd < 0) {
-            StoreLogMsg("open /dev/mtdblock11 NG\r\n");
-            free(ptr);
-            return 0;
-        }
-        wrd = write(fd, ptr, MtdBlockSize);
-        close(fd);
-        if (wrd < MtdBlockSize) {
-            StoreLogMsg("write /dev/mtdblock11 NG\r\n");
-            free(ptr);
-            return 0;
-        }
+		// Save factory default setting value to flash backup setting block
+		fd = open("/dev/mtdblock11", O_RDWR);
+		if (fd < 0)
+		{
+			StoreLogMsg("open /dev/mtdblock11 NG\r\n");
+			free(ptr);
+			return 0;
+		}
+		wrd=write(fd, ptr, MtdBlockSize);
+		close(fd);
+		if(wrd<MtdBlockSize)
+		{
+			StoreLogMsg("write /dev/mtdblock11 NG\r\n");
+			free(ptr);
+			return 0;
+		}
 
-        // Save factory default setting value to flash setting block
-        fd = open("/dev/mtdblock10", O_RDWR);
-        if (fd < 0) {
-            StoreLogMsg("open /dev/mtdblock10 NG\r\n");
-            free(ptr);
-            return 0;
-        }
-        wrd = write(fd, ptr, MtdBlockSize);
-        close(fd);
-        if (wrd < MtdBlockSize) {
-            StoreLogMsg("write /dev/mtdblock10 NG\r\n");
-            free(ptr);
-            return 0;
-        }
-        StoreLogMsg("FactoryConfig write to flash OK\r\n");
-    }
+		// Save factory default setting value to flash setting block
+		fd = open("/dev/mtdblock10", O_RDWR);
+		if (fd < 0)
+		{
+			StoreLogMsg("open /dev/mtdblock10 NG\r\n");
+			free(ptr);
+			return 0;
+		}
+		wrd=write(fd, ptr, MtdBlockSize);
+		close(fd);
+		if(wrd<MtdBlockSize)
+		{
+			StoreLogMsg("write /dev/mtdblock10 NG\r\n");
+			free(ptr);
+			return 0;
+		}
+		StoreLogMsg("FactoryConfig write to flash OK\r\n");
+	}
 
-    free(ptr);
+	free(ptr);
 
-    return FAIL;
+	return FAIL;
 }
 

+ 24 - 31
EVSE/Projects/DD360Audi/Apps/Makefile

@@ -8,6 +8,7 @@ OutputPath = ../output
 DEFINE = -D $(Project)
 
 CFLAGS = -O0 -g3 -Wall -c -fmessage-length=0
+TFLAGS = -lrt -lm -lpthread
 
 #define library variable
 Internal485ProtocolLib = -L $(ModularizationPath)/Internal485Protocol -lInternal485Protocol
@@ -33,69 +34,61 @@ apps: MainTask DoCommTask EvCommTask \
 			PrimaryCommTask ReadCmdlineTask UnsafetyOutputTool \
 				FactoryConfigApp OtherTools CleanExec
 
+LOG_INC = Log
+
 MainTask:
-	rm -f main;
-	$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(CFLAGS) -o main.o main.c
-	$(CC) $(DEFINE) $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(CFLAGS) -o timeout.o timeout.c
-	$(CC) -o main main.o timeout.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3}
+	$(CC) -D $(Project) -includeConfig.h $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(CFLAGS) -o main.o ReMain.c
+	$(CC) -D $(Project) -includeConfig.h $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(CFLAGS) -o timeout.o timeout.c
+	$(CC) $(TFLAGS) -o main main.o timeout.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3}
 
 DoCommTask:
-	rm -f DoComm;
-	$(CC) $(DEFINE) $(CFLAGS) -o ReDoComm.o ReDoComm.c
-	$(CC) -o DoComm ReDoComm.o
+	$(CC) -D $(Project) -includeConfig.h $(CFLAGS) -o DoComm.o ReDoComm.c
+	$(CC) -o DoComm DoComm.o
 
 EvCommTask:
-	rm -f Module_EvComm;
-	$(CC) $(DEFINE) $(CFLAGS) -o Ev_Comm.o Ev_Comm.c
-	$(CC) $(DEFINE) $(CFLAGS) -o Module_EvComm.o Module_EvComm.c
+	$(CC) -D $(Project) -includeConfig.h $(CFLAGS) -o Ev_Comm.o Ev_Comm.c
+	$(CC) -D $(Project) -includeConfig.h $(CFLAGS) -o Module_EvComm.o ReModule_EvComm.c
 	$(CC) -o Module_EvComm Ev_Comm.o Module_EvComm.o
 
 EventLoggingTask:
-	rm -f Module_EventLogging;
-	$(CC) $(DEFINE) $(CFLAGS) -o Module_EventLogging.o Module_EventLogging.c
-	$(CC) -o Module_EventLogging Module_EventLogging.o
+	$(CC) -D $(Project) -includeConfig.h $(SQLite3_H) $(CFLAGS) -o Module_EventLogging.o ReModule_EventLogging.c
+	$(CC) -o Module_EventLogging Module_EventLogging.o ${Lib_SQLite3}
 
 InternalCommTask:
-	rm -f Module_InternalComm;
-	$(CC) $(DEFINE) $(CFLAGS) -o internalComm.o internalComm.c
-	$(CC) $(DEFINE) $(CFLAGS) -o Module_InternalComm.o Module_InternalComm.c
+	$(CC) -D $(Project) -includeConfig.h $(CFLAGS) -o internalComm.o internalComm.c
+	$(CC) -D $(Project) -includeConfig.h $(CFLAGS) -o Module_InternalComm.o ReModule_InternalComm.c
 	$(CC) -o Module_InternalComm Module_InternalComm.o internalComm.o
 
 LcmControlTask:
-	rm -f Module_LcmControl;
-	$(CC) $(DEFINE) $(CFLAGS) -o Module_LcmControl.o Module_LcmControl.c
+	$(CC) -D $(Project) -includeConfig.h $(CFLAGS) -o Module_LcmControl.o ReModule_LcmControl.c
 	$(CC) -o Module_LcmControl Module_LcmControl.o
 
 PrimaryCommTask:
-	rm -f Module_PrimaryComm;
-	$(CC) $(DEFINE) $(CFLAGS) -o Module_PrimaryComm.o Module_PrimaryComm.c
-	$(CC) $(DEFINE) $(CFLAGS) -o PrimaryComm.o PrimaryComm.c
+	$(CC) -D $(Project) -includeConfig.h $(CFLAGS) -o Module_PrimaryComm.o ReModule_PrimaryComm.c
+	$(CC) -D $(Project) -includeConfig.h $(CFLAGS) -o PrimaryComm.o PrimaryComm.c
 	$(CC) -o Module_PrimaryComm Module_PrimaryComm.o PrimaryComm.o
 
 PsuCommTask:
-	rm -f Module_PsuComm;
-	$(CC) $(DEFINE) $(InfypwrPsuComm_H) $(CFLAGS) -o Module_PsuComm.o Module_PsuComm.c
+	$(CC) -D $(Project) $(InfypwrPsuComm_H) -includeConfig.h $(CFLAGS) -o Module_PsuComm.o Module_PsuComm.c
 	$(CC) -o Module_PsuComm Module_PsuComm.o $(InfypwrPsuComm_A)
 
 ReadCmdlineTask:
-	rm -f ReadCmdline;
-	$(CC) $(DEFINE) $(CFLAGS) -o ReadCmdline.o ReadCmdline.c
+	$(CC) -D $(Project) -includeConfig.h $(CFLAGS) -o ReadCmdline.o ReadCmdline.c
 	$(CC) -o ReadCmdline ReadCmdline.o
 
 UnsafetyOutputTool:
-	rm -f UnsafetyOutputTask;
-	$(CC) $(DEFINE) $(InfypwrPsuComm_H) $(CFLAGS) -o OutputTask.o OutputTask.c
+	$(CC) -D $(Project) $(InfypwrPsuComm_H) $(CFLAGS) -o OutputTask.o OutputTask.c
 	$(CC) -o UnsafetyOutputTask OutputTask.o $(InfypwrPsuComm_A)
 
 FactoryConfigApp:
 	@echo "===== Module_FactoryConfig_Task =================================="
 	rm -f FactoryConfig
-#	gcc $(DEFINE) "-I../../" -o FactoryConfig "./FactoryConfig.c"
+#	gcc -D $(Project) "-I../../" -o FactoryConfig "./FactoryConfig.c"
 #	mkdir -p /Storage/SystemLog
 #	./FactoryConfig -f;true
 #	cp /mnt/FactoryDefaultConfig.bin ../Images
 #	rm -f FactoryConfig;
-	$(CC) $(DEFINE) $(CFLAGS) -o FactoryConfig.o FactoryConfig.c
+	$(CC) -D $(Project) $(CFLAGS) -o FactoryConfig.o FactoryConfig.c
 	$(CC) -o FactoryConfig FactoryConfig.o
 
 OtherTools:
@@ -131,8 +124,8 @@ OtherTools:
 	cp -f FactoryConfig $(OutputPath)
 
 CopyFile:
-	rm -rfv $(RootPath)
-	mkdir -p $(RootPath)
+	rm -rfv ../Images/root
+	mkdir -p ../Images/root
 
 CleanExec:
 	rm -f *.o

+ 72 - 101
EVSE/Projects/DD360Audi/Apps/Module_EvComm.c

@@ -1,37 +1,35 @@
-#include <sys/time.h>
-#include <sys/timeb.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/shm.h>
-#include <sys/mman.h>
-#include <linux/can.h>
-#include <linux/can/raw.h>
-#include <linux/wireless.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdio.h>      /*璅蹱�頛詨�頛詨枂摰𡁶儔*/
-#include <stdlib.h>     /*璅蹱��賣彍摨怠�蝢�*/
-#include <unistd.h>     /*Unix 璅蹱��賣彍摰𡁶儔*/
-#include <fcntl.h>      /*瑼娍綉�嗅�蝢�*/
-#include <termios.h>    /*PPSIX 蝯�垢�批�摰𡁶儔*/
-#include <errno.h>      /*�航炊�笔�蝢�*/
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <ctype.h>
-#include <ifaddrs.h>
-
-#include "../../define.h"
-#include "Module_EvComm.h"
-#include "Config.h"
+#include    <sys/time.h>
+#include    <sys/timeb.h>
+#include    <sys/types.h>
+#include    <sys/stat.h>
+#include    <sys/types.h>
+#include    <sys/ioctl.h>
+#include    <sys/socket.h>
+#include    <sys/ipc.h>
+#include    <sys/shm.h>
+#include    <sys/shm.h>
+#include    <sys/mman.h>
+#include    <linux/can.h>
+#include    <linux/can/raw.h>
+#include    <linux/wireless.h>
+#include    <arpa/inet.h>
+#include    <netinet/in.h>
+
+#include    <unistd.h>
+#include    <stdarg.h>
+#include    <stdio.h>      /*標準輸入輸出定義*/
+#include    <stdlib.h>     /*標準函數庫定義*/
+#include    <unistd.h>     /*Unix 標準函數定義*/
+#include    <fcntl.h>      /*檔控制定義*/
+#include    <termios.h>    /*PPSIX 終端控制定義*/
+#include    <errno.h>      /*錯誤號定義*/
+#include    <errno.h>
+#include    <string.h>
+#include    <time.h>
+#include    <ctype.h>
+#include    <ifaddrs.h>
+#include    "../../define.h"
+#include    "Module_EvComm.h"
 
 #define ARRAY_SIZE(A)       (sizeof(A) / sizeof(A[0]))
 #define PASS                1
@@ -63,16 +61,16 @@ float _outCur_1 = 0;
 float _outVol_2 = 0;
 float _outCur_2 = 0;
 
-// �𣂼���憭批��駁𤓖憯橒��䭾�銝滚� type 瑽滨�靘����
+// 限制最大充電電壓,因應不同 type 槍線來限制
 // Chademo : 500V, 125A,
 // GB : 750, 120A
 // CCS : 950V, 120A
-float maxChargingVol[2] = { 9500, 9500 };           // �𣂼���憭批��駁𤓖憯橒�憒���扳芋憛𠰴�憛思� 0
-// �𣂼���憭批��駁𤓖瘚���賡��誯� Web
-float maxChargingCur[2] = { 5000, 2000 };           // �𣂼���憭批��駁𤓖瘚��憒���扳芋憛𠰴�憛思� 0
-float maxChargingPow = 0;                           // �𣂼���憭批��餉��𧶏�憒���扳芋憛𠰴�憛思� 0
+float maxChargingVol[2] = { 5000, 9500 };           // 限制最大充電電壓,如依照模塊則填上 0
+// 限制最大充電電流與能量透過 Web
+float maxChargingCur[2] = { 5000, 1200 };           // 限制最大充電電流,如依照模塊則填上 0
+float maxChargingPow = 0;                           // 限制最大充電能量,如依照模塊則填上 0
 
-// 瑽滩�閮�
+// 槍資訊
 struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
 struct Ev_Board_Cmd Ev_Cmd = {
@@ -1016,13 +1014,8 @@ void ClearAbnormalStatus_CCS(byte gun_index)
         return;
     }
 
-    if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "012219", 6) == EQUAL &&
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP == YES) {
-        memcpy(code, "012219", 6);
-        memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
-        isCleanCheck = true;
-    } else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023701", 6) == EQUAL &&
-               ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail == YES) {
+    if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023701", 6) == EQUAL &&
+            ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail == YES) {
         memcpy(code, "023701", 6);
         memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
         isCleanCheck = true;
@@ -1736,7 +1729,6 @@ void ClearAbnormalStatus_CCS(byte gun_index)
             if (index != gun_index || ShmSysConfigAndInfo->SysConfig.TotalConnectorCount == 1) {
                 PRINTF_FUNC("CCS clean error : index = %d, EvConnAlarmCode = %s, code = %s \n", index, _chargingData[index]->EvConnAlarmCode, code);
                 if (strncmp((char *)_chargingData[index]->EvConnAlarmCode, code, 6) != EQUAL) {
-                    if (strncmp(code, "012219", 6) == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP = NO; }
                     if (strncmp(code, "023701", 6) == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = NO; }
                     if (strncmp(code, "023737", 6) == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsRESTemperatureInhibit = NO; }
                     if (strncmp(code, "023738", 6) == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVShiftPosition = NO; }
@@ -1897,10 +1889,6 @@ void AbnormalStopAnalysis(byte gun_index, byte *errCode)
 
     memcpy(_chargingData[gun_index]->EvConnAlarmCode, string, 6);
     PRINTF_FUNC("NOTIFICATION_EV_STOP : EvConnAlarmCode = %s \n", _chargingData[gun_index]->EvConnAlarmCode);
-    //OVP error
-    if (strcmp(string, "012217") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChademoOutputOVP = YES; }
-    if (strcmp(string, "012219") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP = YES; }
-    if (strcmp(string, "012221") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemGbOutputOVP = YES; }
 
     if (strcmp(string, "023700") == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvCommFail = YES; }
     if (strcmp(string, "023704") == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryMalfun = YES; }
@@ -2154,7 +2142,7 @@ void CANReceiver()
         struct can_frame frame;
         int intCmd;
 
-        // 瑽滩�閮�
+        // 槍資訊
         struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
         struct timeval _cmd_ack_timeout[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
@@ -2277,22 +2265,9 @@ void CANReceiver()
                 break;
                 case ACK_GET_OUTPUT_REQ: {
                     _chargingData[targetGun]->EvBatterySoc = frame.data[1];
-
-                    //Jerry add set voltage limit
                     _chargingData[targetGun]->EvBatterytargetVoltage = (float)((frame.data[3] << 8) + frame.data[2]) / 10;
-                    if (_chargingData[targetGun]->EvBatterytargetVoltage > maxChargingVol[targetGun] * 0.1) {
-                        _chargingData[targetGun]->EvBatterytargetVoltage = maxChargingVol[targetGun] * 0.1;
-                    }
-                    //printf("id = %d, EvBatterytargetVoltage = %.2f\r\n", targetGun, _chargingData[targetGun]->EvBatterytargetVoltage);
-                    //Jerry add set currency limit
                     _chargingData[targetGun]->EvBatterytargetCurrent = (float)((frame.data[5] << 8) + frame.data[4]) / 10;
-                    if (_chargingData[targetGun]->EvBatterytargetCurrent > maxChargingCur[targetGun] * 0.1) {
-                        _chargingData[targetGun]->EvBatterytargetCurrent = maxChargingCur[targetGun] * 0.1;
-                    }
-                    //printf("id = %d, EvBatterytargetCurrent = %.2f\r\n", targetGun, _chargingData[targetGun]->EvBatterytargetCurrent);
-
                     _chargingData[targetGun]->RemainChargingDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
-                    //printf("RemainChargingDuration = %d\r\n",  _chargingData[targetGun]->RemainChargingDuration);
 
                     if (_chargingData[targetGun]->Type == _Type_Chademo) {
                         //if (ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].EvDetection != frame.data[0])
@@ -2380,7 +2355,7 @@ void CANReceiver()
                 }
                 break;
                 case NOTIFICATION_EV_STOP: {
-                    // 頠羓垢閬���𨀣迫
+                    // 車端要求停止
                     // frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
                     PRINTF_FUNC("(%d) NOTIFICATION_EV_STOP err level = %d-----------------------------\n", targetGun, frame.data[0]);
                     //if (frame.data[0] == 0x02)
@@ -2403,9 +2378,9 @@ void CANReceiver()
 //================================================
 // Main process
 //================================================
-// 瑼X䰻 Byte 銝剜��� Bit ����
-// _byte : 甈脫㺿霈羓� byte
-// _bit : 閰� byte ��洵撟曉�� bit
+// 檢查 Byte 中某個 Bit 的值
+// _byte : 欲改變的 byte
+// _bit : 該 byte 的第幾個 bit
 unsigned char EvDetectionStatus(unsigned char _byte, unsigned char _bit)
 {
     return ( _byte & mask_table[_bit] ) != 0x00;
@@ -2443,28 +2418,24 @@ void SetPresentChargingOutputCap(struct ChargingInfoData *chargingData_1, struct
 {
     float pow1 = 0, cur1 = 0;
     float pow2 = 0, cur2 = 0;
-
-#if !defined DD360 && !defined DD360Audi
     float vol = 0;
-#endif //!defined DD360 && !defined DD360Audi
 
     pow1 = chargingData_1->AvailableChargingPower;
     cur1 = chargingData_1->AvailableChargingCurrent;
 
-#if !defined DD360 && !defined DD360Audi
     vol = chargingData_1->MaximumChargingVoltage;
+#ifndef DD360
     GetMaxVolAndCurMethod(chargingData_1->Index, &vol, &cur1);
     GetMaxPowerMethod(chargingData_1->Index, &pow1);
-#endif //!defined DD360 && !defined DD360Audi
+#endif
 
     pow2 = chargingData_2->AvailableChargingPower;
     cur2 = chargingData_2->AvailableChargingCurrent;
-
-#if !defined DD360 && !defined DD360Audi
     vol = chargingData_2->MaximumChargingVoltage;
+#ifndef DD360
     GetMaxVolAndCurMethod(chargingData_2->Index, &vol, &cur2);
     GetMaxPowerMethod(chargingData_2->Index, &pow2);
-#endif //!defined DD360 && !defined DD360Audi
+#endif
 
     if (_pow_1 != pow1 ||
             _cur_1 != cur1 ||
@@ -2674,7 +2645,7 @@ int main(int argc, char *argv[])
     while (CanFd) {
         for (byte _index = 0; _index < gun_count; _index++) {
             if (priorityLow == 1) {
-                // �芸�甈𡃏�雿� - �芾��匧��匧朖銝齿��滩岷��
+                // 優先權較低 - 只要有回應即不會再詢問
                 if (_chargingData[_index]->Type == _Type_Chademo &&
                         ShmCHAdeMOData->evse[_chargingData[_index]->type_index].SelfTest_Comp != PASS) {
                     SyncRtcInfo(_index, _chargingData[_index]->Evboard_id, (int)rtc);
@@ -2691,7 +2662,7 @@ int main(int argc, char *argv[])
                     }
                 }
 
-                // �箏�閬��敺㛖�鞈�� : 1.瑽漤�����, 2."Connector 1" 皞怠漲, 3."Connector 2" 皞怠漲, 4.Pilot Voltage
+                // 固定要取得的資訊 : 1.槍鎖狀態, 2."Connector 1" 溫度, 3."Connector 2" 溫度, 4.Pilot Voltage
                 //PRINTF_FUNC("GetMiscellaneousInfo. index = %d, Eid = %d \n", _index, _chargingData[_index]->Evboard_id);
                 GetMiscellaneousInfo(_index,
                                      _chargingData[_index]->RelayK1K2Status,
@@ -2730,7 +2701,7 @@ int main(int argc, char *argv[])
                 }
                 break;
             case S_PREPARNING: {
-                // 閮剖��嗅�頛詨枂
+                // 設定當前輸出
                 if (gun_count == 1) {
                     SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
                 } else if (gun_count == 2) {
@@ -2741,7 +2712,7 @@ int main(int argc, char *argv[])
             }
             break;
             case S_PREPARING_FOR_EV: {
-                // �见�蝣箄�頠羓垢�臬炏�峕��见���𤓖 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
+                // 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
                 GetOutputReq(_index, _chargingData[_index]->Evboard_id);
 
 //                  PRINTF_FUNC("PresentChargingVoltage = %f \n", _chargingData[_index]->PresentChargingVoltage);
@@ -2750,7 +2721,7 @@ int main(int argc, char *argv[])
 //                  PRINTF_FUNC("AvailableChargingCurrent = %f \n", _chargingData[_index]->AvailableChargingCurrent);
 //                  PRINTF_FUNC("MaximumChargingVoltage = %f \n", _chargingData[_index]->MaximumChargingVoltage);
 
-                // 閮剖��嗅�頛詨枂
+                // 設定當前輸出
                 if (gun_count == 1) {
                     SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
                 } else if (gun_count == 2) {
@@ -2759,7 +2730,7 @@ int main(int argc, char *argv[])
 
                 if (priorityLow == 1) {
                     float maxVol, maxCur;
-                    // 璅�垢頛詨枂�賢�
+                    // 樁端輸出能力
                     maxVol = _chargingData[_index]->MaximumChargingVoltage;
                     maxCur = _chargingData[_index]->AvailableChargingCurrent;
 
@@ -2775,7 +2746,7 @@ int main(int argc, char *argv[])
                                           maxVol,
                                           _chargingData[_index]->Evboard_id);
 
-                    // �硋�頠羓垢�餅�鞈�� : 1.AC or DC ? 2.Total battery cap, 3.Max battery vol, 4.Max battery cur
+                    // 取得車端電池資訊 : 1.AC or DC ? 2.Total battery cap, 3.Max battery vol, 4.Max battery cur
                     GetEvBatteryInfo(_index, _chargingData[_index]->Evboard_id);
                 }
                 gettimeofday(&_chk_ratingPower_timeout[_index], NULL);
@@ -2784,10 +2755,10 @@ int main(int argc, char *argv[])
             case S_PREPARING_FOR_EVSE:
             case S_CCS_PRECHARGE_ST0:
             case S_CCS_PRECHARGE_ST1: {
-                // �见�蝣箄�頠羓垢�臬炏�峕��见���𤓖
+                // 開始確認車端是否同意開始充電
                 GetOutputReq(_index, _chargingData[_index]->Evboard_id);
 
-                // 閮剖��嗅�頛詨枂
+                // 設定當前輸出
                 if (gun_count == 1) {
                     SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
                 } else if (gun_count == 2) {
@@ -2795,16 +2766,16 @@ int main(int argc, char *argv[])
                 }
 
                 if (priorityLow % 5 == 1) {
-                    // 璅�垢頛詨枂�賢��寡�
+                    // 樁端輸出能力改變
                     if (gun_count == 1) {
                         SetPresentChargingOutputCap(_chargingData[0], _chargingData[0]);
                     } else if (gun_count == 2) {
                         SetPresentChargingOutputCap(_chargingData[0], _chargingData[1]);
                     }
                 }
-                // ����𡁶䰻 Isolation 皜祈岫����
+                // 持續通知 Isolation 測試狀態
                 if (priorityLow == 1) {
-                    // �� 500 V 憒���其�蝘㘾��� GFD �賜泵��� PASS
+                    // 拉 500 V 如果在一秒鐘內 GFD 都符合則 PASS
 //                      if (_chargingData[_index]->FireChargingVoltage >= 3500)
 //                          _chargingData[_index]->GroundFaultStatus = GFD_PASS;
 
@@ -2814,7 +2785,7 @@ int main(int argc, char *argv[])
                         //if ((GetTimeoutValue(_derating_time) / 1000) > 1000)
                         unsigned char _result = _chargingData[_index]->GroundFaultStatus;
 
-                        // GB & Chademo ~ Warning 銋笔�蝞� Pass嚗���� CCS 隤滩���� Warning ����舀凒��
+                        // GB & Chademo ~ Warning 也先算 Pass,因為 CCS 認證會驗 Warning 故不可更動
                         if (_chargingData[_index]->Type == _Type_Chademo ||
                                 _chargingData[_index]->Type == _Type_GB) {
                             if (_result == GFD_WARNING) {
@@ -2845,7 +2816,7 @@ int main(int argc, char *argv[])
             }
             break;
             case S_CHARGING: {
-                // 閮�� Power
+                // 計算 Power
                 _chargingData[_index]->PresentChargingPower = ((float)((_chargingData[_index]->PresentChargingVoltage) * (_chargingData[_index]->PresentChargingCurrent)) / 1000);
 
                 if (chargingTime[_index] == 0 ||
@@ -2866,10 +2837,10 @@ int main(int argc, char *argv[])
                     }
                 }
 
-                // �见�蝣箄�頠羓垢�臬炏�峕��见���𤓖
+                // 開始確認車端是否同意開始充電
                 GetOutputReq(_index, _chargingData[_index]->Evboard_id);
 
-                // 閮剖��嗅�頛詨枂
+                // 設定當前輸出
                 if (gun_count == 1) {
                     SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
                 } else if (gun_count == 2) {
@@ -2878,7 +2849,7 @@ int main(int argc, char *argv[])
 
                 // for test end
                 if (priorityLow % 5 == 0) {
-                    // 璅�垢頛詨枂�賢��寡�
+                    // 樁端輸出能力改變
                     if (gun_count == 1) {
                         SetPresentChargingOutputCap(_chargingData[0], _chargingData[0]);
                     } else if (gun_count == 2) {
@@ -2892,7 +2863,7 @@ int main(int argc, char *argv[])
                     SetIsolationStatus(_index, _chargingData[_index]->GroundFaultStatus, _chargingData[_index]->Evboard_id);
                 }
 
-                // GFD 憭望��漤�𡁶䰻
+                // GFD 失敗再通知
                 if (priorityLow == 1) {
                     if (_chargingData[_index]->Type == _Type_CCS_2 &&
                             _chargingData[_index]->PrechargeStatus == PRECHARGE_READY) {
@@ -2902,14 +2873,14 @@ int main(int argc, char *argv[])
             }
             break;
             case S_TERMINATING: {
-                // 閮剖��嗅�頛詨枂
+                // 設定當前輸出
                 if (gun_count == 1) {
                     SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
                 } else if (gun_count == 2) {
                     SetPresentChargingOutputPower(_chargingData[0], _chargingData[1]);
                 }
 
-                // 瑽漤���銁嚗��隞�”�舀�蝡航�瘙���𨀣迫
+                // 槍鎖還在,則代表是樁端要求的停止
                 if (_chargingData[_index]->GunLocked == START ||
                         _chargingData[_index]->Type == _Type_CCS_2) {
                     byte normalStop = 0x01;
@@ -2930,7 +2901,7 @@ int main(int argc, char *argv[])
             }
             break;
             case S_COMPLETE: {
-                // 閮剖��嗅�頛詨枂
+                // 設定當前輸出
                 if (gun_count == 1) {
                     SetPresentChargingOutputPower(_chargingData[0], _chargingData[0]);
                 } else if (gun_count == 2) {
@@ -2940,7 +2911,7 @@ int main(int argc, char *argv[])
                 if (priorityLow == 1) {
                     float maxVol, maxCur;
 
-                    // 璅�垢頛詨枂�賢�
+                    // 樁端輸出能力
                     maxVol = _chargingData[_index]->MaximumChargingVoltage;
                     maxCur = _chargingData[_index]->AvailableChargingCurrent;
 
@@ -2956,7 +2927,7 @@ int main(int argc, char *argv[])
             }
         }
         priorityLow >= 20 ? priorityLow = 1 : priorityLow++;
-        usleep(45000); //EV 撠𤩺踎�朞� (50 ms)
+        usleep(45000); //EV 小板通訊 (50 ms)
     }
     DEBUG_INFO("Module_EvComm : Can-bus port = %d \n", CanFd);
     return FAIL;

+ 52 - 43
EVSE/Projects/DD360Audi/Apps/Module_EvComm.h

@@ -1,41 +1,39 @@
 #ifndef MODULE_EVCOMM_H_
 #define MODULE_EVCOMM_H_
 
-#include 	<stdbool.h>
+#include    <stdbool.h>
 
 int CanFd;
 
-typedef unsigned char 		byte;
+typedef unsigned char       byte;
 
-extern struct Ev_Board_Cmd
-{
-	int none;							// 0
-	int address_assignment;				// 0x00000200
-	int get_firmware_ver;				// 0x00000400
-	int get_hardware_ver;				// 0x00000500
-	int charging_permission;			// 0x00000600
-	int present_output_power;			// 0x00000700
-	int present_output_cap;				// 0x00000800
-	int get_output_req;					// 0x00000900
-	int get_battery_info;				// 0x00000A00
-	int evse_stop_charging;				// 0x00000C00
-	int get_miscellaneous_info;			// 0x00000D00
+extern struct Ev_Board_Cmd {
+    int none;                           // 0
+    int address_assignment;             // 0x00000200
+    int get_firmware_ver;               // 0x00000400
+    int get_hardware_ver;               // 0x00000500
+    int charging_permission;            // 0x00000600
+    int present_output_power;           // 0x00000700
+    int present_output_cap;             // 0x00000800
+    int get_output_req;                 // 0x00000900
+    int get_battery_info;               // 0x00000A00
+    int evse_stop_charging;             // 0x00000C00
+    int get_miscellaneous_info;         // 0x00000D00
 
-	int download_req;					// 0x00000E00
-	int start_block_transfer;			// 0x00000F00
-	int data_transfer;					// 0x00001000
-	int download_finish;				// 0x00001100
+    int download_req;                   // 0x00000E00
+    int start_block_transfer;           // 0x00000F00
+    int data_transfer;                  // 0x00001000
+    int download_finish;                // 0x00001100
 
-	int isolation_status;				// 0x00001200
-	int sync_rtc_info;					// 0x00001400
-	int evse_precharge_info;			// 0x00001500
-}Ev_Cmd;
+    int isolation_status;               // 0x00001200
+    int sync_rtc_info;                  // 0x00001400
+    int evse_precharge_info;            // 0x00001500
+} Ev_Cmd;
 
-extern struct Ev_Cmd_Dir
-{
-	unsigned short master_to_slave;
-	unsigned short slave_to_master;
-}Ev_Dir;
+extern struct Ev_Cmd_Dir {
+    unsigned short master_to_slave;
+    unsigned short slave_to_master;
+} Ev_Dir;
 
 struct timeval _id_assign_time;
 
@@ -53,27 +51,38 @@ void GetEvBatteryInfo(byte gun_index, byte toId);
 void GetMiscellaneousInfo(byte gun_index, byte relayStatus, float power, float voltage, byte toId);
 void SetIsolationStatus(byte gun_index, byte result, byte toId);
 void SetEvsePrechargeInfo(byte gun_index, byte result, byte toId);
-// µo°e¹q¼Î¥D°Ê°±¤î¥R¹qµ²ªG¤Î­ì¦]
+// 發�電�主動�止充電�果�原因
 void EvseStopChargingEvent(byte stopResult, byte *stopReason, byte toId);
 
 // Receive msg From can-bus.
 
-enum Receieve_PSU_msgf
-{
-	// ¨®ºÝ¥D°Ê
-	ADDRESS_REQ = 						0x080001FF,
-	NOTIFICATION_EV_STATUS = 			0x08000300,
-	NOTIFICATION_EV_STOP = 				0x08000B00,
+enum Receieve_PSU_msgf {
+    // 車端主動
+    ADDRESS_REQ =                       0x080001FF,
+    NOTIFICATION_EV_STATUS =            0x08000300,
+    NOTIFICATION_EV_STOP =              0x08000B00,
 
-	// ¨®ºÝ¦^À³
-	ACK_EV_FW_VERSION = 				0x08000400,
-	ACK_EV_HW_VERSION = 				0x08000500,
-	ACK_GET_OUTPUT_REQ =				0x08000900,
-	ACK_GET_EV_BATTERY_INFO =			0x08000A00,
-	ACK_GET_MISCELLANEOUS_INFO = 		0x08000D00,
-	ACK_EVSE_ISOLATION_STATUS = 		0x08001200,
-	ACK_EVSE_PRECHAGE_INFO = 			0x08001500,
+    // 車端回應
+    ACK_EV_FW_VERSION =                 0x08000400,
+    ACK_EV_HW_VERSION =                 0x08000500,
+    ACK_GET_OUTPUT_REQ =                0x08000900,
+    ACK_GET_EV_BATTERY_INFO =           0x08000A00,
+    ACK_GET_MISCELLANEOUS_INFO =        0x08000D00,
+    ACK_EVSE_ISOLATION_STATUS =         0x08001200,
+    ACK_EVSE_PRECHAGE_INFO =            0x08001500,
 };
 
+//DS60-120 add
+enum EV_LOG_INDEX {
+    EV_LOG_OUTPUT_CAP_POW = 0,
+    EV_LOG_OUTPUT_CAP_CUR = 1,
+    EV_LOG_NOW_OUTPUT_VOL = 2,
+    EV_LOG_NOW_OUTPUT_CUR = 3,
+    EV_LOG_EVSE_MAX_VOL =   4,
+    EV_LOG_EVSE_MAX_CUR =   5,
+    EV_LOG_MAX_BATT_VOL =   6,
+    EV_LOG_REAL_CAP_POW =   7,
+    EV_LOG_SOC =            8
+};
 #endif /* MODULE_EVCOMM_H_ */
 

+ 251 - 208
EVSE/Projects/DD360Audi/Apps/Module_EventLogging.c

@@ -1,41 +1,41 @@
-#include    <sys/time.h>
-#include    <sys/timeb.h>
+#include 	<sys/time.h>
+#include 	<sys/timeb.h>
 #include    <sys/types.h>
 #include    <sys/stat.h>
-#include    <sys/types.h>
-#include    <sys/ioctl.h>
-#include    <sys/socket.h>
-#include    <sys/ipc.h>
-#include    <sys/shm.h>
-#include    <sys/shm.h>
-#include    <sys/mman.h>
-#include    <linux/wireless.h>
-#include    <arpa/inet.h>
-#include    <netinet/in.h>
+#include 	<sys/types.h>
+#include 	<sys/ioctl.h>
+#include 	<sys/socket.h>
+#include 	<sys/ipc.h>
+#include 	<sys/shm.h>
+#include 	<sys/shm.h>
+#include 	<sys/mman.h>
+#include 	<linux/wireless.h>
+#include 	<arpa/inet.h>
+#include 	<netinet/in.h>
 
-#include    <unistd.h>
-#include    <stdarg.h>
-#include    <stdio.h>      /*璅蹱�頛詨�頛詨枂摰𡁶儔*/
-#include    <stdlib.h>     /*璅蹱��賣彍摨怠�蝢�*/
-#include    <unistd.h>     /*Unix 璅蹱��賣彍摰𡁶儔*/
-#include    <fcntl.h>      /*瑼娍綉�嗅�蝢�*/
-#include    <termios.h>    /*PPSIX 蝯�垢�批�摰𡁶儔*/
-#include    <errno.h>      /*�航炊�笔�蝢�*/
-#include    <errno.h>
-#include    <string.h>
-#include    <time.h>
-#include    <ctype.h>
-#include    <ifaddrs.h>
-#include    "../../define.h"
+#include 	<unistd.h>
+#include 	<stdarg.h>
+#include    <stdio.h>      /*標準輸入輸出定義*/
+#include    <stdlib.h>     /*標準函數庫定義*/
+#include    <unistd.h>     /*Unix 標準函數定義*/
+#include    <fcntl.h>      /*檔控制定義*/
+#include    <termios.h>    /*PPSIX 終端控制定義*/
+#include    <errno.h>      /*錯誤號定義*/
+#include 	<errno.h>
+#include 	<string.h>
+#include	<time.h>
+#include	<ctype.h>
+#include 	<ifaddrs.h>
+#include	"../../define.h"
 
-#define ARRAY_SIZE(A)       (sizeof(A) / sizeof(A[0]))
-#define PASS                1
-#define FAIL                -1
-#define YES                 1
-#define NO                  0
+#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
+#define PASS				1
+#define FAIL				-1
+#define YES					1
+#define NO					0
 
-struct SysConfigAndInfo         *ShmSysConfigAndInfo;
-struct StatusCodeData           *ShmStatusCodeData;
+struct SysConfigAndInfo			*ShmSysConfigAndInfo;
+struct StatusCodeData 			*ShmStatusCodeData;
 
 void PRINTF_FUNC(char *string, ...);
 
@@ -46,71 +46,74 @@ int StoreLogMsg(const char *fmt, ...);
 
 int StoreLogMsg(const char *fmt, ...)
 {
-    char Buf[4096 + 256];
-    char buffer[4096];
-    va_list args;
-    struct timeb  SeqEndTime;
-    struct tm *tm;
+	char Buf[4096+256];
+	char buffer[4096];
+	va_list args;
+	struct timeb  SeqEndTime;
+	struct tm *tm;
 
-    va_start(args, fmt);
-    int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-    va_end(args);
+	va_start(args, fmt);
+	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
+	va_end(args);
 
-    memset(Buf, 0, sizeof(Buf));
-    ftime(&SeqEndTime);
-    SeqEndTime.time = time(NULL);
-    tm = localtime(&SeqEndTime.time);
+	memset(Buf,0,sizeof(Buf));
+	ftime(&SeqEndTime);
+	SeqEndTime.time = time(NULL);
+	tm=localtime(&SeqEndTime.time);
 
-    if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES) {
-        sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
-                tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
-        printf("%s \n", Buf);
-    } else {
-        sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-                tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
-                buffer,
-                tm->tm_year + 1900, tm->tm_mon + 1);
-        system(Buf);
-    }
+	if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
+	{
+		sprintf(Buf,"%02d:%02d:%02d:%03d - %s",
+			tm->tm_hour,tm->tm_min,tm->tm_sec,SeqEndTime.millitm, buffer);
+		printf("%s \n", Buf);
+	}
+	else
+	{
+		sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
+			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,SeqEndTime.millitm,
+			buffer,
+			tm->tm_year+1900,tm->tm_mon+1);
+		system(Buf);
+	}
 
-    return rc;
+	return rc;
 }
 
 int DiffTimeb(struct timeb ST, struct timeb ET)
 {
-    //return milli-second
-    unsigned int StartTime, StopTime;
+	//return milli-second
+	unsigned int StartTime,StopTime;
 
-    StartTime = (unsigned int)ST.time;
-    StopTime = (unsigned int)ET.time;
-    return (StopTime - StartTime) * 1000 + ET.millitm - ST.millitm;
+	StartTime=(unsigned int)ST.time;
+	StopTime=(unsigned int)ET.time;
+	return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
 }
 
 void PRINTF_FUNC(char *string, ...)
 {
-    va_list args;
-    char buffer[4096];
-    va_start(args, string);
-    vsnprintf(buffer, sizeof(buffer), string, args);
-    va_end(args);
+	va_list args;
+	char buffer[4096];
+	va_start(args, string);
+	vsnprintf(buffer, sizeof(buffer), string, args);
+	va_end(args);
 
-    DEBUG_INFO("%s \n", buffer);
+	DEBUG_INFO("%s \n", buffer);
 }
 
 //=================================
 // Common routine
 //=================================
-char *getTimeString(void)
+char* getTimeString(void)
 {
-    char *result = malloc(21);
-    time_t timep;
-    struct tm *p;
-    time(&timep);
-    p = gmtime(&timep);
+	char *result=malloc(21);
+	time_t timep;
+	struct tm *p;
+	time(&timep);
+	p=gmtime(&timep);
 
-    sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900 + p->tm_year), (1 + p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
+	sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
 
-    return result;
+	return result;
 }
 
 //==========================================
@@ -118,35 +121,43 @@ char *getTimeString(void)
 //==========================================
 int InitShareMemory()
 {
-    int result = PASS;
-    int MeterSMId;
+	int result = PASS;
+	int MeterSMId;
 
-    //creat ShmSysConfigAndInfo
-    if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0) {
-#ifdef SystemLogMessage
-        DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
-#endif
-        result = FAIL;
-    } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-#ifdef SystemLogMessage
-        DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
-#endif
-        result = FAIL;
-    } else
+	//creat ShmSysConfigAndInfo
+	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0)
+    {
+		#ifdef SystemLogMessage
+		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
+		#endif
+		result = FAIL;
+	}
+    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+    	#ifdef SystemLogMessage
+    	DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
+		#endif
+    	result = FAIL;
+   	 }
+    else
     {}
 
-    //creat ShmStatusCodeData
-    if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0) {
-#ifdef SystemLogMessage
-        DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
-#endif
-        result = FAIL;
-    } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-#ifdef SystemLogMessage
-        DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
-#endif
-        result = FAIL;
-    } else
+   	 //creat ShmStatusCodeData
+   	 if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0)
+    {
+		#ifdef SystemLogMessage
+   		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
+		#endif
+   		result = FAIL;
+	}
+    else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+    	#ifdef SystemLogMessage
+    	DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
+		#endif
+    	result = FAIL;
+   	}
+    else
     {}
 
     return result;
@@ -157,125 +168,157 @@ int InitShareMemory()
 //================================================
 void AddFaultCodeToBuf(unsigned char *Code)
 {
-    if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount < 10) {
-        memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[ShmSysConfigAndInfo->SysWarningInfo.WarningCount][0], Code, 7);
-        ShmSysConfigAndInfo->SysWarningInfo.WarningCount++;
-    }
+	if(ShmSysConfigAndInfo->SysWarningInfo.WarningCount < 10)
+	{
+		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[ShmSysConfigAndInfo->SysWarningInfo.WarningCount][0], Code, 7);
+		ShmSysConfigAndInfo->SysWarningInfo.WarningCount++;
+	}
 }
 
 void RemoveFaultCodeToBuf(unsigned char *Code)
 {
-    unsigned char find = 0x01;
-    char _code[7];
-    sprintf(_code, "%s", Code);
+	unsigned char find = 0x01;
+	char _code[7];
+	sprintf(_code,"%s", Code);
 
-    // �羓㮾�𦦵��航炊蝣潔�甈∠宏�歹��踹��滩�憿舐內
-    while (find) {
-        find = 0x00;
-        for (unsigned char i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
-            if (find == 0x00) {
-                if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], _code, 7) == 0) {
-                    find = 0x01;
-                }
-            } else {
-                memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i - 1][0],
-                       &ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], 7);
-            }
-        }
+	// 把相關的錯誤碼一次移除,避免重複顯示
+	while(find)
+	{
+		find = 0x00;
+		for(unsigned char i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++)
+		{
+			if (find == 0x00)
+			{
+				if(memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], _code, 7) == 0)
+				{
+					find = 0x01;
+				}
+			}
+			else
+			{
+				memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i - 1][0],
+					&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], 7);
+			}
+		}
 
-        if (find) {
-            ShmSysConfigAndInfo->SysWarningInfo.WarningCount--;
-        }
-    }
+		if (find)
+		{
+			ShmSysConfigAndInfo->SysWarningInfo.WarningCount--;
+		}
+	}
 }
 
 int main(void)
 {
-    int ByteCount, BitCount;
-    unsigned char tmp, EventCodeTmp[7];
+	int ByteCount,BitCount;
+	unsigned char tmp, EventCodeTmp[7];
 
-    if (InitShareMemory() == FAIL) {
-#ifdef SystemLogMessage
-        DEBUG_ERROR("InitShareMemory NG\n");
-#endif
-        if (ShmStatusCodeData != NULL) {
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
-        }
-        sleep(5);
-        return 0;
-    }
+	if(InitShareMemory() == FAIL)
+	{
+		#ifdef SystemLogMessage
+		DEBUG_ERROR("InitShareMemory NG\n");
+		#endif
+		if(ShmStatusCodeData!=NULL)
+		{
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
+		}
+		sleep(5);
+		return 0;
+	}
 
-    for (;;) {
-        //check Fault Status
-        for (ByteCount = 0; ByteCount < sizeof(ShmStatusCodeData->FaultCode.PreviousFaultVal); ByteCount++) {
-            if (ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[ByteCount] != ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount]) {
-                tmp = ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[ByteCount]; //prevent be modified during following process
-                for (BitCount = 0; BitCount < 8; BitCount++) {
-                    if (((tmp >> BitCount) & 0x01) != ((ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] >> BitCount) & 0x01)) {
-                        memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
-                        memcpy(EventCodeTmp, FaultStatusCode[ByteCount * 8 + BitCount], sizeof(EventCodeTmp) - 1);
-                        if (((tmp >> BitCount) & 0x01) == 0) { //Recovered
-                            //EventCodeTmp[0]=1;
-                            DEBUG_INFO("Recovery Fault Code = %s\n", EventCodeTmp);
-                            ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] &= ~(1 << BitCount);
-                            RemoveFaultCodeToBuf(EventCodeTmp);
-                        } else {
-                            DEBUG_INFO("Fault Code = %s\n", EventCodeTmp);
-                            ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] |= (1 << BitCount);
-                            AddFaultCodeToBuf(EventCodeTmp);
-                        }
-                    }
-                }
-            }
-        }
+	for(;;)
+	{
+		//check Fault Status
+		for(ByteCount=0;ByteCount<sizeof(ShmStatusCodeData->FaultCode.PreviousFaultVal);ByteCount++)
+		{
+			if(ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[ByteCount] != ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount])
+			{
+				tmp=ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[ByteCount]; //prevent be modified during following process
+				for(BitCount=0;BitCount<8;BitCount++)
+				{
+					if(((tmp>>BitCount)&0x01) != ((ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount]>>BitCount)&0x01))
+					{
+						memset(EventCodeTmp,0,sizeof(EventCodeTmp));
+						memcpy(EventCodeTmp,FaultStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
+						if(((tmp>>BitCount)&0x01)==0)//Recovered
+						{
+							//EventCodeTmp[0]=1;
+							DEBUG_INFO("Recovery Fault Code = %s\n", EventCodeTmp);
+							ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] &= ~(1<<BitCount);
+							RemoveFaultCodeToBuf(EventCodeTmp);
+						}
+						else
+						{
+							DEBUG_INFO("Fault Code = %s\n", EventCodeTmp);
+							ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] |= (1<<BitCount);
+							AddFaultCodeToBuf(EventCodeTmp);
+						}
+					}
+				}
+			}
+		}
 
-        //check Alarm Status
-        for (ByteCount = 0; ByteCount < sizeof(ShmStatusCodeData->AlarmCode.PreviousAlarmVal); ByteCount++) {
-            if (ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[ByteCount] != ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount]) {
-                tmp = ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[ByteCount]; //prevent be modified during following process
-                for (BitCount = 0; BitCount < 8; BitCount++) {
-                    if (((tmp >> BitCount) & 0x01) != ((ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] >> BitCount) & 0x01)) {
-                        memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
-                        memcpy(EventCodeTmp, AlarmStatusCode[ByteCount * 8 + BitCount], sizeof(EventCodeTmp) - 1);
-                        if (((tmp >> BitCount) & 0x01) == 0) { //Recovered
-                            //EventCodeTmp[0]=1;
-                            DEBUG_INFO("Recovery Alarm Code = %s\n", EventCodeTmp);
-                            ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] &= ~(1 << BitCount);
-                            RemoveFaultCodeToBuf(EventCodeTmp);
-                        } else {
-                            DEBUG_INFO("Alarm Code = %s\n", EventCodeTmp);
-                            ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] |= (1 << BitCount);
-                            AddFaultCodeToBuf(EventCodeTmp);
-                        }
-                    }
-                }
-            }
-        }
+		//check Alarm Status
+		for(ByteCount=0;ByteCount<sizeof(ShmStatusCodeData->AlarmCode.PreviousAlarmVal);ByteCount++)
+		{
+			if(ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[ByteCount] != ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount])
+			{
+				tmp=ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[ByteCount]; //prevent be modified during following process
+				for(BitCount=0;BitCount<8;BitCount++)
+				{
+					if(((tmp>>BitCount)&0x01) != ((ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount]>>BitCount)&0x01))
+					{
+						memset(EventCodeTmp,0,sizeof(EventCodeTmp));
+						memcpy(EventCodeTmp,AlarmStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
+						if(((tmp>>BitCount)&0x01)==0)//Recovered
+						{
+							//EventCodeTmp[0]=1;
+							DEBUG_INFO("Recovery Alarm Code = %s\n", EventCodeTmp);
+							ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] &= ~(1<<BitCount);
+							RemoveFaultCodeToBuf(EventCodeTmp);
+						}
+						else
+						{
+							DEBUG_INFO("Alarm Code = %s\n", EventCodeTmp);
+							ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] |= (1<<BitCount);
+							AddFaultCodeToBuf(EventCodeTmp);
+						}
+					}
+				}
+			}
+		}
 
-        //check Info Status
-        for (ByteCount = 0; ByteCount < sizeof(ShmStatusCodeData->InfoCode.PreviousInfoVal); ByteCount++) {
-            if (ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[ByteCount] != ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount]) {
-                tmp = ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[ByteCount]; //prevent be modified during following process
-                for (BitCount = 0; BitCount < 8; BitCount++) {
-                    if (((tmp >> BitCount) & 0x01) != ((ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] >> BitCount) & 0x01)) {
-                        memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
-                        memcpy(EventCodeTmp, InfoStatusCode[ByteCount * 8 + BitCount], sizeof(EventCodeTmp) - 1);
-                        if (((tmp >> BitCount) & 0x01) == 0) { //Recovered
-                            //EventCodeTmp[0]=1;
-                            DEBUG_INFO("Recovery Info Code = %s\n", EventCodeTmp);
-                            ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] &= ~(1 << BitCount);
-                            RemoveFaultCodeToBuf(EventCodeTmp);
-                        } else {
-                            DEBUG_INFO("Info Code = %s\n", EventCodeTmp);
-                            ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] |= (1 << BitCount);
-                            AddFaultCodeToBuf(EventCodeTmp);
-                        }
-                    }
-                }
-            }
-        }
-        usleep(500000);
-    }
+		//check Info Status
+		for(ByteCount=0;ByteCount<sizeof(ShmStatusCodeData->InfoCode.PreviousInfoVal);ByteCount++)
+		{
+			if(ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[ByteCount] != ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount])
+			{
+				tmp=ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[ByteCount]; //prevent be modified during following process
+				for(BitCount=0;BitCount<8;BitCount++)
+				{
+					if(((tmp>>BitCount)&0x01) != ((ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount]>>BitCount)&0x01))
+					{
+						memset(EventCodeTmp,0,sizeof(EventCodeTmp));
+						memcpy(EventCodeTmp,InfoStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
+						if(((tmp>>BitCount)&0x01)==0)//Recovered
+						{
+							//EventCodeTmp[0]=1;
+							DEBUG_INFO("Recovery Info Code = %s\n", EventCodeTmp);
+							ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] &= ~(1<<BitCount);
+							RemoveFaultCodeToBuf(EventCodeTmp);
+						}
+						else
+						{
+							DEBUG_INFO("Info Code = %s\n", EventCodeTmp);
+							ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] |= (1<<BitCount);
+							AddFaultCodeToBuf(EventCodeTmp);
+						}
+					}
+				}
+			}
+		}
+		usleep(500000);
+	}
 
-    return FAIL;
+	return FAIL;
 }

+ 197 - 166
EVSE/Projects/DD360Audi/Apps/Module_InternalComm.c

@@ -1,37 +1,35 @@
-#include <sys/time.h>
-#include <sys/timeb.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/shm.h>
-#include <sys/mman.h>
-#include <linux/wireless.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdio.h>      /*標準輸入輸出定義*/
-#include <stdlib.h>     /*標準函數庫定義*/
-#include <unistd.h>     /*Unix 標準函數定義*/
-#include <fcntl.h>      /*檔控制定義*/
-#include <termios.h>    /*PPSIX 終端控制定義*/
-#include <errno.h>      /*錯誤號定義*/
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <ctype.h>
-#include <ifaddrs.h>
-#include <math.h>
-#include <stdbool.h>
-
-#include "../../define.h"
-#include "internalComm.h"
-#include "Config.h"
+#include    <sys/time.h>
+#include    <sys/timeb.h>
+#include    <sys/types.h>
+#include    <sys/stat.h>
+#include    <sys/types.h>
+#include    <sys/ioctl.h>
+#include    <sys/socket.h>
+#include    <sys/ipc.h>
+#include    <sys/shm.h>
+#include    <sys/shm.h>
+#include    <sys/mman.h>
+#include    <linux/wireless.h>
+#include    <arpa/inet.h>
+#include    <netinet/in.h>
+
+#include    <unistd.h>
+#include    <stdarg.h>
+#include    <stdio.h>      /*標準輸入輸出定義*/
+#include    <stdlib.h>     /*標準函數庫定義*/
+#include    <unistd.h>     /*Unix 標準函數定義*/
+#include    <fcntl.h>      /*檔控制定義*/
+#include    <termios.h>    /*PPSIX 終端控制定義*/
+#include    <errno.h>      /*錯誤號定義*/
+#include    <errno.h>
+#include    <string.h>
+#include    <time.h>
+#include    <ctype.h>
+#include    <ifaddrs.h>
+#include    <math.h>
+#include    "../../define.h"
+#include    "internalComm.h"
+#include    <stdbool.h>
 
 #define AudiCustomized              1
 #define ARRAY_SIZE(A)       (sizeof(A) / sizeof(A[0]))
@@ -39,7 +37,6 @@
 #define FAIL                -1
 #define YES                 1
 #define NO                  0
-#define OUTPUT_VOL_CHK_TIME    200     // ms
 #define TEN_MINUTES         600
 #define ENV_TEMP_MIN        45
 #define ENV_TEMP_MAX        50
@@ -130,8 +127,6 @@ struct timeval  _ac_charging_comp;
 struct timeval  _ac_preparing;
 struct timeb    _ac_startChargingTime;
 struct timeb    _ac_endChargingTime;
-bool _isOvpChkTimeFlag[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-struct timeval _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
 unsigned short _setFanSpeed = 0;
 float _beforeChargingTotalEnergy = 0.0;
@@ -424,7 +419,7 @@ void GetPresentInputVol()
         ShmSysConfigAndInfo->SysInfo.InputVoltageT = ShmRelayModuleData->InputL3Volt = inputVoltage.L3N_L31;
 
         //********************************************************************************************************//
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
         // Vin (UVP)
         if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC) {
             if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_IEC) {
@@ -469,7 +464,6 @@ void GetPresentInputVol()
                 ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
             }
         }
-#endif //!defined DD360 && !defined DD360Audi
         //********************************************************************************************************//
         // Vin (OVP)
         if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC) {
@@ -515,6 +509,7 @@ void GetPresentInputVol()
                 ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
             }
         }
+#endif
     }
 }
 
@@ -538,33 +533,33 @@ void GetPersentOutputVol()
         for (int index = 0; index < gunCount; index++) {
             if (index == 0) {
                 if (_chargingData[index]->Evboard_id == 0x01) {
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
                     _chargingData[index]->FuseChargingVoltage = ShmRelayModuleData->Gun1FuseOutputVolt;
 #else
                     _chargingData[index]->PresentChargingCurrent = ShmRelayModuleData->Gun1FuseOutputVolt / 10;
                     _chargingData[index]->PresentChargingVoltage = _chargingData[index]->FireChargingVoltage / 10;
                     _chargingData[index]->FuseChargingVoltage = _chargingData[index]->FireChargingVoltage;
-#endif //!defined DD360 && !defined DD360Audi
+#endif
                     _chargingData[index]->FireChargingVoltage = ShmRelayModuleData->Gun1RelayOutputVolt;
 
                 } else if (_chargingData[index]->Evboard_id == 0x02) {
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
                     _chargingData[index]->FuseChargingVoltage = ShmRelayModuleData->Gun2FuseOutputVolt;
 #else
                     _chargingData[index]->PresentChargingCurrent = ShmRelayModuleData->Gun2FuseOutputVolt / 10;
                     _chargingData[index]->PresentChargingVoltage = _chargingData[index]->FireChargingVoltage / 10;
                     _chargingData[index]->FuseChargingVoltage = _chargingData[index]->FireChargingVoltage;
-#endif //!defined DD360 && !defined DD360Audi
+#endif
                     _chargingData[index]->FireChargingVoltage = ShmRelayModuleData->Gun2RelayOutputVolt;
                 }
             } else if (index == 1) {
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
                 _chargingData[index]->FuseChargingVoltage = ShmRelayModuleData->Gun2FuseOutputVolt;
 #else
                 _chargingData[index]->PresentChargingCurrent = ShmRelayModuleData->Gun2FuseOutputVolt / 10;
                 _chargingData[index]->PresentChargingVoltage = _chargingData[index]->FireChargingVoltage / 10;
                 _chargingData[index]->FuseChargingVoltage = _chargingData[index]->FireChargingVoltage;
-#endif //!defined DD360 && !defined DD360Audi
+#endif
                 _chargingData[index]->FireChargingVoltage = ShmRelayModuleData->Gun2RelayOutputVolt;
             }
 
@@ -604,9 +599,9 @@ void GetFanSpeed()
 void GetRelayOutputStatus()
 {
     if (Query_Relay_Output(Uart5Fd, Addr.Relay, &regRelay) == PASS) {
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
         regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
-#endif //!defined DD360 && !defined DD360Audi
+#endif
     }
 }
 
@@ -623,7 +618,7 @@ void CheckK1K2RelayOutput(byte index)
 
             if (_chargingData[index]->Type == _Type_CCS_2) {
                 if (gunCount == 1) {
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
                     if (regRelay.relay_event.bits.Gun1_N == YES && regRelay.relay_event.bits.CCS_Precharge == YES) {
                         _chargingData[index]->RelayKPK2Status = YES;
                     } else {
@@ -635,7 +630,7 @@ void CheckK1K2RelayOutput(byte index)
                     } else {
                         _chargingData[index]->RelayKPK2Status = NO;
                     }
-#endif //!defined DD360 && !defined DD360Audi
+#endif
                 } else {
                     if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST0) {
                         _chargingData[index]->RelayKPK2Status = YES;
@@ -652,7 +647,7 @@ void CheckK1K2RelayOutput(byte index)
             }
 
             if (_chargingData[index]->Type == _Type_CCS_2) {
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
                 if (regRelay.relay_event.bits.Gun2_N == YES && regRelay.relay_event.bits.CCS_Precharge == YES) {
                     _chargingData[index]->RelayKPK2Status = YES;
                 } else {
@@ -664,7 +659,7 @@ void CheckK1K2RelayOutput(byte index)
                 } else {
                     _chargingData[index]->RelayKPK2Status = NO;
                 }
-#endif //!defined DD360 && !defined DD360Audi
+#endif
             }
         }
     } else if (index == 1) {
@@ -675,7 +670,7 @@ void CheckK1K2RelayOutput(byte index)
         }
 
         if (_chargingData[index]->Type == _Type_CCS_2) {
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
             if (regRelay.relay_event.bits.Gun2_N == YES && regRelay.relay_event.bits.CCS_Precharge == YES) {
                 _chargingData[index]->RelayKPK2Status = YES;
             } else {
@@ -687,7 +682,7 @@ void CheckK1K2RelayOutput(byte index)
             } else {
                 _chargingData[index]->RelayKPK2Status = NO;
             }
-#endif //!defined DD360 && !defined DD360Audi
+#endif
         }
     }
 
@@ -935,7 +930,7 @@ void SetK1K2RelayStatus(byte index)
         }
     } else if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST0) {
         if (_chargingData[index]->Evboard_id == 0x01) {
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
             if (_chargingData[index]->Type == _Type_CCS_2) {
                 if (gunCount == 1) {
                     if (regRelay.relay_event.bits.CCS_Precharge == NO) {
@@ -945,9 +940,9 @@ void SetK1K2RelayStatus(byte index)
                     }
                 }
             }
-#endif //!defined DD360 && !defined DD360Audi
+#endif
         } else if (_chargingData[index]->Evboard_id == 0x02) {
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
             if (_chargingData[index]->Type == _Type_CCS_2) {
                 if (regRelay.relay_event.bits.CCS_Precharge == NO) {
                     outputRelay.relay_event.bits.CCS_Precharge = YES;
@@ -955,11 +950,11 @@ void SetK1K2RelayStatus(byte index)
                     outputRelay.relay_event.bits.Gun2_P = NO;
                 }
             }
-#endif //!defined DD360 && !defined DD360Audi
+#endif
         }
     } else if (_chargingData[index]->SystemStatus == S_CCS_PRECHARGE_ST1) {
         if (_chargingData[index]->Evboard_id == 0x01) {
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
             if (_chargingData[index]->Type == _Type_CCS_2) {
                 if (gunCount == 1) {
                     if (regRelay.relay_event.bits.Gun1_P == NO) {
@@ -969,9 +964,9 @@ void SetK1K2RelayStatus(byte index)
                     }
                 }
             }
-#endif //!defined DD360 && !defined DD360Audi
+#endif
         } else if (_chargingData[index]->Evboard_id == 0x02) {
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
             if (_chargingData[index]->Type == _Type_CCS_2) {
                 if (regRelay.relay_event.bits.Gun2_P == NO) {
                     outputRelay.relay_event.bits.Gun2_P = YES;
@@ -979,7 +974,7 @@ void SetK1K2RelayStatus(byte index)
                     outputRelay.relay_event.bits.CCS_Precharge = NO;
                 }
             }
-#endif //!defined DD360 && !defined DD360Audi
+#endif
         }
     }
 }
@@ -1017,6 +1012,7 @@ void CheckAcInputOvpStatus(byte index)
 //          }
 //      }
 //      else
+        DEBUG_INFO("CheckAcInputOvpStatus\r\n");
         _chargingData[index]->StopChargeFlag = YES;
     }
 }
@@ -1026,6 +1022,7 @@ void CheckPhaseLossStatus(byte index)
     if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == YES ||
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == YES ||
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == YES) {
+        DEBUG_INFO("CheckPhaseLossStatus\r\n");
         _chargingData[index]->StopChargeFlag = YES;
     }
 }
@@ -1177,17 +1174,12 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
         led_color.Connect_2_Red = _colorBuf;
     } else {
         if (ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf) {
-            if ((chargingData_1->SystemStatus == S_BOOTING ||
-                    chargingData_1->SystemStatus == S_IDLE ||
-                    chargingData_1->SystemStatus == S_RESERVATION) &&
-                    (chargingData_2->SystemStatus == S_BOOTING ||
-                     chargingData_2->SystemStatus == S_IDLE ||
-                     chargingData_2->SystemStatus == S_RESERVATION)) {
+            if ((chargingData_1->SystemStatus == S_BOOTING || chargingData_1->SystemStatus == S_IDLE || chargingData_1->SystemStatus == S_RESERVATION) &&
+                    (chargingData_2->SystemStatus == S_BOOTING || chargingData_2->SystemStatus == S_IDLE || chargingData_2->SystemStatus == S_RESERVATION)) {
 #ifdef AudiCustomized
                 led_color.Connect_1_Green = _colorBuf;
                 led_color.Connect_1_Blue = _colorBuf;
                 led_color.Connect_1_Red = _colorBuf;
-
                 led_color.Connect_2_Green = _colorBuf;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Red = _colorBuf;
@@ -1195,19 +1187,14 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
                 led_color.Connect_1_Green = _colorBuf;
                 led_color.Connect_1_Blue = COLOR_MIN_LV;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
-
                 led_color.Connect_2_Green = _colorBuf;
                 led_color.Connect_2_Blue = COLOR_MIN_LV;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
 #endif
-            } else if ((chargingData_1->SystemStatus >= S_AUTHORIZING &&
-                        chargingData_1->SystemStatus <= S_COMPLETE) ||
-                       (chargingData_1->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
-                        chargingData_1->SystemStatus <= S_CCS_PRECHARGE_ST1) ||
-                       (chargingData_2->SystemStatus >= S_AUTHORIZING &&
-                        chargingData_2->SystemStatus <= S_COMPLETE) ||
-                       (chargingData_2->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
-                        chargingData_2->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
+            } else if ((chargingData_1->SystemStatus >= S_AUTHORIZING && chargingData_1->SystemStatus <= S_COMPLETE) ||
+                       (chargingData_1->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingData_1->SystemStatus <= S_CCS_PRECHARGE_ST1) ||
+                       (chargingData_2->SystemStatus >= S_AUTHORIZING && chargingData_2->SystemStatus <= S_COMPLETE) ||
+                       (chargingData_2->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingData_2->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Blue = _colorBuf;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
@@ -1216,66 +1203,42 @@ void SetLedColor(struct ChargingInfoData *chargingData_1, struct ChargingInfoDat
                 led_color.Connect_2_Red = COLOR_MIN_LV;
             }
         } else {
-            if (chargingData_1->SystemStatus == S_BOOTING ||
-                    chargingData_1->SystemStatus == S_IDLE ||
-                    chargingData_1->SystemStatus == S_RESERVATION ||
-                    chargingData_1->SystemStatus == S_MAINTAIN) {
-
-                if (chargingData_1->IsAvailable == NO) { //For Audi
-                    led_color.Connect_1_Green = COLOR_MIN_LV;
-                    led_color.Connect_1_Blue = COLOR_MIN_LV;
-                    led_color.Connect_1_Red = _colorBuf;
-                } else {
+            if (chargingData_1->SystemStatus == S_BOOTING || chargingData_1->SystemStatus == S_IDLE || chargingData_1->SystemStatus == S_RESERVATION) {
 #ifdef AudiCustomized
-                    led_color.Connect_1_Green = _colorBuf;
-                    led_color.Connect_1_Blue = _colorBuf;
-                    led_color.Connect_1_Red = _colorBuf;
+                led_color.Connect_1_Green = _colorBuf;
+                led_color.Connect_1_Blue = _colorBuf;
+                led_color.Connect_1_Red = _colorBuf;
 #else
-                    led_color.Connect_1_Green = _colorBuf;
-                    led_color.Connect_1_Blue = COLOR_MIN_LV;
-                    led_color.Connect_1_Red = COLOR_MIN_LV;
+                led_color.Connect_1_Green = _colorBuf;
+                led_color.Connect_1_Blue = COLOR_MIN_LV;
+                led_color.Connect_1_Red = COLOR_MIN_LV;
 #endif
-                }
-            } else if ((chargingData_1->SystemStatus >= S_AUTHORIZING &&
-                        chargingData_1->SystemStatus <= S_COMPLETE) ||
-                       (chargingData_1->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
-                        chargingData_1->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
+            } else if ((chargingData_1->SystemStatus >= S_AUTHORIZING && chargingData_1->SystemStatus <= S_COMPLETE) ||
+                       (chargingData_1->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingData_1->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Blue = _colorBuf;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
             }
 
             // --------------------------------------------------------------------------
-            if (chargingData_2->SystemStatus == S_BOOTING ||
-                    chargingData_2->SystemStatus == S_IDLE ||
-                    chargingData_2->SystemStatus == S_RESERVATION ||
-                    chargingData_2->SystemStatus == S_MAINTAIN) {
-                if (chargingData_2->IsAvailable == NO) {
-                    led_color.Connect_2_Green = COLOR_MIN_LV;
-                    led_color.Connect_2_Blue = COLOR_MIN_LV;
-                    led_color.Connect_2_Red = _colorBuf;
-                } else {
+            if (chargingData_2->SystemStatus == S_BOOTING || chargingData_2->SystemStatus == S_IDLE || chargingData_2->SystemStatus == S_RESERVATION) {
 #ifdef AudiCustomized
-                    led_color.Connect_2_Green = _colorBuf;
-                    led_color.Connect_2_Blue = _colorBuf;
-                    led_color.Connect_2_Red = _colorBuf;
+                led_color.Connect_2_Green = _colorBuf;
+                led_color.Connect_2_Blue = _colorBuf;
+                led_color.Connect_2_Red = _colorBuf;
 #else
-                    led_color.Connect_2_Green = _colorBuf;
-                    led_color.Connect_2_Blue = COLOR_MIN_LV;
-                    led_color.Connect_2_Red = COLOR_MIN_LV;
+                led_color.Connect_2_Green = _colorBuf;
+                led_color.Connect_2_Blue = COLOR_MIN_LV;
+                led_color.Connect_2_Red = COLOR_MIN_LV;
 #endif
-                }
-            } else if ((chargingData_2->SystemStatus >= S_AUTHORIZING &&
-                        chargingData_2->SystemStatus <= S_COMPLETE) ||
-                       (chargingData_2->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
-                        chargingData_2->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
+            } else if ((chargingData_2->SystemStatus >= S_AUTHORIZING && chargingData_2->SystemStatus <= S_COMPLETE) ||
+                       (chargingData_2->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingData_2->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
             }
         }
     }
-
     if (_checkLedChanged > 0) {
         if (Config_Led_Color(Uart5Fd, Addr.Led, &led_color) == PASS) {
             _checkLedChanged--;
@@ -1411,7 +1374,7 @@ int InitComPort()
     tios.c_iflag = 0;
     tios.c_oflag = 0;
     tios.c_cc[VMIN] = 0;
-    tios.c_cc[VTIME] = (byte)0;     // timeout 0.5 second
+    tios.c_cc[VTIME] = (byte)5;     // timeout 0.5 second
     tios.c_lflag = 0;
     tcflush(fd, TCIFLUSH);
     ioctl (fd, TCSETS, &tios);
@@ -1550,10 +1513,9 @@ void MatchRelayStatus()
 {
     // 因為 AC Contactor 沒有 Feedback,所以暫時先這樣處理
     //regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
     ShmSysConfigAndInfo->SysInfo.AcContactorStatus  = regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
-#endif //!defined DD360 && !defined DD360Audi
-
+#endif
     regRelay.relay_event.bits.CCS_Precharge = outputRelay.relay_event.bits.CCS_Precharge;
     regRelay.relay_event.bits.Gun1_P = outputRelay.relay_event.bits.Gun1_P;
     regRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_N;
@@ -1632,38 +1594,18 @@ void CableCheckDetected(byte index)
 void CheckOutputPowerOverCarReq(byte index)
 {
     float fireV = _chargingData[index]->FireChargingVoltage;
-    float carV = _chargingData[index]->EvBatteryMaxVoltage * 10;
+    float carV = _chargingData[index]->EvBatterytargetVoltage * 10;
 
     if ((_chargingData[index]->EvBatterytargetVoltage * 10) > 1500 &&
             (_chargingData[index]->Type == _Type_Chademo ||
              _chargingData[index]->Type == _Type_CCS_2 ||
              _chargingData[index]->Type == _Type_GB)) {
-        if (fireV >= (carV + (carV * 0.02))) {
-            if (!_isOvpChkTimeFlag[index]) {
-                if ((_chargingData[index]->PresentChargingVoltage * 10) >= VOUT_MIN_VOLTAGE * 10) {
-                    gettimeofday(&_checkOutputVolProtectTimer[index], NULL);
-                    _isOvpChkTimeFlag[index] = YES;
-                }
-            } else {
-                PRINTF_FUNC("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
-                            _chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10));
-                DEBUG_ERROR("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
-                            _chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10));
-                if ((GetTimeoutValue(_checkOutputVolProtectTimer[index]) / 1000) >= OUTPUT_VOL_CHK_TIME) {
-                    if (_chargingData[index]->Type == _Type_Chademo) {
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChademoOutputOVP = YES;
-                    } else if (_chargingData[index]->Type == _Type_CCS_2) {
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP = YES;
-                    } else if (_chargingData[index]->Type == _Type_GB) {
-                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemGbOutputOVP = YES;
-                    }
-                    _chargingData[index]->StopChargeFlag = YES;
-                }
-            }
-        } else {
-            if (_isOvpChkTimeFlag[index] == YES) {
-                _isOvpChkTimeFlag[index] = NO;
-            }
+        if (fireV >= (carV + (carV * 0.1))) {
+            PRINTF_FUNC("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
+                        _chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10));
+            DEBUG_ERROR("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
+                        _chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10));
+            _chargingData[index]->StopChargeFlag = YES;
         }
     }
 }
@@ -2049,7 +1991,7 @@ void AcChargeTypeProcess()
             break;
             case S_PREPARNING: {
                 if (isModeChange()) {
-                    ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;//_LCM_NONE; //Jerry add
+                    ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
                     ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = DEFAULT_AC_INDEX;
                     if (ShmSysConfigAndInfo->SysInfo.OrderCharging != NO_DEFINE) {
                         ShmSysConfigAndInfo->SysInfo.OrderCharging = NO_DEFINE;
@@ -2150,7 +2092,7 @@ int main(void)
     // Open Uart5 for RB
     Uart5Fd = InitComPort();
     Initialization();
-    sleep(1);
+    sleep(3);
 
     if (Uart5Fd < 0) {
         PRINTF_FUNC("(Internal) open port error. \n");
@@ -2179,14 +2121,12 @@ int main(void)
     //bool printRelayStatus = true;
     for (;;) {
         bool isCharging = false;
-
         // 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
         if (ShmRelayModuleData->SelfTest_Comp == NO) {
             GetFwAndHwVersion_Relay();
             SetRtcData_Relay();
             sleep(1);
         }
-
 #ifndef NO_FAN_BOARD
         if (ShmFanModuleData->SelfTest_Comp == NO) {
             GetFwAndHwVersion_Fan();
@@ -2195,8 +2135,7 @@ int main(void)
             sleep(1);
             gettimeofday(&_priority_time, NULL);
         }
-#endif //NO_FAN_BOARD
-
+#endif
         // 自檢階段處理,自檢階段如果讀不到版號則代表該系統沒有掛燈板
         if (ShmLedModuleData->SelfTest_Comp == NO) {
             // 自檢階段
@@ -2221,13 +2160,12 @@ int main(void)
             // 輸出電壓
             GetPersentOutputVol();
 
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
             // 三相輸入電壓
             GetPresentInputVol();
             // 讀取當前 AC relay 狀態
             regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
-#endif //!defined DD360 && !defined DD360Audi
-
+#endif
             //GetRelayOutputStatus();
 
             for (int i = 0; i < gunCount; i++) {
@@ -2240,18 +2178,17 @@ int main(void)
                 // 依據當前各槍的狀態選擇 搭上/放開 Relay
                 SetK1K2RelayStatus(i);
 
-#if !defined DD360 && !defined DD360Audi
+#ifndef DD360
                 if (ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy == YES) {
                     CheckPhaseLossStatus(i);
                 }
 
                 CheckAcInputOvpStatus(i);
-#endif //!defined DD360 && !defined DD360Audi
 
+#endif
                 if (_chargingData[i]->SystemStatus == S_IDLE) {
                     _chargingData[i]->RelayWeldingCheck = NO;
                     _isRelayWelding[i] = NO;
-                    _isOvpChkTimeFlag[i] = NO;
                 }
 
                 if (_chargingData[i]->SystemStatus == S_BOOTING ||
@@ -2274,7 +2211,7 @@ int main(void)
 
                     if (_chargingData[i]->SystemStatus == S_CHARGING) {
                         CheckOutputPowerOverCarReq(i);
-                        //CheckOutputVolNoneMatchFire(i);
+                        CheckOutputVolNoneMatchFire(i);
                     } else {
                         _isOutputNoneMatch[i] = NO;
                     }
@@ -2337,8 +2274,53 @@ int main(void)
 
                 }
             }
-        }
 
+
+//          if(IsNoneMatchRelayStatus())
+//          {
+//              if (printRelayStatus)
+//              {
+////                    PRINTF_FUNC("Match Relay Target, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x \n",
+////                            outputRelay.relay_event.bits.AC_Contactor,
+////                            outputRelay.relay_event.bits.Gun1_P,
+////                            outputRelay.relay_event.bits.Gun1_N,
+////                            outputRelay.relay_event.bits.Gun2_P,
+////                            outputRelay.relay_event.bits.Gun2_N,
+////                            outputRelay.relay_event.bits.CCS_Precharge,
+////                            outputRelay.relay_event.bits.Gun1_Parallel_P,
+////                            outputRelay.relay_event.bits.Gun1_Parallel_N);
+//              }
+//              printRelayStatus = false;
+//              if (Config_Relay_Output(Uart5Fd, Addr.Relay, &outputRelay))
+//              {
+//                  PRINTF_FUNC("Match Relay Target, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x \n",
+//                          outputRelay.relay_event.bits.AC_Contactor,
+//                          outputRelay.relay_event.bits.Gun1_P,
+//                          outputRelay.relay_event.bits.Gun1_N,
+//                          outputRelay.relay_event.bits.Gun2_P,
+//                          outputRelay.relay_event.bits.Gun2_N,
+//                          outputRelay.relay_event.bits.CCS_Precharge,
+//                          outputRelay.relay_event.bits.Gun1_Parallel_P,
+//                          outputRelay.relay_event.bits.Gun1_Parallel_N);
+//              }
+//          }
+//          else
+//          {
+//              if (!printRelayStatus)
+//              {
+//                  PRINTF_FUNC("Match Relay, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x \n",
+//                          regRelay.relay_event.bits.AC_Contactor,
+//                          regRelay.relay_event.bits.Gun1_P,
+//                          regRelay.relay_event.bits.Gun1_N,
+//                          regRelay.relay_event.bits.Gun2_P,
+//                          regRelay.relay_event.bits.Gun2_N,
+//                          regRelay.relay_event.bits.CCS_Precharge,
+//                          regRelay.relay_event.bits.Gun1_Parallel_P,
+//                          regRelay.relay_event.bits.Gun1_Parallel_N);
+//              }
+//              printRelayStatus = true;
+//          }
+        }
 #ifndef NO_FAN_BOARD
         if (ShmFanModuleData->SelfTest_Comp == YES) {
             if (GetTimeoutValue(_priority_time) / 1000 >= 1000) {
@@ -2353,12 +2335,61 @@ int main(void)
                 ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
                 ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
 
+//              if (isCharging)
+//              {
+////                    if (ShmFanModuleData->PresentFan1Speed < MAX_FAN_SPEED ||
+////                        ShmFanModuleData->PresentFan2Speed < MAX_FAN_SPEED ||
+////                        ShmFanModuleData->PresentFan3Speed < MAX_FAN_SPEED ||
+////                        ShmFanModuleData->PresentFan4Speed < MAX_FAN_SPEED)
+////                    {
+////                        ShmFanModuleData->SetFan1Speed = MAX_FAN_SPEED;
+////                        ShmFanModuleData->SetFan2Speed = MAX_FAN_SPEED;
+////                        ShmFanModuleData->SetFan3Speed = MAX_FAN_SPEED;
+////                        ShmFanModuleData->SetFan4Speed = MAX_FAN_SPEED;
+////                    }
+//
+//                  // 在還沒問到 PSU 溫度~ 還是要有個最小轉速
+//                  ShmFanModuleData->SetFan1Speed = MIN_FAN_SPEED;
+//                  ShmFanModuleData->SetFan2Speed = MIN_FAN_SPEED;
+//                  ShmFanModuleData->SetFan3Speed = MIN_FAN_SPEED;
+//                  ShmFanModuleData->SetFan4Speed = MIN_FAN_SPEED;
+//
+//                  if (ShmFanModuleData->TestFanSpeed > 0)
+//                  {
+//                      ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
+//                      ShmFanModuleData->SetFan2Speed = ShmFanModuleData->TestFanSpeed;
+//                      ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
+//                      ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
+//                  }
+//              }
+//              else
+//              {
+////                    if (ShmFanModuleData->PresentFan1Speed > MIN_FAN_SPEED ||
+////                        ShmFanModuleData->PresentFan2Speed > MIN_FAN_SPEED ||
+////                        ShmFanModuleData->PresentFan3Speed > MIN_FAN_SPEED ||
+////                        ShmFanModuleData->PresentFan4Speed > MIN_FAN_SPEED)
+////                    {
+//                      ShmFanModuleData->SetFan1Speed = MIN_FAN_SPEED;
+//                      ShmFanModuleData->SetFan2Speed = MIN_FAN_SPEED;
+//                      ShmFanModuleData->SetFan3Speed = MIN_FAN_SPEED;
+//                      ShmFanModuleData->SetFan4Speed = MIN_FAN_SPEED;
+////                    }
+//
+//                  // 停止時,如溫度還是很高,則需要維持該轉速直到溫度降低
+//                  if (ShmFanModuleData->TestFanSpeed >= MAX_FAN_SPEED)
+//                  {
+//                      ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
+//                      ShmFanModuleData->SetFan2Speed = ShmFanModuleData->TestFanSpeed;
+//                      ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
+//                      ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
+//                  }
+//              }
+
                 //PRINTF_FUNC("set fan = %d \n", ShmFanModuleData->SetFan1Speed);
                 SetFanModuleSpeed();
             }
         }
-#endif //NO_FAN_BOARD
-
+#endif
         if (ShmLedModuleData->SelfTest_Comp == YES) {
             if (GetTimeoutValue(_led_priority_time) / 1000 >= 1000) {
                 if (gunCount == 1) {

+ 181 - 217
EVSE/Projects/DD360Audi/Apps/Module_LcmContro.h

@@ -1,232 +1,196 @@
-#include <sys/time.h>
-#include <sys/timeb.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/shm.h>
-#include <sys/mman.h>
-#include <linux/wireless.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdio.h>      /*璅蹱�頛詨�頛詨枂摰𡁶儔*/
-#include <stdlib.h>     /*璅蹱��賣彍摨怠�蝢�*/
-#include <unistd.h>     /*Unix 璅蹱��賣彍摰𡁶儔*/
-#include <fcntl.h>      /*瑼娍綉�嗅�蝢�*/
-#include <termios.h>    /*PPSIX 蝯�垢�批�摰𡁶儔*/
-#include <errno.h>      /*�航炊�笔�蝢�*/
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <ctype.h>
-#include <ifaddrs.h>
-#include <stdbool.h>
-#include "../../define.h"
-#include "Config.h"
-
-#define ARRAY_SIZE(A)       (sizeof(A) / sizeof(A[0]))
-#define PASS                1
-#define FAIL                -1
-#define YES                 1
-#define NO                  0
-
-typedef unsigned char           byte;
-
-struct SysConfigAndInfo         *ShmSysConfigAndInfo;
-struct StatusCodeData           *ShmStatusCodeData;
-struct FanModuleData            *ShmFanModuleData;
-struct PrimaryMcuData           *ShmPrimaryMcuData;
-
-#define NO_DEFINE               255
-#define DEFAULT_AC_INDEX        2
-
-#define TIME_MAX_SEC            2592000 // 銝��𧢲�嚗𣬚���
-#define POWER_MAX_KW            5000
-#define ENERGY_MAX_KWH          5000
-
-#define CMD_TITLE_1             0x5A
-#define CMD_TITLE_2             0xA5
-#define CMD_READ                0x80
-#define CMD_WRITE               0x81
-#define CMD_MULTI_WRITE         0x82
-#define CMD_MULTI_READ          0x83
-
-#define CMD_BACKLIGHT           0x01
-#define CMD_REGISTER            0x03
-
-//#define NOODOE_QR_CODE_URL      "https://ev-alpha-test.noodoe.com/station?id=" ////For Audi
-#define NOODOE_QR_CODE_URL      "https://ev.noodoe.com/station?id=" ////For Audi
-
-enum _BATTERY_LEVEL_FOR_MAP {
-    _BATTERY_LEVEL_FOR_MAP_EMP = 0x00,
-    _BATTERY_LEVEL_FOR_MAP_LV1 = 0x01,
-    _BATTERY_LEVEL_FOR_MAP_LV2 = 0x02,
-    _BATTERY_LEVEL_FOR_MAP_LV3 = 0x03,
-    _BATTERY_LEVEL_FOR_MAP_LV4 = 0x04,
-    _BATTERY_LEVEL_FOR_MAP_LV5 = 0x05,
+#include 	<sys/time.h>
+#include 	<sys/timeb.h>
+#include    <sys/types.h>
+#include    <sys/stat.h>
+#include 	<sys/types.h>
+#include 	<sys/ioctl.h>
+#include 	<sys/socket.h>
+#include 	<sys/ipc.h>
+#include 	<sys/shm.h>
+#include 	<sys/shm.h>
+#include 	<sys/mman.h>
+#include 	<linux/wireless.h>
+#include 	<arpa/inet.h>
+#include 	<netinet/in.h>
+
+#include 	<unistd.h>
+#include 	<stdarg.h>
+#include    <stdio.h>      /*標準輸入輸出定義*/
+#include    <stdlib.h>     /*標準函數庫定義*/
+#include    <unistd.h>     /*Unix 標準函數定義*/
+#include    <fcntl.h>      /*檔控制定義*/
+#include    <termios.h>    /*PPSIX 終端控制定義*/
+#include    <errno.h>      /*錯誤號定義*/
+#include 	<errno.h>
+#include 	<string.h>
+#include	<time.h>
+#include	<ctype.h>
+#include 	<ifaddrs.h>
+#include 	<stdbool.h>
+#include	"../../define.h"
+
+#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
+#define PASS				1
+#define FAIL				-1
+#define YES					1
+#define NO					0
+
+typedef unsigned char 			byte;
+
+struct SysConfigAndInfo			*ShmSysConfigAndInfo;
+struct StatusCodeData 			*ShmStatusCodeData;
+struct FanModuleData			*ShmFanModuleData;
+
+#define NO_DEFINE			255
+#define DEFAULT_AC_INDEX	2
+
+#define TIME_MAX_SEC		2592000 // 一個月,秒數
+#define POWER_MAX_KW		5000
+#define ENERGY_MAX_KWH		5000
+
+#define CMD_TITLE_1				0x5A
+#define CMD_TITLE_2				0xA5
+#define CMD_READ				0x80
+#define CMD_WRITE				0x81
+#define CMD_MULTI_WRITE			0x82
+#define CMD_MULTI_READ			0x83
+
+#define CMD_BACKLIGHT			0x01
+#define CMD_REGISTER			0x03
+
+enum _BATTERY_LEVEL_FOR_MAP
+{
+	_BATTERY_LEVEL_FOR_MAP_EMP = 0x00,
+	_BATTERY_LEVEL_FOR_MAP_LV1 = 0x01,
+	_BATTERY_LEVEL_FOR_MAP_LV2 = 0x02,
+	_BATTERY_LEVEL_FOR_MAP_LV3 = 0x03,
+	_BATTERY_LEVEL_FOR_MAP_LV4 = 0x04,
+	_BATTERY_LEVEL_FOR_MAP_LV5 = 0x05,
 };
 
 int _port;
-//char* pPortName         = "/dev/ttyO2";
-char *pPortName           = "/dev/ttyS3";
-char *moduleName          = "DMT80480T070_09WT";
+//char* pPortName = "/dev/ttyO2";
+char* pPortName = "/dev/ttyS3";
+char* moduleName = "DMT80480T070_09WT";
 byte _totalCount;
 byte acgunCount;
 struct ChargingInfoData *_chargingInfoData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
 
 byte ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV5;
-byte isDiffStatus         = false;
-byte isChangeBattMap      = false;
-// �嗅��豢������
-short _currentPage        = _LCM_SELECT_GUN;//_LCM_NONE; ////For Audi
-short _oldPage            = _LCM_SELECT_GUN;//_LCM_NONE; ////For Audi
-byte _gunIndex            = 0;
-bool _wifi_conn_status    = false;
+byte isDiffStatus = false;
+byte isChangeBattMap = false;
+// 當前選擇的槍號
+short _currentPage = _LCM_NONE;
+short _oldPage = _LCM_NONE;
+byte _gunIndex = 0;
+bool _wifi_conn_status = false;
 bool _battery_display_ani = false;
-byte _curPage_index       = 0;
-bool _page_reload         = false;
+byte _curPage_index = 0;
+bool _page_reload = false;
 
 // LCM - HW
-byte _everyPageRollChange    = 0;
-short __conn_status          = 0x0030;
-short __ethernet_status      = 0x0032;
-short __3G4G_status          = 0x0036;
-short __3G4G_status1         = 0x0037;
-short __3G4G_move_status     = 0x0038;
-short __wifi_status          = 0x003C;
-
-short __sel_gun_btn          = 0x0040;
-short __ret_home_btn         = 0x0042;
-short __stop_method_btn      = 0x0044;
-
-short __qr_code              = 0x0250;
-short __main_rfid            = 0x0052;
-short __main_qr              = 0x0054;
-short __main_app             = 0x0056;
-
-short __plug_in_arrow        = 0x0060;
-
-short __conn_line            = 0x0066;
-
-short __gun_type_index       = 0x0070;
-short __cmp_gun_type_index   = 0x0080; ////For Audi
-short __batt_map_empty       = 0x0090; ////For Audi
-short __qr_code_pre          = 0x0280;
-
-short __side_top             = 0x0090;
-short __side_down            = 0x0092;
-short __side_mid             = 0x0094;
-
-short __conn_line_chag       = 0x0096;
-short __batt_map             = 0x0100;
-short __soc_value_charging   = 0x0102;
-short __remain_time_map      = 0x0106;
-short __power_map            = 0x0108;
-short __energy_map           = 0x010A;
-short __remain_time_tx       = 0x0110;
-short __output_eng_tx        = 0x0120;
-short __total_out_eng_tx     = 0x0130;
-short __conn_line_comp       = 0x0140;
-short __charging_fee_map     = 0x0146;
-short __charging_fee_tx      = 0x0150;
-
-short __money_by_rate        = 0x0200;
-short __money_rate           = 0x0220;
-short __money_rate_map       = 0x0230;
-
-////For Audi, for select gun
-short __left_gun_map         = 0x0260;
-short __right_gun_map        = 0x0262;
-short __add_chk_btn          = 0x0264;
-//short __station_id         = 0x0270;
-short __balance              = 0x0270;
-short __remain_balance       = 0x0280;
-short __custStationIdL1      = 0x0450;
-//short __custStationIdL2      = 0x0470;
-short _emergency_map         = 0x011C;
+byte _everyPageRollChange = 0;
+short __conn_status = 0x0030;
+short __ethernet_status = 0x0032;
+short __3G4G_status = 0x0036;
+short __wifi_status = 0x003C;
+
+short __sel_gun_btn = 0x0040;
+short __ret_home_btn = 0x0042;
+short __stop_method_btn = 0x0044;
+
+short __qr_code = 0x0250;
+short __main_rfid = 0x0052;
+short __main_qr = 0x0054;
+short __main_app = 0x0056;
+
+short __plug_in_arrow = 0x0060;
+
+short __conn_line = 0x0066;
+
+short __gun_type_index = 0x0070;
+short __qr_code_pre = 0x0280;
+
+short __side_top = 0x0090;
+short __side_down = 0x0092;
+short __side_mid = 0x0094;
+
+short __conn_line_chag = 0x0096;
+short __batt_map = 0x0100;
+short __soc_value_charging = 0x0102;
+short __remain_time_map = 0x0106;
+short __power_map = 0x0108;
+short __energy_map = 0x010A;
+short __remain_time_tx = 0x0110;
+short __output_eng_tx = 0x0120;
+short __total_out_eng_tx = 0x0130;
+short __conn_line_comp = 0x0140;
+short __charging_fee_map = 0x0146;
+short __charging_fee_tx = 0x0150;
+
+short __money_by_rate = 0x0200;
+short __money_rate = 0x0220;
+short __money_rate_map = 0x0230;
 
 // ICON ID
-byte _disappear              = 0;
-byte _disconnect             = 1;
-byte _connect                = 2;
-byte _warning                = 3;
-byte _arrow_dark             = 4;
-byte _arrow_light            = 5;
-byte _3G4G_disconnect        = 6;
-byte __3G4G_connect          = 7;
-byte _wifi_disconnect        = 8;
-byte _wifi_connect           = 9;
-byte _logo                   = 10;
-byte _conn_map1              = 11;
-byte _conn_map2              = 12;
-byte _sel_gun_btn            = 13;
-byte _back_home_btn          = 14;
-byte _stop_charging_btn      = 15;
+byte _disappear = 0;
+byte _disconnect = 1;
+byte _connect = 2;
+byte _warning = 3;
+byte _arrow_dark = 4;
+byte _arrow_light = 5;
+byte _3G4G_disconnect = 6;
+byte __3G4G_connect = 7;
+byte _wifi_disconnect = 8;
+byte _wifi_connect = 9;
+byte _logo = 10;
+byte _conn_map1 = 11;
+byte _conn_map2 = 12;
+byte _sel_gun_btn = 13;
+byte _back_home_btn = 14;
+byte _stop_charging_btn = 15;
 byte _stop_charging_btn_scan = 16;
-byte _chademo_dark           = 17;
-byte _ccs_dark               = 18;
-byte _gbt_dark               = 19;
-byte _actype_dark            = 20;
-byte _chademo_light          = 21;
-byte _ccs_light              = 22;
-byte _gbt_light              = 23;
-byte _actype_light           = 24;
-byte _main_none_rfid         = 25;
-byte _main_rfid              = 26;
-byte _main_none_app          = 27;
-byte _main_app               = 28;
-byte _main_none_qr           = 29;
-byte _main_qr                = 30;
-byte _charging_map1          = 31;
-byte _charging_map2          = 32;
-byte _battery_empty          = 33;
-byte _battery_cap_20         = 34;
-byte _battery_cap_40         = 35;
-byte _battery_cap_60         = 36;
-byte _battery_cap_80         = 37;
-byte _battery_cap_100        = 38;
-byte _battery_map            = 39;
-byte _power_map              = 40;
-byte _time_map               = 41;
-byte _complete_map           = 42;
-byte _battery_soc_20         = 43;
-byte _battery_soc_40         = 44;
-byte _battery_soc_60         = 45;
-byte _battery_soc_80         = 46;
-byte _battery_soc_100        = 47;
-byte _battery_eng_map        = 48;
-byte _money_map              = 49;
-byte _elapse_time_map        = 50;
-byte _charging_money         = 51;
-//byte _side_none_rfid       = 52;
-//byte _side_rfid            = 53;
-//byte _side_none_app        = 54;
-//byte _side_app             = 55;
-//byte _side_none_qr         = 56;
-//byte _side_qr              = 57;
-byte _eth_disconnect         = 52; //58;
-byte _eth_connect            = 53; //59;
-
-byte _chademo_dark_cmp       = 54;
-byte _ccs_dark_cmp           = 55;
-byte _gbt_dark_cmp           = 56;
-byte _actype_dark_cmp        = 57;
-byte _chademo_light_cmp      = 58;
-byte _ccs_light_cmp          = 59;
-byte _gbt_light_cmp          = 60;
-byte _actype_light_cmp       = 61;
-
-////For Audi
-byte _left_gun_disable_map   = 66;
-byte _left_gun_enable_map    = 67;
-byte _right_gun_disable_map  = 68;
-byte _right_gun_enable_map   = 69;
-byte _select_gun_btn         = 70;
-byte _emergency_disable_map  = 72;
+byte _chademo_dark = 17;
+byte _ccs_dark = 18;
+byte _gbt_dark = 19;
+byte _actype_dark = 20;
+byte _chademo_light = 21;
+byte _ccs_light = 22;
+byte _gbt_light = 23;
+byte _actype_light = 24;
+byte _main_none_rfid = 25;
+byte _main_rfid = 26;
+byte _main_none_app = 27;
+byte _main_app = 28;
+byte _main_none_qr = 29;
+byte _main_qr = 30;
+byte _charging_map1 = 31;
+byte _charging_map2 = 32;
+byte _battery_empty = 33;
+byte _battery_cap_20 = 34;
+byte _battery_cap_40 = 35;
+byte _battery_cap_60 = 36;
+byte _battery_cap_80 = 37;
+byte _battery_cap_100 = 38;
+byte _battery_map = 39;
+byte _power_map = 40;
+byte _time_map = 41;
+byte _complete_map = 42;
+byte _battery_soc_20 = 43;
+byte _battery_soc_40 = 44;
+byte _battery_soc_60 = 45;
+byte _battery_soc_80 = 46;
+byte _battery_soc_100 = 47;
+byte _battery_eng_map = 48;
+byte _money_map = 49;
+byte _elapse_time_map = 50;
+byte _charging_money = 51;
+byte _side_none_rfid = 52;
+byte _side_rfid = 53;
+byte _side_none_app = 54;
+byte _side_app = 55;
+byte _side_none_qr = 56;
+byte _side_qr = 57;
+byte _eth_disconnect = 58;
+byte _eth_connect = 59;

+ 13 - 34
EVSE/Projects/DD360Audi/Apps/Module_LcmControl.c

@@ -1,4 +1,4 @@
-#include "Module_LcmContro.h"
+#include "ReModule_LcmControl.h"
 #include "Config.h"
 #include "AudiCust.h"
 
@@ -336,7 +336,7 @@ void ChangeWarningFunc()
     // 最多一次五筆
     //PRINTF_FUNC("LCM PageIndex = %d \n", ShmSysConfigAndInfo->SysWarningInfo.PageIndex);
     //PRINTF_FUNC("WarningCount = %d \n", ShmSysConfigAndInfo->SysWarningInfo.WarningCount);
-#if 0
+#if !defined DD360 && !defined DD360Audi
     for (i = 0; (i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
         memset(cmd, 0x00, sizeof(cmd));
         if ((i) >= 5) {
@@ -400,7 +400,7 @@ void ChangeWarningFunc()
         DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
     }
 
-#endif
+#endif //!defined DD360 && !defined DD360Audi
 }
 
 //================================================
@@ -408,6 +408,7 @@ void ChangeWarningFunc()
 //================================================
 void ChangeQrCode_Idle(char *input)
 {
+#if defined DD360Audi
     int len = strlen(input) + 3;
     int loop = 0;
     int i = 0, j = 0, k = 0, l = 0;
@@ -467,7 +468,7 @@ void ChangeQrCode_Idle(char *input)
         DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
     }*/
 
-#if 0
+#else
     int len = strlen(input);
     byte cmd[len];
 
@@ -479,11 +480,12 @@ void ChangeQrCode_Idle(char *input)
     }
 
     DisplayValueToLcm(__qr_code, cmd, len);
-#endif //0
+#endif defined DD360Audi
 }
 
 void ChangeQrCode_Charge(char *input)
 {
+#if defined DD360Audi
     int len = strlen(input) + 3;
     int loop = 0;
     int i = 0, j = 0, k = 0, l = 0;
@@ -541,7 +543,7 @@ void ChangeQrCode_Charge(char *input)
         DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
     }*/
 
-#if 0
+#else
     int len = strlen(input);
     byte cmd[len];
 
@@ -553,7 +555,7 @@ void ChangeQrCode_Charge(char *input)
     }
 
     DisplayValueToLcm(__qr_code_pre, cmd, len);
-#endif //0
+#endif //defined DD360Audi
 }
 
 //================================================
@@ -1066,6 +1068,7 @@ void ProcessPageInfo()
     _page_reload = IsPageReloadChk();
 
     switch (_currentPage) {
+#if defined DD360Audi
     case _LCM_SELECT_GUN: ////For Audi
         if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == 0) {
             ChangeDisplay2Value(__left_gun_map, _left_gun_enable_map);
@@ -1076,6 +1079,7 @@ void ProcessPageInfo()
         }
         ChangeDisplay2Value(__add_chk_btn, _select_gun_btn);
         break;
+#endif //defined DD360Audi
 
     case _LCM_IDLE: {
         if (ShmSysConfigAndInfo->SysConfig.isRFID) {
@@ -1111,41 +1115,16 @@ void ProcessPageInfo()
     case _LCM_AUTHORIZ_FAIL:
     case _LCM_WAIT_FOR_PLUG: {
         FirstPageChanged();
+#if defined DD360Audi
         if (_currentPage == _LCM_AUTHORIZ_COMP) { ////For Audi
             ChangeBalanceValue(__balance, ShmSysConfigAndInfo->SysInfo.CurGunSelected);
         }
+#endif //defined DD360Audi
     }
     break;
     case _LCM_PRE_CHARGE:
     case _LCM_CHARGING:
     case _LCM_COMPLETE: {
-#if 0
-        if (_totalCount + acgunCount >= 2) {
-            if (ShmSysConfigAndInfo->SysConfig.isRFID) {
-                ChangeDisplay2Value(__side_top, _side_rfid);
-            } else {
-                ChangeDisplay2Value(__side_top, _side_none_rfid);
-            }
-
-            if (ShmSysConfigAndInfo->SysConfig.isQRCode) {
-                ChangeDisplay2Value(__side_mid, _side_qr);
-            } else {
-                ChangeDisplay2Value(__qr_code_pre, _disappear);
-                ChangeDisplay2Value(__side_mid, _side_none_qr);
-                needReloadQr = true;
-            }
-
-            if (ShmSysConfigAndInfo->SysConfig.isAPP) {
-                ChangeDisplay2Value(__side_down, _side_app);
-            } else {
-                ChangeDisplay2Value(__side_down, _side_none_app);
-            }
-        } else {
-            ChangeDisplay2Value(__side_top, _disappear);
-            ChangeDisplay2Value(__side_mid, _disappear);
-            ChangeDisplay2Value(__side_down, _disappear);
-        }
-#endif //0
 
         bool isShowAc = false;
         if (acgunCount > 0) {

+ 448 - 396
EVSE/Projects/DD360Audi/Apps/Module_PrimaryComm.c

@@ -1,51 +1,51 @@
-#include    <sys/time.h>
-#include    <sys/timeb.h>
+#include 	<sys/time.h>
+#include 	<sys/timeb.h>
 #include    <sys/types.h>
 #include    <sys/stat.h>
-#include    <sys/types.h>
-#include    <sys/ioctl.h>
-#include    <sys/socket.h>
-#include    <sys/ipc.h>
-#include    <sys/shm.h>
-#include    <sys/shm.h>
-#include    <sys/mman.h>
-#include    <linux/wireless.h>
-#include    <arpa/inet.h>
-#include    <netinet/in.h>
-
-#include    <unistd.h>
-#include    <stdarg.h>
-#include    <stdio.h>      /*璅蹱�頛詨�頛詨枂摰𡁶儔*/
-#include    <stdlib.h>     /*璅蹱��賣彍摨怠�蝢�*/
-#include    <unistd.h>     /*Unix 璅蹱��賣彍摰𡁶儔*/
-#include    <fcntl.h>      /*瑼娍綉�嗅�蝢�*/
-#include    <termios.h>    /*PPSIX 蝯�垢�批�摰𡁶儔*/
-#include    <errno.h>      /*�航炊�笔�蝢�*/
-#include    <errno.h>
-#include    <string.h>
-#include    <time.h>
-#include    <ctype.h>
-#include    <ifaddrs.h>
-#include    <math.h>
-#include    "../../define.h"
-#include    "PrimaryComm.h"
-#include    <stdbool.h>
-
-#define ARRAY_SIZE(A)       (sizeof(A) / sizeof(A[0]))
-#define PASS                1
-#define FAIL                -1
-#define YES                 1
-#define NO                  0
-
-typedef unsigned char       byte;
-
-struct SysConfigAndInfo         *ShmSysConfigAndInfo;
-struct StatusCodeData           *ShmStatusCodeData;
-struct PrimaryMcuData           *ShmPrimaryMcuData;
+#include 	<sys/types.h>
+#include 	<sys/ioctl.h>
+#include 	<sys/socket.h>
+#include 	<sys/ipc.h>
+#include 	<sys/shm.h>
+#include 	<sys/shm.h>
+#include 	<sys/mman.h>
+#include 	<linux/wireless.h>
+#include 	<arpa/inet.h>
+#include 	<netinet/in.h>
+
+#include 	<unistd.h>
+#include 	<stdarg.h>
+#include    <stdio.h>      /*標準輸入輸出定義*/
+#include    <stdlib.h>     /*標準函數庫定義*/
+#include    <unistd.h>     /*Unix 標準函數定義*/
+#include    <fcntl.h>      /*檔控制定義*/
+#include    <termios.h>    /*PPSIX 終端控制定義*/
+#include    <errno.h>      /*錯誤號定義*/
+#include 	<errno.h>
+#include 	<string.h>
+#include	<time.h>
+#include	<ctype.h>
+#include 	<ifaddrs.h>
+#include 	<math.h>
+#include	"../../define.h"
+#include	"PrimaryComm.h"
+#include 	<stdbool.h>
+
+#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
+#define PASS				1
+#define FAIL				-1
+#define YES					1
+#define NO					0
+
+typedef unsigned char 		byte;
+
+struct SysConfigAndInfo			*ShmSysConfigAndInfo;
+struct StatusCodeData 			*ShmStatusCodeData;
+struct PrimaryMcuData			*ShmPrimaryMcuData;
 
 void trim(char *s);
-int mystrcmp(char *p1, char *p2);
-void substr(char *dest, const char *src, unsigned int start, unsigned int cnt);
+int mystrcmp(char *p1,char *p2);
+void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
 void split(char **arr, char *str, const char *del);
 
 int Uart1Fd;
@@ -56,7 +56,7 @@ Rtc rtc;
 
 struct timeval _flash_time;
 byte flash = NO;
-struct ChargingInfoData *ChargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+struct ChargingInfoData *ChargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];	
 unsigned char ChillerSwitch;
 unsigned int ChillerOnTime;
 
@@ -69,123 +69,124 @@ int StoreLogMsg(const char *fmt, ...);
 
 int StoreLogMsg(const char *fmt, ...)
 {
-    char Buf[4096 + 256];
-    char buffer[4096];
-    va_list args;
-    struct timeb  SeqEndTime;
-    struct tm *tm;
-
-    va_start(args, fmt);
-    int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-    va_end(args);
-
-    memset(Buf, 0, sizeof(Buf));
-    ftime(&SeqEndTime);
-    SeqEndTime.time = time(NULL);
-    tm = localtime(&SeqEndTime.time);
-
-    if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES) {
-        sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
-                tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
-        printf("%s \n", Buf);
-    } else {
-        sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-                tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
-                buffer,
-                tm->tm_year + 1900, tm->tm_mon + 1);
-        system(Buf);
-    }
-
-    return rc;
+	char Buf[4096+256];
+	char buffer[4096];
+	va_list args;
+	struct timeb  SeqEndTime;
+	struct tm *tm;
+
+	va_start(args, fmt);
+	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
+	va_end(args);
+
+	memset(Buf,0,sizeof(Buf));
+	ftime(&SeqEndTime);
+	SeqEndTime.time = time(NULL);
+	tm=localtime(&SeqEndTime.time);
+
+	if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
+	{
+		sprintf(Buf,"%02d:%02d:%02d:%03d - %s",
+			tm->tm_hour,tm->tm_min,tm->tm_sec,SeqEndTime.millitm, buffer);
+		printf("%s \n", Buf);
+	}
+	else
+	{
+		sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
+			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,SeqEndTime.millitm,
+			buffer,
+			tm->tm_year+1900,tm->tm_mon+1);
+		system(Buf);
+	}
+
+	return rc;
 }
 
 int DiffTimeb(struct timeb ST, struct timeb ET)
 {
-    //return milli-second
-    unsigned int StartTime, StopTime;
+	//return milli-second
+	unsigned int StartTime,StopTime;
 
-    StartTime = (unsigned int)ST.time;
-    StopTime = (unsigned int)ET.time;
-    return (StopTime - StartTime) * 1000 + ET.millitm - ST.millitm;
+	StartTime=(unsigned int)ST.time;
+	StopTime=(unsigned int)ET.time;
+	return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
 }
 
 void PRINTF_FUNC(char *string, ...)
 {
-    va_list args;
-    char buffer[4096];
-    va_start(args, string);
-    vsnprintf(buffer, sizeof(buffer), string, args);
-    va_end(args);
+	va_list args;
+	char buffer[4096];
+	va_start(args, string);
+	vsnprintf(buffer, sizeof(buffer), string, args);
+	va_end(args);
 
-    DEBUG_INFO("%s \n", buffer);
+	DEBUG_INFO("%s \n", buffer);
 }
 //=================================
 // Common routine
 //=================================
-char *getTimeString(void)
+char* getTimeString(void)
 {
-    char *result = malloc(21);
-    time_t timep;
-    struct tm *p;
-    time(&timep);
-    p = gmtime(&timep);
+	char *result=malloc(21);
+	time_t timep;
+	struct tm *p;
+	time(&timep);
+	p=gmtime(&timep);
 
-    sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900 + p->tm_year), (1 + p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
+	sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
 
-    return result;
+	return result;
 }
 
 void trim(char *s)
 {
-    int i = 0, j, k, l = 0;
+    int i=0, j, k, l=0;
 
-    while ((s[i] == ' ') || (s[i] == '\t') || (s[i] == '\n')) {
+    while((s[i]==' ')||(s[i]=='\t')||(s[i]=='\n'))
         i++;
-    }
 
-    j = strlen(s) - 1;
-    while ((s[j] == ' ') || (s[j] == '\t') || (s[j] == '\n')) {
+    j = strlen(s)-1;
+    while((s[j]==' ')||(s[j]=='\t')||(s[j]=='\n'))
         j--;
-    }
 
-    if (i == 0 && j == strlen(s) - 1) { }
-    else if (i == 0) { s[j + 1] = '\0'; }
+    if(i==0 && j==strlen(s)-1) { }
+    else if(i==0) s[j+1] = '\0';
     else {
-        for (k = i; k <= j; k++) { s[l++] = s[k]; }
+        for(k=i; k<=j; k++) s[l++] = s[k];
         s[l] = '\0';
     }
 }
 
-int mystrcmp(char *p1, char *p2)
+int mystrcmp(char *p1,char *p2)
 {
-    while (*p1 == *p2) {
-        if (*p1 == '\0' || *p2 == '\0') {
+    while(*p1==*p2)
+    {
+        if(*p1=='\0' || *p2=='\0')
             break;
-        }
         p1++;
         p2++;
     }
-    if (*p1 == '\0' && *p2 == '\0') {
-        return (PASS);
-    } else {
-        return (FAIL);
-    }
+    if(*p1=='\0' && *p2=='\0')
+        return(PASS);
+    else
+        return(FAIL);
 }
 
-void substr(char *dest, const char *src, unsigned int start, unsigned int cnt)
+void substr(char *dest, const char* src, unsigned int start, unsigned int cnt)
 {
-    strncpy(dest, src + start, cnt);
-    dest[cnt] = 0;
+	strncpy(dest, src + start, cnt);
+	dest[cnt] = 0;
 }
 
 void split(char **arr, char *str, const char *del)
 {
-    char *s = strtok(str, del);
+	char *s = strtok(str, del);
 
-    while (s != NULL) {
-        *arr++ = s;
-        s = strtok(NULL, del);
-    }
+	while(s != NULL)
+	{
+		*arr++ = s;
+		s = strtok(NULL, del);
+	}
 }
 
 //==========================================
@@ -193,47 +194,56 @@ void split(char **arr, char *str, const char *del)
 //==========================================
 int InitShareMemory()
 {
-    int result = PASS;
-    int MeterSMId;
-
-    //creat ShmSysConfigAndInfo
-    if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0) {
-#ifdef SystemLogMessage
-        DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
-#endif
-        result = FAIL;
-    } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-#ifdef SystemLogMessage
-        DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
-#endif
-        result = FAIL;
-    }
-
-    //creat ShmStatusCodeData
-    if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0) {
-#ifdef SystemLogMessage
-        DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
-#endif
-        result = FAIL;
-    } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-#ifdef SystemLogMessage
-        DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
-#endif
-        result = FAIL;
-    }
-
-    //creat ShmStatusCodeData
-    if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0) {
-#ifdef SystemLogMessage
-        DEBUG_ERROR("shmget ShmPrimaryMcuData NG\n");
-#endif
-        result = FAIL;
-    } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-#ifdef ShmPrimaryMcuData
-        DEBUG_ERROR("shmat ShmPrimaryMcuData NG\n");
-#endif
-        result = FAIL;
-    }
+	int result = PASS;
+	int MeterSMId;
+
+	//creat ShmSysConfigAndInfo
+	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0)
+    {
+		#ifdef SystemLogMessage
+		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
+		#endif
+		result = FAIL;
+	}
+    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+    	#ifdef SystemLogMessage
+    	DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
+		#endif
+    	result = FAIL;
+   	 }
+
+   	 //creat ShmStatusCodeData
+   	 if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0)
+    {
+		#ifdef SystemLogMessage
+   		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
+		#endif
+   		result = FAIL;
+	}
+    else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+    {
+    	#ifdef SystemLogMessage
+    	DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
+		#endif
+    	result = FAIL;
+   	}
+
+	//creat ShmStatusCodeData
+	if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0)
+	{
+		#ifdef SystemLogMessage
+		DEBUG_ERROR("shmget ShmPrimaryMcuData NG\n");
+		#endif
+		result = FAIL;
+	}
+	else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		#ifdef ShmPrimaryMcuData
+		DEBUG_ERROR("shmat ShmPrimaryMcuData NG\n");
+		#endif
+		result = FAIL;
+	}
 
     return result;
 }
@@ -243,138 +253,156 @@ int InitShareMemory()
 //================================================
 void GetFwAndHwVersion()
 {
-    if (Query_FW_Ver(Uart1Fd, Addr.IoExtend, &ver) == PASS) {
-        //PRINTF_FUNC("Primary FW Rev = %s \n", ver.Version_FW);
-        strcpy((char *)ShmPrimaryMcuData->version, ver.Version_FW);
-        strcpy((char *) ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ver.Version_FW);
-    }
-
-    if (Query_HW_Ver(Uart1Fd, Addr.IoExtend, &ver) == PASS)
-        ;//PRINTF_FUNC("Primary HW Rev  = %s \n", ver.Version_HW);
+	if(Query_FW_Ver(Uart1Fd, Addr.IoExtend, &ver) == PASS)
+	{
+		//PRINTF_FUNC("Primary FW Rev = %s \n", ver.Version_FW);
+		strcpy((char *)ShmPrimaryMcuData->version, ver.Version_FW);
+		strcpy((char *) ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ver.Version_FW);
+	}
+
+	if (Query_HW_Ver(Uart1Fd, Addr.IoExtend, &ver) == PASS)
+		;//PRINTF_FUNC("Primary HW Rev  = %s \n", ver.Version_HW);
 }
 
 void GetInputGpioStatus()
 {
-    //PRINTF_FUNC("GetInputGpioStatus \n");
-    if (Query_Gpio_Input(Uart1Fd, Addr.IoExtend, &gpio_in) == PASS) {
-#if !defined DD360 && !defined DD360Audi
-        ShmSysConfigAndInfo->SysInfo.AcContactorStatus = ShmPrimaryMcuData->InputDet.bits.AcContactorDetec = gpio_in.AC_Connector;
-        ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec = gpio_in.AC_MainBreaker;
-#else
-        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning = ~gpio_in.AC_Connector;
-        ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsLiquidChillerWaterLevelFault = ~gpio_in.AC_MainBreaker;
-#endif //!defined DD360 && !defined DD360Audi
-
-        ShmPrimaryMcuData->InputDet.bits.SpdDetec = gpio_in.SPD;
-        ShmPrimaryMcuData->InputDet.bits.DoorOpen = ~gpio_in.Door_Open;
-
-        ShmPrimaryMcuData->InputDet.bits.Button1 = gpio_in.Button[0];
-        ShmPrimaryMcuData->InputDet.bits.Button2 = gpio_in.Button[1];
-        ShmPrimaryMcuData->InputDet.bits.EmergencyButton = gpio_in.Emergency_Btn;
-        ShmPrimaryMcuData->InputDet.bits.Key0 = ~gpio_in.Key[0] & 0x01;
-        ShmPrimaryMcuData->InputDet.bits.Key1 = ~gpio_in.Key[1] & 0x01;
-        ShmPrimaryMcuData->InputDet.bits.Key2 = ~gpio_in.Key[2] & 0x01;
-        ShmPrimaryMcuData->InputDet.bits.Key3 = ~gpio_in.Key[3] & 0x01;
-        /*printf(" gpio_in.Key[0]~ gpio_in.Key[3]=%d, %d, %d, %d\n",
-        ShmPrimaryMcuData->InputDet.bits.Key0 , ShmPrimaryMcuData->InputDet.bits.Key1,
-        ShmPrimaryMcuData->InputDet.bits.Key2,ShmPrimaryMcuData->InputDet.bits.Key3);
-        printf("ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning=%d\n", ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning);
-        printf("ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsLiquidChillerWaterLevelFault=%d\n", ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsLiquidChillerWaterLevelFault);
-        */
-        //PRINTF_FUNC("left = %d \n", ShmPrimaryMcuData->InputDet.bits.Button1);
-        //PRINTF_FUNC("right = %d \n", ShmPrimaryMcuData->InputDet.bits.Button2);
-        //PRINTF_FUNC("ShmSysConfigAndInfo->SysInfo.AcContactorStatus = %d \n", ShmSysConfigAndInfo->SysInfo.AcContactorStatus);
-#if !defined DD360 && !defined DD360Audi
-        if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == YES) {
-            DEBUG_ERROR("AC Mainbreaker occur. \n");
-        }
-#endif //!defined DD360 && !defined DD360Audi
-    }
+	//PRINTF_FUNC("GetInputGpioStatus \n");
+	if (Query_Gpio_Input(Uart1Fd, Addr.IoExtend, &gpio_in) == PASS)
+	{
+		#ifndef DD360
+		ShmSysConfigAndInfo->SysInfo.AcContactorStatus = ShmPrimaryMcuData->InputDet.bits.AcContactorDetec = gpio_in.AC_Connector;
+		ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec = gpio_in.AC_MainBreaker;
+		#else
+		ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning = ~gpio_in.AC_Connector;
+		ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsLiquidChillerWaterLevelFault = ~gpio_in.AC_MainBreaker;
+		#endif
+		
+		ShmPrimaryMcuData->InputDet.bits.SpdDetec = gpio_in.SPD;
+		ShmPrimaryMcuData->InputDet.bits.DoorOpen = ~gpio_in.Door_Open;
+
+		ShmPrimaryMcuData->InputDet.bits.Button1 = gpio_in.Button[0];
+		ShmPrimaryMcuData->InputDet.bits.Button2 = gpio_in.Button[1];
+		ShmPrimaryMcuData->InputDet.bits.EmergencyButton = gpio_in.Emergency_Btn;
+		ShmPrimaryMcuData->InputDet.bits.Key0 = ~gpio_in.Key[0]&0x01;	
+		ShmPrimaryMcuData->InputDet.bits.Key1 = ~gpio_in.Key[1]&0x01;
+		ShmPrimaryMcuData->InputDet.bits.Key2 = ~gpio_in.Key[2]&0x01;
+		ShmPrimaryMcuData->InputDet.bits.Key3 = ~gpio_in.Key[3]&0x01;
+		/*printf(" gpio_in.Key[0]~ gpio_in.Key[3]=%d, %d, %d, %d\n", 
+		ShmPrimaryMcuData->InputDet.bits.Key0 , ShmPrimaryMcuData->InputDet.bits.Key1,
+		ShmPrimaryMcuData->InputDet.bits.Key2,ShmPrimaryMcuData->InputDet.bits.Key3);
+		printf("ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning=%d\n", ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning);
+		printf("ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsLiquidChillerWaterLevelFault=%d\n", ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsLiquidChillerWaterLevelFault);
+		*/
+		//PRINTF_FUNC("left = %d \n", ShmPrimaryMcuData->InputDet.bits.Button1);
+		//PRINTF_FUNC("right = %d \n", ShmPrimaryMcuData->InputDet.bits.Button2);
+		//PRINTF_FUNC("ShmSysConfigAndInfo->SysInfo.AcContactorStatus = %d \n", ShmSysConfigAndInfo->SysInfo.AcContactorStatus);
+		#ifndef DD360
+		if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == YES)
+			DEBUG_ERROR("AC Mainbreaker occur. \n");
+		#endif	
+	}
 }
 
 void SetOutputGpio(byte flash)
 {
-    Gpio_out gpio;
-    gpio.Button_LED[0] = flash;
-    gpio.Button_LED[1] = flash;
-
-    gpio.System_LED[0] = 0x00;
-    gpio.System_LED[1] = 0x00;
-    gpio.System_LED[2] = 0x00;
-    gpio.System_LED[3] = 0x00;
-
-#if defined DD360 || defined DD360Audi
-    if ((ChargingData[0]->PresentChargingCurrent) >= 150) {
-        ChillerSwitch = 1;
-        ChillerOnTime = time((time_t *)NULL);
-    } else {
-        if (ChillerSwitch == 1) {
-            if ((ChargingData[0]->PresentChargingCurrent) >= 100) {
-                ChillerSwitch = 1;
-                ChillerOnTime = time((time_t *)NULL);
-            } else {
-                if ((time((time_t *)NULL) - ChillerOnTime) >= 600) {
-                    ChillerSwitch = 0;
-                } else {
-                    ChillerSwitch = 1;
-                }
-            }
-        } else {
-            ChillerSwitch = 0;
-        }
-    }
-    gpio.AC_Connector = ChillerSwitch;//Chiller ON/OFF Control, "0: Chiller disable, 1: Chiller enable"
-
-    //printf("ChargingData[0]->PresentChargingCurrent=%f,ChargingData[1]->PresentChargingCurrent=%f,ChillerSwitch=%d\n",ChargingData[0]->PresentChargingCurrent,ChargingData[1]->PresentChargingCurrent,ChillerSwitch);
-#else
-    gpio.AC_Connector = 0x00;
-#endif //defined DD360 || DD360Audi
-
-    gpio.AC_Breaker = 0x00;
-
-    if (Config_Gpio_Output(Uart1Fd, Addr.IoExtend, &gpio) == PASS) {
-        //PRINTF_FUNC("SetOutputGpio sucessfully. %d \n", flash);
-    } else {
-        //PRINTF_FUNC("SetOutputGpio fail. \n");
-    }
+	Gpio_out gpio;
+	gpio.Button_LED[0] = flash;
+	gpio.Button_LED[1] = flash;
+
+	gpio.System_LED[0] = 0x00;
+	gpio.System_LED[1] = 0x00;
+	gpio.System_LED[2] = 0x00;
+	gpio.System_LED[3] = 0x00;
+	
+	#ifdef DD360
+	if((ChargingData[0]->PresentChargingCurrent)>=150)
+	{	
+		ChillerSwitch=1;
+		ChillerOnTime=time((time_t*)NULL);
+	}
+	else
+	{
+		if(ChillerSwitch==1)
+		{
+			if((ChargingData[0]->PresentChargingCurrent)>=100)
+			{	
+				ChillerSwitch=1;
+				ChillerOnTime=time((time_t*)NULL);
+			}
+			else
+			{
+				if((time((time_t*)NULL)-ChillerOnTime)>=600)
+				{
+					ChillerSwitch=0;
+				}
+				else
+				{
+					ChillerSwitch=1;	
+				}
+			}		
+		}	
+		else
+		{
+			ChillerSwitch=0;
+		}
+	}	
+	gpio.AC_Connector = ChillerSwitch;//Chiller ON/OFF Control, "0: Chiller disable, 1: Chiller enable"
+	
+	//printf("ChargingData[0]->PresentChargingCurrent=%f,ChargingData[1]->PresentChargingCurrent=%f,ChillerSwitch=%d\n",ChargingData[0]->PresentChargingCurrent,ChargingData[1]->PresentChargingCurrent,ChillerSwitch);
+	#else
+	gpio.AC_Connector = 0x00;
+	#endif
+	gpio.AC_Breaker = 0x00;
+
+	if (Config_Gpio_Output(Uart1Fd, Addr.IoExtend, &gpio) == PASS)
+	{
+		//PRINTF_FUNC("SetOutputGpio sucessfully. %d \n", flash);
+	}
+	else
+	{
+		//PRINTF_FUNC("SetOutputGpio fail. \n");
+	}
 }
 
 void SetRtcData()
 {
-    struct timeb csuTime;
-    struct tm *tmCSU;
-
-    ftime(&csuTime);
-    tmCSU = localtime(&csuTime.time);
-//  PRINTF_FUNC("Time : %04d-%02d-%02d %02d:%02d:%02d \n", tmCSU->tm_year + 1900,
-//          tmCSU->tm_mon + 1, tmCSU->tm_mday, tmCSU->tm_hour, tmCSU->tm_min,
-//          tmCSU->tm_sec);
-
-    rtc.RtcData[0] = '0' + (tmCSU->tm_year + 1900) / 1000 % 10;
-    rtc.RtcData[1] = '0' + (tmCSU->tm_year + 1900) / 100 % 10;
-    rtc.RtcData[2] = '0' + (tmCSU->tm_year + 1900) / 10 % 10;
-    rtc.RtcData[3] = '0' + (tmCSU->tm_year + 1900) / 1 % 10;
-
-    rtc.RtcData[4] = '0' + (tmCSU->tm_mon + 1) / 10 % 10;
-    rtc.RtcData[5] = '0' + (tmCSU->tm_mon + 1) / 1 % 10;
-
-    rtc.RtcData[6] = '0' + (tmCSU->tm_mday) / 10 % 10;
-    rtc.RtcData[7] = '0' + (tmCSU->tm_mday) / 1 % 10;
-
-    rtc.RtcData[8] = '0' + (tmCSU->tm_hour) / 10 % 10;
-    rtc.RtcData[9] = '0' + (tmCSU->tm_hour) / 1 % 10;
-
-    rtc.RtcData[10] = '0' + (tmCSU->tm_min) / 10 % 10;
-    rtc.RtcData[11] = '0' + (tmCSU->tm_min) / 1 % 10;
-
-    rtc.RtcData[12] = '0' + (tmCSU->tm_sec) / 10 % 10;
-    rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
-
-    if (Config_Rtc_Data(Uart1Fd, Addr.IoExtend, &rtc) == PASS) {
-        //PRINTF_FUNC("SetRtc sucessfully. \n");
-    } else {
-        //PRINTF_FUNC("SetRtc fail. \n");
-    }
+	struct timeb csuTime;
+	struct tm *tmCSU;
+
+	ftime(&csuTime);
+	tmCSU = localtime(&csuTime.time);
+//	PRINTF_FUNC("Time : %04d-%02d-%02d %02d:%02d:%02d \n", tmCSU->tm_year + 1900,
+//			tmCSU->tm_mon + 1, tmCSU->tm_mday, tmCSU->tm_hour, tmCSU->tm_min,
+//			tmCSU->tm_sec);
+
+	rtc.RtcData[0] = '0' + (tmCSU->tm_year + 1900) / 1000 % 10;
+	rtc.RtcData[1] = '0' + (tmCSU->tm_year + 1900) / 100 % 10;
+	rtc.RtcData[2] = '0' + (tmCSU->tm_year + 1900) / 10 % 10;
+	rtc.RtcData[3] = '0' + (tmCSU->tm_year + 1900) / 1 % 10;
+
+	rtc.RtcData[4] = '0' + (tmCSU->tm_mon + 1) / 10 % 10;
+	rtc.RtcData[5] = '0' + (tmCSU->tm_mon + 1) / 1 % 10;
+
+	rtc.RtcData[6] = '0' + (tmCSU->tm_mday) / 10 % 10;
+	rtc.RtcData[7] = '0' + (tmCSU->tm_mday) / 1 % 10;
+
+	rtc.RtcData[8] = '0' + (tmCSU->tm_hour) / 10 % 10;
+	rtc.RtcData[9] = '0' + (tmCSU->tm_hour) / 1 % 10;
+
+	rtc.RtcData[10] = '0' + (tmCSU->tm_min) / 10 % 10;
+	rtc.RtcData[11] = '0' + (tmCSU->tm_min) / 1 % 10;
+
+	rtc.RtcData[12] = '0' + (tmCSU->tm_sec) / 10 % 10;
+	rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
+
+	if (Config_Rtc_Data(Uart1Fd, Addr.IoExtend, &rtc) == PASS)
+	{
+		//PRINTF_FUNC("SetRtc sucessfully. \n");
+	}
+	else
+	{
+		//PRINTF_FUNC("SetRtc fail. \n");
+	}
 }
 
 //================================================
@@ -382,136 +410,160 @@ void SetRtcData()
 //================================================
 int InitComPort()
 {
-    int fd;
-    struct termios tios;
-
-    fd = open(priPortName, O_RDWR);
-    if (fd <= 0) {
-#ifdef SystemLogMessage
-        DEBUG_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;
-    tios.c_iflag = 0;
-    tios.c_oflag = 0;
-    tios.c_cc[VMIN] = 0;
-    tios.c_cc[VTIME] = (unsigned char)1;
-    tios.c_lflag = 0;
-    tcflush(fd, TCIFLUSH);
-    ioctl (fd, TCSETS, &tios);
-
-    return fd;
+	int fd;
+	struct termios tios;
+
+	fd = open(priPortName, O_RDWR);
+	if(fd<=0)
+	{
+		#ifdef SystemLogMessage
+		DEBUG_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;
+	tios.c_iflag = 0;
+	tios.c_oflag = 0;
+	tios.c_cc[VMIN]=0;
+	tios.c_cc[VTIME]=(unsigned char)1;
+	tios.c_lflag=0;
+	tcflush(fd, TCIFLUSH);
+	ioctl (fd, TCSETS, &tios);
+
+	return fd;
 }
 
 unsigned long GetTimeoutValue(struct timeval _sour_time)
 {
-    struct timeval _end_time;
-    gettimeofday(&_end_time, NULL);
+	struct timeval _end_time;
+	gettimeofday(&_end_time, NULL);
 
-    return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
+	return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
 }
 
 int FindChargingInfoData(byte target, struct ChargingInfoData **chargingData)
 {
-    for (byte index = 0; index < CHAdeMO_QUANTITY; index++) {
-        if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target) {
-            chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
-            return 1;
-        }
-    }
-
-    for (byte index = 0; index < CCS_QUANTITY; index++) {
-        if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target) {
-            chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
-            return 1;
-        }
-    }
-
-    for (byte index = 0; index < GB_QUANTITY; index++) {
-        if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target) {
-            chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
-            return 1;
-        }
-    }
-
-    return 0;
+	for (byte index = 0; index < CHAdeMO_QUANTITY; index++)
+	{
+		if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target)
+		{
+			chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
+			return 1;
+		}
+	}
+
+	for (byte index = 0; index < CCS_QUANTITY; index++)
+	{
+		if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target)
+		{
+			chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
+			return 1;
+		}
+	}
+
+	for (byte index = 0; index < GB_QUANTITY; index++)
+	{
+		if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target)
+		{
+			chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
+			return 1;
+		}
+	}
+
+	return 0;
 }
 
 int main(void)
 {
-    if (InitShareMemory() == FAIL) {
-#ifdef SystemLogMessage
-        DEBUG_ERROR("InitShareMemory NG\n");
-#endif
-        if (ShmStatusCodeData != NULL) {
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
-        }
-        sleep(5);
-        return 0;
-    }
+	if(InitShareMemory() == FAIL)
+	{
+		#ifdef SystemLogMessage
+		DEBUG_ERROR("InitShareMemory NG\n");
+		#endif
+		if(ShmStatusCodeData!=NULL)
+		{
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
+		}
+		sleep(5);
+		return 0;
+	}
+	
+	for (byte _index = 0; _index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; _index++)
+	{
+		if (!FindChargingInfoData(_index, &ChargingData[0]))
+		{
+			DEBUG_ERROR("FindChargingInfoData false \n");
+			break;
+		}
+	}
+	ChillerSwitch=0;
+	Uart1Fd = InitComPort();
+	//PRINTF_FUNC("407 Port id = %d \n", Uart1Fd);
+
+	if(Uart1Fd < 0)
+	{
+		#ifdef SystemLogMessage
+		DEBUG_ERROR("InitComPort (Uart1 : AM3352 - STM32) NG");
+		#endif
+
+		if (ShmStatusCodeData != NULL)
+		{
+			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = 1;
+		}
+		sleep(5);
+		return 0;
+	}
+
+	SetRtcData();
+	gettimeofday(&_flash_time, NULL);
+	for(;;)
+	{
+		if (strcmp((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, " ") == 0x00)
+		{
+			if ((GetTimeoutValue(_flash_time) / 1000) > 1000)
+			{
+				if (flash == NO)
+					flash = YES;
+				else
+					flash = NO;
+				SetOutputGpio(flash);
+				gettimeofday(&_flash_time, NULL);
+			}
+		}
+		else
+		{
+			if ((GetTimeoutValue(_flash_time) / 1000) > 5000)
+			{
+				if (flash == NO)
+					flash = YES;
+
+				SetOutputGpio(flash);
+				gettimeofday(&_flash_time, NULL);
+			}
+		}
+
+		// 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
+		// 模組更新 FW 後,需重新做
+		if(ShmPrimaryMcuData->SelfTest_Comp != PASS)
+		{
+			//PRINTF_FUNC("(407) Get Fw and Hw Ver. \n");
+			GetFwAndHwVersion();
+			sleep(1);
+			ShmPrimaryMcuData->SelfTest_Comp = PASS;
+		}
+		else
+		{
+			GetInputGpioStatus();
+		}
+
+		usleep(100000);
+	}
+
+	return FAIL;
+}
+
 
-    for (byte _index = 0; _index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; _index++) {
-        if (!FindChargingInfoData(_index, &ChargingData[0])) {
-            DEBUG_ERROR("FindChargingInfoData false \n");
-            break;
-        }
-    }
-    ChillerSwitch = 0;
-    Uart1Fd = InitComPort();
-    //PRINTF_FUNC("407 Port id = %d \n", Uart1Fd);
-
-    if (Uart1Fd < 0) {
-#ifdef SystemLogMessage
-        DEBUG_ERROR("InitComPort (Uart1 : AM3352 - STM32) NG");
-#endif
-
-        if (ShmStatusCodeData != NULL) {
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CsuInitFailed = 1;
-        }
-        sleep(5);
-        return 0;
-    }
 
-    SetRtcData();
-    gettimeofday(&_flash_time, NULL);
-    for (;;) {
-        if (strcmp((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, " ") == 0x00) {
-            if ((GetTimeoutValue(_flash_time) / 1000) > 1000) {
-                if (flash == NO) {
-                    flash = YES;
-                } else {
-                    flash = NO;
-                }
-                SetOutputGpio(flash);
-                gettimeofday(&_flash_time, NULL);
-            }
-        } else {
-            if ((GetTimeoutValue(_flash_time) / 1000) > 5000) {
-                if (flash == NO) {
-                    flash = YES;
-                }
-
-                SetOutputGpio(flash);
-                gettimeofday(&_flash_time, NULL);
-            }
-        }
-
-        // 蝔见��见�銋见�~ 敹����Ⅱ摰� FW ��𧋦��′擃𠉛��穿�蝣箄�敺�!!~ 閰脫芋蝯��蝞埈糓��迤�� Initial Comp.
-        // 璅∠��湔鰵 FW 敺䕘����齿鰵��
-        if (ShmPrimaryMcuData->SelfTest_Comp != PASS) {
-            //PRINTF_FUNC("(407) Get Fw and Hw Ver. \n");
-            GetFwAndHwVersion();
-            sleep(1);
-            ShmPrimaryMcuData->SelfTest_Comp = PASS;
-        } else {
-            GetInputGpioStatus();
-        }
-
-        usleep(100000);
-    }
 
-    return FAIL;
-}

+ 283 - 251
EVSE/Projects/DD360Audi/Apps/OutputTask.c

@@ -1,134 +1,150 @@
 /*
  * OutputTask.c
  *
- *  Created on: 2020年2月25日
+ *  Created on: 2020¦~2¤ë25¤é
  *      Author: 7564
  */
 
-#include    "OutputTask.h"
+#include 	"OutputTask.h"
 
 bool isOpen;
 
 int InitComPort()
 {
-    int fd;
-    struct termios tios;
-
-    fd = open(priPortName, O_RDWR);
-    if (fd <= 0) {
-#ifdef SystemLogMessage
-        DEBUG_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;
-    tios.c_iflag = 0;
-    tios.c_oflag = 0;
-    tios.c_cc[VMIN] = 0;
-    tios.c_cc[VTIME] = (unsigned char)1;
-    tios.c_lflag = 0;
-    tcflush(fd, TCIFLUSH);
-    ioctl (fd, TCSETS, &tios);
-
-    return fd;
+	int fd;
+	struct termios tios;
+
+	fd = open(priPortName, O_RDWR);
+	if(fd<=0)
+	{
+		#ifdef SystemLogMessage
+		DEBUG_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;
+	tios.c_iflag = 0;
+	tios.c_oflag = 0;
+	tios.c_cc[VMIN]=0;
+	tios.c_cc[VTIME]=(unsigned char)1;
+	tios.c_lflag=0;
+	tcflush(fd, TCIFLUSH);
+	ioctl (fd, TCSETS, &tios);
+
+	return fd;
 }
 
 unsigned long GetTimeoutValue(struct timeval _sour_time)
 {
-    struct timeval _end_time;
-    gettimeofday(&_end_time, NULL);
+	struct timeval _end_time;
+	gettimeofday(&_end_time, NULL);
 
-    return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
+	return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
 }
 
 void ShowMainMsg()
 {
-    printf("Max Vol : %f, Max Cur : %d, POW : %d \n", UnSafeDataInfo->PSU_VOLTAGE,
-           UnSafeDataInfo->PSU_CURRENT, UnSafeDataInfo->PSU_POWER);
-    printf("=> ");
+	printf("Max Vol : %f, Max Cur : %d, POW : %d \n", UnSafeDataInfo->PSU_VOLTAGE,
+			UnSafeDataInfo->PSU_CURRENT, UnSafeDataInfo->PSU_POWER);
+	printf("=> ");
 }
 
 void ChkButtonStatus()
 {
-    if (Button1 == PRESS && !leftBtnPush) {
-        if (!leftBtnPush) {
-            leftBtnPush = true;
-            if (_charging_mode == CHARGING_MODE_STOP) {
-                _charging_mode = CHARGING_MODE_START;
-                printf("****************** Switch to Charging Mode ******************\n");
-            }
-        } else if (Button1 == RELEASE) {
-            if (leftBtnPush) {
-                leftBtnPush = false;
-            }
-        }
-    }
-
-    if (Button2 == PRESS && !rightBtnPush) {
-        if (!rightBtnPush) {
-            rightBtnPush = true;
-            if (_charging_mode == CHARGING_MODE_START) {
-                _charging_mode = CHARGING_MODE_TERMINATING;
-                printf("****************** Switch to Stop Mode ******************\n");
-            }
-        } else if (Button2 == RELEASE) {
-            if (rightBtnPush) {
-                rightBtnPush = false;
-            }
-        }
-    }
+	if (Button1 == PRESS && !leftBtnPush)
+	{
+		if(!leftBtnPush)
+		{
+			leftBtnPush = true;
+			if (_charging_mode == CHARGING_MODE_STOP)
+			{
+				_charging_mode = CHARGING_MODE_START;
+				printf("****************** Switch to Charging Mode ******************\n");
+			}
+		}
+		else if (Button1 == RELEASE)
+		{
+			if(leftBtnPush)
+			{
+				leftBtnPush = false;
+			}
+		}
+	}
+
+	if (Button2 == PRESS && !rightBtnPush)
+	{
+		if(!rightBtnPush)
+		{
+			rightBtnPush = true;
+			if (_charging_mode == CHARGING_MODE_START)
+			{
+				_charging_mode = CHARGING_MODE_TERMINATING;
+				printf("****************** Switch to Stop Mode ******************\n");
+			}
+		}
+		else if (Button2 == RELEASE)
+		{
+			if(rightBtnPush)
+			{
+				rightBtnPush = false;
+			}
+		}
+	}
 }
 
 void GetModuleCountCallback(byte group, byte count)
 {
-    printf("group = %d, count = %d \n", group, count);
-    if (group == SYSTEM_CMD) {
-        UnSafeDataInfo->PSU_COUNT = count;
-    }
+	printf("group = %d, count = %d \n", group, count);
+	if (group == SYSTEM_CMD)
+		UnSafeDataInfo->PSU_COUNT = count;
 }
 
 void GetAvailableCapCallback(byte address, short maxVol, short minVol, short maxCur, short totalPow)
 {
-    int _groupPower = 0, _groupCurrent = 0;
+	int _groupPower = 0, _groupCurrent = 0;
 
-    UnSafeDataInfo->PsuModule[address].PSU_VOLTAGE_INFO = maxVol;
-    UnSafeDataInfo->PsuModule[address].PSU_CURRENT_INFO = maxCur;
-    UnSafeDataInfo->PsuModule[address].PSU_POWER_INFO = totalPow;
+	UnSafeDataInfo->PsuModule[address].PSU_VOLTAGE_INFO = maxVol;
+	UnSafeDataInfo->PsuModule[address].PSU_CURRENT_INFO = maxCur;
+	UnSafeDataInfo->PsuModule[address].PSU_POWER_INFO = totalPow;
 
-    for (byte index = 0; index < UnSafeDataInfo->PSU_COUNT; index++) {
-        _groupCurrent += UnSafeDataInfo->PsuModule[address].PSU_CURRENT_INFO;
-        _groupPower += UnSafeDataInfo->PsuModule[address].PSU_POWER_INFO;
-    }
+	for (byte index = 0; index < UnSafeDataInfo->PSU_COUNT; index++)
+	{
+		_groupCurrent += UnSafeDataInfo->PsuModule[address].PSU_CURRENT_INFO;
+		_groupPower += UnSafeDataInfo->PsuModule[address].PSU_POWER_INFO;
+	}
 
-    UnSafeDataInfo->PSU_VOLTAGE = maxVol;
-    UnSafeDataInfo->PSU_CURRENT = _groupCurrent;
-    UnSafeDataInfo->PSU_POWER = _groupPower;
+	UnSafeDataInfo->PSU_VOLTAGE = maxVol;
+	UnSafeDataInfo->PSU_CURRENT = _groupCurrent;
+	UnSafeDataInfo->PSU_POWER = _groupPower;
 }
 
 void GetStatusCallback(byte group, byte address, byte temp, int alarm)
 {
-    printf("alarm = %d \n", alarm);
+	printf("alarm = %d \n", alarm);
 }
 
 void GetInputVoltageCallback(byte address, unsigned short vol1, unsigned short vol2, unsigned short vol3)
 {
-    printf("vol1 = %d, vol2 = %d, vol3 = %d \n", vol1, vol2, vol3);
+	printf("vol1 = %d, vol2 = %d, vol3 = %d \n", vol1, vol2, vol3);
 }
 
 int CreateShareMemory()
 {
-    int MeterSMId;
-
-    if ((MeterSMId = shmget(ShmTestKey, sizeof(struct UnSafeData), IPC_CREAT | 0777)) < 0) {
-        return 0;
-    } else if ((UnSafeDataInfo = shmat(MeterSMId, NULL, 0))   == (void *) - 1) {
-        return 0;
-    }
-    memset(UnSafeDataInfo, 0, sizeof(struct UnSafeData));
-
-    return 1;
+	int MeterSMId;
+
+	if ((MeterSMId = shmget(ShmTestKey,	sizeof(struct UnSafeData), IPC_CREAT | 0777)) < 0)
+	{
+		return 0;
+	}
+	else if ((UnSafeDataInfo = shmat(MeterSMId, NULL, 0))	== (void *) -1)
+	{
+		return 0;
+	}
+	memset(UnSafeDataInfo, 0, sizeof(struct UnSafeData));
+
+	return 1;
 }
 
 static void get_char(char *word)
@@ -142,200 +158,216 @@ static void get_char(char *word)
     tv.tv_usec = 10; //wait input timout time
 
     //if input
-    if (select(1, &rfds, NULL, NULL, &tv) > 0) {
-        fgets(word, 128, stdin);
+    if (select(1, &rfds, NULL, NULL, &tv) > 0)
+    {
+    	fgets(word, 128, stdin);
     }
 }
 
 void GetInputString()
 {
-    char word[128];
-    char newString[7][10];
-    int i, j, ctr;
-
-    get_char(word);
-
-    if (strlen(word) == 0) {
-        return;
-    }
-    //fgets(word, sizeof(word), stdin);
-
-    j = 0;
-    ctr = 0;
-    for (i = 0; i <= (strlen(word)); i++) {
-        if (word[i] == ' ' || word[i] == '\0' || word[i] == 10) {
-            newString[ctr][j] = '\0';
-            ctr++;
-            j = 0;
-        } else {
-            newString[ctr][j] = word[i];
-            j++;
-        }
-    }
-
-    VOLTAGE = atof(newString[0]);
-    CURRENT = atof(newString[1]);
-    if (VOLTAGE <= UnSafeDataInfo->PSU_VOLTAGE && CURRENT <= UnSafeDataInfo->PSU_CURRENT) {
-        //printf("OutputVol = %f, OutputCur = %f \n", VOLTAGE, CURRENT);
-    } else {
-        ShowMainMsg();
-    }
+	char word[128];
+	char newString[7][10];
+	int i, j, ctr;
+
+	get_char(word);
+
+	if (strlen(word) == 0)
+	    return;
+	//fgets(word, sizeof(word), stdin);
+
+	j = 0;
+	ctr = 0;
+	for (i = 0; i <= (strlen(word)); i++) {
+		if (word[i] == ' ' || word[i] == '\0' || word[i] == 10) {
+			newString[ctr][j] = '\0';
+			ctr++;
+			j = 0;
+		} else {
+			newString[ctr][j] = word[i];
+			j++;
+		}
+	}
+
+	VOLTAGE = atof(newString[0]);
+	CURRENT = atof(newString[1]);
+	if (VOLTAGE <= UnSafeDataInfo->PSU_VOLTAGE && CURRENT <= UnSafeDataInfo->PSU_CURRENT)
+	{
+		//printf("OutputVol = %f, OutputCur = %f \n", VOLTAGE, CURRENT);
+	}
+	else
+	{
+		ShowMainMsg();
+	}
 }
 
 void GetIavailableCallback(byte address, unsigned short Iavail, unsigned short Vext)
 {
-    //printf("address = %d, Iavail = %d, Vext = %d \n", address, Iavail, Vext);
+	//printf("address = %d, Iavail = %d, Vext = %d \n", address, Iavail, Vext);
 }
 
 void GetOutputAndTempCallback(byte address, unsigned short outputVol,
-                              unsigned short outputCur, unsigned short outputPower, unsigned char Temperature)
+		unsigned short outputCur, unsigned short outputPower, unsigned char Temperature)
 {
-    //printf("***Output Value and Temp*** address = %d, Vol = %d, Cur = %d, Pow = %d, Temp = %d \n",
-    //      address, outputVol, outputCur, outputPower, Temperature);
+	//printf("***Output Value and Temp*** address = %d, Vol = %d, Cur = %d, Pow = %d, Temp = %d \n",
+	//		address, outputVol, outputCur, outputPower, Temperature);
 }
 
 void GetModuleStatusCallback(byte address, unsigned char isErr, unsigned char status,
-                             unsigned char err1, unsigned char err2, unsigned char err3, unsigned char err4)
+		unsigned char err1, unsigned char err2, unsigned char err3, unsigned char err4)
 {
-    //int alarm = (err2 << 24) | (err3 << 16) | (err4 << 8);
-
-    // err2 == state 2
-    // err3 == state 1
-    // err4 == state 0
-    //printf("***Status*** address = %d, alarm = %d \n", address, alarm);
-//  printf("***Status*** address = %d, err1 = %d, err2 = %d, err3 = %d, err4 = %d \n",
-//          address, err1,err2,err3,err4);
+	//int alarm = (err2 << 24) | (err3 << 16) | (err4 << 8);
+
+	// err2 == state 2
+	// err3 == state 1
+	// err4 == state 0
+	//printf("***Status*** address = %d, alarm = %d \n", address, alarm);
+//	printf("***Status*** address = %d, err1 = %d, err2 = %d, err3 = %d, err4 = %d \n",
+//			address, err1,err2,err3,err4);
 }
 
 void GetModuleInputCallback(byte address, unsigned short inputR,
-                            unsigned short inputS, unsigned short inputT)
+		unsigned short inputS, unsigned short inputT)
 {
 
 }
 
 int main(void)
 {
-    isOpen = false;
-
-    if (CreateShareMemory() == 0) {
-        printf("CreateShareMemory fail. \n");
-        return 0;
-    }
-    RefreshModuleCount(&GetModuleCountCallback);
-    RefreshAvailableCap(&GetAvailableCapCallback);
-
-    RefreshStatus(&GetStatusCallback);
-    RefreshInputVol(&GetInputVoltageCallback);
-
-    RefreshIavailable(&GetIavailableCallback);
-
-    AutoMode_RefreshOutputAndTemp(&GetOutputAndTempCallback);
-    AutoMode_RefreshModuleStatus(&GetModuleStatusCallback);
-    AutoMode_RefreshModuleInput(&GetModuleInputCallback);
-
-    Uart1Fd = InitComPort();
-    libInitialize = InitialCommunication();
-
-    if (Uart1Fd < 0 || !libInitialize) {
-        printf("Initial port fail. \n");
-        return 0;
-    }
-
-    sleep(5);
-    gettimeofday(&_cmdSubPriority_time, NULL);
-    VOLTAGE = 0.0;
-    CURRENT = 0.0;
-
-    SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
-//  while (1)
-//  {
-//      printf("++++++++++++++2++++++++++++++++++++++++++++++++++++++\n");
-//      SetWalkInConfig(0, YES, 0);
-//      SetWalkInConfig(1, NO, 0);
-//      printf("++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
-//      sleep(1);
-//  }
+	isOpen =false;
+
+	if(CreateShareMemory() == 0)
+	{
+		printf("CreateShareMemory fail. \n");
+		return 0;
+	}
+	RefreshModuleCount(&GetModuleCountCallback);
+	RefreshAvailableCap(&GetAvailableCapCallback);
+
+	RefreshStatus(&GetStatusCallback);
+	RefreshInputVol(&GetInputVoltageCallback);
+
+	RefreshIavailable(&GetIavailableCallback);
+
+	AutoMode_RefreshOutputAndTemp(&GetOutputAndTempCallback);
+	AutoMode_RefreshModuleStatus(&GetModuleStatusCallback);
+	AutoMode_RefreshModuleInput(&GetModuleInputCallback);
+
+	Uart1Fd = InitComPort();
+	libInitialize = InitialCommunication();
+
+	if (Uart1Fd < 0 || !libInitialize)
+	{
+		printf("Initial port fail. \n");
+		return 0;
+	}
+
+	sleep(5);
+	gettimeofday(&_cmdSubPriority_time, NULL);
+	VOLTAGE = 0.0;
+	CURRENT = 0.0;
+
+	SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
+//	while (1)
+//	{
+//		printf("++++++++++++++2++++++++++++++++++++++++++++++++++++++\n");
+//		SetWalkInConfig(0, YES, 0);
+//		SetWalkInConfig(1, NO, 0);
+//		printf("++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+//		sleep(1);
+//	}
 //
-//  sleep(1);
-//      printf("++++++++++++++2++++++++++++++++++++++++++++++++++++++\n");
-//      SetWalkInConfig(SYSTEM_CMD, NO, 0);
-//      printf("++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
-//  return 0;
-    while (1) {
-        GetInputGpioStatus();
-        //ChkButtonStatus();
-        // 切� Walk-in mode (default 5s -> 2s)
-        SetWalkInConfig(SYSTEM_CMD, NO, 0);
-
-        int time = GetTimeoutValue(_cmdSubPriority_time) / 1000;
-        while (isGetCount == YES) {
-            if (_charging_mode == CHARGING_MODE_START) {
-                // �得模塊輸出�定電�能力
-                GetModuleIavailable(0);
-            }
-
-            GetInputString();
-            if (VOLTAGE > 150 && CURRENT >= 0) {
-                _charging_mode = CHARGING_MODE_START;
-            } else {
-                _charging_mode = CHARGING_MODE_TERMINATING;
-            }
-            //printf("_charging_mode = %d \n", _charging_mode);
-            switch (_charging_mode) {
-            case CHARGING_MODE_START: {
-                //if (!isOpen)
-                {
-                    //SwitchPower(SYSTEM_CMD, PSU_POWER_ON);
-                    //FlashLed(SYSTEM_CMD, PSU_FLASH_ON);
-                    SetDirModulePresentOutput(0,
-                                              VOLTAGE * 10,
-                                              CURRENT * 10,
-                                              0x01,
-                                              0x01);
-                }
-                //PresentOutputVol(SYSTEM_CMD, VOLTAGE * 10, CURRENT * 10);
-            }
-            break;
-            case CHARGING_MODE_TERMINATING: {
-                //if (isOpen)
-                {
-                    SetDirModulePresentOutput(0,
-                                              VOLTAGE * 10,
-                                              CURRENT * 10,
-                                              0x00,
-                                              0x01);
-                    //SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
-                    //FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
-                }
-            }
-            break;
-            }
-            //GetStatus(0);
-            //GetModuleInput(0);
-            sleep(1);
-        }
-
-        if (UnSafeDataInfo->PSU_COUNT <= 0) {
-            if (time > 1000) {
-                printf("Step 1 : GetModuleCount...... \n");
-                GetModuleCount(SYSTEM_CMD);
-                gettimeofday(&_cmdSubPriority_time, NULL);
-            }
-        } else if (time < 5000) {
-            printf("Step 2 : GetModuleCap...... \n");
-            GetModuleCap(0);
-
-            SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
-            FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
-        } else {
-            ShowMainMsg();
-            isGetCount = YES;
-        }
-
-        sleep(1);
-    }
-
-    return 0;
+//	sleep(1);
+//		printf("++++++++++++++2++++++++++++++++++++++++++++++++++++++\n");
+//		SetWalkInConfig(SYSTEM_CMD, NO, 0);
+//		printf("++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+//	return 0;
+	while (1)
+	{
+		GetInputGpioStatus();
+		//ChkButtonStatus();
+		// ¤Á´« Walk-in mode (default 5s -> 2s)
+		SetWalkInConfig(SYSTEM_CMD, NO, 0);
+
+		int time = GetTimeoutValue(_cmdSubPriority_time) / 1000;
+		while(isGetCount == YES)
+		{
+			if (_charging_mode == CHARGING_MODE_START)
+			{
+				// ¨ú±o¼Ò¶ô¿é¥XÃB©w¹q¬y¯à¤O
+				GetModuleIavailable(0);
+			}
+
+			GetInputString();
+			if (VOLTAGE > 150 && CURRENT >= 0)
+				_charging_mode = CHARGING_MODE_START;
+			else
+				_charging_mode = CHARGING_MODE_TERMINATING;
+			//printf("_charging_mode = %d \n", _charging_mode);
+			switch(_charging_mode)
+			{
+				case CHARGING_MODE_START:
+				{
+					//if (!isOpen)
+					{
+						//SwitchPower(SYSTEM_CMD, PSU_POWER_ON);
+						//FlashLed(SYSTEM_CMD, PSU_FLASH_ON);
+						SetDirModulePresentOutput(0,
+												VOLTAGE * 10,
+												CURRENT * 10,
+												0x01,
+												0x01);
+					}
+					//PresentOutputVol(SYSTEM_CMD, VOLTAGE * 10, CURRENT * 10);
+				}
+					break;
+				case CHARGING_MODE_TERMINATING:
+				{
+					//if (isOpen)
+					{
+						SetDirModulePresentOutput(0,
+							VOLTAGE * 10,
+							CURRENT * 10,
+							0x00,
+							0x01);
+						//SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
+						//FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
+					}
+				}
+					break;
+			}
+			//GetStatus(0);
+			//GetModuleInput(0);
+			sleep(1);
+		}
+
+		if (UnSafeDataInfo->PSU_COUNT <= 0)
+		{
+			if (time > 1000)
+			{
+				printf("Step 1 : GetModuleCount...... \n");
+				GetModuleCount(SYSTEM_CMD);
+				gettimeofday(&_cmdSubPriority_time, NULL);
+			}
+		}
+		else if (time < 5000)
+		{
+			printf("Step 2 : GetModuleCap...... \n");
+			GetModuleCap(0);
+
+			SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
+			FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
+		}
+		else
+		{
+			ShowMainMsg();
+			isGetCount = YES;
+		}
+
+		sleep(1);
+	}
+
+	return 0;
 }
 
 

+ 340 - 321
EVSE/Projects/DD360Audi/Apps/PrimaryComm.c

@@ -1,362 +1,381 @@
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
+#include    <sys/time.h>
+#include    <sys/timeb.h>
 #include    <sys/types.h>
 #include    <sys/stat.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/wireless.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
-
-#include 	<unistd.h>
-#include 	<stdarg.h>
-#include    <stdio.h>      /*シミキヌソ鬢Jソ鬣Xゥwクq*/
-#include    <stdlib.h>     /*シミキヌィ郛ニョwゥwクq*/
-#include    <unistd.h>     /*Unix シミキヌィ郛ニゥwクq*/
-#include    <fcntl.h>      /*タノアアィ鉀wクq*/
-#include    <termios.h>    /*PPSIX イラコンアアィ鉀wクq*/
-#include    <errno.h>      /*ソ�~クケゥwクq*/
-#include 	<errno.h>
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include 	<math.h>
-#include 	"PrimaryComm.h"
-
-#define PASS				1
-#define FAIL				-1
-
-struct Address Addr={0x01,0x02,0x03,0x04,0xFF};
-struct Command Cmd={0x01,0x02,0x0a,0x86,0x87,0xe0,0xe1,0xe2,0xe3};
-
-int tranceive(int fd, unsigned char* cmd, unsigned char cmd_len, unsigned char* rx)
+#include    <sys/types.h>
+#include    <sys/ioctl.h>
+#include    <sys/socket.h>
+#include    <sys/ipc.h>
+#include    <sys/shm.h>
+#include    <sys/shm.h>
+#include    <sys/mman.h>
+#include    <linux/wireless.h>
+#include    <arpa/inet.h>
+#include    <netinet/in.h>
+
+#include    <unistd.h>
+#include    <stdarg.h>
+#include    <stdio.h>      /*讓呎コ冶シク蜈・霈ク蜃コ螳夂セゥ*/
+#include    <stdlib.h>     /*讓呎コ門�謨ク蠎ォ螳夂セゥ*/
+#include    <unistd.h>     /*Unix 讓呎コ門�謨ク螳夂セゥ*/
+#include    <fcntl.h>      /*讙疲而蛻カ螳夂セゥ*/
+#include    <termios.h>    /*PPSIX 邨らォッ謗ァ蛻カ螳夂セゥ*/
+#include    <errno.h>      /*骭ッ隱、陌溷ョ夂セゥ*/
+#include    <errno.h>
+#include    <string.h>
+#include    <time.h>
+#include    <ctype.h>
+#include    <ifaddrs.h>
+#include    <math.h>
+#include    "PrimaryComm.h"
+
+#define PASS                1
+#define FAIL                -1
+
+struct Address Addr = {0x01, 0x02, 0x03, 0x04, 0xFF};
+struct Command Cmd = {0x01, 0x02, 0x0a, 0x86, 0x87, 0xe0, 0xe1, 0xe2, 0xe3};
+
+int tranceive(int fd, unsigned char *cmd, unsigned char cmd_len, unsigned char *rx)
 {
-	int len;
-	//sleep(2); //required to make flush work, for some reason
-	tcflush(fd,TCIOFLUSH);
-	if(write(fd, cmd, cmd_len) >= cmd_len)
-	{
-		usleep(50000);
-		len = read(fd, rx, 512);
-	}
-	else
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("Serial command %s response fail.\n", cmd);
-		#endif
-	}
-
-	return len;
+    int len;
+    //sleep(2); //required to make flush work, for some reason
+    tcflush(fd, TCIOFLUSH);
+    if (write(fd, cmd, cmd_len) >= cmd_len) {
+        usleep(50000);
+        len = read(fd, rx, 512);
+    } else {
+#ifdef SystemLogMessage
+        DEBUG_ERROR("Serial command %s response fail.\n", cmd);
+#endif
+    }
+
+    return len;
 }
 
 unsigned char Query_FW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf)
 {
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_FW_Ver, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 0)
-	{
-		for(int idx = 0; idx < (rx[4] | rx[5]<<8); idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			memcpy(Ret_Buf->Version_FW, (char *)rx+6, (rx[4] | rx[5]<<8));
-			*(Ret_Buf->Version_FW + 8) = 0x00;
-			result = PASS;
-		}
-	}
-
-	return result;
+    unsigned char result = FAIL;
+    unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_FW_Ver, 0x00, 0x00, 0x00};
+    unsigned char rx[512];
+    unsigned char chksum = 0x00;
+    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+
+    if (len > 0) {
+        for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++) {
+            chksum ^= rx[6 + idx];
+        }
+
+        if ((chksum == rx[6 + (rx[4] | rx[5] << 8)]) &&
+                (rx[2] == tx[1]) &&
+                (rx[1] == tx[2]) &&
+                (rx[3] == tx[3])) {
+            memcpy(Ret_Buf->Version_FW, (char *)rx + 6, (rx[4] | rx[5] << 8));
+            *(Ret_Buf->Version_FW + 8) = 0x00;
+            result = PASS;
+        }
+    }
+
+    return result;
 }
 
 unsigned char Query_HW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf)
 {
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_HW_Ver, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	if(tranceive(fd, tx, sizeof(tx), rx) >0)
-	{
-		for(int idx = 0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			memcpy(Ret_Buf->Version_HW, (char *)rx+6, (rx[4] | rx[5]<<8));
-			//*(Ret_Buf->Version_HW + 8) = 0x00;
-			result = PASS;
-		}
-	}
-
-	return result;
+    unsigned char result = FAIL;
+    unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_HW_Ver, 0x00, 0x00, 0x00};
+    unsigned char rx[512];
+    unsigned char chksum = 0x00;
+
+    if (tranceive(fd, tx, sizeof(tx), rx) > 0) {
+        for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++) {
+            chksum ^= rx[6 + idx];
+        }
+
+        if ((chksum == rx[6 + (rx[4] | rx[5] << 8)]) &&
+                (rx[2] == tx[1]) &&
+                (rx[1] == tx[2]) &&
+                (rx[3] == tx[3])) {
+            memcpy(Ret_Buf->Version_HW, (char *)rx + 6, (rx[4] | rx[5] << 8));
+            //*(Ret_Buf->Version_HW + 8) = 0x00;
+            result = PASS;
+        }
+    }
+
+    return result;
 }
 
 unsigned char Query_Gpio_Input(unsigned char fd, unsigned char targetAddr, Gpio_in *Ret_Buf)
 {
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_Gpio_In, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-	unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
-
-	if(len > 0)
-	{
-		for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]))
-		{
-			Ret_Buf->AC_Connector 		= (rx[6] >> 0) & 0x01;
-			Ret_Buf->AC_MainBreaker 	= (rx[6] >> 1) & 0x01;
-			Ret_Buf->SPD 				= (rx[6] >> 2) & 0x01;
-			Ret_Buf->Door_Open 			= (rx[6] >> 3) & 0x01;
-			Ret_Buf->GFD[0] 			= (rx[6] >> 4) & 0x01;
-			Ret_Buf->GFD[1] 			= (rx[6] >> 5) & 0x01;
-			Ret_Buf->AC_Drop 			= (rx[6] >> 6) & 0x01;
-			Ret_Buf->Emergency_IO 		= (rx[6] >> 7) & 0x01;
-
-			Ret_Buf->Emergency_Btn		= (rx[7] >> 0) & 0x01;
-			Ret_Buf->Button[0] 			= (rx[7] >> 1) & 0x01;
-			Ret_Buf->Button[1] 			= (rx[7] >> 2) & 0x01;
-			Ret_Buf->Key[0]				= (rx[7] >> 3) & 0x01;
-			Ret_Buf->Key[1]				= (rx[7] >> 4) & 0x01;
-			Ret_Buf->Key[2]				= (rx[7] >> 5) & 0x01;
-			Ret_Buf->Key[3]				= (rx[7] >> 6) & 0x01;
-			result = PASS;
-		}
-	}
-
-	return result;
+    unsigned char result = FAIL;
+    unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.query_Gpio_In, 0x00, 0x00, 0x00};
+    unsigned char rx[512];
+    unsigned char chksum = 0x00;
+    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+
+    if (len > 0) {
+        for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++) {
+            chksum ^= rx[6 + idx];
+        }
+
+        if ((chksum == rx[6 + (rx[4] | rx[5] << 8)]) &&
+                (rx[2] == tx[1]) &&
+                (rx[1] == tx[2]) &&
+                (rx[3] == tx[3])) {
+            Ret_Buf->AC_Connector       = (rx[6] >> 0) & 0x01;
+            Ret_Buf->AC_MainBreaker     = (rx[6] >> 1) & 0x01;
+            Ret_Buf->SPD                = (rx[6] >> 2) & 0x01;
+            Ret_Buf->Door_Open          = (rx[6] >> 3) & 0x01;
+            Ret_Buf->GFD[0]             = (rx[6] >> 4) & 0x01;
+            Ret_Buf->GFD[1]             = (rx[6] >> 5) & 0x01;
+            Ret_Buf->AC_Drop            = (rx[6] >> 6) & 0x01;
+            Ret_Buf->Emergency_IO       = (rx[6] >> 7) & 0x01;
+
+            Ret_Buf->Emergency_Btn      = (rx[7] >> 0) & 0x01;
+            Ret_Buf->Button[0]          = (rx[7] >> 1) & 0x01;
+            Ret_Buf->Button[1]          = (rx[7] >> 2) & 0x01;
+            Ret_Buf->Key[0]             = (rx[7] >> 3) & 0x01;
+            Ret_Buf->Key[1]             = (rx[7] >> 4) & 0x01;
+            Ret_Buf->Key[2]             = (rx[7] >> 5) & 0x01;
+            Ret_Buf->Key[3]             = (rx[7] >> 6) & 0x01;
+            result = PASS;
+        }
+    }
+
+    return result;
 }
 
 unsigned char Config_Gpio_Output(unsigned char fd, unsigned char targetAddr, Gpio_out *Set_Buf)
 {
-	unsigned char result = FAIL;
-	unsigned char tx[9] = {0xaa, 0x00, targetAddr, Cmd.config_Gpio_Output, 0x01, 0x00, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	for (int idx = 0; idx < 2; idx++)
-		tx[6] |= (Set_Buf->Button_LED[idx] ? 0x01:0x00) << (0+idx);
-
-	for (int idx = 0; idx < 4; idx++)
-			tx[6] |= (Set_Buf->System_LED[idx] ? 0x01:0x00) << (2+idx);
-
-	tx[6] |= (Set_Buf->AC_Connector ? 0x01:0x00) << 6;
-	tx[6] |= (Set_Buf->AC_Breaker ? 0x01:0x00) << 7;
-
-	for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++)
-		chksum ^= tx[6+idx];
-	tx[7] = chksum;
-
-	if (tranceive(fd, tx, sizeof(tx), rx) > 0)
-	{
-		chksum = 0x00;
-		for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == tx[6]))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
+    unsigned char result = FAIL;
+    unsigned char tx[9] = {0xaa, 0x00, targetAddr, Cmd.config_Gpio_Output, 0x01, 0x00, 0x00, 0x00};
+    unsigned char rx[512];
+    unsigned char chksum = 0x00;
+
+    for (int idx = 0; idx < 2; idx++) {
+        tx[6] |= (Set_Buf->Button_LED[idx] ? 0x01 : 0x00) << (0 + idx);
+    }
+
+    for (int idx = 0; idx < 4; idx++) {
+        tx[6] |= (Set_Buf->System_LED[idx] ? 0x01 : 0x00) << (2 + idx);
+    }
+
+    tx[6] |= (Set_Buf->AC_Connector ? 0x01 : 0x00) << 6;
+    tx[6] |= (Set_Buf->AC_Breaker ? 0x01 : 0x00) << 7;
+
+    for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++) {
+        chksum ^= tx[6 + idx];
+    }
+    tx[7] = chksum;
+
+    if (tranceive(fd, tx, sizeof(tx), rx) > 0) {
+        chksum = 0x00;
+        for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++) {
+            chksum ^= rx[6 + idx];
+        }
+
+        if ((chksum == rx[6 + (rx[4] | rx[5] << 8)]) &&
+                (rx[2] == tx[1]) &&
+                (rx[1] == tx[2]) &&
+                (rx[3] == tx[3]) &&
+                (rx[6] == tx[6])) {
+            result = PASS;
+        }
+    }
+
+    return result;
 }
 
 unsigned char Config_Rtc_Data(unsigned char fd, unsigned char targetAddr, Rtc *Set_Buf)
 {
-	unsigned char result = FAIL;
-	unsigned char tx[21] = { 0xaa, 0x00, targetAddr, Cmd.config_Rtc_Data, 0x0E, 0x00, Set_Buf->RtcData[0], Set_Buf->RtcData[1],
-			Set_Buf->RtcData[2], Set_Buf->RtcData[3], Set_Buf->RtcData[4], Set_Buf->RtcData[5], Set_Buf->RtcData[6], Set_Buf->RtcData[7],
-			Set_Buf->RtcData[8], Set_Buf->RtcData[9], Set_Buf->RtcData[10], Set_Buf->RtcData[11], Set_Buf->RtcData[12], Set_Buf->RtcData[13]};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++)
-		chksum ^= tx[6 + idx];
-	tx[20] = chksum;
-
-	if (tranceive(fd, tx, sizeof(tx), rx) > 0)
-	{
-		chksum = 0x00;
-		for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++)
-		{
-			chksum ^= rx[6 + idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-				(rx[2] == tx[1]) &&
-				(rx[1] == tx[2]) &&
-				(rx[3] == tx[3]) &&
-				(rx[6] == tx[6]))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
+    unsigned char result = FAIL;
+    unsigned char tx[21] = { 0xaa, 0x00, targetAddr, Cmd.config_Rtc_Data, 0x0E, 0x00, Set_Buf->RtcData[0], Set_Buf->RtcData[1],
+                             Set_Buf->RtcData[2], Set_Buf->RtcData[3], Set_Buf->RtcData[4], Set_Buf->RtcData[5], Set_Buf->RtcData[6], Set_Buf->RtcData[7],
+                             Set_Buf->RtcData[8], Set_Buf->RtcData[9], Set_Buf->RtcData[10], Set_Buf->RtcData[11], Set_Buf->RtcData[12], Set_Buf->RtcData[13]
+                           };
+    unsigned char rx[512];
+    unsigned char chksum = 0x00;
+
+    for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++) {
+        chksum ^= tx[6 + idx];
+    }
+    tx[20] = chksum;
+
+    if (tranceive(fd, tx, sizeof(tx), rx) > 0) {
+        chksum = 0x00;
+        for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++) {
+            chksum ^= rx[6 + idx];
+        }
+
+        if ((chksum == rx[6 + (rx[4] | rx[5] << 8)]) &&
+                (rx[2] == tx[1]) &&
+                (rx[1] == tx[2]) &&
+                (rx[3] == tx[3]) &&
+                (rx[6] == tx[6])) {
+            result = PASS;
+        }
+    }
+
+    return result;
 }
 
+unsigned char Config_Model_Name(unsigned char fd, unsigned char targetAddr, unsigned char *modelname)
+{
+    unsigned char result = FAIL;
+    unsigned char tx[21] = {0xaa, 0x00, targetAddr, Cmd.config_Model_Name, 0x0E, 0x00,
+                            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+                           };
+    unsigned char rx[512];
+    unsigned char chksum = 0x00;
+
+    memcpy(tx + 6, modelname, 14);
+
+    for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++) {
+        chksum ^= tx[6 + idx];
+    }
+    tx[20] = chksum;
+
+//  for(int i = 0; i < 21; i++)
+//              printf ("tx = %x \n", tx[i]);
+    unsigned char len = tranceive(fd, tx, sizeof(tx), rx);
+//  for(int i = 0; i < len; i++)
+//                  printf ("rx = %x \n", rx[i]);
+    if (len > 6) {
+        if (len < 6 + (rx[4] | rx[5] << 8)) {
+            return result;
+        }
+
+        chksum = 0x00;
+        for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++) {
+            chksum ^= rx[6 + idx];
+        }
+
+        if ((chksum == rx[6 + (rx[4] | rx[5] << 8)]) &&
+                (rx[2] == tx[1]) &&
+                (rx[1] == tx[2]) &&
+                (rx[3] == tx[3]) &&
+                rx[6] == PASS) {
+            result = PASS;
+        }
+    }
+
+    return result;
+}
 unsigned char Update_Start(unsigned char fd, unsigned char targetAddr, unsigned int crc32)
 {
-	unsigned char result = FAIL;
-	unsigned char tx[11] = {0xaa, 0x00, targetAddr, Cmd.update_Start, 0x04, 0x00, (crc32>>0)&0xff, (crc32>>8)&0xff, (crc32>>16)&0xff, (crc32>>24)&0xff, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++)
-		chksum ^= tx[6+idx];
-	tx[10] = chksum;
-
-
-	if(tranceive(fd, tx, sizeof(tx), rx) > 0)
-	{
-		chksum = 0x00;
-		for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x00))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
+    unsigned char result = FAIL;
+    unsigned char tx[11] = {0xaa, 0x00, targetAddr, Cmd.update_Start, 0x04, 0x00, (crc32 >> 0) & 0xff, (crc32 >> 8) & 0xff, (crc32 >> 16) & 0xff, (crc32 >> 24) & 0xff, 0x00};
+    unsigned char rx[512];
+    unsigned char chksum = 0x00;
+
+    for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++) {
+        chksum ^= tx[6 + idx];
+    }
+    tx[10] = chksum;
+
+
+    if (tranceive(fd, tx, sizeof(tx), rx) > 0) {
+        chksum = 0x00;
+        for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++) {
+            chksum ^= rx[6 + idx];
+        }
+
+        if ((chksum == rx[6 + (rx[4] | rx[5] << 8)]) &&
+                (rx[2] == tx[1]) &&
+                (rx[1] == tx[2]) &&
+                (rx[3] == tx[3]) &&
+                (rx[6] == 0x00)) {
+            result = PASS;
+        }
+    }
+
+    return result;
 }
 
 unsigned char Update_Abord(unsigned char fd, unsigned char targetAddr)
 {
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.update_Start, 0x04, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	if(tranceive(fd, tx, sizeof(tx), rx) >0)
-	{
-		for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x00))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
+    unsigned char result = FAIL;
+    unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.update_Start, 0x04, 0x00, 0x00};
+    unsigned char rx[512];
+    unsigned char chksum = 0x00;
+
+    if (tranceive(fd, tx, sizeof(tx), rx) > 0) {
+        for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++) {
+            chksum ^= rx[6 + idx];
+        }
+
+        if ((chksum == rx[6 + (rx[4] | rx[5] << 8)]) &&
+                (rx[2] == tx[1]) &&
+                (rx[1] == tx[2]) &&
+                (rx[3] == tx[3]) &&
+                (rx[6] == 0x00)) {
+            result = PASS;
+        }
+    }
+
+    return result;
 }
 
 unsigned char Update_Transfer(unsigned char fd, unsigned char targetAddr, unsigned int startAddr, unsigned char *data, unsigned short int length)
 {
-	unsigned char result = FAIL;
-	unsigned char tx[11 + length];
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	tx[0] = 0xaa;
-	tx[1] = 0x00;
-	tx[2] = targetAddr;
-	tx[3] = Cmd.update_Transfer;
-	tx[4] = (4 + length) & 0xff;
-	tx[5] = ((4 + length)>>8) & 0xff;
-	tx[6] = (startAddr>>0) & 0xff;
-	tx[7] = (startAddr>>8) & 0xff;
-	tx[8] = (startAddr>>16) & 0xff;
-	tx[9] = (startAddr>>24) & 0xff;
-	memcpy(tx+10, data, length);
-
-	for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++)
-		chksum ^= tx[6+idx];
-	tx[sizeof(tx)-1] = chksum;
-
-	if(tranceive(fd, tx, sizeof(tx), rx) >0)
-	{
-		for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x00))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
+    unsigned char result = FAIL;
+    unsigned char tx[11 + length];
+    unsigned char rx[512];
+    unsigned char chksum = 0x00;
+
+    tx[0] = 0xaa;
+    tx[1] = 0x00;
+    tx[2] = targetAddr;
+    tx[3] = Cmd.update_Transfer;
+    tx[4] = (4 + length) & 0xff;
+    tx[5] = ((4 + length) >> 8) & 0xff;
+    tx[6] = (startAddr >> 0) & 0xff;
+    tx[7] = (startAddr >> 8) & 0xff;
+    tx[8] = (startAddr >> 16) & 0xff;
+    tx[9] = (startAddr >> 24) & 0xff;
+    memcpy(tx + 10, data, length);
+
+    for (int idx = 0; idx < (tx[4] | tx[5] << 8); idx++) {
+        chksum ^= tx[6 + idx];
+    }
+    tx[sizeof(tx) - 1] = chksum;
+
+    if (tranceive(fd, tx, sizeof(tx), rx) > 0) {
+        for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++) {
+            chksum ^= rx[6 + idx];
+        }
+
+        if ((chksum == rx[6 + (rx[4] | rx[5] << 8)]) &&
+                (rx[2] == tx[1]) &&
+                (rx[1] == tx[2]) &&
+                (rx[3] == tx[3]) &&
+                (rx[6] == 0x00)) {
+            result = PASS;
+        }
+    }
+
+    return result;
 }
 
 unsigned char Update_Finish(unsigned char fd, unsigned char targetAddr)
 {
-	unsigned char result = FAIL;
-	unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.update_Finish, 0x04, 0x00, 0x00};
-	unsigned char rx[512];
-	unsigned char chksum = 0x00;
-
-	if(tranceive(fd, tx, sizeof(tx), rx) >0)
-	{
-		for(int idx=0;idx<(rx[4] | rx[5]<<8);idx++)
-		{
-			chksum ^= rx[6+idx];
-		}
-
-		if((chksum == rx[6+(rx[4] | rx[5]<<8)]) &&
-		   (rx[2] == tx[1]) &&
-		   (rx[1] == tx[2]) &&
-		   (rx[3] == tx[3]) &&
-		   (rx[6] == 0x00))
-		{
-			result = PASS;
-		}
-	}
-
-	return result;
+    unsigned char result = FAIL;
+    unsigned char tx[7] = {0xaa, 0x00, targetAddr, Cmd.update_Finish, 0x04, 0x00, 0x00};
+    unsigned char rx[512];
+    unsigned char chksum = 0x00;
+
+    if (tranceive(fd, tx, sizeof(tx), rx) > 0) {
+        for (int idx = 0; idx < (rx[4] | rx[5] << 8); idx++) {
+            chksum ^= rx[6 + idx];
+        }
+
+        if ((chksum == rx[6 + (rx[4] | rx[5] << 8)]) &&
+                (rx[2] == tx[1]) &&
+                (rx[1] == tx[2]) &&
+                (rx[3] == tx[3]) &&
+                (rx[6] == 0x00)) {
+            result = PASS;
+        }
+    }
+
+    return result;
 }
 

+ 46 - 49
EVSE/Projects/DD360Audi/Apps/PrimaryComm.h

@@ -1,64 +1,60 @@
 #ifndef PRIMARYCOMM_H_
 #define PRIMARYCOMM_H_
 
-extern struct Address
-{
-	unsigned char Aux;
-	unsigned char Fan;
-	unsigned char Relay;
-	unsigned char IoExtend;
-	unsigned char Broadcast;
-}Addr;
+extern struct Address {
+    unsigned char Aux;
+    unsigned char Fan;
+    unsigned char Relay;
+    unsigned char IoExtend;
+    unsigned char Broadcast;
+} Addr;
 
-extern struct Command
-{
-	unsigned char query_FW_Ver; 		//0x01
-	unsigned char query_HW_Ver;		//0x02
-	unsigned char query_Gpio_In;		//0x0a
+extern struct Command {
+    unsigned char query_FW_Ver;         //0x01
+    unsigned char query_HW_Ver;     //0x02
+    unsigned char query_Gpio_In;        //0x0a
+    unsigned char query_charging_power; // 0x2C
 
-	unsigned char config_Gpio_Output;	//0x86
-	unsigned char config_Rtc_Data;		//0x87
+    unsigned char config_Model_Name;            //0x83
+    unsigned char config_Gpio_Output;   //0x86
+    unsigned char config_Rtc_Data;      //0x87
 
-	unsigned char update_Start;		//0xe0
-	unsigned char update_Abort;		//0xe1
-	unsigned char update_Transfer;		//0xe2
-	unsigned char update_Finish;		//0xe3
+    unsigned char update_Start;     //0xe0
+    unsigned char update_Abort;     //0xe1
+    unsigned char update_Transfer;      //0xe2
+    unsigned char update_Finish;        //0xe3
 
-}Cmd;
+} Cmd;
 
-typedef struct Verion
-{
-	char Version_FW[16];
-	char Version_HW[16];
-}Ver;
+typedef struct Verion {
+    char Version_FW[16];
+    char Version_HW[16];
+} Ver;
 
-typedef struct GPIO_IN
-{
-	unsigned char AC_Connector;
-	unsigned char AC_MainBreaker;
-	unsigned char SPD;
-	unsigned char Door_Open;
-	unsigned char GFD[2];
-	unsigned char AC_Drop;
-	unsigned char Emergency_IO;
+typedef struct GPIO_IN {
+    unsigned char AC_Connector;
+    unsigned char AC_MainBreaker;
+    unsigned char SPD;
+    unsigned char Door_Open;
+    unsigned char GFD[2];
+    unsigned char AC_Drop;
+    unsigned char Emergency_IO;
 
-	unsigned char Emergency_Btn;
-	unsigned char Button[2];
-	unsigned char Key[4];
-}Gpio_in;
+    unsigned char Emergency_Btn;
+    unsigned char Button[2];
+    unsigned char Key[4];
+} Gpio_in;
 
-typedef struct GPIO_OUT
-{
-	unsigned char Button_LED[2];
-	unsigned char System_LED[4];
-	unsigned char AC_Connector;
-	unsigned char AC_Breaker;
-}Gpio_out;
+typedef struct GPIO_OUT {
+    unsigned char Button_LED[2];
+    unsigned char System_LED[4];
+    unsigned char AC_Connector;
+    unsigned char AC_Breaker;
+} Gpio_out;
 
-typedef struct RTC
-{
-	unsigned char RtcData[14];
-}Rtc;
+typedef struct RTC {
+    unsigned char RtcData[14];
+} Rtc;
 
 extern unsigned char Query_FW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf);
 extern unsigned char Query_HW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf);
@@ -66,6 +62,7 @@ extern unsigned char Query_Gpio_Input(unsigned char fd, unsigned char targetAddr
 
 extern unsigned char Config_Gpio_Output(unsigned char fd, unsigned char targetAddr, Gpio_out *Set_Buf);
 extern unsigned char Config_Rtc_Data(unsigned char fd, unsigned char targetAddr, Rtc *Set_Buf);
+unsigned char Config_Model_Name(unsigned char fd, unsigned char targetAddr, unsigned char *modelname);
 // 13 bytes
 // year : 4, month : 2, day : 2, hour : 2, min : 2, sec : 2
 //extern unsigned char Config_RTC();

+ 204 - 135
EVSE/Projects/DD360Audi/Apps/ReDoComm.c

@@ -540,7 +540,7 @@ static int updateFirmwareHandle(uint8_t *imgName)
     return ret;
 }
 
-static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
+static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
 {
     int ret = PASS;
     uint8_t i = 0, j = 0;
@@ -572,21 +572,21 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
 
         case MISC_CMD_OPERATIVE_STATE:
             if ((value > YES) || (value < NO)) {
-                if (id == 2) {
+                if (plugNum == 1) {
                     clearMiscCommand();
                 }
                 break;
             }
 
-            DEBUG_INFO("change availability id = %d, value = %d\r\n", id - 1, value);
-            ShmOCPP16Data->CsMsg.bits[id - 1].ChangeAvailabilityReq = YES;
+            DEBUG_INFO("change availability plugNum = %d, value = %d\r\n", plugNum, value);
+            ShmOCPP16Data->CsMsg.bits[plugNum].ChangeAvailabilityReq = YES;
             if (value == YES) {
-                strcpy((char *)ShmOCPP16Data->ChangeAvailability[id - 1].Type, "Operative");
+                strcpy((char *)ShmOCPP16Data->ChangeAvailability[plugNum].Type, "Operative");
             } else if (value == NO) {
-                strcpy((char *)ShmOCPP16Data->ChangeAvailability[id - 1].Type, "Inoperative");
+                strcpy((char *)ShmOCPP16Data->ChangeAvailability[plugNum].Type, "Inoperative");
             }
 
-            if (id == 2) {
+            if (plugNum == 1) {
                 clearMiscCommand();
             }
             break;
@@ -615,21 +615,39 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
             break;
 
         case MISC_CMD_ACCOUNT_BALANCE:
-            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (id - 1)) {
+            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (plugNum)) {
                 clearMiscCommand();
                 break;
             }
 
-            if (getConfirmSelectedGun(id - 1) == FAIL) {
+#if defined DD360Audi
+            if (getConfirmSelectedGun(plugNum) == FAIL) {
                 DEBUG_INFO("Remote start not select gun\r\n");
                 break;
             }
+#endif //DD360Audi
 
-            gAudiCustInfo->PricesInfo[id - 1].Balance = transPricesUnit((int)value);
-            DEBUG_INFO("%d misc balance = %.2f\r\n", id, gAudiCustInfo->PricesInfo[id - 1].Balance);
+            gAudiCustInfo->PricesInfo[plugNum].Balance = transPricesUnit((int)value);
+            DEBUG_INFO("%d misc balance = %.2f\r\n", plugNum, gAudiCustInfo->PricesInfo[plugNum].Balance);
             clearMiscCommand();
             break;
 
+        case MISC_CMD_BACKEND_STATUS :
+            gAudiCustInfo->EthDevStatus.Backend = value;
+            break;
+
+        case MISC_CMD_ETHERNET_STATUS :
+            gAudiCustInfo->EthDevStatus.Ethernet = value;
+            break;
+
+        case MISC_CMD_WIFI_STATUS :
+            gAudiCustInfo->EthDevStatus.Wifi = value;
+            break;
+
+        case MISC_CMD_4G_STATUS :
+            gAudiCustInfo->EthDevStatus.FourG = value;
+            break;
+
         //--- Control Dispenser ---
         case MISC_CMD_HARDWARE_REBOOT:
             if (value != YES) {
@@ -657,24 +675,24 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
 
         case MISC_CMD_REMOTE_START_CHARGING:
             if (value != YES) {
-                if (id == 2) {
+                if (plugNum == 1) {
                     clearMiscCommand();
                 }
                 break;
             }
-            DEBUG_INFO("Remote start charging id = %d\r\n", id);
+            DEBUG_INFO("Remote start charging plugNum = %d\r\n", plugNum);
 
-            //if (getConfirmSelectedGun(id - 1) == FAIL) {
+            //if (getConfirmSelectedGun(plugNum - 1) == FAIL) {
             //    DEBUG_INFO("Remote start not select gun\r\n");
             //    break;
             //}
-
-            if (getSelGunWaitToAuthor(id - 1) == FAIL) {
+#if defined DD360Audi
+            if (getSelGunWaitToAuthor(plugNum) == FAIL) {
                 DEBUG_ERROR("Remote start gun already charging\r\n");
                 break;
             }
 
-            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (id - 1)) {
+            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (plugNum)) {
                 if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == LEFT_GUN_NUM &&
                         (gAudiCustInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM ||
                          gAudiCustInfo->SelGunInfo.LeftGun == SEL_GUN_ATHOR)) {
@@ -699,20 +717,23 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
                     ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
                 }
 
-                ShmSysConfigAndInfo->SysInfo.CurGunSelected = (id - 1);
+                ShmSysConfigAndInfo->SysInfo.CurGunSelected = (plugNum);
                 ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
             }
-
+#else
+            ShmSysConfigAndInfo->SysInfo.CurGunSelected = (plugNum);
+            ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
+#endif //DD360Audi
             setConfirmSelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
 
-            ShmOCPP16Data->CsMsg.bits[id - 1].RemoteStartTransactionReq = YES;
-            gAudiCustInfo->PricesInfo[id - 1].Balance = 0.00;
+            ShmOCPP16Data->CsMsg.bits[plugNum].RemoteStartTransactionReq = YES;
+            gAudiCustInfo->PricesInfo[plugNum].Balance = 0.00;
             clearMiscCommand();
             break;
 
         case MISC_CMD_REMOTE_STOP_CHARGING:
             if (value != YES) {
-                if (id == 2) {
+                if (plugNum == 1) {
                     clearMiscCommand();
                 }
                 break;
@@ -723,14 +744,14 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
             ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
             gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
             ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
-            destroySelectGun(id - 1);
+            destroySelectGun(plugNum);
 
             clearMiscCommand();
             break;
 
         case MISC_CMD_REMOTE_UNLOCK:
             if (value != YES) {
-                if (id == 2) {
+                if (plugNum == 1) {
                     clearMiscCommand();
                 }
                 break;
@@ -743,9 +764,9 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
                 ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
                 gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
                 ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
-                destroySelectGun(id - 1);
+                destroySelectGun(plugNum);
             } else {
-                ChargingData[id - 1]->StopChargeFlag = YES;
+                ChargingData[plugNum]->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
             }
             break;
 
@@ -759,7 +780,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
     return ret;
 }
 
-static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
+static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
 {
     uint8_t addr = 0;
     float MaxVolt, MaxCurrent, MaxPower;
@@ -775,7 +796,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
         if (MaxVolt > MAX_VOLTAGE) {
             MaxVolt = MAX_VOLTAGE;
         }
-        ChargingData[gunID]->MaximumChargingVoltage = MaxVolt;
+        ChargingData[plugNum]->MaximumChargingVoltage = MaxVolt;
     }
 
     MaxCurrent = (float)(ntohs(pCapabilityInfo->OutputCurrent));
@@ -783,7 +804,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
         if (MaxCurrent > MAX_CURRENCY) {
             MaxCurrent = MAX_CURRENCY;
         }
-        ChargingData[gunID]->AvailableChargingCurrent = MaxCurrent;
+        ChargingData[plugNum]->AvailableChargingCurrent = MaxCurrent;
     }
 
     MaxPower = (float)(ntohs(pCapabilityInfo->OutputPower));
@@ -791,7 +812,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
         if (MaxPower > MAX_POWER) {
             MaxPower = MAX_POWER;
         }
-        ChargingData[gunID]->AvailableChargingPower = MaxPower;
+        ChargingData[plugNum]->AvailableChargingPower = MaxPower;
     }
     //MaxVolt = (float)(data[0] << 8 |data[1]);
     //MaxCurrent = (float)(data[2] << 8 | data[3]);
@@ -803,20 +824,20 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
     pAccountInfo = (AccountInfo *)&data[addr];
 
     ShmSysConfigAndInfo->SysConfig.BillingData.Currency = pAccountInfo->Currency;
-    gAudiCustInfo->PricesInfo[gunID].UserPrices         = transPricesUnit(ntohl(pAccountInfo->UserPrices));
-    ChargingData[gunID]->ChargingFee                    = transPricesUnit(ntohl(pAccountInfo->TotalCost));
-    gAudiCustInfo->PricesInfo[gunID].Balance            = transPricesUnit(ntohl(pAccountInfo->Balance));
+    gAudiCustInfo->PricesInfo[plugNum].UserPrices         = transPricesUnit(ntohl(pAccountInfo->UserPrices));
+    ChargingData[plugNum]->ChargingFee                    = transPricesUnit(ntohl(pAccountInfo->TotalCost));
+    gAudiCustInfo->PricesInfo[plugNum].Balance            = transPricesUnit(ntohl(pAccountInfo->Balance));
 
-    if ((pricesInfo[gunID].UserPrices != gAudiCustInfo->PricesInfo[gunID].UserPrices) ||
-            (pricesInfo[gunID].Balance != gAudiCustInfo->PricesInfo[gunID].Balance)) {
-        pricesInfo[gunID].UserPrices = gAudiCustInfo->PricesInfo[gunID].UserPrices;
-        pricesInfo[gunID].Balance = gAudiCustInfo->PricesInfo[gunID].Balance;
+    if ((pricesInfo[plugNum].UserPrices != gAudiCustInfo->PricesInfo[plugNum].UserPrices) ||
+            (pricesInfo[plugNum].Balance != gAudiCustInfo->PricesInfo[plugNum].Balance)) {
+        pricesInfo[plugNum].UserPrices = gAudiCustInfo->PricesInfo[plugNum].UserPrices;
+        pricesInfo[plugNum].Balance = gAudiCustInfo->PricesInfo[plugNum].Balance;
 
         DEBUG_INFO("id = %d, user prices = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s\r\n",
-                   gunID,
-                   gAudiCustInfo->PricesInfo[gunID].UserPrices,
-                   ChargingData[gunID]->ChargingFee,
-                   gAudiCustInfo->PricesInfo[gunID].Balance,
+                   plugNum,
+                   gAudiCustInfo->PricesInfo[plugNum].UserPrices,
+                   ChargingData[plugNum]->ChargingFee,
+                   gAudiCustInfo->PricesInfo[plugNum].Balance,
                    (uint8_t *)Currency[ShmSysConfigAndInfo->SysConfig.BillingData.Currency]);
     }
 
@@ -886,74 +907,82 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     uint8_t count = 0;
     uint8_t EventCodeTmp[7] = {0};
     uint8_t StatusArray[MAX_REGISTER_NUM][WARNING_CODE_SIZE] = {0};
-    uint8_t remaindLen = dataLen % dataLen;
+    uint8_t remaindLen = 0;
     uint8_t statusCodeError = 0;
 
-    if (remaindLen != 0) {
-        dataLen -= remaindLen;
-    }
+    //if (dataLen <= 0) {
+    //    return FAIL;
+    //}
 
-    if (dataLen < WARNING_CODE_SIZE) {
-        DEBUG_ERROR("fail status code length = %d\r\n", dataLen);
-        Hexdump(data, dataLen);
-        if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 0) {
-            for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
-                usleep(128);
-                if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '3' ||  //from backend or power cabinet
-                        (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0] >= 'B' &&
-                         ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '4')) {
-                    memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
-                    memcpy(EventCodeTmp,
-                           ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i],
-                           sizeof(EventCodeTmp));
-                    removeFaultCodeToBuf(EventCodeTmp);
+    if (dataLen > 0) {
+        remaindLen = dataLen % WARNING_CODE_SIZE;
+
+        if (remaindLen != 0) {
+            dataLen -= remaindLen;
+        }
+
+        if (dataLen < WARNING_CODE_SIZE) {
+            DEBUG_ERROR("fail status code length = %d\r\n", dataLen);
+            Hexdump(data, dataLen);
+            if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 0) {
+                for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+                    usleep(128);
+                    if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '3' ||  //from backend or power cabinet
+                            (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0] >= 'B' &&
+                             ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '4')) {
+                        memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
+                        memcpy(EventCodeTmp,
+                               ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i],
+                               sizeof(EventCodeTmp));
+                        removeFaultCodeToBuf(EventCodeTmp);
+                    }
                 }
             }
+            return FAIL;
         }
-        return FAIL;
-    }
 
-    for (count = 0; count < dataLen; count += WARNING_CODE_SIZE) {
-        usleep(128);
-        // misc command status code handle
-        if (strncmp((char *)&data[count], MISC_ST_MISC_CMD, WARNING_CODE_SIZE) == 0) {
-            //if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
-            gDoCommGblData.MiscCmd = REG_MISC_CONTROL;
-            //}
-            memset((char *)&data[count], 0, WARNING_CODE_SIZE);
-            continue;
-        } else if (strncmp((char *)&data[count], MISC_ST_VERSION, WARNING_CODE_SIZE) == 0) {
-            //if (gDoCommGblData.MiscCmd != REG_REPORT_CSU_VERSION) {
-            gDoCommGblData.MiscCmd = REG_REPORT_CSU_VERSION;
-            //}
-            memset((char *)&data[count], 0, WARNING_CODE_SIZE);
-            continue;
-        }
+        for (count = 0; count < dataLen; count += WARNING_CODE_SIZE) {
+            usleep(128);
+            // misc command status code handle
+            if (strncmp((char *)&data[count], MISC_ST_MISC_CMD, WARNING_CODE_SIZE) == 0) {
+                //if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
+                gDoCommGblData.MiscCmd = REG_MISC_CONTROL;
+                //}
+                memset((char *)&data[count], 0, WARNING_CODE_SIZE);
+                continue;
+            } else if (strncmp((char *)&data[count], MISC_ST_VERSION, WARNING_CODE_SIZE) == 0) {
+                //if (gDoCommGblData.MiscCmd != REG_REPORT_CSU_VERSION) {
+                gDoCommGblData.MiscCmd = REG_REPORT_CSU_VERSION;
+                //}
+                memset((char *)&data[count], 0, WARNING_CODE_SIZE);
+                continue;
+            }
 
-        if (CompareArrayIsZero((uint8_t *)&data[count], WARNING_CODE_SIZE) == true) {
-            memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
-            memcpy(EventCodeTmp, (char *)&data[count], sizeof(EventCodeTmp));
-            DEBUG_ERROR("error status = %s\r\n", EventCodeTmp);
-            continue;
-        }
+            if (CompareArrayIsZero((uint8_t *)&data[count], WARNING_CODE_SIZE) == true) {
+                memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
+                memcpy(EventCodeTmp, (char *)&data[count], sizeof(EventCodeTmp));
+                DEBUG_ERROR("error status = %s\r\n", EventCodeTmp);
+                continue;
+            }
 
-        strncpy((char *)&StatusArray[count / WARNING_CODE_SIZE], (char *)&data[count], WARNING_CODE_SIZE);
+            strncpy((char *)&StatusArray[count / WARNING_CODE_SIZE], (char *)&data[count], WARNING_CODE_SIZE);
 
-        ret = 0;
-        for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
-            usleep(128);
-            if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0],
-                       StatusArray[count / WARNING_CODE_SIZE],
-                       WARNING_CODE_SIZE) == 0) {
-                ret = 1;
-                break;
+            ret = 0;
+            for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+                usleep(128);
+                if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0],
+                           StatusArray[count / WARNING_CODE_SIZE],
+                           WARNING_CODE_SIZE) == 0) {
+                    ret = 1;
+                    break;
+                }
             }
-        }
 
-        if (ret == 0) {
-            addFaultCodeToBuf(StatusArray[count / WARNING_CODE_SIZE]);
+            if (ret == 0) {
+                addFaultCodeToBuf(StatusArray[count / WARNING_CODE_SIZE]);
+            }
+            //Rtn=StatusCodeProcessing(StatusArray[count/6]);
         }
-        //Rtn=StatusCodeProcessing(StatusArray[count/6]);
     }
 
     for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
@@ -995,7 +1024,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     return PASS;
 }
 
-static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t id, uint8_t reg)
+static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_t reg)
 {
     int ret = PASS;
     uint8_t rawDataLen = 0;
@@ -1037,7 +1066,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t id, uint8_t reg
         break;
 
     case REG_CHARGING_CAP:
-        chargingcapabilityHandle(pCsuResult->Data.Data, id - 1);
+        chargingcapabilityHandle(pCsuResult->Data.Data, plugNum);
         break;
 
     case REG_CHARGING_TARGET:
@@ -1086,7 +1115,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t id, uint8_t reg
         break;
 
     case REG_MISC_CONTROL:
-        miscCommandHandle(rawDataLen, pCsuResult->Head.ID, pCsuResult->Data.Data);
+        miscCommandHandle(rawDataLen, plugNum, pCsuResult->Data.Data);
         break;
 
     case REG_REPORT_CSU_VERSION:
@@ -1120,6 +1149,8 @@ static int composeSocketData(int fd,
     int ret = PASS;
     int size = 0;
     int sendPktLen = 0;
+    uint8_t i = 0;
+    uint8_t plugNum = 0;
     CsuCmdPkt csuCmdPkt = {0};
     CsuResultPkt csuResult = {0};
 
@@ -1158,7 +1189,14 @@ static int composeSocketData(int fd,
         return FAIL;
     }
 
-    ret = responsePackeHandle(fd, (uint8_t *)&csuResult, id, csuCmdPkt.Data.Register);
+    for (i = 0; i < sizeof(gDoCommGblData.ConnectorID); i++) {
+        if (id == gDoCommGblData.ConnectorID[i]) {
+            plugNum = i;
+            break;
+        }
+    }
+
+    ret = responsePackeHandle(fd, (uint8_t *)&csuResult, plugNum, csuCmdPkt.Data.Register);
 
     return ret;
 }
@@ -1320,26 +1358,34 @@ static int writeUserID(int fd, uint8_t id, uint8_t *pUserID)
 
 static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
 {
-    uint8_t dataBuf[2] = {0};
+    uint8_t dataBuf[8] = {0};
     int ret = PASS;
 
-    if (ChargingData[plugNum]->SystemStatus <= 2) {
-        dataBuf[0] = 0;    //idle
-    } else if ((ChargingData[plugNum]->SystemStatus <= 7) ||
-               (ChargingData[plugNum]->SystemStatus == 17) ||
-               (ChargingData[plugNum]->SystemStatus == 18)) {
-        dataBuf[0] = 1;    //preparing
-    } else if (ChargingData[plugNum]->SystemStatus == 8) {
-        dataBuf[0] = 2;    //charging
-    } else if (ChargingData[plugNum]->SystemStatus == 9) {
-        dataBuf[0] = 3;    //terminating
+    if (ChargingData[plugNum]->SystemStatus <= S_AUTHORIZING) {
+        dataBuf[0] = CONN_ST_IDLE;    //idle
+        strcpy((char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode, "");
+    } else if ((ChargingData[plugNum]->SystemStatus <= S_PREPARING_FOR_EVSE) ||
+               (ChargingData[plugNum]->SystemStatus == S_CCS_PRECHARGE_ST0) ||
+               (ChargingData[plugNum]->SystemStatus == S_CCS_PRECHARGE_ST1)) {
+        dataBuf[0] = CONN_ST_PREPARING;    //preparing
+    } else if (ChargingData[plugNum]->SystemStatus == S_CHARGING) {
+        dataBuf[0] = CONN_ST_CHARGING;    //charging
+    } else if (ChargingData[plugNum]->SystemStatus == S_TERMINATING) {
+        dataBuf[0] = CONN_ST_TERMINATING;    //terminating
+    } else if ((ChargingData[plugNum]->SystemStatus == S_ALARM) ||
+               (ChargingData[plugNum]->SystemStatus == S_FAULT)) {
+        dataBuf[0] = CONN_ST_ALARM;
+        if (strcmp((char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode, "") != 0) {
+            strncpy((char *)&dataBuf[1], (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode, WARNING_CODE_SIZE);
+            DEBUG_INFO("ID = %d, VendorErrorCode = %s\r\n", plugNum, (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
+        }
     }
 
     ret = composeSocketData(fd,
                             id,
                             OP_WRITE_DATA,
                             REG_CONNECTOR_STATE,
-                            1,
+                            sizeof(dataBuf) - 1,
                             &dataBuf[0]);
     return ret;
 }
@@ -1358,13 +1404,13 @@ static int writePlugInStatus(int fd, uint8_t plugNum, uint8_t id)
     return ret;
 }
 
-static int readSoftwareUpdate(int fd)
+static int readSoftwareUpdate(int fd, uint8_t gunID)
 {
     int ret = PASS;
     uint8_t dataBuf[2] = {ShmSysConfigAndInfo->SysInfo.FirmwareUpdate, 0};
 
     ret = composeSocketData(fd,
-                            0x01,
+                            gunID,
                             OP_READ_DATA,
                             REG_SOFTWARE_UPDATE,
                             1,
@@ -1413,7 +1459,7 @@ static int readChargingCapability(int fd, uint8_t id)
     return ret;
 }
 
-static int writeDispenserStatus(int fd)
+static int writeDispenserStatus(int fd, uint8_t gunID)
 {
     uint8_t warningCount = 0;
     uint8_t count = 0;
@@ -1441,7 +1487,7 @@ static int writeDispenserStatus(int fd)
     }
 
     ret = composeSocketData(fd,
-                            ID_OF_DISPENSER,
+                            gunID,
                             OP_WRITE_DATA,
                             REG_DISPENSER_STATUS,
                             strlen((char *)CurWarnCodeTmp),
@@ -1450,12 +1496,12 @@ static int writeDispenserStatus(int fd)
     return ret;
 }
 
-static int readPowerCabinetStatus(int fd)
+static int readPowerCabinetStatus(int fd, uint8_t gunID)
 {
     int ret = PASS;
 
     ret = composeSocketData(fd,
-                            ID_OF_DISPENSER,
+                            gunID,
                             OP_READ_DATA,
                             REG_POWER_CABINET_STATUS,
                             0,
@@ -1614,7 +1660,7 @@ static int InitShareMemory(void)
     return result;
 }
 
-static void updateFirmwareProcess(int fd, uint8_t totalConnCount)
+static void updateFirmwareProcess(int fd, uint8_t gunID, uint8_t totalConnCount)
 {
     bool canUpdateFirmware = true;
     uint8_t plugNum = 0;
@@ -1634,7 +1680,7 @@ static void updateFirmwareProcess(int fd, uint8_t totalConnCount)
     if (canUpdateFirmware) {
         ftime(&updateTime);
         if (DiffTimeb(gRegTimeUp[0][REG_SOFTWARE_UPDATE], updateTime) > LOOP_RETRY_TIME * 5) {
-            readSoftwareUpdate(fd);
+            readSoftwareUpdate(fd, gunID);
             ftime(&gRegTimeUp[0][REG_SOFTWARE_UPDATE]);
         }
 
@@ -1642,7 +1688,7 @@ static void updateFirmwareProcess(int fd, uint8_t totalConnCount)
             while (ackCount != 0) {
                 ftime(&updateTime);
                 if (DiffTimeb(gRegTimeUp[0][REG_SOFTWARE_UPDATE], updateTime) > LOOP_RETRY_TIME / 2) {
-                    readSoftwareUpdate(fd);
+                    readSoftwareUpdate(fd, gunID);
                     ftime(&gRegTimeUp[0][REG_SOFTWARE_UPDATE]);
                     if (ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == NO) {
                         ackCount--;
@@ -1657,14 +1703,22 @@ static void updateFirmwareProcess(int fd, uint8_t totalConnCount)
 static void checkAuthorProcess(int fd, uint8_t plugNum)
 {
     int ret = 0;
+    uint8_t gunID = 0;
     struct timeb AuthNowTime;
 
+#if defined DD360Audi
+    gunID = gDoCommGblData.ConnectorID[ShmSysConfigAndInfo->SysInfo.CurGunSelected];
+    //gunID = gDoCommGblData.ConnectorID[plugNum];
+#else
+    gunID = ID_REGISTER;
+#endif // DD360Audi
+
     if ((ShmOCPP16Data->SpMsg.bits.AuthorizeReq == YES) || (ShmSysConfigAndInfo->SysInfo.AuthorizeFlag == YES)) {
         ftime(&AuthNowTime);
 
         if (DiffTimeb(gRegTimeUp[plugNum][REG_USER_ID], AuthNowTime) > LOOP_RETRY_TIME) {
             ret = writeUserID(fd,
-                              ShmSysConfigAndInfo->SysInfo.CurGunSelected + 1,
+                              gunID,
                               ShmSysConfigAndInfo->SysConfig.UserId);
             if (ret >= 0) {
                 memset(ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status,
@@ -1679,7 +1733,14 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
                 //printf("gAudiCustInfo->PricesInfo[plugNum].Balance = %.2f, %.2f\r\n",
                 //       gAudiCustInfo->PricesInfo[plugNum].Balance,
                 //       FAIL_BALANCE_PRICES);
-                if (gAudiCustInfo->PricesInfo[plugNum].Balance != FAIL_BALANCE_PRICES) {
+#if defined DD360Audi
+                if (gAudiCustInfo->PricesInfo[plugNum].Balance != FAIL_BALANCE_PRICES)
+#else
+                if (gAudiCustInfo->PricesInfo[plugNum].Balance == FAIL_BALANCE_PRICES) {
+                    gAudiCustInfo->PricesInfo[plugNum].Balance = 0;
+                }
+#endif //
+                {
                     ShmOCPP16Data->SpMsg.bits.AuthorizeConf    = 1; //isAuthorizedComplete
                     ShmOCPP16Data->SpMsg.bits.AuthorizeReq     = 0;
                     ShmSysConfigAndInfo->SysInfo.AuthorizeFlag = 0;
@@ -1707,6 +1768,8 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
             if (WriteModelName(fd) == PASS) {
                 gDoCommGblData.DisConnCount = 0;
                 curReg = REG_CONNECTOR_ID;
+            } else {
+                sleep(1);
             }
             break;
 
@@ -1714,12 +1777,14 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
             if (readConnectorID(fd) == PASS) {
                 gDoCommGblData.DisConnCount = 0;
                 curReg = REG_REPORT_CSU_VERSION;
+            } else {
+                sleep(1);
             }
             break;
 
         case REG_POWER_CABINET_STATUS:
             if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME) {
-                readPowerCabinetStatus(fd);
+                readPowerCabinetStatus(fd, gunID);
                 ftime(&gRegTimeUp[plugNum][curReg]);
             }
             curReg = REG_DISPENSER_STATUS;
@@ -1727,7 +1792,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
 
         case REG_DISPENSER_STATUS:
             if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME) {
-                writeDispenserStatus(fd);
+                writeDispenserStatus(fd, gunID);
                 ftime(&gRegTimeUp[plugNum][curReg]);
             }
             curReg = REG_PLUG_IN_STATE;
@@ -1858,8 +1923,9 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
 //    return NO;
 //}
 
-static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
+static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8_t gunID)
 {
+    uint8_t i = 0;
     struct timeb AuthNowTime = {0};
 
     switch (ChargingData[plugNum]->SystemStatus) {
@@ -1896,8 +1962,9 @@ static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
         ftime(&AuthNowTime);
         if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME) {
             if (readChargePermission(fd, gunID) && readChargingCapability(fd, gunID)) {
-                ShmPsuData->SystemAvailablePower = (ChargingData[0]->AvailableChargingPower +
-                                                    ChargingData[1]->AvailableChargingPower);
+                for (i = 0; i < totalGun; i++) {
+                    ShmPsuData->SystemAvailablePower += ChargingData[i]->AvailableChargingPower;
+                }
                 ShmPsuData->SystemPresentPsuQuantity = (ShmPsuData->SystemAvailablePower / 30);
             }
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
@@ -1923,7 +1990,7 @@ static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
                 DEBUG_INFO("Stop charging by power cabinet's permission = %d, %d\r\n",
                            plugNum,
                            REG_CHARGING_PERMISSION);
-                ChargingData[plugNum]->StopChargeFlag = 1;
+                ChargingData[plugNum]->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
             }
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
         }
@@ -1952,7 +2019,7 @@ static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
                 DEBUG_INFO("Stop charging by power cabinet's permission = %d, %d\r\n",
                            plugNum,
                            REG_CHARGING_PERMISSION);
-                ChargingData[plugNum]->StopChargeFlag = 1;
+                ChargingData[plugNum]->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
             }
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
         }
@@ -1978,7 +2045,8 @@ static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
                 DEBUG_INFO("Stop charging by power cabinet's permission = %d, %d\r\n",
                            plugNum,
                            REG_CHARGING_PERMISSION);
-                ChargingData[plugNum]->StopChargeFlag = 1;
+                ChargingData[plugNum]->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
+                //printf("%d StopChargeFlag = %d\r\n", plugNum, ChargingData[plugNum]->StopChargeFlag);
             }
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
         }
@@ -2091,14 +2159,15 @@ int main(int argc, char *argv[])
 
             initDone = messageTrigger(fd, 0, 0, REG_MODEL_NAME); //first trigger model name and connector id
         } else {
-            checkAuthorProcess(fd, 0);
+            //checkAuthorProcess(fd, 0);
 
             plugNum = 0;
             gunID = 0;
             for (plugNum = 0; plugNum < totalConnCount; plugNum++) {
                 //plugNum = setup chargingData value for bottom layer
-                gunID = (plugNum  + 1); //connector Id, 1 = left gun, 2 = right gun
-                systemStatusProcess(fd, plugNum, gunID);
+                //gunID = (plugNum  + 1); //connector Id, 1 = left gun, 2 = right gun
+                gunID = gDoCommGblData.ConnectorID[plugNum];
+                systemStatusProcess(fd, totalConnCount, plugNum, gunID);
 
                 initDone = messageTrigger(fd,
                                           plugNum,
@@ -2126,7 +2195,7 @@ int main(int argc, char *argv[])
 
         //update dispenser firmware
         if (initDone != DISPENER_INIT_FAIL) {
-            updateFirmwareProcess(fd, totalConnCount);
+            updateFirmwareProcess(fd, gDoCommGblData.ConnectorID[0], totalConnCount);
         }
 
         usleep(1000);

+ 22 - 2
EVSE/Projects/DD360Audi/Apps/ReDoComm.h

@@ -58,6 +58,15 @@
 #define OP_WRITE_DATA                           0x02
 #define OP_WAIT_RESPONSE                        0x03
 
+//------------------------------------------------------------------------------
+//--- connector status ---
+//------------------------------------------------------------------------------
+#define CONN_ST_IDLE                            0x00
+#define CONN_ST_PREPARING                       0x01
+#define CONN_ST_CHARGING                        0x02
+#define CONN_ST_TERMINATING                     0x03
+#define CONN_ST_ALARM                           0x04
+
 //------------------------------------------------------------------------------
 //--- dispenser register ---
 //------------------------------------------------------------------------------
@@ -101,6 +110,11 @@
 #define MISC_CMD_DEFAULT_CURRENCY               0x0004
 #define MISC_CMD_ACCOUNT_BALANCE                0x0005
 
+#define MISC_CMD_BACKEND_STATUS                 0x0006
+#define MISC_CMD_ETHERNET_STATUS                0x0007
+#define MISC_CMD_WIFI_STATUS                    0x0008
+#define MISC_CMD_4G_STATUS                      0x0009
+
 #define MISC_CMD_HARDWARE_REBOOT                0x0101
 #define MISC_CMD_SOFTWARE_RESTART               0x0102
 #define MISC_CMD_REMOTE_START_CHARGING          0x0103
@@ -114,12 +128,18 @@
 #pragma pack(push)
 #pragma pack(1)
 
+typedef struct StConnectorIDTable {
+    uint8_t DcConnID1;
+    uint8_t DcConnID2;
+    uint8_t AcConnID;
+} ConnectorIDTable;
+
 typedef struct StDoCommGlobalVar {
     uint8_t SeqNum;
     uint8_t DisConnCount;
-    uint8_t ConnectorID[2]; //keep from power cabinet
+    uint8_t ConnectorID[3]; //keep from power cabinet
     uint8_t MiscCmd;
-    uint8_t Reserved[3];
+    uint8_t Reserved[2];
 } DoCommGblData;
 
 typedef struct StCommnadHead {

+ 140 - 104
EVSE/Projects/DD360Audi/Apps/ReMain.c

@@ -53,7 +53,11 @@
 #define MtdBlockSize                            0x600000
 #define SYSFS_GPIO_DIR                          "/sys/class/gpio"
 #define UPGRADE_FAN                             0x02
-#define UPGRADE_RB                              0x09 //0x09 for dispenser //0x03 old module use
+#if defined DD360 || defined DD360Audi
+#define UPGRADE_RB                              0x09 //0x09 for DD360 dispenser
+#else
+#define UPGRADE_RB                              0x03 //other module use
+#endif //defined DD360 || defined DD360Audi
 #define UPGRADE_PRI                             0x04
 #define UPGRADE_AC                              0x05
 #define UPGRADE_LED                             0x06
@@ -1150,18 +1154,21 @@ void InitEthernet()
 
             if (!ethResult &&
                     ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode != _SYS_WIFI_MODE_DISABLE &&
-                    (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W' || ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')) {
+                    (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W' ||
+                     ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')) {
                 //ethResult = ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn;
                 ethResult = ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi == YES ? NO : YES;
 
                 if (ethResult) {
-                    if ((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')) {
+                    if ((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W') ||
+                            (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')) {
                         system("/sbin/ifmetric eth0 1");
                         system("/sbin/ifmetric mlan0 0");
                     }
 
 
-                    if ((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')) {
+                    if ((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') ||
+                            (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')) {
                         system("/sbin/ifmetric ppp0 2");
                     }
                 }
@@ -1169,16 +1176,19 @@ void InitEthernet()
 
             if (!ethResult &&
                     ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled == YES &&
-                    (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T' || ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')) {
+                    (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T' ||
+                     ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')) {
                 //ethResult = ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn;
                 ethResult = ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi == YES ? NO : YES;
 
                 if (ethResult) {
-                    if ((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')) {
+                    if ((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W') ||
+                            (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')) {
                         system("/sbin/ifmetric mlan0 2");
                     }
 
-                    if ((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') || (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')) {
+                    if ((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T') ||
+                            (ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D')) {
                         system("/sbin/ifmetric eth0 1");
                         system("/sbin/ifmetric ppp0 0");
                     }
@@ -1261,11 +1271,12 @@ void GetFirmwareVersion()
         if (ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'J') {
             chademo++;
             count++;
-        } else  if (ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'G') {
+        } else if (ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'G') {
             gb++;
             count++;
-        } else  if (ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'U' ||
-                    ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'E') {
+        } else if (ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'U' ||
+                   ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'V' ||
+                   ShmSysConfigAndInfo->SysConfig.ModelName[7 + idx] == 'E') {
             ccs++;
             count++;
         }
@@ -1658,7 +1669,7 @@ void SelfTestRun()
                     DEBUG_INFO_MSG("Primary FW Rev = %s", ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev);
                     ShmPrimaryMcuData->SelfTest_Comp = YES;
                 }
-#if 1 //DS60-120 remove
+#if 0 //DS60-120 remove
                 if ((strlen((char *)ShmSysConfigAndInfo->SysInfo.LedModuleFwRev) != 0 ||
                         ShmSysConfigAndInfo->SysInfo.LedModuleFwRev[0] != '\0')
                         && (ShmLedModuleData->SelfTest_Comp != YES)
@@ -1667,13 +1678,16 @@ void SelfTestRun()
                     ShmLedModuleData->SelfTest_Comp = YES;
                 }
 #endif //0
+
                 // EV 小板
                 if (!evInitFlag) {
                     evInitFlag = YES;
                     for (byte index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++) {
+                        //DEBUG_INFO_MSG("index = %d, charging index = %d, type = %d\r\n", index, chargingInfo[index]->type_index, chargingInfo[index]->Type);
                         if (chargingInfo[index]->Type == _Type_Chademo) {
-                            if ((strlen((char *)ShmCHAdeMOData->evse[chargingInfo[index]->type_index].version) != 0 || ShmCHAdeMOData->evse[chargingInfo[index]->type_index].version[0] != '\0')
-                                    && (ShmCHAdeMOData->evse[chargingInfo[index]->type_index].SelfTest_Comp != YES)
+                            if ((strlen((char *)ShmCHAdeMOData->evse[chargingInfo[index]->type_index].version) != 0 ||
+                                    ShmCHAdeMOData->evse[chargingInfo[index]->type_index].version[0] != '\0')
+                                    //&& (ShmCHAdeMOData->evse[chargingInfo[index]->type_index].SelfTest_Comp != YES)
                                ) {
                                 DEBUG_INFO_MSG("CHAdeMO[%d] FW Rev = %s", chargingInfo[index]->type_index, ShmCHAdeMOData->evse[chargingInfo[index]->type_index].version);
                                 ShmCHAdeMOData->evse[chargingInfo[index]->type_index].SelfTest_Comp = YES;
@@ -1682,8 +1696,9 @@ void SelfTestRun()
                                 evInitFlag = NO;
                             }
                         } else if (chargingInfo[index]->Type == _Type_GB) {
-                            if ((strlen((char *)ShmGBTData->evse[chargingInfo[index]->type_index].version) != 0 || ShmGBTData->evse[chargingInfo[index]->type_index].version[0] != '\0')
-                                    && (ShmGBTData->evse[chargingInfo[index]->type_index].SelfTest_Comp != YES)
+                            if ((strlen((char *)ShmGBTData->evse[chargingInfo[index]->type_index].version) != 0 ||
+                                    ShmGBTData->evse[chargingInfo[index]->type_index].version[0] != '\0')
+                                    //&& (ShmGBTData->evse[chargingInfo[index]->type_index].SelfTest_Comp != YES)
                                ) {
                                 DEBUG_INFO_MSG("GBT[%d] FW Rev = %s", chargingInfo[index]->type_index, ShmGBTData->evse[chargingInfo[index]->type_index].version);
                                 ShmGBTData->evse[chargingInfo[index]->type_index].SelfTest_Comp = YES;
@@ -1693,7 +1708,7 @@ void SelfTestRun()
                             }
                         } else if (chargingInfo[index]->Type == _Type_CCS_2) {
                             if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
-                                if ((strlen((char *)ShmCcsData->V2GMessage_DIN70121[chargingInfo[index]->type_index].version) != 0 &&
+                                if ((strlen((char *)ShmCcsData->V2GMessage_DIN70121[chargingInfo[index]->type_index].version) != 0 ||
                                         ShmCcsData->V2GMessage_DIN70121[chargingInfo[index]->type_index].version[0] != '\0')
                                         /*&&(ShmCcsData->V2GMessage_DIN70121[chargingInfo[index]->type_index].SelfTest_Comp != YES)*/
                                    ) {
@@ -1724,7 +1739,7 @@ void SelfTestRun()
                 if ( ShmFanModuleData->SelfTest_Comp &&
                         ShmRelayModuleData->SelfTest_Comp &&
                         ShmPrimaryMcuData->SelfTest_Comp &&
-                        ShmLedModuleData->SelfTest_Comp &&
+                        //ShmLedModuleData->SelfTest_Comp &&
                         evInitFlag
                    ) {
                     ShmSysConfigAndInfo->SysInfo.SelfTestSeq = _STEST_AC_CONTACTOR;
@@ -1876,8 +1891,9 @@ int StoreUsrConfigData(struct SysConfigData *UsrData)
 //===============================================
 // Common Detect Chk - Stop Charging ?
 //===============================================
-bool isEvBoardStopChargeFlag(byte gunIndex)
+int isEvBoardStopChargeFlag(byte gunIndex)
 {
+    //printf("StopChargeFlag = %d\r\n", chargingInfo[gunIndex]->StopChargeFlag);
     return chargingInfo[gunIndex]->StopChargeFlag;
 }
 
@@ -2366,7 +2382,8 @@ void EmcOccureByString(char *code)
     byte level = 2;
     // 嚴重的急停有以下幾種 : EMC 按鈕、Mainbreak、Dooropen
     // 其錯誤等級為 2
-    /*
+
+#if defined DD360 || defined DD360Audi
     //DS60-120 remove
     if (strncmp(code, "012251", 6) == EQUAL ||
             strncmp(code, "012252", 6) == EQUAL ||
@@ -2377,19 +2394,25 @@ void EmcOccureByString(char *code)
             strncmp(code, "042200", 6) == EQUAL ||
             strncmp(code, "042201", 6) == EQUAL ||
             strncmp(code, "042202", 6) == EQUAL ||
-            strncmp(code, "042267", 6) == EQUAL) {
-                */
-    for (byte gun = 0; gun < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun++) {
-        if ((chargingInfo[gun]->SystemStatus > S_IDLE && chargingInfo[gun]->SystemStatus < S_TERMINATING) ||
-                (chargingInfo[gun]->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingInfo[gun]->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
-            //ChargingTerminalProcess(gun);
-            ChargingAlarmProcess(gun);
+            strncmp(code, "042267", 6) == EQUAL)
+#endif //defined DD360 || defined DD360Audi
+    {
+        for (byte gun = 0; gun < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun++) {
+            //strncpy((char *)ShmOCPP16Data->StatusNotification[gun].VendorErrorCode, code, 6);
+
+            if ((chargingInfo[gun]->SystemStatus > S_IDLE &&
+                    chargingInfo[gun]->SystemStatus < S_TERMINATING) ||
+                    (chargingInfo[gun]->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
+                     chargingInfo[gun]->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
+                //ChargingTerminalProcess(gun);
+                ChargingAlarmProcess(gun);
+            }
         }
+#if defined DD360 || defined DD360Audi
+        StopChargingProcessByString(level);
+        InformOcppErrOccur(4);
+#endif //defined DD360 || defined DD360Audi
     }
-
-    StopChargingProcessByString(level);
-    //InformOcppErrOccur(4);
-    //}
 }
 
 void ReleaseBoardErrOccurByString(byte index, char *code)
@@ -2512,12 +2535,12 @@ void ChkPrimaryStatus()
     }
 
     //DS60-120 add
-    if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
-            ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS) {
-        ShmSysConfigAndInfo->SysConfig.ShowInformation = YES;
-    } else {
-        ShmSysConfigAndInfo->SysConfig.ShowInformation = NO;
-    }
+    //if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
+    //        ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS) {
+    //    ShmSysConfigAndInfo->SysConfig.ShowInformation = YES;
+    //} else {
+    //    ShmSysConfigAndInfo->SysConfig.ShowInformation = NO;
+    //}
 
     if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
             !leftBtnPush
@@ -2720,7 +2743,7 @@ void CheckErrorOccurStatus(byte index)
                     memcpy(chargingInfo[index]->ConnectorAlarmCode, "012205", 6);
                 }
             }
-
+            //DEBUG_INFO_MSG("1 CheckErrorOccurStatus\r\n");
             chargingInfo[index]->StopChargeFlag = YES;
             //------------------------------------------------------------------
         } else {
@@ -2757,6 +2780,7 @@ void CheckErrorOccurStatus(byte index)
                 memcpy(chargingInfo[index]->ConnectorAlarmCode, "012202", 6);
             }
         }
+        //DEBUG_INFO_MSG("2 CheckErrorOccurStatus\r\n");
         chargingInfo[index]->StopChargeFlag = YES;
         //----------------------------------------------------------------------
     } else {
@@ -2871,7 +2895,7 @@ void CheckGunTypeFromHw()
         }
     }
 
-#if 0 //DS60-120 remove
+#if 1 //DS60-120 remove
     //BD1(Left-CCS-CND1-SMR2-左槍), BD2(Right-CHADEMO-CND2-SMR1-右槍), CCS: 10 , CHAdeMO: 01 , GBT: 11
     //CcsChargingData [0至1] 分別為 Right至Left
     //model name 槍順序左至右分別為Right至Left
@@ -5130,7 +5154,30 @@ void TheEndCharging(byte gun_index)
 
 void UpdateErrorCodeToOcpp(byte index)
 {
-    //printf("ConnectorAlarmCode = %s \n", chargingInfo[index]->ConnectorAlarmCode);
+    uint8_t i = 0;
+
+    if ((strcmp((char *)chargingInfo[index]->ConnectorAlarmCode, "") == EQUAL) &&
+            (strcmp((char *)chargingInfo[index]->EvConnAlarmCode, "") == EQUAL)
+       ) {
+        for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+            if (strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012251", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012252", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012238", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "042251", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "042252", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012304", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "042200", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "042201", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "042202", 6) == EQUAL ||
+                    strncmp((char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "042267", 6) == EQUAL) {
+
+                strncpy((char *)ShmOCPP16Data->StatusNotification[index].VendorErrorCode, (char *)&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], 6);
+                //DEBUG_INFO_MSG("1 %d = VendorErrorCode = %s\r\n", index, (char *)ShmOCPP16Data->StatusNotification[index].VendorErrorCode);
+                break;
+            }
+        }
+    }
+
     if (strcmp((char *)chargingInfo[index]->ConnectorAlarmCode, "") != EQUAL) {
         strcpy((char *)ShmOCPP16Data->StatusNotification[index].ErrorCode, "InternalError");
         strcpy((char *)ShmOCPP16Data->StatusNotification[index].VendorErrorCode, (char *)chargingInfo[index]->ConnectorAlarmCode);
@@ -5138,6 +5185,8 @@ void UpdateErrorCodeToOcpp(byte index)
         strcpy((char *)ShmOCPP16Data->StatusNotification[index].ErrorCode, "OtherError");
         strcpy((char *)ShmOCPP16Data->StatusNotification[index].VendorErrorCode, (char *)chargingInfo[index]->EvConnAlarmCode);
     }
+
+    //DEBUG_INFO_MSG("2 %d = VendorErrorCode = %s\r\n", index, (char *)ShmOCPP16Data->StatusNotification[index].VendorErrorCode);
 }
 
 void AdjustChargerCurrent()
@@ -5327,6 +5376,8 @@ static void powerCabinetPsuAlarmStatus(void)
 
 int main(void)
 {
+    uint8_t evBoardStopState = 0;
+
     if (CreateShareMemory() == 0) {
         DEBUG_ERROR_MSG("CreatShareMemory NG\r\n");
         if (ShmStatusCodeData != NULL) {
@@ -5485,7 +5536,6 @@ int main(void)
                         ChargingProfileFlat(_index);
                         _ocppProfileChkFlag = 0;
                     } else if (chargingInfo[_index]->SystemStatus != S_CHARGING) {
-
                         ChargingProfileFlat(_index);
                         _ocppProfileChkFlag = 0;
                     } else {
@@ -5504,7 +5554,6 @@ int main(void)
                 }
 #endif //defined METER_ENABLE
             }
-
             gettimeofday(&_cmdMainPriority_time, NULL);
         }
 
@@ -5534,11 +5583,7 @@ int main(void)
             //PRINTF_FUNC("index = %d, ErrorCode = %s \n", gun_index, ShmOCPP16Data->StatusNotification[gun_index].ErrorCode);
             switch (chargingInfo[gun_index]->SystemStatus) {
             case S_IDLE:
-            case S_RESERVATION:
-            case S_MAINTAIN:
-            case S_FAULT: {
-                if (chargingInfo[gun_index]->SystemStatus == S_IDLE &&
-                        isModeChange(gun_index)) {
+                if (isModeChange(gun_index)) {
                     DEBUG_INFO_MSG("S_IDLE================================== %x \n", gun_index);
                     chargingInfo[gun_index]->PresentChargedDuration = 0;
                     chargingInfo[gun_index]->RemainChargingDuration = 0;
@@ -5556,8 +5601,10 @@ int main(void)
                     destroySelGun(gun_index);
 #endif //defined DD360Audi
                     ResetDetAlarmStatus(gun_index); //recovery OVP status code
-                } else if (chargingInfo[gun_index]->SystemStatus == S_RESERVATION &&
-                           isModeChange(gun_index)) {
+                    //strcpy((char *)ShmOCPP16Data->StatusNotification[gun_index].VendorErrorCode, "");
+                }
+            case S_RESERVATION:
+                if (isModeChange(gun_index)) {
                     DEBUG_INFO_MSG("S_RESERVATION....................%x \n", gun_index);
                     ShmOCPP16Data->CsMsg.bits[gun_index].ReserveNowConf = YES;
                 }
@@ -5566,6 +5613,8 @@ int main(void)
                     setChargerMode(gun_index, MODE_MAINTAIN);
                 }
 
+            case S_MAINTAIN:
+            case S_FAULT: {
                 if (ShmSysConfigAndInfo->SysWarningInfo.Level == 2) {
                     if (gun_index == ShmSysConfigAndInfo->SysInfo.CurGunSelected) {
                         ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_FIX;
@@ -5585,9 +5634,9 @@ int main(void)
                     }
 
                     ClearDetectPluginFlag();
-#if !defined DD360 && !defined DD360Audi
+//#if !defined DD360 && !defined DD360Audi
                     UpdateErrorCodeToOcpp(gun_index);
-#endif //!defined DD360 && !defined DD360Audi
+//#endif //!defined DD360 && !defined DD360Audi
                     setChargerMode(gun_index, MODE_FAULT);
                 } else {
 #if 1
@@ -5657,11 +5706,6 @@ int main(void)
                             // Idle 正常程序起點
                             // 判斷是否有啟用檢查插槍
                             if (isDetectPlugin()) {
-                                //PRINTF_FUNC("----------------ShmSysConfigAndInfo->SysInfo.PageIndex--------------- %d \n", ShmSysConfigAndInfo->SysInfo.PageIndex);
-                                //PRINTF_FUNC("----------------ShmSysConfigAndInfo->SysInfo.SystemPage--------------- %d \n", ShmSysConfigAndInfo->SysInfo.SystemPage);
-                                //PRINTF_FUNC("----------------ShmSysConfigAndInfo->SysInfo.ConnectorPage--------------- %d \n", ShmSysConfigAndInfo->SysInfo.ConnectorPage);
-                                //PRINTF_FUNC("----------------isCardScan--------------- %d \n", isCardScan);
-
                                 // 卡號驗證成功後,等待充電槍插入充電車
                                 if (chargingInfo[gun_index]->RemoteStartFlag == YES) {
                                     if (chargingInfo[gun_index]->ConnectorPlugIn == YES &&
@@ -5873,12 +5917,17 @@ int main(void)
                     }
                 }
 
-                if (isEvBoardStopChargeFlag(gun_index) == YES) {
+                if ((evBoardStopState = isEvBoardStopChargeFlag(gun_index)) > 0) {
                     // 板端要求停止 (錯誤)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
                         strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
                     }
-                    ChargingAlarmProcess(gun_index);
+
+                    if (evBoardStopState == EV_BOARD_STOP_CHARGING) {
+                        ChargingAlarmProcess(gun_index);
+                    } else if (evBoardStopState == POWER_CABINET_STOP_CHARGING) {
+                        ChargingTerminalProcess(gun_index);
+                    }
                 } else if (isEvBoardNormalStopChargeFlag(gun_index) == YES) {
                     // 板端要求停止 (正常)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
@@ -5891,11 +5940,6 @@ int main(void)
                     ChargingTerminalProcess(gun_index);
                 }
 
-                //if (isEvBoardStopChargeFlag(gun_index) == YES || OcppRemoteStop(gun_index) == YES) {
-                //    // 板端或後臺要求停止
-                //    ChargingTerminalProcess(gun_index);
-                //}
-
                 if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
                     ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_PRE_CHARGE;
                     ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_NONE;
@@ -5927,12 +5971,17 @@ int main(void)
                     }
                 }
 
-                if (isEvBoardStopChargeFlag(gun_index) == YES) {
+                if ((evBoardStopState = isEvBoardStopChargeFlag(gun_index)) > 0) {
                     // 板端要求停止 (錯誤)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
                         strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
                     }
-                    ChargingAlarmProcess(gun_index);
+
+                    if (evBoardStopState == EV_BOARD_STOP_CHARGING) {
+                        ChargingAlarmProcess(gun_index);
+                    } else if (evBoardStopState == POWER_CABINET_STOP_CHARGING) {
+                        ChargingTerminalProcess(gun_index);
+                    }
                 } else if (isEvBoardNormalStopChargeFlag(gun_index) == YES) {
                     // 板端要求停止 (正常)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
@@ -5945,12 +5994,6 @@ int main(void)
                     ChargingTerminalProcess(gun_index);
                 }
 
-                //if (isEvBoardStopChargeFlag(gun_index) == YES  ||
-                //        OcppRemoteStop(gun_index) == YES) {
-                //    // 板端或後臺要求停止
-                //    ChargingTerminalProcess(gun_index);
-                //}
-
                 // LCM => Pre-charging
                 if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
                     ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_PRE_CHARGE;
@@ -6008,12 +6051,17 @@ int main(void)
                     }
                 }
 
-                if (isEvBoardStopChargeFlag(gun_index) == YES) {
+                if ((evBoardStopState = isEvBoardStopChargeFlag(gun_index)) > 0) {
                     // 板端要求停止 (錯誤)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
                         strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
                     }
-                    ChargingAlarmProcess(gun_index);
+
+                    if (evBoardStopState == EV_BOARD_STOP_CHARGING) {
+                        ChargingAlarmProcess(gun_index);
+                    } else if (evBoardStopState == POWER_CABINET_STOP_CHARGING) {
+                        ChargingTerminalProcess(gun_index);
+                    }
                 } else if (isEvBoardNormalStopChargeFlag(gun_index) == YES) {
                     // 板端要求停止 (正常)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
@@ -6026,12 +6074,6 @@ int main(void)
                     ChargingTerminalProcess(gun_index);
                 }
 
-                //if (isEvBoardStopChargeFlag(gun_index) == YES ||
-                //        OcppRemoteStop(gun_index) == YES) {
-                //    // 板端或後臺要求停止
-                //    ChargingTerminalProcess(gun_index);
-                //}
-
                 // LCM => Pre-charging
                 if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
                     ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_PRE_CHARGE;
@@ -6105,12 +6147,17 @@ int main(void)
                     }
                 }
 
-                if (isEvBoardStopChargeFlag(gun_index) == YES) {
+                if ((evBoardStopState = isEvBoardStopChargeFlag(gun_index)) > 0) {
                     // 板端要求停止 (錯誤)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
                         strcpy((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "EVDisconnected");
                     }
-                    ChargingAlarmProcess(gun_index);
+                    //printf("%d evBoardStopState = %d\r\n", gun_index, evBoardStopState);
+                    if (evBoardStopState == EV_BOARD_STOP_CHARGING) {
+                        ChargingAlarmProcess(gun_index);
+                    } else if (evBoardStopState == POWER_CABINET_STOP_CHARGING) {
+                        ChargingTerminalProcess(gun_index);
+                    }
                 } else if (isEvBoardNormalStopChargeFlag(gun_index) == YES) {
                     // 板端要求停止 (正常)
                     if (strcmp((char *)ShmOCPP16Data->StopTransaction[gun_index].StopReason, "") == EQUAL) {
@@ -6127,16 +6174,6 @@ int main(void)
                     ChargingTerminalProcess(gun_index);
                 }
 
-                //if (isEvBoardStopChargeFlag(gun_index) ||
-                //        OcppRemoteStop(gun_index) ||
-                //        CheckBackendChargingTimeout(gun_index) ||
-                //        CheckBackendChargingEnergy(gun_index) ||
-                //        strcmp((char *)ShmOCPP16Data->StartTransaction[gun_index].ResponseIdTagInfo.Status, "Invalid") == EQUAL) {
-                //    DEBUG_INFO_MSG("S_CHARGING=======Stop=========================== %f \n", (chargingInfo[gun_index]->EvBatterytargetVoltage * 10));
-                //    // 板端或後臺要求停止
-                //    ChargingTerminalProcess(gun_index);
-                //}
-
                 // LCM => Charging
                 if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
                     ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_CHARGING;
@@ -6322,9 +6359,13 @@ int main(void)
                     RecordAlarmCode(gun_index, "012235");
                 }
 
-                if (isEvBoardStopChargeFlag(gun_index) == YES) {
+                if ((evBoardStopState = isEvBoardStopChargeFlag(gun_index)) > 0) {
                     // 板端要求停止 (錯誤)
-                    ChargingAlarmProcess(gun_index);
+                    if (evBoardStopState == EV_BOARD_STOP_CHARGING) {
+                        ChargingAlarmProcess(gun_index);
+                    } else if (evBoardStopState == POWER_CABINET_STOP_CHARGING) {
+                        ChargingTerminalProcess(gun_index);
+                    }
                 } else if (isEvBoardNormalStopChargeFlag(gun_index) == YES) {
                     // 板端要求停止 (正常)
                     ChargingTerminalProcess(gun_index);
@@ -6334,11 +6375,6 @@ int main(void)
                     ChargingTerminalProcess(gun_index);
                 }
 
-                //if (isEvBoardStopChargeFlag(gun_index) == YES) {
-                //    // 板端要求停止
-                //    ChargingTerminalProcess(gun_index);
-                //}
-
                 // 等待 EV 小板 (CCS) 通知可以開始 Precharge
                 // 切換 D+ Relay to Precharge Relay
                 if (isPrechargeStatus_ccs(gun_index) == 39 || isPrechargeStatus_ccs(gun_index) == 40) {
@@ -6374,9 +6410,14 @@ int main(void)
                     RecordAlarmCode(gun_index, "012235");
                 }
 
-                if (isEvBoardStopChargeFlag(gun_index) == YES) {
+                if ((evBoardStopState = isEvBoardStopChargeFlag(gun_index)) > 0) {
                     // 板端要求停止 (錯誤)
-                    ChargingAlarmProcess(gun_index);
+                    if (evBoardStopState == EV_BOARD_STOP_CHARGING) {
+                        ChargingAlarmProcess(gun_index);
+                    } else if (evBoardStopState == POWER_CABINET_STOP_CHARGING) {
+                        ChargingTerminalProcess(gun_index);
+                    }
+
                 } else if (isEvBoardNormalStopChargeFlag(gun_index) == YES) {
                     // 板端要求停止 (正常)
                     ChargingTerminalProcess(gun_index);
@@ -6386,11 +6427,6 @@ int main(void)
                     ChargingTerminalProcess(gun_index);
                 }
 
-                //if (isEvBoardStopChargeFlag(gun_index) == YES) {
-                //    // 板端要求停止
-                //    ChargingTerminalProcess(gun_index);
-                //}
-
                 // 等待小板通知進入充電
                 // 切換 D+ Relay to Precharge Relay
                 if (chargingInfo[gun_index]->RelayK1K2Status == YES) {

+ 1 - 0
EVSE/Projects/DD360Audi/Apps/ReModule_EvComm.c

@@ -3338,6 +3338,7 @@ int main(int argc, char *argv[])
                 }
             }
             break;
+            case S_ALARM:
             case S_TERMINATING: {
                 // 設定當前輸出
                 if (gun_count == 1) {

+ 5 - 2
EVSE/Projects/DD360Audi/Apps/ReModule_InternalComm.c

@@ -326,7 +326,7 @@ void GetFwAndHwVersion_Led()
         // SystemInfo
         strcpy((char *) ShmSysConfigAndInfo->SysInfo.LedModuleFwRev, ver.Version_FW);
         //PRINTF_FUNC("GetFwAndHwVersion_Led s1 = %s \n", ver.Version_FW);
-        //ShmLedModuleData->SelfTest_Comp = YES;
+        ShmLedModuleData->SelfTest_Comp = YES;
     } else {
         //PRINTF_FUNC("GetFwAndHwVersion_Led fail \n");
     }
@@ -1166,6 +1166,7 @@ void CheckAcInputOvpStatus(byte index)
 //          }
 //      }
 //      else
+        //DEBUG_INFO("CheckAcInputOvpStatus\r\n");
         _chargingData[index]->StopChargeFlag = YES;
     }
 }
@@ -1175,6 +1176,7 @@ void CheckPhaseLossStatus(byte index)
     if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL1InputUVP == YES ||
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL2InputUVP == YES ||
             ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP == YES) {
+        //DEBUG_INFO("CheckPhaseLossStatus\r\n");
         _chargingData[index]->StopChargeFlag = YES;
     }
 }
@@ -2375,7 +2377,7 @@ int main(void)
     // Open Uart5 for RB
     Uart5Fd = InitComPort();
     Initialization();
-    sleep(3);
+    sleep(1);
 
     if (Uart5Fd < 0) {
         PRINTF_FUNC("(Internal) open port error. \n");
@@ -2392,6 +2394,7 @@ int main(void)
     outputRelay.relay_event.bits.Gun2_P = 0x00;
     if (Config_Relay_Output(Uart5Fd, Addr.Relay, &outputRelay) != PASS) {
         PRINTF_FUNC("Config_Relay_Output fail \n");
+
     }
 
     cur_led_color.Connect_1_Red = COLOR_MIN_LV;

+ 112 - 42
EVSE/Projects/DD360Audi/Apps/ReModule_LcmControl.c

@@ -339,7 +339,7 @@ void ChangeWarningFunc()
     // 最多一次五筆
     //PRINTF_FUNC("LCM PageIndex = %d \n", ShmSysConfigAndInfo->SysWarningInfo.PageIndex);
     //PRINTF_FUNC("WarningCount = %d \n", ShmSysConfigAndInfo->SysWarningInfo.WarningCount);
-#if !defined DD360 && !defined DD360Audi
+//#if !defined DD360 && !defined DD360Audi
     for (i = 0; (i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
         memset(cmd, 0x00, sizeof(cmd));
         if ((i) >= 5) {
@@ -362,48 +362,50 @@ void ChangeWarningFunc()
         DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
         DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
     }
-#else
-    for (i = 0; (i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
-        memset(cmd, 0x00, sizeof(cmd));
-        if ((i - j) >= 5) {
-            break;
-        }
-        if (
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033900", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033901", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033902", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043627", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043628", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043622", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043623", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043624", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043625", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043626", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042241", 6) == 0) ||
-            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042242", 6) == 0)
-        ) {
-            j++;
-            continue;
-        }
-        //error code
-        string2ByteArray(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], cmd);
-        DisplayValueToLcm(0x0010 + ((i - j) * 6), cmd, sizeof(cmd));
-        //警告標示
-        memset(cmd, 0x00, sizeof(cmd));
 
-        cmd[0] = 0x00;
-        cmd[1] = 0x01;
-        DisplayValueToLcm(0x0002 + ((i - j) * 2), cmd, 2);
-    }
+    /*#else
+        for (i = 0; (i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+            memset(cmd, 0x00, sizeof(cmd));
+            if ((i - j) >= 5) {
+                break;
+            }
+            if (
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033900", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033901", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033902", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043627", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043628", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043622", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043623", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043624", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043625", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043626", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042241", 6) == 0) ||
+                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042242", 6) == 0)
+            ) {
+                j++;
+                continue;
+            }
+            //error code
+            string2ByteArray(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], cmd);
+            DisplayValueToLcm(0x0010 + ((i - j) * 6), cmd, sizeof(cmd));
+            //警告標示
+            memset(cmd, 0x00, sizeof(cmd));
+
+            cmd[0] = 0x00;
+            cmd[1] = 0x01;
+            DisplayValueToLcm(0x0002 + ((i - j) * 2), cmd, 2);
+        }
 
-    memset(cmd, 0x00, sizeof(cmd));
-    i = i - j;
-    for (; (i) < 5; i++) {
-        DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
-        DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
-    }
+        memset(cmd, 0x00, sizeof(cmd));
+        i = i - j;
+        for (; (i) < 5; i++) {
+            DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
+            DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
+        }
 
-#endif //!defined DD360 && !defined DD360Audi
+    #endif //!defined DD360 && !defined DD360Audi
+    */
 }
 
 //================================================
@@ -483,7 +485,7 @@ void ChangeQrCode_Idle(char *input)
     }
 
     DisplayValueToLcm(__qr_code, cmd, len + 1);
-#endif defined DD360Audi
+#endif //defined DD360Audi
 }
 
 void ChangeQrCode_Charge(char *input)
@@ -927,9 +929,74 @@ void RefreshConnStatus()
     // Wifi priority is higher than Ethernet
 #if defined DD360 || defined DD360Audi
     uint8_t i = 0;
-    unsigned char flag[4] = {0};
+    uint8_t ehtStatus = 0;
 
     for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+        if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012304", 6) == 0) {
+            ehtStatus = 1;
+            //if (gAudiCustInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
+            //    gAudiCustInfo->EthDevStatus.Ethernet = DEV_ST_ENABLE_NO_USE;
+            //}
+            break;
+        }
+    }
+
+    if (gAudiCustInfo->EthDevStatus.Backend == DEV_ST_DISABLE) {
+        ChangeDisplay2Value(__conn_status, _disappear);
+    } else if (gAudiCustInfo->EthDevStatus.Backend == DEV_ST_ENABLE_USE) {
+        ChangeDisplay2Value(__conn_status, _connect);
+    } else if (gAudiCustInfo->EthDevStatus.Backend == DEV_ST_ENABLE_NO_USE) {
+        ChangeDisplay2Value(__conn_status, _disconnect);
+    }
+
+    if (ehtStatus == 1) {
+        if (gAudiCustInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
+            ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
+        }
+    } else {
+        if (gAudiCustInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
+            ChangeDisplay2Value(__ethernet_status, _eth_connect);
+        }
+        //if (gAudiCustInfo->EthDevStatus.Ethernet == DEV_ST_DISABLE) {
+        //} else if (gAudiCustInfo->EthDevStatus.Ethernet == DEV_ST_ENABLE_USE) {
+        //    ChangeDisplay2Value(__ethernet_status, _eth_connect);
+        //} else if (gAudiCustInfo->EthDevStatus.Ethernet == DEV_ST_ENABLE_NO_USE) {
+        //    ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
+        //}
+    }
+
+    if (gAudiCustInfo->EthDevStatus.Wifi == DEV_ST_DISABLE) {
+        ChangeDisplay2Value(__wifi_status, _disappear);
+
+        ChangeDisplay2Value(__3G4G_status, _disappear);
+        if (gAudiCustInfo->EthDevStatus.FourG == DEV_ST_DISABLE) {
+            ChangeDisplay2Value(__3G4G_move_status, _disappear);
+        } else if (gAudiCustInfo->EthDevStatus.FourG == DEV_ST_ENABLE_USE) {
+            ChangeDisplay2Value(__3G4G_move_status, __3G4G_connect);
+        } else if (gAudiCustInfo->EthDevStatus.FourG == DEV_ST_ENABLE_NO_USE) {
+            ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect);
+        }
+    } else if (gAudiCustInfo->EthDevStatus.Wifi == DEV_ST_ENABLE_USE) {
+        ChangeDisplay2Value(__3G4G_move_status, _disappear);
+        ChangeDisplay2Value(__wifi_status, _wifi_connect);
+    } else if (gAudiCustInfo->EthDevStatus.Wifi == DEV_ST_ENABLE_NO_USE) {
+        ChangeDisplay2Value(__3G4G_move_status, _disappear);
+        ChangeDisplay2Value(__wifi_status, _wifi_disconnect);
+    }
+
+    if (gAudiCustInfo->EthDevStatus.Wifi != DEV_ST_DISABLE) {
+        if (gAudiCustInfo->EthDevStatus.FourG == DEV_ST_DISABLE) {
+            ChangeDisplay2Value(__3G4G_status, _disappear);
+        } else if (gAudiCustInfo->EthDevStatus.FourG == DEV_ST_ENABLE_USE) {
+            ChangeDisplay2Value(__3G4G_status, __3G4G_connect);
+        } else if (gAudiCustInfo->EthDevStatus.FourG == DEV_ST_ENABLE_NO_USE) {
+            ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect);
+        }
+    }
+
+    //unsigned char flag[4] = {0};
+
+    /*for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
         //printf("status code = %s\r\n", &ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0]);
         if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], "012304", 6) == 0) {
             flag[0] = 1;
@@ -966,6 +1033,7 @@ void RefreshConnStatus()
         }
     }
 
+
     if (flag[0] == 1) {
         ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
     } else {
@@ -1010,6 +1078,7 @@ void RefreshConnStatus()
             ChangeDisplay2Value(__3G4G_status, __3G4G_connect);
         }
     }
+    */
 #else
 // eth
     if (ShmSysConfigAndInfo->SysInfo.ethInternetConn == YES) {
@@ -1911,6 +1980,7 @@ int main(void)
     acgunCount = ShmSysConfigAndInfo->SysConfig.AcConnectorCount;
     Initialization();
 
+    //printf("_LCM_COMPLETE \r\n");
     //ChangeToOtherPage(_LCM_COMPLETE);
     //return 0;
 

+ 14 - 3
EVSE/Projects/DD360Audi/Apps/ReModule_PrimaryComm.c

@@ -285,8 +285,18 @@ void GetInputGpioStatus()
         //ShmSysConfigAndInfo->SysInfo.AcContactorStatus = ShmPrimaryMcuData->InputDet.bits.AcContactorDetec = gpio_in.AC_Connector;
         //ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec = gpio_in.AC_MainBreaker;
 #else
-        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning = ~gpio_in.AC_Connector;
-        ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsLiquidChillerWaterLevelFault = ~gpio_in.AC_MainBreaker;
+        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)
+
+           ) {
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning = ~gpio_in.AC_Connector;
+            ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsLiquidChillerWaterLevelFault = ~gpio_in.AC_MainBreaker;
+        } else {
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning = gpio_in.AC_Connector;
+            ShmStatusCodeData->FaultCode.FaultEvents.bits.CcsLiquidChillerWaterLevelFault = gpio_in.AC_MainBreaker;
+        }
 #endif //!defined DD360 && !defined DD360Audi
 
         ShmPrimaryMcuData->InputDet.bits.SpdDetec = gpio_in.SPD;
@@ -300,6 +310,7 @@ void GetInputGpioStatus()
 #else
         ShmPrimaryMcuData->InputDet.bits.DoorOpen = gpio_in.Door_Open;
 #endif //defined DD360 ||defined DD360Audi
+
         ShmPrimaryMcuData->InputDet.bits.Button1 = gpio_in.Button[0];
         ShmPrimaryMcuData->InputDet.bits.Button2 = gpio_in.Button[1];
         ShmPrimaryMcuData->InputDet.bits.EmergencyButton = gpio_in.Emergency_Btn;
@@ -618,7 +629,7 @@ int main(void)
 #endif //defined METER_ENABLE
         }
 
-        usleep(100000);
+        usleep(50000);
     }
 
     return FAIL;

File diff suppressed because it is too large
+ 590 - 475
EVSE/Projects/DD360Audi/Apps/ReadCmdline.c


BIN
EVSE/Projects/DD360Audi/Apps/UnsafetyOutputTask


+ 0 - 5678
EVSE/Projects/DD360Audi/Apps/define.h

@@ -1,5678 +0,0 @@
-#ifndef	DEFINE_H_
-#define	DEFINE_H_
-
-/**************************************************************************************/
-/*********************************NAND Flash mapping *****************************/
-/**************************************************************************************/
-/*
-  sector size	512 KiB
-  Page size       4096 b
-  OOB size        224 b
-  Erase size    	524288 b
--------------------------------------------------------------------------------------------------------------------------------
-Segment 					Physical address 			Size
--------------------------------------------------------------------------------------------------------------------------------
-MLO								0x00000000-0x0007FFFF		512 KB
-Primary u-boot 					0x00080000-0x0017FFFF		1 MB
-Environment 					0x00180000-0x001FFFFF		512 KB
-Secondary u-boot	 			0x00200000-0x002FFFFF		1 MB
-Primary dtb						0x00300000-0x0037FFFF		512 KB
-Secondary dtb					0x00380000-0x003FFFFF		512 KB
-Primary kernel					0x00400000-0x00DFFFFF		10 MB
-Secondary Kernel 				0x00E00000-0x017FFFFF		10 MB
-Primary root file system		0x03000000-0x05FFFFFF		48 MB
-Secondary root file system		0x06000000-0x08FFFFFF		48 MB
-Primary user configuration 		0x09000000-0x095FFFFF		6 MB
-Secondary user configuration	0x09600000-0x09BFFFFF		6 MB
-Factory default configuration	0x09C00000-0x0A1FFFFF		6 MB
-Storage							0x0A200000-0x7FFFFFFF		1886 MB
-*/
-
-/**************************************************************************************/
-/*********************************System Limitation**********************************/
-/**************************************************************************************/
-/*Rating outout power and current*/
-#define RATED_POWER			25		//kW
-#define RATED_CURRENT			350		//Amp, it depend on the capacity of charging connector
-
-/*relevant to Quantity */
-#ifdef AWRegular
-    #define MAX_PSU_QUANTITY        62
-    #define CHAdeMO_QUANTITY        1
-    #define CCS_QUANTITY            1
-    #define GB_QUANTITY             0
-    #define AC_QUANTITY             1
-    #define GENERAL_GUN_QUANTITY    0
-    #define PSU_QUANTITY            2
-    #define ONE_CONNECTOR_USE       0
-#elif BYTONGB
-	#define MAX_PSU_QUANTITY        62
-	#define CHAdeMO_QUANTITY        1
-	#define CCS_QUANTITY            1
-	#define GB_QUANTITY             0
-	#define AC_QUANTITY             1
-    #define GENERAL_GUN_QUANTITY	0
-	#define PSU_QUANTITY            2
-	#define ONE_CONNECTOR_USE       0
-#elif DW30
-	#define MAX_PSU_QUANTITY        62
-	#define CHAdeMO_QUANTITY        0
-	#define CCS_QUANTITY            1
-	#define GB_QUANTITY             0
-	#define AC_QUANTITY             0
-    #define GENERAL_GUN_QUANTITY	0
-	#define PSU_QUANTITY            2
-	#define ONE_CONNECTOR_USE       0
-#elif DM30
-	#define MAX_PSU_QUANTITY        62
-	#define CHAdeMO_QUANTITY        0
-	#define CCS_QUANTITY            1
-	#define GB_QUANTITY             0
-	#define AC_QUANTITY             0
-    #define GENERAL_GUN_QUANTITY	0
-	#define PSU_QUANTITY            2
-	#define ONE_CONNECTOR_USE       0
-#elif DS60120
-	#define MAX_PSU_QUANTITY        62
-	#define CHAdeMO_QUANTITY        2
-	#define CCS_QUANTITY            2
-	#define GB_QUANTITY             2
-	#define AC_QUANTITY             1
-    #define GENERAL_GUN_QUANTITY	0
-	#define PSU_QUANTITY            2
-	#define ONE_CONNECTOR_USE       0
-#elif DS60210
-	#define MAX_PSU_QUANTITY        62
-	#define CHAdeMO_QUANTITY        1
-	#define CCS_QUANTITY            1
-	#define GB_QUANTITY             0
-	#define AC_QUANTITY             0
-    #define GENERAL_GUN_QUANTITY	0
-	#define PSU_QUANTITY            2
-	#define ONE_CONNECTOR_USE       0
-#elif PlugIt360
-    #define MAX_PSU_QUANTITY        62
-    #define CHAdeMO_QUANTITY        0
-    #define CCS_QUANTITY            1
-    #define GB_QUANTITY             0
-    #define AC_QUANTITY             0
-    #define GENERAL_GUN_QUANTITY	0
-    #define PSU_QUANTITY            2
-    #define ONE_CONNECTOR_USE       0
-#elif DD360
-    #define MAX_PSU_QUANTITY        62
-    #define CHAdeMO_QUANTITY        2
-    #define CCS_QUANTITY            2
-    #define GB_QUANTITY             2
-    #define AC_QUANTITY             0
-    #define GENERAL_GUN_QUANTITY	0
-    #define PSU_QUANTITY            12
-    #define ONE_CONNECTOR_USE       0
-#elif DO360
-    #define MAX_PSU_QUANTITY        62
-    #define CHAdeMO_QUANTITY        0
-    #define CCS_QUANTITY            0
-    #define GB_QUANTITY             0
-    #define AC_QUANTITY             0
-    #define GENERAL_GUN_QUANTITY    4
-    #define PSU_QUANTITY            6
-    #define ONE_CONNECTOR_USE       0
-#elif ATE
-    #define MAX_PSU_QUANTITY        62
-    #define CHAdeMO_QUANTITY        0
-    #define CCS_QUANTITY            1
-    #define GB_QUANTITY             0
-    #define AC_QUANTITY             0
-    #define GENERAL_GUN_QUANTITY	0
-    #define PSU_QUANTITY            2
-    #define ONE_CONNECTOR_USE       0
-#else
-    #define MAX_PSU_QUANTITY        62
-    #define CHAdeMO_QUANTITY        2
-    #define CCS_QUANTITY            2
-    #define GB_QUANTITY             2
-    #define AC_QUANTITY             1
-    #define GENERAL_GUN_QUANTITY    0
-    #define PSU_QUANTITY            2
-    #define ONE_CONNECTOR_USE       0
-#endif
-
-#define CONNECTOR_QUANTITY			(CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY + AC_QUANTITY + GENERAL_GUN_QUANTITY)
-
-/*SystemLog message*/
-#define SystemLogMessage			//for debug info save to log file
-//#define ConsloePrintLog				//for debug info print to console
-
-/**************************************************************************************/
-/*****************************share memory key information*****************************/
-/**************************************************************************************/
-#define ShmSysConfigAndInfoKey	1001
-#define ShmPsuKey				1002
-#define ShmCHAdeMOCommKey		1003
-#define ShmCcsCommKey			1004
-#define ShmStatusCodeKey		1005
-#define ShmPrimaryMcuKey		1006
-#define ShmFanBdKey				1007
-#define ShmRelayBdKey			1008
-#define ShmOcppModuleKey		1009
-#define ShmGBTCommKey			1010
-#define ShmLedBdKey				1011
-#define ShmOcpp20ModuleKey		1012
-#define ShmRelay2BdKey			1013
-
-/**************************************************************************************/
-/****************** Share memory configuration value constant define ******************/
-/**************************************************************************************/
-enum SYSTEM_STATUS
-{
-	SYS_MODE_BOOTING		= 0,
-	SYS_MODE_IDLE    	  	= 1,
-	SYS_MODE_AUTHORIZING		= 2,
-	SYS_MODE_MODE_REASSIGN_CHECK	= 3,
-	SYS_MODE_REASSIGN		= 4,
-	SYS_MODE_PREPARING		= 5,
-	SYS_MODE_PREPARE_FOR_EV		= 6,
-	SYS_MODE_PREPARE_FOR_EVSE	= 7,
-	SYS_MODE_CHARGING		= 8,
-	SYS_MODE_TERMINATING		= 9,
-	SYS_MODE_COMPLETE		= 10,
-	SYS_MODE_ALARM			= 11,
-	SYS_MODE_FAULT			= 12,
-	SYS_MODE_RESERVATION		= 13,
-	SYS_MODE_BOOKING		= 14,
-	SYS_MODE_MAINTAIN		= 15,
-	SYS_MODE_DEBUG			= 16,
-	SYS_MODE_CCS_PRECHARGE_STEP0	= 17,
-	SYS_MODE_CCS_PRECHARGE_STEP1	= 18,
-	SYS_MODE_UPDATE			= 19
-};
-
-enum AUTHORIZATION_MODE
-{
-	AUTH_MODE_ENABLE		= 0,
-	AUTH_MODE_DISABLE		= 1
-};
-
-enum LCD_LANGUAGE
-{
-	LCD_LANG_ENGLISH		= 0,
-	LCD_LANG_CHT			= 1,
-	LCD_LANG_CHS			= 2,
-	LCD_LANG_JAPANESE		= 3,
-	LCD_LANG_FRENCH			= 4,
-	LCD_LANG_ITALIAN		= 5,
-	LCD_LANG_SPANISH		= 6,
-	LCD_LANG_GERMAN			= 7,
-	LCD_LANG_DUTCH			= 8,
-	LCD_LANG_NORWEGIAN		= 9,
-	LCD_LANG_FINNISH		= 10,
-	LCD_LANG_SWEDISH		= 11,
-	LCD_LANG_SLOVENIAN		= 12,
-	LCD_LANG_THAI			= 13,
-};
-
-
-enum RFID_ENDIAN
-{
-	RFID_ENDIAN_LITTLE		= 0,
-	RFID_ENDIAN_BIG			= 1
-};
-
-enum PHASE_LOSS_POLICY
-{
-	LOSS_POLICY_CHARGING		= 0,
-	LOSS_POLICY_STOP		= 1
-};
-
-enum CCS_AUTHPRIZATION_MODE
-{
-	CCS_AUTH_MODE_EIM		= 0,
-	CCS_AUTH_MODE_MIXED		= 1
-};
-
-enum OFF_LINE_POLICY
-{
-	OFF_POLICY_LOCALLIST		= 0,
-	OFF_POLICY_PH_RFID		= 1,
-	OFF_POLICY_FREE			= 2,
-	OFF_POLICY_NOCHARGE		= 3
-};
-
-/*Configuration enum*/
-enum CoreProfile {
-	 AllowOfflineTxForUnknownId=0,
-	 AuthorizationCacheEnabled,
-	 AuthorizeRemoteTxRequests,
-	 BlinkRepeat,
-	 ClockAlignedDataInterval,
-	 ConnectionTimeOut,
-	 GetConfigurationMaxKeys,
-	 HeartbeatInterval,
-	 LightIntensity,
-	 LocalAuthorizeOffline,
-	 LocalPreAuthorize,
-	 MaxEnergyOnInvalidId,
-	 MeterValuesAlignedData,
-	 MeterValuesAlignedDataMaxLength,
-	 MeterValuesSampledData,
-	 MeterValuesSampledDataMaxLength,
-	 MeterValueSampleInterval,
-	 MinimumStatusDuration,
-	 NumberOfConnectors,
-	 ResetRetries,
-	 ConnectorPhaseRotation,
-	 ConnectorPhaseRotationMaxLength,
-	 StopTransactionOnEVSideDisconnect,
-	 StopTransactionOnInvalidId,
-	 StopTxnAlignedData,
-	 StopTxnAlignedDataMaxLength,
-	 StopTxnSampledData,
-	 StopTxnSampledDataMaxLength,
-	 SupportedFeatureProfiles,
-	 SupportedFeatureProfilesMaxLength,
-	 TransactionMessageAttempts,
-	 TransactionMessageRetryInterval,
-	 UnlockConnectorOnEVSideDisconnect,
-	 WebSocketPingInterval,
-	 QueueOffLineStartTransactionMessage,
-	 AuthorizationKey,
-	 SecurityProfile,
-     DefaultPrice,
-     CustomDisplayCostAndPrice,
-     CustomIdleFeeAfterStop,
-	 _CoreProfile_CNT
-};
-
-/**************************************************************************************/
-/****structure SysConfigData => shall store the data to NAND flash****************/
-/****structure SysInfoData => shall NOT store the data to NAND flash***************/
-/****according to System Configuration and Information Table.xlsx Rev.0.2 *******/
-/**************************************************************************************/
-struct NoneUse
-{
-	unsigned char		unknown;					// None use struct
-};
-
-struct EthConfigData
-{
-	unsigned char		EthDhcpClient;				//0: enable,1: disable
-	unsigned char		EthMacAddress[18];			//default: Null
-	unsigned char		EthIpAddress[16];			//Eth0 default:192.168.0.10	,Eth1 default:192.168.1.10
-	unsigned char		EthSubmaskAddress[16];		//Eth0 default:255.255.255.0	,Eth1 default:255.255.255.0
-	unsigned char		EthGatewayAddress[16];		//Eth0 default:192.168.0.254	,Eth1 default:192.168.1.254
-};
-
-struct WifiConfigData
-{
-	unsigned char		WifiMode;					//0: disable, 1: Infrastructure client, 2: Infrastructure server, 3: Ad-Hoc
-	unsigned char		WifiSsid[256];				//default: Null
-	unsigned char		WifiPassword[256];			//default: Null
-	int					WifiRssi;					//dbm
-	unsigned char		WifiDhcpServer;				//0: enable, 1: disable
-	unsigned char		WifiDhcpClient;				//0: enable, 1: disable
-	unsigned char		WifiMacAddress[18];			//default: Null
-	unsigned char		WifiIpAddress[16];			//default:192.168.2.10
-	unsigned char		WifiSubmaskAddress[16];		//default:255.255.255.0
-	unsigned char		WifiGatewayAddress[16];		//default:192.168.2.254
-	unsigned char		WifiNetworkConn;			//0: disconnected, 1: connected
-};
-
-struct TeleConfigData
-{
-	unsigned char		TelcomModelName[64];		//default: Null
-	unsigned char		TelcomSoftwareVer[64];		//default: Null
-	unsigned char		TelcomApn[256];				//default: Null
-	int					TelcomRssi;					//dbm
-	unsigned char		TelcomChapPapId[256];		//default: Null
-	unsigned char		TelcomChapPapPwd[256];		//default: Null
-	unsigned char		TelcomModemImei[16];		//default: Null
-	unsigned char		TelcomSimImsi[16];			//default: Null
-	unsigned char		TelcomSimIccid[22];			//default: Null
-	unsigned char		TelcomSimStatus;			//0: no SIM card is found, 1: valid SIM card, 2: invalid SIM card
-	unsigned char		TelcomModemMode;			//0: No services, 1: CDMA, 2: GSM/GPRS, 3: WCDMA, 4: GSM/WCDMA, 5: TD_SCDMA mode, 6: Unknow
-	unsigned char		TelcomIpAddress[16];		//default: Null
-	unsigned char		TelcomNetworkConn;			//0: disconnected, 1: connected
-	unsigned char		TelcomEnabled;				//0: disable, 1: enable
-};
-
-struct BtConfigData
-{
-	unsigned char		LoginCentralID[64];			//default: Null
-	unsigned char		isLogin;					//0: Central device non-login	1: Central device login
-	unsigned char		isRequestStart;				//0: no action	1: request start charging
-	unsigned char		isRequestStop;				//0: no action	1: request stop charging
-};
-
-struct BillingConfigData
-{
-	unsigned char		isBilling;					//0:not for business	1:for business
-	unsigned char		Currency;					//
-	float				Fee[24];					//fee for 24 hours
-	float 				Cur_fee;					// display current fee
-};
-
-struct LED
-{
-	unsigned char 			Intensity;					// LED bar intensity	0: Darkest	1: Medium	2: Brightest
-
-	unsigned char			Red[3];						// Red color	0~100, element 0: IDLE		1: CHARGING		2: FAULT
-	unsigned char			Green[3];					// Green color	0~100, element 0: IDLE		1: CHARGING		2: FAULT
-	unsigned char			Blue[3];					// Blue color	0~100, element 0: IDLE		1: CHARGING		2: FAULT
-};
-
-struct Schedule
-{
-	unsigned char   isEnable;     						// 0: disable schedule function  1: enable schedule function
-	unsigned char   scheduleType;    					// 0: Once   1: Daily
-	unsigned char   scheduleMethod;    					// 0: Continuous 1: Specificate end time
-	unsigned char   startTimeHour;    					// Schedule start trigger time hour
-	unsigned char   startTimeMinute;   					// Schedule start trigger time minute
-	unsigned char   stopTimeHour;    					// Schedule stop trigger time hour
-	unsigned char   stopTimeMinute;    					// Schedule stop trigger time minute
-	unsigned char   isTriggerStart;    					// 0: disable; 1: enable
-	unsigned char   isTriggerStop;    					// 0: disable; 1: enable
-};
-
-struct SysConfigData
-{
-	/**************System***************/
-	unsigned char 			CsuBootLoadFwRev[32];			//CSU board bootloader firmware version
-	unsigned char			ModelName[64];				//charger model name
-	unsigned char			AcModelName[64];			//for third gun (DC + AC)
-	unsigned char			SerialNumber[64];			//charger system serial number
-	unsigned char			SystemId[128];				//charger system ID
-	unsigned char			SystemDateTime[32];			//charger system date and time
-	unsigned char			AcPhaseCount;				//AC EVSE power phase quantity,  1: One phase	3: Three phase
-	unsigned char			AuthorisationMode;			//0: enable, 1: disable
-	unsigned char			DefaultLanguage;			//
-	unsigned char			RfidCardNumEndian;			//0: little endian,  1: big endian
-	unsigned short			AcPlugInTimes;				//0~65535
-	unsigned short			GbPlugInTimes;				//0~65535
-	unsigned short			Ccs1PlugInTime;				//0~65535
-	unsigned short			Ccs2PlugInTimes;			//0~65535
-	unsigned short			ChademoPlugInTimes;			//0~65535
-	unsigned char			PsuAcInputType;				//0: 220, 1: 277
-	unsigned short			RatingCurrent;				//0: Depend on Model name,	1 ~ rating value amp
-	unsigned short			AcRatingCurrent;			//for third gun; 0: Depend on Model name,	1 ~ rating value amp
-	unsigned char			isAPP;						//for AuthorisationMode=0; 0:false, 1:true
-	unsigned char			isQRCode;					//for AuthorisationMode=0; 0:false, 1:true
-	unsigned char			isRFID;						//for AuthorisationMode=0; 0:false, 1:true
-	unsigned char			QRCodeMadeMode;				//for isQRCode=1 ; 0: default	1:customized
-	unsigned char			QRCodeContent[128];			//for QRCodeMadeMode=1
-	unsigned char			TotalConnectorCount;		//Connector count
-	unsigned char 			AcConnectorCount;			// For DC type
-	unsigned char			SwitchDebugFlag;			// Console Debug
-	unsigned char			AlwaysGfdFlag;
-	/**************Charging***************/
-	unsigned short			MaxChargingEnergy;			//0: no limit,	1 ~ 65535	kWh
-	unsigned short			MaxChargingPower;			//0: rating value, 1 ~ RATING_POWER	kW
-	unsigned short			MaxChargingCurrent;			//0: rating value, 1 ~ RATING_CURRENT	amp
-	unsigned short			AcMaxChargingCurrent;		//for third gun; 0: rating value, 1 ~ RATING_CURRENT	amp
-	unsigned short			MaxChargingDuration;		//0: no limit,	1 ~ 65535	minutes
-	unsigned char			PhaseLossPolicy;			//0: charging,  1: stop charging
-	unsigned char			LocalWhiteCard[10][32];		//Max. card quantity is 10
-	unsigned char			UserId[32];					//the user use this ID to trigger charging event, it can be RFID card number, OCPP IdTag, etc.
-	struct BillingConfigData BillingData;
-	/**************Network***************/
-	unsigned char 			FtpServer[256];				//the ftp server for Phihong server to do data transimission
-	struct EthConfigData	Eth0Interface;
-	struct EthConfigData	Eth1Interface;
-	struct WifiConfigData 	AthInterface;
-	struct TeleConfigData	TelecomInterface;
-	struct BtConfigData		Bluetooth;
-	/**************Backend***************/
-	unsigned int 			BackendConnTimeout;			//default : 300s
-	unsigned char   		OfflinePolicy;				//0: local list, 1: Phihong RFID tag, 2: free charging, 3: no charging
-	unsigned short	   		OfflineMaxChargeEnergy;		//0: same as MaxChargingEnergy, 1 ~ 65535 kWh
-	unsigned short	   		OfflineMaxChargeDuration;	//0: same as MaxChargeDuration, 1 ~ 65535 minutes
-	unsigned char 			OcppServerURL[512];			//http: non-secure OCPP 1.5-S, https: secure OCPP 1.5-S, ws: non-secure OCPP 1.6-J, wss: secure OCPP 1.6-J"
-	unsigned char 			ChargeBoxId[128];
-	unsigned char			chargePointVendor[20];		//the Vendor of the ChargePoint
-	unsigned int 			Checksum;					//4 bytes checksum
-	struct LED				LedInfo;					// LED configuration info
-	unsigned char			ShowInformation;
-};
-
-struct ChargingInfoData
-{
-	unsigned char 		Index;
-	unsigned char 		slotsIndex;
-	unsigned char 		Type;					// 0 : Chademo, 1 : CCS, 2: GB
-	unsigned char 		type_index;
-	unsigned char 		Evboard_id;				// for EV board
-	unsigned char 		StopChargeFlag;			// for EV board
-	unsigned char		SystemStatus;				//0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault
-	unsigned char		PreviousSystemStatus;		// 0: Booting, 1: idle, 2: authorizing, 3: preparing, 4: charging, 5: terminating, 6: alarm, 7: fault	
-	int 			ReservationId;
-	unsigned char 		IsAvailable;
-	float MaximumChargingVoltage;	// unit 0.1V
-	float AvailableChargingCurrent;	// unit 0.1A
-	float AvailableChargingPower;	// unit .01kW
-	float DividChargingCurrent;		//0~6553.5 amp
-	float DeratingChargingCurrent;  //0~6553.5 amp
-	float DeratingChargingPower;	//0~6553.5 kW
-	float FuseChargingVoltage;		//0~6553.5 volt
-	float FireChargingVoltage;		//0~6553.5 volt
-	float PresentChargingVoltage;	//0~6553.5 volt
-	float PresentChargingCurrent;		//0~6553.5 amp
-	float PresentChargingPower;		//0~6553.5 kW
-	float PresentChargedEnergy;		//0~6553.5 kWh
-	int PresentChargedDuration;	// second
-	int RemainChargingDuration;	// second
-	float EvBatteryMaxVoltage;		// 0~6553.5 volt
-	float EvBatterytargetVoltage;		// 0~6553.5 volt
-	float EvBatterytargetCurrent; 	//102.3				0~200(A) (unit:1A)
-	int EvBatterySoc;				// 0~100%
-	unsigned char ConnectorPlugIn;			//0: unplug, 1: Plug-in
-	unsigned char GunLocked;				//0: unlocked 1: locked
-	float PilotVoltage;
-	unsigned char PilotState;//1:state A, 2:State B1, 3:State B2, 4:State C, 5:State D, 6:State E, 7:State F, 8: Pilot error
-	unsigned char PilotDuty;					// 0~100%
-	unsigned char			StartUserId[32];			// This ID is trigger start charging event user by RFID?|ack-end?。LE.
-	unsigned char			StartDateTime[32];			// Charging cycle start date time
-	unsigned char			StopDateTime[32];			// Charging cycle stop date time
-	unsigned char			StartMethod;
-	float					ChargingFee;
-	// Connector Temp
-	unsigned char 		ConnectorTemp;			//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;
-	unsigned char 		RelayWeldingCheck;		// 0 : No Comp., 1 : Comp.
-	unsigned char 		PrechargeStatus;		// for ccs precharge => 0x00 : None defined, 0x01 : Accepted
-	float 				PowerConsumption;		// This contains the meter value (Power Consumption) kWh
-	unsigned char		RelayK1K2Status;		// 0x00 : open, 0x01 : close
-	unsigned char		RelayKPK2Status;		// 0x00 : open, 0x01 : close
-	unsigned char 	 	TimeoutFlag;			// 0 : none,
-	struct timeval		TimeoutTimer;
-	unsigned char 		MaxChargeEnable;
-	unsigned char		IsReadyToCharging;
-	unsigned char		CcsAuthentication;				// 0:EIM, 1:EIM & PnC mixed
-	unsigned char		AcCcsChargingMode;				// 0:BC (PWM) only, 1:BC & PLC mixed
-	unsigned short		SampleChargingCur[10];
-
-	/**************Alston for AC***************/
-	unsigned char 		SelfTest_Comp;
-	unsigned char		version[16];
-	unsigned char 		IsModeChagned;
-	unsigned char 		IsCharging;
-	unsigned char 		IsErrorOccur;
-	float 				RealMaxVoltage;
-	float				RealMaxCurrent;
-	float 				RealMaxPower;
-	unsigned char 		ConnectorWarningCode[7];
-	unsigned char 		ConnectorAlarmCode[7];
-	unsigned char 		EvConnAlarmCode[7];
-	float 				ChargingProfileCurrent;			//0~6553.5 amp
-	float 				ChargingProfilePower;			//0~6553.5 kW
-	float 				PresentChargingVoltageL2;		//0~6553.5 volt
-	float 				PresentChargingVoltageL3;		//0~6553.5 volt
-	float 				PresentChargingCurrentL2;		//0~6553.5 amp	
-	float 				PresentChargingCurrentL3;		//0~6553.5 amp
-	char 				RemoteStartFlag;
-	unsigned char 		MaxChargingToAverPassFlag;
-	unsigned char		EVCCID[18];						//the MAC address of the EVCC in Hex
-	unsigned char 		isRemoteStart;
-	struct Schedule		schedule;						// Schedule
-	int 				EvBatteryStartSoc;				// 0~100%
-	unsigned char 		UnKnowStopChargeFlag;			// for EV board
-};
-
-typedef union
-{
-    unsigned int SettingValue;
-    struct
-    {
-        unsigned int AuthorizeRequest:1;        // 0: idle, 1: requesting
-        unsigned int res:31;
-    }bits;
-}DispenserSettingFlag;
-
-struct DispenserModule
-{
-    unsigned char   LocalStatus;                // 0: None, 1: Identification, 2: Idle, 3: Alarm, 4: Charging, 5: _DS_Timeout
-    unsigned char   ConnectorQuantity;          //Connector count
-    unsigned char   ConnectorID[2];             //Available Connector ID: 1 ~ 4
-    unsigned char   UserId[32];                 //the user use this ID to trigger charging event, it can be RFID card number, OCPP IdTag, etc.
-    unsigned char   ModelName[64];              //charger model name
-    unsigned char   SerialNumber[64];           //charger system serial number
-    unsigned char   SystemId[128];              //charger system ID
-    unsigned char   AuthorisationMode;          //0: enable, 1: disable
-    unsigned char   RfidCardNumEndian;          //0: little endian,  1: big endian
-    unsigned char   isAPP;                      //for AuthorisationMode=0; 0:false, 1:true
-    unsigned char   isQRCode;                   //for AuthorisationMode=0; 0:false, 1:true
-    unsigned char   isRFID;                     //for AuthorisationMode=0; 0:false, 1:true
-    unsigned char   QRCodeMadeMode;             //for isQRCode=1 ; 0: default	1:customized
-    unsigned char   QRCodeContent[128];         //for QRCodeMadeMode=1
-
-    unsigned char   FactoryConfiguration;       //0: normal, 1: trigger, charger will return the configuration to factory default if trigger
-    unsigned char   CsuBootLoadFwRev[32];       //CSU board bootloader firmware version
-    unsigned char   CsuKernelFwRev[32];         //CSU board OS kernel firmware version
-    unsigned char   CsuRootFsFwRev[32];         //CSU board root file system firmware version
-    unsigned char   CsuPrimFwRev[32];           //CSU board root file system firmware version
-    unsigned char   LcmFwRev[32];               //LCM module firmware version
-    unsigned char   PsuPrimFwRev[32];           //PSU primary firmware version
-    unsigned char   PsuSecFwRev[32];            //PSU secondary firmware version
-    unsigned char   FanModuleFwRev[32];         //Fan  module firmware version
-    unsigned char   RelayModuleFwRev[32];       //Relay control  module firmware version
-    unsigned char   TelcomModemFwRev[32];       //the 3G/4G modem firmware version
-    unsigned char   LedModuleFwRev[32];         //LED control module firmware version
-    unsigned char   Connector1FwRev[32];        //Connector1 module firmware version
-    unsigned char   Connector2FwRev[32];        //Connector2 module firmware version
-    struct   LED    LedInfo;                    // LED configuration info
-
-                                                // 0: Authorize idle, 1: Authorize wait,   2: Authorizing
-    unsigned char           AuthorizeStatus;    // 3: Authorize ok,   4: Authorizing fail
-    DispenserSettingFlag    Setting;
-};
-
-struct ConnectionInfoData
-{
-    unsigned char Status;                       // 0: free, 1: WaitModelName, 2: DispenserMatched
-    unsigned char DispenserIndex;
-    unsigned int  IpAddress;
-};
-
-struct DispenserInfoData
-{
-    unsigned char               DispenserQuantity;
-    unsigned char               TotalConnectorQuantity;
-    struct DispenserModule      Dispenser[GENERAL_GUN_QUANTITY];
-
-    union
-    {
-        unsigned char Status;
-        struct
-        {
-            unsigned char Dispenser1:1;             // 1: ever checkin, 0: never checkin
-            unsigned char Dispenser2:1;             // 1: ever checkin, 0: never checkin
-            unsigned char Dispenser3:1;             // 1: ever checkin, 0: never checkin
-            unsigned char Dispenser4:1;             // 1: ever checkin, 0: never checkin
-            unsigned char Dispenser5:1;             // 1: ever checkin, 0: never checkin
-            unsigned char Dispenser6:1;             // 1: ever checkin, 0: never checkin
-            unsigned char Dispenser7:1;             // 1: ever checkin, 0: never checkin
-            unsigned char Dispenser8:1;             // 1: ever checkin, 0: never checkin
-        }Flag;
-    }CheckInLog;                                                        // record dispenser checkin status
-    unsigned char               ConnectorLog[GENERAL_GUN_QUANTITY];     // record connector quantity of dispenser
-    struct ConnectionInfoData   ConnectionInfo[GENERAL_GUN_QUANTITY];
-};
-
-struct WARNING_CODE_INFO
-{
-    unsigned char WarningCount;
-    unsigned char PageIndex;
-    unsigned char WarningCode[10][7];
-    unsigned char Level;
-    unsigned char ExtraErrProcess;                      // 0 : none, 1 : input uvp..
-};
-
-typedef union
-{
-    unsigned int Value;
-    struct
-    {
-        unsigned int  AuthorizeRequestType:4;           // 0: not authorize, 1: local authorized, 2: remote start authorized
-        unsigned int  PermissionRequest:1;              // 0: no request,    1: dispenser request to charging
-        unsigned int  RemoteStartRequest:1;             // 0: no request,    1: remote start
-        unsigned int  RemoteStopRequest:1;              // 0: no request,    1: remote stop
-        unsigned int  res:25;
-    }bits;
-}ConnectorParameter;
-
-struct ConnectorInfoData
-{
-    unsigned char RemoteStatus;                         // 0: Idle, 1: Preparing, 2: Charging, 3: Terminating
-    unsigned char Enable;                               // 0: Disable, 1: Enable
-    unsigned char ReadyToCharge;                        // 0: Not Ready, 1: Ready to Charge
-    unsigned char ParentDispensetIndex;                 // Parent Dispenser Index: 0 ~ 3
-    ConnectorParameter       Parameter;
-                                                        // 0: Authorize idle, 1: Authorize wait,   2: Authorizing
-    unsigned char            AuthorizeStatus;           // 3: Authorize ok,   4: Authorizing fail
-    struct ChargingInfoData  GeneralChargingData;
-    struct WARNING_CODE_INFO WarningInfo;
-};
-
-typedef union
-{
-    unsigned int SettingValue;
-    struct
-    {
-        unsigned int StartAuthorize:1;          // 0: idle,    1: authorizing
-        unsigned int AuthorizingCompleted:1;    // 0: not yet, 1: authorizing completed
-        unsigned int AuthorizeTargetIndex:4;    // dispenser or connector index from 0 ~ 3
-        unsigned int AuthorizeSrc:4;            // 0: not authorize, 1: local authorize, 2: remote authorize
-        unsigned int res:22;
-    }bits;
-}CabinetSettingFlag;
-
-struct SysInfoData
-{
-	/**************System***************/
-	unsigned char BootingStatus;			// 0 : booting, 1 : Initializing Complete.
-	unsigned char AuthorizeFlag;			// 0 : None, 1 : Authorizing
-	unsigned char FactoryConfiguration;	//0: normal, 1: trigger, charger will return the configuration to factory default if trigger
-	float InputVoltageR;			//0~655.35 volt
-	float InputVoltageS;				//0~655.35 volt
-	float InputVoltageT;				//0~655.35 volt
-	unsigned int SystemFanRotaSpeed;		//0 ~ 65535 RPM
-	unsigned int PsuFanRotaSpeed;			//0 ~ 65535 RPM
-	unsigned char AuxPower5V;				//0 ~ 255 volt
-	unsigned char AuxPower12V;				//0 ~ 255 volt
-	unsigned char AuxPower24V;				//0 ~ 255 volt
-	unsigned char AuxPower48V;				//0 ~ 255 volt
-	unsigned char CsuHwRev[32];			//CSU board hardware version
-	unsigned char CsuBootLoadFwRev[32];	//CSU board bootloader firmware version
-	unsigned char CsuKernelFwRev[32];//CSU board OS kernel firmware version
-	unsigned char CsuRootFsFwRev[32];//CSU board root file system firmware version
-	unsigned char CsuPrimFwRev[32];	//CSU board root file system firmware version
-	unsigned char LcmHwRev[32];	//LCM module hardware version
-	unsigned char LcmFwRev[32];	//LCM module firmware version
-	unsigned char PsuHwRev[32];		//PSU hardware version
-	unsigned char PsuPrimFwRev[32];		//PSU primary firmware version
-	unsigned char PsuSecFwRev[32];			//PSU secondary firmware version
-	unsigned char AuxPwrHwRev[32];		//Aux. power module hardware version
-	unsigned char AuxPwrFwRev[32];		//Aux. power module firmware version
-	unsigned char FanModuleHwRev[32];		//Fan  module hardware version
-	unsigned char FanModuleFwRev[32];		//Fan  module firmware version
-	unsigned char RelayModuleHwRev[32];	//Relay control  module hardware version
-	unsigned char RelayModuleFwRev[32];	//Relay control  module firmware version
-	unsigned char TelcomModemFwRev[32];	//the 3G/4G modem firmware version
-	unsigned char LedModuleFwRev[32];	//LED control module firmware version
-	unsigned char Connector1FwRev[32];	//Connector1 module firmware version
-	unsigned char Connector2FwRev[32];	//Connector2 module firmware version
-	int SystemAmbientTemp;		// -40 ~ 215 degree C
-	int SystemCriticalTemp;		// -40 ~ 215 degree C
-	int CcsConnectorTemp;		// -40 ~ 215 degree C
-	int PsuAmbientTemp;			// -40 ~ 215 degree C
-	/**************Charging***************/
-	struct ChargingInfoData 	ChademoChargingData[CHAdeMO_QUANTITY];
-	struct ChargingInfoData 	CcsChargingData[CCS_QUANTITY];
-	struct ChargingInfoData 	GbChargingData[GB_QUANTITY];
-	struct ChargingInfoData 	AcChargingData[AC_QUANTITY];
-	unsigned char CurGunSelected;
-	unsigned char CurGunSelectedByAc;
-	/**************Network***************/
-	unsigned char 		InternetConn;					//0: disconnected, 1: connected
-	/**************Backend***************/
-	unsigned char 		OcppConnStatus;					//0: disconnected, 1: connected
-	char 				OrderCharging;
-	/**************Alston***************/
-	unsigned char 		WaitForPlugit;					//0: none scan, 1: scanning
-	unsigned char 		PageIndex;						//0 : Initialize
-														//1 : idle
-														//4 : Authorizing
-														//5 : Authorizing complete
-														//6 : Authorizing fail
-														//7 : Wait for Plug
-														//8 : Pre-charge
-														//9 : Charging
-	unsigned char 		SelfTestSeq;					//
-	unsigned char 		ReAssignedFlag;					//
-	unsigned char		CanAverageCharging;
-	unsigned char 		MainChargingMode;				// 0 : Max, 1 : Average 
-	unsigned char 		BridgeRelayStatus;
-	unsigned char 		FirmwareUpdate;					// 0 : none, 1 : update.
-	unsigned char 		AcContactorStatus;				// 0: disconnected, 1: connected
-	unsigned char 	 	SystemTimeoutFlag;				// 0 : none, 1 : self test
-	struct timeval		SystemTimeoutTimer;
-	unsigned char 		SystemPage;
-	unsigned char 		ConnectorPage;
-	unsigned char		IsAlternatvieConf;				// 0 : normal, 1 : alternative
-	unsigned char		StartToChargingFlag;			// 0 : Stop, 1 : Start for modbus
-	unsigned char 		ChargerType;					// 0 : IEC, 1 : UL
-    unsigned char       ethInternetConn;                // 0 : disconnected, 1: connected
-
-    // DO360
-    unsigned char Relay2ModuleHwRev[32];	//Relay control  module hardware version
-    unsigned char Relay2ModuleFwRev[32];	//Relay control  module firmware version
-    struct DispenserInfoData DispenserInfo;
-    struct ConnectorInfoData ConnectorInfo[GENERAL_GUN_QUANTITY];
-    CabinetSettingFlag       CabinetSetting;
-};
-
-struct SysConfigAndInfo
-{
-	struct SysConfigData				SysConfig;
-	struct SysInfoData					SysInfo;
-	struct WARNING_CODE_INFO			SysWarningInfo;
-};
-
-char Currency[54][3]=
-{
-	"AED",	// - Emirati Dirham
-	"ARS",	// - Argentine Peso
-	"AUD",	// - Australian Dollar
-	"BGN",	// - Bulgarian Lev
-	"BHD",	// - Bahraini Dinar
-	"BND",	// - Bruneian Dollar
-	"BRL",	// - Brazilian Real
-	"BWP",	// - Botswana Pula
-	"CAD",	// - Canadian Dollar
-	"CHF",	// - Swiss Franc
-	"CLP",	// - Chilean Peso
-	"CNY",	// - Chinese Yuan Renminbi
-	"COP",	// - Colombian Peso
-	"CZK",	// - Czech Koruna
-	"DKK",	// - Danish Krone
-	"EUR",	// - Euro
-	"GBP",	// - British Pound
-	"HKD",	// - Hong Kong Dollar
-	"HRK",	// - Croatian Kuna
-	"HUF",	// - Hungarian Forint
-	"IDR",	// - Indonesian Rupiah
-	"ILS",	// - Israeli Shekel
-	"INR",	// - Indian Rupee
-	"IRR",	// - Iranian Rial
-	"ISK",	// - Icelandic Krona
-	"JPY",	// - Japanese Yen
-	"KRW",	// - South Korean Won
-	"KWD",	// - Kuwaiti Dinar
-	"KZT",	// - Kazakhstani Tenge
-	"LKR",	// - Sri Lankan Rupee
-	"LYD",	// - Libyan Dinar
-	"MUR",	// - Mauritian Rupee
-	"MXN",	// - Mexican Peso
-	"MYR",	// - Malaysian Ringgit
-	"NOK",	// - Norwegian Krone
-	"NPR",	// - Nepalese Rupee
-	"NZD",	// - New Zealand Dollar
-	"OMR",	// - Omani Rial
-	"PHP",	// - Philippine Peso
-	"PKR",	// - Pakistani Rupee
-	"PLN",	// - Polish Zloty
-	"QAR",	// - Qatari Riyal
-	"RON",	// - Romanian New Leu
-	"RUB",	// - Russian Ruble
-	"SAR",	// - Saudi Arabian Riyal
-	"SEK",	// - Swedish Krona
-	"SGD",	// - Singapore Dollar
-	"THB",	// - Thai Baht
-	"TRY",	// - Turkish Lira
-	"TTD",	// - Trinidadian Dollar
-	"TWD",	// - Taiwan New Dollar
-	"USD",	// - US Dollar
-	"VEF",	// - Venezuelan Bolivar
-	"ZAR"	// - South African Rand	
-};
-
-/**************************************************************************************/
-/**************************Alarm Share memory**************************************/
-/***************************************************************************************
-	Status Code	A				B					C											D	E	F
-				0: Issue		1: From EVSE 		1: Fault (unrecoverable)					001 ~ 999 serial number
-			    										e.g., hardware broken, system latch
-				1: Recovered	2: From EV			2: Alarm (recoverable)
-			   											e.g., OTP, OVP
-								3: From Backend		3: Information
-			  											e.g., swipe card to stop charging
-
-according to XXX.Revxx
-***************************************************************************************/
-/**************************************************************************************/
-char FaultStatusCode[40][6]=
-{
-	"011001",	//CHAdeMO output fuse blew
-	"011002",	//CCS output fuse blew
-	"011003",	//GB output fuse blew
-	"011004",	//RCD/CCID self-test fail
-	"011005",	//AC input contactor 1 welding
-	"011006",	//AC input contactor 1 driving fault
-	"011007",	//AC input contactor 2 welding
-	"011008",	//AC input contactor 2 driving fault
-	"011009",	//AC output relay welding
-	"011010",	//AC output relay  driving fault
-	"011011",	//CHAdeMO output relay welding
-	"011012",	//CHAdeMO output relay driving fault
-	"011013",	//CCS output relay welding
-	"011014",	//CCS output relay driving fault
-	"011015",	//GB output relay welding
-	"011016",	//GB output relay driving fault
-	"011017",	//AC connector temperature sensor broken
-	"011018",	//CHAdeMO connector temperature sensor broken
-	"011019",	//CCS connector temperature sensor broken
-	"011020",	//GB connector temperature sensor broken
-	"011021",	//WiFi module broken
-	"011022",	//3G/4G module broken
-	"011023",	//Aux. power module broken
-	"011024",	//Relay control module /smart box broken
-	"011025",	//CHAdeMO connector lock fail
-	"011026",	//GB connector lock fail
-	"011027",	//AC connector lock fail
-	"011028",	//CHAdeMO module broken
-	"011029",	//CCS module broken
-	"011030",	//GBT module broken
-	"011031",	//PSU module broken
-	"011032",	//RCD/CCID module broken
-	"011033",	//Maximum Output Current setup error
-	"011034",	//Shutter fault 
-	"011035",	//Ble module broken
-	"011036",	//Rotary switch fault
-	"011037",	//CCS liquid chiller water level fault
-	"011038",	//Reserved
-	"011039",	//Reserved
-	"011040"	//Reserved
-};
-
-struct FaultCodeData
-{
-	unsigned char PreviousFaultVal[5];
-	union
-	{
-		unsigned char FaultVal[5];
-		struct
-		{
-			//FaultVal[0]
-		    unsigned char ChademoOutputFuseBlew:1;				//bit 0
-			unsigned char CcsOutputFuseBlew:1;					//bit 1
-			unsigned char GbOutputFuseBlew:1;   				//bit 2
-			unsigned char RcdSelfTestFail:1;					//bit 3
-			unsigned char AcInputContactor1Welding:1;			//bit 4
-			unsigned char AcInputContactor1DrivingFault:1;		//bit 5
-			unsigned char AcInputContactor2Welding:1;			//bit 6
-			unsigned char AcInputContactor2DrivingFault:1;		//bit 7
-			//FaultVal[1]
-			unsigned char AcOutputRelayWelding:1;				//bit 0
-			unsigned char AcOutputRelayDrivingFault:1;			//bit 1
-			unsigned char ChademoOutputRelayWelding:1;			//bit 2
-			unsigned char ChademoOutputRelayDrivingFault:1;		//bit 3
-			unsigned char CcsOutputRelayWelding:1;				//bit 4
-			unsigned char CcsOutputRelayDrivingFault:1;			//bit 5
-			unsigned char GbOutputRelayWelding:1;				//bit 6
-			unsigned char GbOutputRelayDrivingFault:1;			//bit 7
-			//FaultVal[2]
-			unsigned char AcConnectorTempSensorBroken:1;		//bit 0
-			unsigned char ChademoConnectorTempSensorBroken:1;	//bit 1
-			unsigned char CcsConnectorTempSensorBroken:1;		//bit 2
-			unsigned char GbConnectorTempSensorBroken:1;		//bit 3
-			unsigned char WiFiModuleBroken:1;					//bit 4
-			unsigned char Telecom4GModuleBroken:1;				//bit 5
-			unsigned char AuxPowerModuleBroken:1;				//bit 6
-			unsigned char RelayControlModuleBroken :1;			//bit 7
-			//FaultVal[3]
-			unsigned char ChademoConnectorLockFail:1;			//bit 0
-			unsigned char GbConnectorLockFail:1;				//bit 1
-			unsigned char AcConnectorLockFail:1;				//bit 2
-			unsigned char ChademoModuleBroken:1;				//bit 3
-			unsigned char CcsModuleBroken:1;					//bit 4
-			unsigned char GbModuleBroken:1;						//bit 5
-			unsigned char PsuModuleBroken:1;					//bit 6
-			unsigned char RcdCcidModuleBroken:1;				//bit 7		
-			//FaultVal[4]
-			unsigned char MaximumOutputCurrentSetupError:1;		//bit 0
-			unsigned char ShutterFault:1;						//bit 1
-			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
-		}bits;
-	}FaultEvents;
-};
-
-char AlarmStatusCode[128][6]=
-{
-	"012200",	//System L1 input OVP
-	"012201",	//System L2 input OVP
-	"012202",	//System L3 input OVP
-	"012203",	//System L1 input UVP
-	"012204",	//System L2 input UVP
-	"012205",	//System L3 input UVP
-	"012206",	//PSU L1 input OVP
-	"012207",	//PSU L2 input OVP
-	"012208",	//PSU L3 input OVP
-	"012209",	//PSU L1 input UVP
-	"012210",	//PSU L2 input UVP
-	"012211",	//PSU L3 input UVP
-	"012212",	//System L1 input drop
-	"012213",	//System L2 input drop
-	"012214",	//System L3 input drop
-	"012215",	//System AC output OVP
-	"012216",	//System AC output OCP L1
-	"012217",	//System CHAdeMO output OVP
-	"012218",	//System CHAdeMO output OCP
-	"012219",	//System CCS output OVP
-	"012220",	//System CCS output OCP
-	"012221",	//System GB output OVP
-	"012222",	//System GB output OCP
-	"012223",	//System ambient/inlet OTP
-	"012224",	//System critical point OTP
-	"012225",	//PSU ambient/inlet OTP
-	"012226",	//PSU critical point OTP
-	"012227",	//Aux. power module OTP
-	"012228",	//Relay board/smart box OTP
-	"012229",	//CHAdeMO connector OTP
-	"012230",	//CCS connector OTP
-	"012231",	//GB connector OTP
-	"012232",	//AC connector OTP
-	"012233",	//RCD/CCID trip
-	"012234",	//CHAdeMO GFD trip
-	"012235",	//CCS GFD trip
-	"012236",	//GB GFD trip
-	"012237",	//SPD trip
-	"012238",	//Main power breaker trip
-	"012239",	//Aux. power breaker trip
-	"012240",	//PSU communication fail
-	"012241",	//WiFi module communication fail
-	"012242",	//3G/4G module communication fail
-	"012243",	//RFID module communication fail
-	"012244",	//Bluetooth module communication fail
-	"012245",	//LCM module communication fail
-	"012246",	//Aux. power module communication fail
-	"012247",	//Relay control boaed/smart box communication fail
-	"012248",	//CCS module communication fail
-	"012249",	//CHAdeMO module communication fail
-	"012250",	//GBT module communication fail
-	"012251",	//Emergency stop
-	"012252",	//Door open
-	"012253",	//System fan decay
-	"012254",	//Fail to create share memory
-	"012255",	//CSU initialization failed
-	"012256",	//AC Ground Fault
-	"012257",	//MCU self-test Fault
-	"012258",	//Relay self-test Fault
-	"012259",	//CHAdeMO groundfault detection timeout (GFD)
-	"012260",	//CCS groundfault detection timeout (GFD)
-	"012261",	//GB groundfault detection timeout (GFD)
-	"012262",	//Circuit Short L1
-	"012263",	// PSU Duplicate ID
-	"012264", 	// PSU Output Short Circuit
-	"012265", 	// PSU Discharge Abnormal
-	"012266", 	// PSU Dc Side ShutDown
-	"012267", 	// PSU Failure Alarm
-	"012268", 	// PSU Protection Alarm
-	"012269", 	// PSU FanFailure Alarm
-	"012270", 	// PSU Input UVP
-	"012271",	// PSU Input OVP
-	"012272", 	// PSU WalkIn State
-	"012273", 	// PSU Power Limited State
-	"012274", 	// PSU Id Repeat
-	"012275", 	// PSU Severe Uneven Current
-	"012276", 	// PSU Three Phase Input Inadequate
-	"012277", 	// PSU Three Phase Onput Imbalance
-	"012278", 	// PSU Ffc Side ShutDown
-	"012279", 	// NO PSU Resource
-	"012280", 	// Self test Failed due to communication of Relayboard failure
-	"012281", 	// Self test Failed due to communication of Fanboard failure
-	"012282", 	// Self test Failed due to communication of Primary failure
-	"012283", 	// Self test Failed due to communication of Chademoboard failure
-	"012284", 	// Self test Failed due to communication of CCSboard failure
-	"012285", 	// Self test Failed due to AC Contact failure
-	"012286", 	// Self test Failed due to communication of PSU failure
-	"012287", 	// Self test Failed due to Model name is none match
-	"012288",	// CCS output UVP
-	"012289",	// Chademo output UVP
-	"012290",	// GBT output UVP
-	"012291",	// Self test Failed due to communication of GBTboard failure
-	"012292",	// Self test Failed due to communication of AC failure
-	"012293",	// Self test Failed due to communication of Ledboard failure
-	"012294",	// Ac input OVP
-	"012295",	// Ac input UVP
-	"012296",	// CHAdeMO groundfault detection - warning
-	"012297",	// CCS groundfault detection - warning
-	"012298",	// GB groundfault detection - warning
-	"012299",	//System AC output OCP L2
-	"012300",	//System AC output OCP L3
-	"012301",	//Circuit Short L2
-	"012302",	//Circuit Short L3
-	"012303",	//CCS liquid chiller water level warning
-	"012304",	//connection disconnected from power cabinet
-
-};
-struct AlarmCodeData
-{
-	unsigned char PreviousAlarmVal[14];
-	union
-	{
-		unsigned char AlarmVal[14];
-		struct
-		{
-			//AlarmVal[0]
-		    unsigned char SystemL1InputOVP:1;					//bit 0
-			unsigned char SystemL2InputOVP:1;					//bit 1
-			unsigned char SystemL3InputOVP:1;   				//bit 2
-			unsigned char SystemL1InputUVP:1;					//bit 3
-			unsigned char SystemL2InputUVP:1;					//bit 4
-			unsigned char SystemL3InputUVP:1;					//bit 5
-			unsigned char PsuL1InputOVP:1;						//bit 6
-			unsigned char PsuL2InputOVP:1;						//bit 7
-			//AlarmVal[1]
-			unsigned char PsuL3InputOVP:1;						//bit 0
-			unsigned char PsuL1InputUVP:1;						//bit 1
-			unsigned char PsuL2InputUVP:1;						//bit 2
-			unsigned char PsuL3InputUVP	:1;						//bit 3
-			unsigned char SystemL1InputDrop:1;					//bit 4
-			unsigned char SystemL2InputDrop:1;					//bit 5
-			unsigned char SystemL3InputDrop:1;					//bit 6
-			unsigned char SystemAcOutputOVP:1;					//bit 7
-			//AlarmVal[2]
-			unsigned char SystemAcOutputOCP:1;					//bit 0
-			unsigned char SystemChademoOutputOVP:1;				//bit 1
-			unsigned char SystemChademoOutputOCP:1;				//bit 2
-			unsigned char SystemCcsOutputOVP:1;					//bit 3
-			unsigned char SystemCcsOutputOCP:1;					//bit 4
-			unsigned char SystemGbOutputOVP:1;					//bit 5
-			unsigned char SystemGbOutputOCP:1;					//bit 6
-			unsigned char SystemAmbientOTP :1;					//bit 7
-			//AlarmVal[3]
-			unsigned char SystemCriticalPointOTP:1;				//bit 0
-			unsigned char PsuAmbientOTP:1;						//bit 1
-			unsigned char PsuCriticalPointOTP:1;				//bit 2
-			unsigned char AuxPowerModuleOTP:1;					//bit 3
-			unsigned char RelayBoardOTP:1;						//bit 4
-			unsigned char ChademoConnectorOTP:1;				//bit 5
-			unsigned char CcsConnectorOTP:1;					//bit 6
-			unsigned char GbConnectorOTP:1;						//bit 7
-			 //AlarmVal[4]
-			unsigned char AcConnectorOTP:1;						//bit 0
-			unsigned char RcdTrip:1;							//bit 1
-			unsigned char ChademoGfdTrip:1;						//bit 2
-			unsigned char CcsGfdTrip:1;							//bit 3
-			unsigned char GbGfdTrip:1;							//bit 4
-			unsigned char SpdTrip:1;							//bit 5
-			unsigned char MainPowerBreakerTrip:1;				//bit 6
-			unsigned char AuxPowerBreakerTrip:1;				//bit 7
-			//AlarmVal[5]
-			unsigned char PsuCommunicationFail:1;				//bit 0
-			unsigned char WiFiModuleCommFail:1;					//bit 1
-			unsigned char Telecom4GModuleCommFail:1;			//bit 2
-			unsigned char RfidModuleCommFail:1;					//bit 3
-			unsigned char BluetoothModuleCommFail:1;			//bit 4
-			unsigned char LcmModuleCommFail:1;					//bit 5
-			unsigned char AuxPowerModuleCommFail:1;				//bit 6
-			unsigned char RelayBoardCommFail:1;					//bit 7
-			//AlarmVal[6]
-			unsigned char CcsModuleCommFail:1;					//bit 0
-			unsigned char ChademoModuleCommFail:1;				//bit 1
-			unsigned char GbModuleCommFail:1;					//bit 2
-			unsigned char EmergencyStopTrip:1;					//bit 3
-			unsigned char DoorOpen:1;							//bit 4
-			unsigned char SystemFanDecay:1;						//bit 5
-			unsigned char FailToCreateShareMemory:1;			//bit 6
-			unsigned char CsuInitFailed:1;						//bit 7
-			//AlarmVal[7]
-			unsigned char AcGroundfaultFail:1;					//bit 0
-			unsigned char McuSelftestFail:1;					//bit 1
-			unsigned char RelaySelftestFail:1;					//bit 2
-			unsigned char ChademoGroundfaultTimeout:1;			//bit 3
-			unsigned char CcsGroundfaultTimeout:1;				//bit 4
-			unsigned char GbGroundfaultTimeout:1;				//bit 5
-			unsigned char CircuitShort:1;						//bit 6
-			unsigned char PsuDuplicateID:1;						//bit 7
-			//AlarmVal[8]
-			unsigned char PsuOutputShortCircuit :1;				//bit 0
-			unsigned char PsuDischargeAbnormal :1;				//bit 1
-			unsigned char PsuDcSideShutDown :1;					//bit 2
-			unsigned char PsuFailureAlarm :1;					//bit 3
-			unsigned char PsuProtectionAlarm :1;				//bit 4
-			unsigned char PsuFanFailureAlarm :1;				//bit 5
-			unsigned char PsuInputUVP:1;						//bit 6
-			unsigned char PsuInputOVP:1;						//bit 7
-			//AlarmVal[9]
-			unsigned char PsuWalkInState :1;					//bit 0
-			unsigned char PsuPowerLimitedState :1;				//bit 1
-			unsigned char PsuIdRepeat :1;						//bit 2
-			unsigned char PsuSevereUnevenCurrent :1;			//bit 3
-			unsigned char PsuThreePhaseInputInadequate :1;		//bit 4
-			unsigned char PsuThreePhaseOnputImbalance :1;		//bit 5
-			unsigned char PsuFfcSideShutDown :1;				//bit 6
-			unsigned char PsuNoResource:1;						//bit 7
-			//AlarmVal[10]
-			unsigned char RelayboardStestFail :1;				//bit 0
-			unsigned char FanboardStestFail :1;					//bit 1
-			unsigned char PrimaryStestFail :1;					//bit 2
-			unsigned char ChademoboardStestFail :1;				//bit 3
-			unsigned char CCSboardStestFail :1;					//bit 4
-			unsigned char AcContactStestFail :1;				//bit 5
-			unsigned char PsuModuleStestFail :1;				//bit 6
-			unsigned char ModelNameNoneMatchStestFail:1;		//bit 7	
-			//AlarmVal[11]
-			unsigned char CcsOutputUVPFail :1;					//bit 0
-			unsigned char ChademoOutputUVPFail :1;				//bit 1
-			unsigned char GbtOutputUVPFail :1;					//bit 2
-			unsigned char GbtboardStestFail :1;					//bit 3
-			unsigned char AcConnectorStestFail:1;				//bit 4
-			unsigned char LedboardStestFail:1;									//bit 5
-			unsigned char AcSystemInputOVP:1;									//bit 6
-			unsigned char AcSystemInputUVP:1;									//bit 7
-			//AlarmVal[12]
-			unsigned char ChademoGroundWarning :1;					//bit 0
-			unsigned char CcsGroundfaultWarning :1;					//bit 1
-			unsigned char GbGroundfaultWarning :1;					//bit 2
-			unsigned char SystemAcOutputOCPL2:1;					//bit 3
-			unsigned char SystemAcOutputOCPL3:1;					//bit 4
-			unsigned char CircuitShortL2:1;							//bit 5
-			unsigned char CircuitShortL3:1;							//bit 6
-			unsigned char CcsLiquidChillerWaterLevelWarning:1;			//bit 7 
-			//AlarmVal[13]
-			unsigned char DisconnectedFromDo :1;						//bit 0
-			unsigned char Reserved :7;								//bit 1~bit7
-		}bits;
-	}AlarmEvents;
-};
-
-char InfoStatusCode[384][6]=
-{
-	//Information comes from EVSE
-	"013600",	//Normal stop charging by user
-	"013601",	//Charging Time's up
-	"013602",	//Replace system air filter
-	"013603",	//Reach to CHAdeMO max. plugging times.
-	"013604",	//Reach to CCS max. plugging times.
-	"013605",	//Reach to GB max. plugging times.
-	"013606",	//Reach to AC max. plugging times.
-	"013607",	//CSU fimrware update fail
-	"013608",	//CHAdeMO Module fimrware update fail
-	"013609",	//CCS Module fimrware update fail
-	"013610",	//GB Module fimrware update fail
-	"013611",	//Aux. power module fimrware update fail
-	"013612",	//Relay control module fimrware update fail
-	"013613",	//LCM module fimrware update fail
-	"013614",	//Bluetooth module fimrware update fail
-	"013615",	//WiFi module fimrware update fail
-	"013616",	//3G/4G module fimrware update fail
-	"013617",	//SMR fimrware update fail
-	"013618",	//RFID module fimrware update fail
-	"013619",	//configured by USB flash drive
-	"013620",	//configured by backend
-	"013621",	//configured by webpage
-	"013622",	//disconnected from Internet through Ethernet
-	"013623",	//disconnected from Internet through WiFi
-	"013624",	//disconnected from Internet through 3G/4G
-	"013625",	//disconnected from AP through WiFi
-	"013626",	//disconnected from APN through 3G/4G
-	"013627",	//WiFi disabled (separated charger only)
-	"013628",	//4G disabled (separated charger only)
-	"013629",	//Reserved
-	"013630",	//Reserved
-	"013631",	//Reserved
-	//Information comes from EV
-	"023700",	//CHAdeMO EV communication Fail
-	"023701",	//CCS EV communication Fail
-	"023702",	//GB EV communication Fail
-	"023703",	//AC: pilot fault
-	"023704",	//CHAdeMO:  battery malfunction
-	"023705",	//CHAdeMO:  no charging permission
-	"023706",	//CHAdeMO:  battery incompatibility
-	"023707",	//CHAdeMO:  battery OVP
-	"023708",	//CHAdeMO:  battery UVP
-	"023709",	//CHAdeMO:  battery OTP
-	"023710",	//CHAdeMO:  battery current difference
-	"023711",	//CHAdeMO:  battery voltage difference
-	"023712",	//CHAdeMO:  shift position
-	"023713",	//CHAdeMO:  battery other fault
-	"023714",	//CHAdeMO:  charging system error
-	"023715",	//CHAdeMO:  EV normal stop
-	"023716",	//CHAdeMO:  connector temperature sensor broken
-	"023717",	//CHAdeMO:  connector lock fail
-	"023718",	//CHAdeMO:	D1 ON No Receive
-	"023719",	//CHAdeMO:	BMS K to J Timeout
-	"023720",	//CHAdeMO:	BMS Charge Allow Timeout
-	"023721",	//CHAdeMO:	Wait GroundFault Timeout
-	"023722",	//CHAdeMO:	BMS EV Relay Timeout
-	"023723",	//CHAdeMO:	BMS Request Current Timeout
-	"023724",	//CHAdeMO:	BMS K to J OFF Timeout
-	"023725",	//CHAdeMO:	BMS EV Relay OFF Timeout
-	"023726",	//CHAdeMO:	ADC More Than 10V
-	"023727",	//CHAdeMO:	ADC More Than 20V
-	"023728",	//CHAdeMO:	BMS Charge Before Stop
-	"023729",	//CHAdeMO:	Charger Get Normal Stop
-	"023730",	//CHAdeMO:	Charger Get Emergency Stop
-	"023731",	//CHAdeMO:  Isolation Result Fail
-	"023732",	//CHAdeMO: 	Miss Link With MotherBoard
-	"023733",	//CHAdeMO:	Output Voltage More Than Limit
-	"023734",	//CHAdeMO:	Request Current More Than Limit
-	"023735",	//CHAdeMO: 	Re Cap BMS Eqr Current Exceed
-	"023736",	//CHAdeMO:	Charge Remain Count Down
-	"023737",	//CCS:CCS_EVCC_EVErrorCode_FAILED_RESSTemperatureInhibit
-	"023738",	//CCS:CCS_EVCC_EVErrorCode_FAILED_EVShiftPosition
-	"023739",	//CCS:CCS_EVCC_EVErrorCode_FAILED_ChargerConnectorLockFault
-	"023740",	//CCS:CCS_EVCC_EVErrorCode_FAILED_EVRESSMalfunction
-	"023741",	//CCS:CCS_EVCC_EVErrorCode_FAILED_ChargingCurrentdifferential
-	"023742",	//CCS:CCS_EVCC_EVErrorCode_FAILED_ChargingVoltageOutOfRange
-	"023743",	//CCS:CCS_EVCC_EVErrorCode_FAILED_ChargingSystemIncompatibility
-	"023744",	//CCS:CCS_EVCC_EVErrorCode_FAILED_EmergencyEvent
-	"023745",	//CCS:CCS_EVCC_EVErrorCode_FAILED_Breaker
-	"023746",	//CCS:CCS_EVCC_EVErrorCode_FAILED_NoData
-	"023747",	//CCS:CCS_EVCC_EVErrorCode_FAILED_reserved_by_DIN_A
-	"023748",	//CCS:CCS_EVCC_EVErrorCode_FAILED_reserved_by_DIN_B
-	"023749",	//CCS:CCS_EVCC_EVErrorCode_FAILED_reserved_by_DIN_C
-	"023750",	//CCS:CCS_EVCC_EVErrorCode_FAILED_reserved_by_ISO_1
-	"023751",	//CCS:CCS_EVCC_EVErrorCode_FAILED_reserved_by_ISO_2
-	"023752",	//CCS:CCS_EVCC_EVErrorCode_FAILED_reserved_by_ISO_3
-	"023753",	//CCS:CCS_EVCC_EVErrorCode_FAILED_reserved_by_OEM_1
-	"023754",	//CCS:CCS_EVCC_EVErrorCode_FAILED_reserved_by_OEM_2
-	"023755",	//CCS:CCS_EVCC_EVErrorCode_FAILED_reserved_by_OEM_3
-	"023756",	//CCS:CCS_EVCC_EVErrorCode_FAILED_reserved_by_OEM_4
-	"023757",	//CCS:CCS_EVCC_EVErrorCode_FAILED_reserved_by_OEM_5
-	"023758",	//CCS:CCS_SECC_ResponseCode_FAILED_SequenceError
-	"023759",	//CCS:CCS_SECC_ResponseCode_FAILED_SignatureError
-	"023760",	//CCS:CCS_SECC_ResponseCode_FAILED_UnknownSession
-	"023761",	//CCS:CCS_SECC_ResponseCode_FAILED_ServiceIDInvalid
-	"023762",	//CCS:CCS_SECC_ResponseCode_FAILED_Payment SelectionInvalid
-	"023763",	//CCS:CCS_SECC_ResponseCode_FAILED_IdentificationSelectionInvalid
-	"023764",	//CCS:CCS_SECC_ResponseCode_FAILED_ServiceSelectionInvalid
-	"023765",	//CCS:CCS_SECC_ResponseCode_FAILED_CertificateExpired
-	"023766",	//CCS:CCS_SECC_ResponseCode_FAILED_CertificateNotYetValid
-	"023767",	//CCS:CCS_SECC_ResponseCode_FAILED_CertificateRevoked
-	"023768",	//CCS:CCS_SECC_ResponseCode_FAILED_NoCertificateAvailable
-	"023769",	//CCS:CCS_SECC_ResponseCode_FAILED_CertChainError
-	"023770",	//CCS:CCS_SECC_ResponseCode_FAILED_CertValidationError
-	"023771",	//CCS:CCS_SECC_ResponseCode_FAILED_CertVerificationError
-	"023772",	//CCS:CCS_SECC_ResponseCode_FAILED_ContractCanceled
-	"023773",	//CCS:CCS_SECC_ResponseCode_FAILED_ChallengeInvalid
-	"023774",	//CCS:CCS_SECC_ResponseCode_FAILED_WrongEnergyTransferMode
-	"023775",	//CCS:CCS_SECC_ResponseCode_FAILED_WrongChargeParameter
-	"023776",	//CCS:CCS_SECC_ResponseCode_FAILED_ChargingProfileInvalid
-	"023777",	//CCS:CCS_SECC_ResponseCode_FAILED_TariffSelectionInvalid
-	"023778",	//CCS:CCS_SECC_ResponseCode_FAILED_EVSEPresentVoltageToLow
-	"023779",	//CCS:CCS_SECC_ResponseCode_FAILED_PowerDeliveryNotApplied
-	"023780",	//CCS:CCS_SECC_ResponseCode_FAILED_MeteringSignatureNotValid
-	"023781",	//CCS:CCS_SECC_ResponseCode_FAILED_NoChargeServiceSelected
-	"023782",	//CCS:CCS_SECC_ResponseCode_FAILED_ContactorError
-	"023783",	//CCS:CCS_SECC_ResponseCode_FAILED_CertificateNotAllowedAtThisEVSE
-	"023784",	//CCS:CCS_SECC_ResponseCode_FAILED_GAChargeStop
-	"023785",	//CCS:CCS_SECC_ResponseCode_FAILED_AlignmentError
-	"023786",	//CCS:CCS_SECC_ResponseCode_FAILED_ACDError
-	"023787",	//CCS:CCS_SECC_ResponseCode_FAILED_AssociationError
-	"023788",	//CCS:CCS_SECC_ResponseCode_FAILED_EVSEChargeAbort
-	"023789",	//CCS:CCS_SECC_ResponseCode_FAILED_NoSupportedApp-Protocol-Protocol
-	"023790",	//CCS:CCS_SECC_ResponseCode_FAILED_ContractNotAccepted
-	"023791",	//CCS:CCS_SECC_ResponseCode_FAILED_MOUnknown
-	"023792",	//CCS:CCS_SECC_ResponseCode_FAILED_OEM_Prov_CertificateRevoke
-	"023793",	//CCS:CCS_SECC_ResponseCode_FAILED_OEM_SubCA1_CertificateRevoked
-	"023794",	//CCS:CCS_SECC_ResponseCode_FAILED_OEM_SubCA2_CertificateRevoked
-	"023795",	//CCS:CCS_SECC_ResponseCode_FAILED_OEM_RootCA_CertificateRevoked
-	"023796",	//CCS:CCS_SECC_ResponseCode_FAILED_MO_Prov_CertificateRevoked
-	"023797",	//CCS:CCS_SECC_ResponseCode_FAILED_MO_SubCA1_CertificateRevoked
-	"023798",	//CCS:CCS_SECC_ResponseCode_FAILED_MO_SubCA2_CertificateRevoked
-	"023799",	//CCS:CCS_SECC_ResponseCode_FAILED_MO_RootCA_CertificateRevoked
-	"023800",	//CCS:CCS_SECC_ResponseCode_FAILED_CPS_Prov_CertificateRevoked
-	"023801",	//CCS:CCS_SECC_ResponseCode_FAILED_CPS_SubCA1_CertificateRevoked
-	"023802",	//CCS:CCS_SECC_ResponseCode_FAILED_CPS_SubCA2_CertificateRevoked
-	"023803",	//CCS:CCS_SECC_ResponseCode_FAILED_CPS_RootCA_CertificateRevoked
-	"023804",	//CCS:CCS_SECC_ResponseCode_FAILED_reserved_1
-	"023805",	//CCS:CCS_SECC_ResponseCode_FAILED_reserved_2
-	"023806",	//CCS:CCS_SECC_ResponseCode_FAILED_reserved_3
-	"023807",	//CCS:CCS_SECC_ResponseCode_FAILED_reserved_4
-	"023808",	//CCS:CCS_SECC_ResponseCode_FAILED_reserved_5
-	"023809",	//CCS:CCS_SECC_TIMEOUT_SLAC_TT_EVSE_SLAC_init
-	"023810",	//CCS:CCS_SECC_TIMEOUT_SLAC_TP_match_response
-	"023811",	//CCS:CCS_SECC_TIMEOUT_CM_START_ATTEN_CHAR_IND
-	"023812",	//CCS:CCS_SECC_TIMEOUT_SLAC_TT_EVSE_match_MNBC
-	"023813",	//CCS:CCS_SECC_TIMEOUT_SLAC_TP_EVSE_avg_atten_calc
-	"023814",	//CCS:CCS_SECC_TIMEOUT_SLAC_CM_ATTEN_CHAR_RSP
-	"023815",	//CCS:CCS_SECC_TIMEOUT_SLAC_CM_VALIDATE_REQ_1ST__CM_SLAC_MATCH_REQ
-	"023816",	//CCS:CCS_SECC_TIMEOUT_SLAC_TT_EVSE_assoc_session
-	"023817",	//CCS:CCS_SECC_TIMEOUT_SLAC_TT_EVSE_vald_toggle
-	"023818",	//CCS:CCS_SECC_TIMEOUT_SLAC_CM_MNBC_SOUND_IND
-	"023819",	//CCS:CCS_SECC_TIMEOUT_SLAC_CM_VALIDATE_REQ_2ND__CM_SLAC_MATCH_REQ
-	"023820",	//CCS:CCS_SECC_TIMEOUT_SLAC_reserved_3
-	"023821",	//CCS:CCS_SECC_TIMEOUT_SLAC_reserved_4
-	"023822",	//CCS:CCS_SECC_TIMEOUT_SLAC_reserved_5
-	"023823",	//CCS:CCS_SECC_TIMEOUT_SLACC_SDP_UDP_TT_match_join
-	"023824",	//CCS:CCS_SECC_TIMEOUT_SLACC_SDP_TCP_TT_match_join
-	"023825",	//CCS:CCS_SECC_TIMEOUT_SLACC_SDP_TP_amp_map_exchange
-	"023826",	//CCS:CCS_SECC_TIMEOUT_SLACC_SDP_TP_link_ready_notification
-	"023827",	//CCS:CCS_SECC_TIMEOUT_SLACC_SDP_reserved_1
-	"023828",	//CCS:CCS_SECC_TIMEOUT_SLACC_SDP_reserved_2
-	"023829",	//CCS:CCS_SECC_TIMEOUT_SLACC_SDP_reserved_3
-	"023830",	//CCS:CCS_SECC_TIMEOUT_SLACC_SDP_reserved_4
-	"023831",	//CCS:CCS_SECC_TIMEOUT_SLACC_SDP_reserved_5
-	"023832",	//CCS:CCS_SECC_TIMEOUT_V2G_Msg_Performance_Time_SupportedAppProtocolRes
-	"023833",	//CCS:CCS_SECC_TIMEOUT_V2G_Msg_Performance_Time_SessionSetupRes
-	"023834",	//CCS:CCS_SECC_TIMEOUT_V2G_Msg_Performance_Time_ServiceDiscoveryRes
-	"023835",	//CCS:CCS_SECC_TIMEOUT_V2G_Msg_Performance_Time_ServicePaymentSelectionRes
-	"023836",	//CCS:CCS_SECC_TIMEOUT_V2G_Msg_Performance_Time_ContractAuthenticationRes
-	"023837",	//CCS:CCS_SECC_TIMEOUT_V2G_Msg_Performance_Time_ChargeParameterDiscoveryRes
-	"023838",	//CCS:CCS_SECC_TIMEOUT_V2G_Msg_Performance_Time_PowerDeliveryRes
-	"023839",	//CCS:CCS_SECC_TIMEOUT_V2G_Msg_Performance_Time_CableCheckRes
-	"023840",	//CCS:CCS_SECC_TIMEOUT_V2G_Msg_Performance_Time_PreChargeRes
-	"023841",	//CCS:CCS_SECC_TIMEOUT_V2G_Msg_Performance_Time_CurrentDemandRes
-	"023842",	//CCS:CCS_SECC_TIMEOUT_V2G_Msg_Performance_Time_WeldingDetectionRes
-	"023843",	//CCS:CCS_SECC_TIMEOUT_V2G_Msg_Performance_Time_SessionStopRes
-	"023844",	//CCS:CCS_SECC_TIMEOUT_V2G_Sequence_Time
-	"023845",	//CCS:CCS_SECC_TIMEOUT_V2G_ReadyToCharge_Performance_Time
-	"023846",	//CCS:CCS_SECC_TIMEOUT_V2G_CommunicationSetup_Performance_Time
-	"023847",	//CCS:CCS_SECC_TIMEOUT_V2G_CableCheck_Performance_Time
-	"023848",	//CCS:CCS_SECC_TIMEOUT_V2G_CPState_Detection_Time
-	"023849",	//CCS:CCS_SECC_TIMEOUT_V2G_CPOscillator_Retain_Time
-	"023850",	//CCS:CCS_SECC_TIMEOUT_V2G_PreCharge_Performace_Time
-	"023851",	//CCS:CCS_SECC_TIMEOUT_V2G_reserved_2
-	"023852",	//CCS:CCS_SECC_TIMEOUT_V2G_reserved_3
-	"023853",	//CCS:CCS_SECC_TIMEOUT_V2G_reserved_4
-	"023854",	//CCS:CCS_SECC_TIMEOUT_V2G_reserved_5
-	"023855",	//CCS:CCS_CAN_TIMEOUT_TP_GET_EV_TARGET_INFO
-	"023856",	//CCS:CCS_CAN_TIMEOUT_TT_GET_EV_TARGET_INFO
-	"023857",	//CCS:CCS_CAN_TIMEOUT_TP_GET_EV_BATTERY_INFO
-	"023858",	//CCS:CCS_CAN_TIMEOUT_TT_GET_EV_BATTERY_INFO
-	"023859",	//CCS:CCS_CAN_TIMEOUT_TP_EV_STOP_EVENT
-	"023860",	//CCS:CCS_CAN_TIMEOUT_TT_EV_STOP_EVENT
-	"023861",	//CCS:CCS_CAN_TIMEOUT_TP_EVSE_STOP_EVENT
-	"023862",	//CCS:CCS_CAN_TIMEOUT_TT_EVSE_STOP_EVENT
-	"023863",	//CCS:CCS_CAN_TIMEOUT_TP_GET_MISC_INFO
-	"023864",	//CCS:CCS_CAN_TIMEOUT_TT_GET_MISC_INFO
-	"023865",	//CCS:CCS_CAN_TIMEOUT_TP_DOWNLOAD_REQUEST
-	"023866",	//CCS:CCS_CAN_TIMEOUT_TT_DOWNLOAD_REQUEST
-	"023867",	//CCS:CCS_CAN_TIMEOUT_TP_START_BLOCK_TRANSFER
-	"023868",	//CCS:CCS_CAN_TIMEOUT_TT_START_BLOCK_TRANSFER
-	"023869",	//CCS:CCS_CAN_TIMEOUT_TP_DATA_TRANSFER
-	"023870",	//CCS:CCS_CAN_TIMEOUT_TT_DATA_TRANSFER
-	"023871",	//CCS:CCS_CAN_TIMEOUT_TP_DOWNLOAD_FINISH
-	"023872",	//CCS:CCS_CAN_TIMEOUT_TT_DOWNLOAD_FINISH
-	"023873",	//CCS:CCS_CAN_TIMEOUT_TP_ISOLATION_STATUS
-	"023874",	//CCS:CCS_CAN_TIMEOUT_TT_ISOLATION_STATUS
-	"023875",	//CCS:CCS_CAN_TIMEOUT_TP_CONNECTOR_INFO
-	"023876",	//CCS:CCS_CAN_TIMEOUT_TT_CONNECTOR_INFO
-	"023877",	//CCS:CCS_CAN_TIMEOUT_TT_RTC_INFO
-	"023878",	//CCS:CCS_CAN_TIMEOUT_TP_RTC_INFO
-	"023879",	//CCS:CCS_CAN_TIMEOUT_TP_EVSE_PRECHARGE_INFO
-	"023880",	//CCS:CCS_CAN_TIMEOUT_TT_EVSE_PRECHARGE_INFO
-	"023881",	//CCS:CCS_CAN_TIMEOUT_MSG_Sequence
-	"023882",	//CCS:CCS_CAN_MSG_Unrecognized_CMD_ID
-	"023883",	//CCS:CCS_SECC_DIN_Msg_Decode_Error
-	"023884",	//CCS:CCS_SECC_DIN_Msg_Encode_Error
-	"023885",	//CCS:CCS_SECC_ISO1_Msg_Decode_Error
-	"023886",	//CCS:CCS_SECC_ISO1_Msg_Encode_Error
-	"023887",	//CCS:CCS_SECC_ISO2_Msg_Decode_Error
-	"023888",	//CCS:CCS_SECC_ISO2_Msg_Encode_Error
-	"023889",	//CCS:CCS_SECC_CP_STATUS_Error
-	"023890",	//CCS:CCS_SECC_Unexpected_60V_Before_Charing_Error
-	"023891",	//CCS:CCS_SECC_Not_Ready_For_Charging
-	"023892",	//CCS:CCS_SECCC_TIMEOUT_QCA7000_COMM (The firmware code of QCA7000 may not be installed, yet)
-	"023893",	//CCS:CCS_SECC_FAIL_QCA7000_SETKEY
-	"023894",	//Reserved
-	"023895",	//Reserved
-	"023896",	//Reserved
-	"023897",	//Reserved
-	"023898",	//Reserved
-	"023899",	//Reserved
-	"023900",	//GBT: ERROR_CODE_GBT_LOS_CC1
-	"023901",	//GBT: ERROR_CODE_GBT_CONNECTOR_LOCK_FAIL
-	"023902",	//GBT: ERROR_CODE_GBT_BATTERY_INCOMPATIBLE
-	"023903",	//GBT: ERROR_CODE_GBT_BMS_BROAA_TIMEOUT
-	"023904",	//GBT: ERROR_CODE_GBT_CSU_PRECHARGE_TIMEOUT
-	"023905",	//GBT: ERROR_CODE_GBT_BMS_PRESENT_VOLTAGE_FAULT
-	"023906",	//GBT: ERROR_CODE_GBT_BMS_VOLTAGE_OVER_RANGE
-	"023907",	//GBT: ERROR_CODE_GBT_BSM_CHARGE_ALLOW_00_10MIN_COUUNTDONE
-	"023908",	//GBT: ERROR_CODE_GBT_WAIT_GROUNDFAULT_TIMEOUT
-	"023909",	//GBT: ERROR_CODE_GBT_ADC_MORE_THAN_10V
-	"023910",	//GBT: ERROR_CODE_GBT_ADC_MORE_THAN_60V
-	"023911",	//GBT: ERROR_CODE_GBT_CHARGER_GET_NORMAL_STOP_CMD
-	"023912",	//GBT: ERROR_CODE_GBT_CHARGER_GET_EMERGENCY_STOP_CMD
-	"023913",	//GBT: ERROR_CODE_GBT_ISOLATION_RESULT_FAIL
-	"023914",	//GBT: ERROR_CODE_GBT_MOTHER_BOARD_MISS_LINK
-	"023915",	//GBT: ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_LIMIT
-	"023916",	//GBT: ERROR_CODE_GBT_REQ_CURRENT_MORE_THAN_LIMIT
-	"023917",	//GBT: ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_10_PERCENT
-	"023918",	//GBT: ERROR_CODE_GBT_OUTPUT_VOLTAGE_DIFF_BCS_5_PERCENT
-	"023919",	//GBT: ERROR_CODE_GBT_STOP_ADC_MORE_THAN_10V
-	"023920",	// Reserved
-	"023921",	// Reserved
-	"023922",	// Reserved
-	"023923",	// Reserved
-	"023924",	// Reserved
-	"023925",	// Reserved
-	"023926",	// Reserved
-	"023927",	// Reserved
-	"023928",	// Reserved
-	"023929",	// Reserved
-	"023930",	//GBT: ERROR_CODE_CEM_BHM_TIMEOUT
-	"023931",	//GBT: ERROR_CODE_CEM_BRM_TIMEOUT
-	"023932",	//GBT: ERROR_CODE_CEM_BCP_TIMEOUT
-	"023933",	//GBT: ERROR_CODE_CEM_BRO_TIMEOUT
-	"023934",	//GBT: ERROR_CODE_CEM_BCL_TIMEOUT
-	"023935",	//GBT: ERROR_CODE_CEM_BCS_TIMEOUT
-	"023936",	//GBT: ERROR_CODE_CEM_BSM_TIMEOUT
-	"023937",	//GBT: ERROR_CODE_CEM_BST_TIMEOUT
-	"023938",	//GBT: ERROR_CODE_CEM_BSD_TIMEOUT
-	"023939",	//GBT: ERROR_CODE_CEM_BEM_OTHER_TIMEOUT
-	"023940",	//GBT: ERROR_CODE_BEM_CRM_TIMEOUT
-	"023941",	//GBT: ERROR_CODE_BEM_CRMAA_TIMEOUT
-	"023942",	//GBT: ERROR_CODE_BEM_CTS_CML_TIMEOUT
-	"023943",	//GBT: ERROR_CODE_BEM_CRO_TIMEOUT
-	"023944",	//GBT: ERROR_CODE_BEM_CCS_TIMEOUT
-	"023945",	//GBT: ERROR_CODE_BEM_CST_TIMEOUT
-	"023946",	//GBT: ERROR_CODE_BEM_CSD_TIMEOUT
-	"023947",	//GBT: ERROR_CODE_BEM_BEM_OTHER_TIMEOUT
-	"023948",	// Reserved
-	"023949",	// Reserved
-	"023950",	//GBT: ERROR_CODE_BST_SOC_GOAL
-	"023951",	//GBT: ERROR_CODE_BST_TOTAL_VOLTAGE_GOAL
-	"023952",	//GBT: ERROR_CODE_BST_CELL_VOLTAGE_GOAL
-	"023953",	//GBT: ERROR_CODE_BST_GET_CST
-	"023954",	//GBT: ERROR_CODE_BST_ISOLATION
-	"023955",	//GBT: ERROR_CODE_BST_OUTPUT_CONNECTOR_OTP
-	"023956",	//GBT: ERROR_CODE_BST_COMPONENT
-	"023957",	//GBT: ERROR_CODE_BST_CHARGE_CONNECTOR
-	"023958",	//GBT: ERROR_CODE_BST_OTP
-	"023959",	//GBT: ERROR_CODE_BST_OTHER
-	"023960",	//GBT: ERROR_CODE_BST_HIGH_V
-	"023961",	//GBT: ERROR_CODE_BST_CC2
-	"023962",	//GBT: ERROR_CODE_BST_CURRENT
-	"023963",	//GBT: ERROR_CODE_BST_VOLTAGE
-	"023964",	//GBT: ERROR_CODE_GET_BST_NO_REASON
-	"023965",	// Reserved
-	"023966",	// Reserved
-	"023967",	// Reserved
-	"023968",	// Reserved
-	"023969",	// Reserved
-	"023970",	//GBT: ERROR_CODE_BSM_CELL_OVER_VOLTAGE
-	"023971",	//GBT: ERROR_CODE_BSM_CELL_UNDER_VOLTAGE
-	"023972",	//GBT: ERROR_CODE_BSM_OVER_SOC
-	"023973",	//GBT: ERROR_CODE_BSM_UNDER_SOC
-	"023974",	//GBT: ERROR_CODE_BSM_CURRENT
-	"023975",	//GBT: ERROR_CODE_BSM_TEMPERATURE
-	"023976",	//GBT: ERROR_CODE_BSM_ISOLATE
-	"023977",	//GBT: ERROR_CODE_BSM_OUTPUT_CONNECTOR
-	"023978",	// Reserved
-	"023979",	// Reserved
-	"033900",	//disconnected from backend through Ethernet
-	"033901",	//disconnected from backend through WiFi
-	"033902",	//disconnected from backend through 3G/4G
-	"033903",	//Remote start charging by backend
-	"033904",	//Remote stop charging by backend
-	"033905",	//Remote reset by backend
-	"033906",	//Authorization failed
-	"033907",	//Reserved
-};
-struct InfoCodeData
-{
-	unsigned char PreviousInfoVal[40];
-	union
-	{
-		unsigned char InfoVal[40];
-		struct
-		{
-			//InfoVal[0]
-		    unsigned char NormalStopChargingByUser:1;				//bit 0
-			unsigned char ChargingTimesUp:1;						//bit 1
-			unsigned char ReplaceSystemAirFilter:1; 				//bit 2
-			unsigned char ReachChademoMaxPluggingTimes:1;			//bit 3
-			unsigned char ReachCcsMaxPluggingTimes:1;				//bit 4
-			unsigned char ReachGbMaxPluggingTimes:1;				//bit 5
-			unsigned char ReachAcMaxPluggingTimes:1;				//bit 6
-			unsigned char CsuFimrwareUpdateFail:1;					//bit 7
-			//InfoVal[1]
-			unsigned char ChademoModuleFimrwareUpdateFail:1;		//bit 0
-			unsigned char CcsModuleFimrwareUpdateFail:1;			//bit 1
-			unsigned char GbModuleFimrwareUpdateFail:1;				//bit 2
-			unsigned char AuxPowerModuleFimrwareUpdateFail:1;		//bit 3
-			unsigned char RelayBoardFimrwareUpdateFail:1;			//bit 4
-			unsigned char LcmModuleFimrwareUpdateFail:1;			//bit 5
-			unsigned char BluetoothModuleFimrwareUpdateFail:1;		//bit 6
-			unsigned char WiFiModuleFimrwareUpdateFail:1;			//bit 7
-			//InfoVal[2]
-			unsigned char Telocom4GModuleFimrwareUpdateFail:1;		//bit 0
-			unsigned char PsuFimrwareUpdateFail:1;					//bit 1
-			unsigned char RfidModuleFimrwareUpdateFail:1;			//bit 2
-			unsigned char ConfiguredByUsbFlashDrive:1;				//bit 3
-			unsigned char ConfiguredByBackend:1;					//bit 4
-			unsigned char ConfiguredByWebpage:1;					//bit 5
-			unsigned char InternetDisconnectViaEthernet:1;			//bit 6
-			unsigned char InternetDisconnectViaWiFi :1;				//bit 7
-	        //InfoVal[3]
-			unsigned char InternetDisconnectVia4Gi:1;				//bit 0
-			unsigned char ApDisconnectViaWiFi:1;					//bit 1
-			unsigned char ApnDisconnectVia4Gi:1;					//bit 2
-			unsigned char WiFiDisable:1;                            //bit 3
-			unsigned char Telocom4GModuleDisable:1;                 //bit 4
-			unsigned char :3;										//bit 5~7 reserved
-			 //InfoVal[4]
-			unsigned char ChademoEvCommFail:1;						//bit 0
-			unsigned char CcsEvCommFail:1;							//bit 1
-			unsigned char GbEvCommFail:1;							//bit 2
-			unsigned char PilotFault:1;								//bit 3
-			unsigned char ChademoBatteryMalfun:1;					//bit 4
-			unsigned char ChademoNoPermission:1;					//bit 5
-			unsigned char ChademoBatteryIncompatibility:1;			//bit 6
-			unsigned char ChademoBatteryOVP:1;						//bit 7
-			//InfoVal[5]
-			unsigned char ChademoBatteryUVP:1;						//bit 0
-			unsigned char ChademoBatteryOTP:1;						//bit 1
-			unsigned char ChademoBatteryCurrentDiff:1;				//bit 2
-			unsigned char ChademoBatteryVoltageDiff:1;				//bit 3
-			unsigned char ChademoShiftPosition:1;					//bit 4
-			unsigned char ChademoBatteryOtherFault:1;				//bit 5
-			unsigned char ChademoChargingSystemError:1;				//bit 6
-			unsigned char ChademoEvNormalStop:1;					//bit 7
-			//InfoVal[6]
-			unsigned char ChademoTempSensorBroken:1;				//bit 0
-			unsigned char ChademoConnectorLockFail:1;				//bit 1
-			unsigned char ChademoD1OnNoReceive:1;					//bit 2
-			unsigned char ChademoBmsKtoJTimeout:1;					//bit 3
-			unsigned char ChademoBmsChargeAllowTimeout:1;			//bit 4
-			unsigned char ChademoWaitGfdTimeout:1;					//bit 5
-			unsigned char ChademoBmsEvRelayTimeout:1;				//bit 6
-			unsigned char ChademoBmsReqCurrentTimeout:1;			//bit 7
-			//InfoVal[7]
-			unsigned char ChademoBmsKtoJOffTimeout :1;				//bit 0
-			unsigned char ChademoBmsEvRelayOffTimeout :1;			//bit 1
-			unsigned char ChademoAdcMoreThan10V :1;					//bit 2
-			unsigned char ChademoAdcMoreThan20V :1;					//bit 3
-			unsigned char ChademoBmsChargeBeforeStop :1;			//bit 4
-			unsigned char ChademoChargerGetNormalStop :1;			//bit 5
-			unsigned char ChademoChargerGetEmergencyStop :1;		//bit 6
-			unsigned char ChademoIsolationResultFail :1;			//bit 7
-			//InfoVal[8]
-			unsigned char ChademoMissLinkWithMotherBoard :1;		//bit 0
-			unsigned char ChademoOutputVolMoreThanLimit :1;			//bit 1
-			unsigned char ChademoReqCurrentMoreThanLimit :1;				//bit 2
-			unsigned char ChademoReCapBmsEqrCurrentExceed :1;				//bit 3
-			unsigned char ChademoChargeRemainCountDown :1;		//bit 4
-			unsigned char CcsRESTemperatureInhibit:1;				//bit 5
-			unsigned char CcsEVShiftPosition:1;				//bit 6
-			unsigned char CcsChargerConnectorLockFault:1;				//bit 7
-			//InfoVal[9]
-			unsigned char CcsEVRESSMalfunction:1;					//bit 0
-			unsigned char CcsChargingCurrentdifferential:1;		//bit 1
-			unsigned char CcsChargingVoltageOutOfRange:1;		//bit 2
-			unsigned char CcsChargingSystemIncompatibility:1;		//bit 3
-			unsigned char CcsEmergencyEvent:1;				//bit 4
-			unsigned char CcsBreaker:1;					//bit 5
-			unsigned char CcsNoData:1;							//bit 6
-			unsigned char Ccsreserved_by_DIN_A:1;				//bit 7
-			//InfoVal[10]
-			unsigned char Ccsreserved_by_DIN_B:1;				//bit 0
-			unsigned char Ccsreserved_by_DIN_C:1;					//bit 1
-			unsigned char Ccsreserved_by_ISO_1:1;				//bit 2
-			unsigned char Ccsreserved_by_ISO_2:1;					//bit 3
-			unsigned char Ccsreserved_by_ISO_3:1;					//bit 4
-			unsigned char Ccsreserved_by_OEM_1:1;				//bit 5
-			unsigned char Ccsreserved_by_OEM_2:1;			//bit 6
-			unsigned char Ccsreserved_by_OEM_3:1;				//bit 7
-			//InfoVal[11]
-			unsigned char Ccsreserved_by_OEM_4:1;			//bit 0
-			unsigned char Ccsreserved_by_OEM_5:1;			//bit 1
-			unsigned char CcsSequenceError:1;			//bit 2
-			unsigned char CcsSignatureError:1;		//bit 3
-			unsigned char CcsUnknownSession:1;					//bit 4
-			unsigned char CcsServiceIDInvalid:1;					//bit 5
-			unsigned char CcsPaymentSelectionInvalid:1;					//bit 6
-			unsigned char CcsIdentificationSelectionInvalid:1;			//bit 7
-			//InfoVal[12]
-			unsigned char CcsServiceSelectionInvalid:1;			//bit 0
-			unsigned char CcsCertificateExpired:1;			//bit 1
-			unsigned char CcsCertificateNotYetValid:1;			//bit 2
-			unsigned char CcsCertificateRevoked:1;			//bit 3
-			unsigned char CcsNoCertificateAvailable:1;			//bit 4
-			unsigned char CcsCertChainError:1;			//bit 5
-			unsigned char CcsCertValidationError:1;			//bit 6
-			unsigned char CcsCertVerificationError:1;			//bit 7
-			//InfoVal[13]
-			unsigned char CcsContractCanceled:1;				//bit 0
-			unsigned char CcsChallengeInvalid:1;				//bit 1
-			unsigned char CcsWrongEnergyTransferMode:1;				//bit 2
-			unsigned char CcsWrongChargeParameter:1;				//bit 3
-			unsigned char CcsChargingProfileInvalid:1;				//bit 4
-			unsigned char CcsTariffSelectionInvalid:1;				//bit 5
-			unsigned char CcsEVSEPresentVoltageToLow:1;				//bit 6
-			unsigned char CcsPowerDeliveryNotApplied:1;			//bit 7
-			//InfoVal[14]
-			unsigned char CcsMeteringSignatureNotValid:1;			//bit 0
-			unsigned char CcsNoChargeServiceSelected:1;			//bit 1
-			unsigned char CcsContactorError:1;					//bit 2
-			unsigned char CcsCertificateNotAllowedAtThisEVSE:1;			//bit 3
-			unsigned char CcsGAChargeStop:1;				//bit 4
-			unsigned char CcsAlignmentError:1;					//bit 5
-			unsigned char CcsACDError:1;					//bit 6
-			unsigned char CcsAssociationError:1;			//bit 7
-			//InfoVal[15]
-			unsigned char CcsEVSEChargeAbort:1;				//bit 0
-			unsigned char CcsNoSupportedAppProtocol:1;					//bit 1
-			unsigned char CcsContractNotAccepted:1;				//bit 2
-			unsigned char CcsMOUnknown:1;					//bit 3
-			unsigned char CcsOEM_Prov_CertificateRevoke:1;				//bit 4
-			unsigned char CcsOEM_SubCA1_CertificateRevoked:1;		//bit 5
-			unsigned char CcsOEM_SubCA2_CertificateRevoked:1;		//bit 6
-			unsigned char CcsOEM_RootCA_CertificateRevoked:1;		//bit 7
-			//InfoVal[16]
-			unsigned char CcsMO_Prov_CertificateRevoked:1;			//bit 0
-			unsigned char CcsMO_SubCA1_CertificateRevoked:1;		//bit 1
-			unsigned char CcsMO_SubCA2_CertificateRevoked:1;		//bit 2
-			unsigned char CcsMO_RootCA_CertificateRevoked:1;		//bit 3
-			unsigned char CcsCPS_Prov_CertificateRevoked:1;		//bit 4
-			unsigned char CcsCPS_SubCA1_CertificateRevoked:1;		//bit 5
-			unsigned char CcsCPS_SubCA2_CertificateRevoked:1;		//bit 6
-			unsigned char CcsCPS_RootCA_CertificateRevoked:1;		//bit 7
-			//InfoVal[17]
-			unsigned char :5;					//bit 0~4 reserved
-			unsigned char CcsTT_EVSE_SLAC_init:1;				//bit 5
-			unsigned char CcsTP_match_response:1;			//bit 6
-			unsigned char CcsTT_match_sequence:1;			//bit 7
-			//InfoVal[18]
-			unsigned char CcsTT_EVSE_match_MNBC:1;				//bit 0
-			unsigned char CcsTP_EVSE_avg_atten_calc:1;				//bit 1
-			unsigned char CcsTT_match_response:1;			//bit 2
-			unsigned char CcsTP_EVSE_match_session:1;			//bit 3
-			unsigned char CcsTT_EVSE_assoc_session:1;			//bit 4
-			unsigned char CcsTT_EVSE_vald_toggle:1;			//bit 5
-			unsigned char CcsSeccSlacTimeoutCmMnbcSound:1;			//bit 6 reserved
-			unsigned char CcsSeccSlacTimeoutCmValidateReq:1;			//bit 7 reserved
-			//InfoVal[19]
-			unsigned char :3;					//bit 0~2 reserved
-			unsigned char CcsUDP_TT_match_join:1;			//bit 3
-			unsigned char CcsTCP_TT_match_join:1;				//bit 4
-			unsigned char CcsTP_amp_map_exchange:1;			//bit 5
-			unsigned char CcsTP_link_ready_notification:1;			//bit 6
-			unsigned char :1;				//bit 7 resetved
-			//InfoVal[20]
-			unsigned char :4;						//bit 0~3 reserved
-			unsigned char CcsSupportedAppProtocolRes:1;			//bit 4
-			unsigned char CcsSessionSetupRes:1;				//bit 5
-			unsigned char CcsServiceDiscoveryRes:1;				//bit 6
-			unsigned char CcsServicePaymentSelectionRes:1;		//bit 7
-			//InfoVal[21]
-			unsigned char CcsContractAuthenticationRes:1;			//bit 0
-			unsigned char CcsChargeParameterDiscoveryRes:1;			//bit 1
-			unsigned char CcsPowerDeliveryRes:1;			//bit 2
-			unsigned char CcsCableCheckRes:1;			//bit 3
-			unsigned char CcsPreChargeRes:1;					//bit 4
-			unsigned char CcsCurrentDemandRes:1;					//bit 5
-			unsigned char CcsWeldingDetectionRes:1;				//bit 6
-			unsigned char CcsSessionStopRes:1;					//bit 7
-			//InfoVal[22]
-			unsigned char CcsSequence_Time:1;						//bit 0
-			unsigned char CcsReadyToCharge_Performance_Time:1;				//bit 1
-			unsigned char CcsCommunicationSetup_Performance_Time:1;					//bit 2
-			unsigned char CcsCableCheck_Performance_Time:1;				//bit 3
-			unsigned char CcsCPState_Detection_Time:1;			//bit 4
-			unsigned char CcsCPOscillator_Retain_Time:1;					//bit 5
-			unsigned char CcsSeccTimeoutV2GPreChargePerformaceTime:1;			//bit 6
-			unsigned char :1;			//bit 7 reserved
-			//InfoVal[23]
-			unsigned char :3;					//bit 0~2 reserved
-			unsigned char CcsTP_GET_EV_TARGET_INFO:1;			//bit 3
-			unsigned char CcsTT_GET_EV_TARGET_INFO:1;		//bit 4
-			unsigned char CcsTP_GET_EV_BATTERY_INFO:1;		//bit 5
-			unsigned char CcsTT_GET_EV_BATTERY_INFO:1;		//bit 6
-			unsigned char CcsTP_EV_STOP_EVENT:1;				//bit 7
-			//InfoVal[24]
-			unsigned char CcsTT_EV_STOP_EVENT:1;			//bit 0
-			unsigned char CcsTP_EVSE_STOP_EVENT:1;			//bit 1
-			unsigned char CcsTT_EVSE_STOP_EVENT:1;			//bit 2
-			unsigned char CcsTP_GET_MISC_INFO:1;			//bit 3
-			unsigned char CcsTT_GET_MISC_INFO:1;			//bit 4
-			unsigned char CcsTP_DOWNLOAD_REQUEST:1;			//bit 5
-			unsigned char CcsTT_DOWNLOAD_REQUEST:1;			//bit 6
-			unsigned char CcsTP_START_BLOCK_TRANSFER:1;			//bit 7
-			//InfoVal[25]
-			unsigned char CcsTT_START_BLOCK_TRANSFER:1;		//bit 0
-			unsigned char CcsTP_DATA_TRANSFER:1;			//bit 1
-			unsigned char CcsTT_DATA_TRANSFER:1;			//bit 2
-			unsigned char CcsTP_DOWNLOAD_FINISH:1;			//bit 3
-			unsigned char CcsTT_DOWNLOAD_FINISH:1;			//bit 4
-			unsigned char CcsTP_ISOLATION_STATUS:1;			//bit 5
-			unsigned char CcsTT_ISOLATION_STATUS:1;			//bit 6
-			unsigned char CcsTP_CONNECTOR_INFO:1;			//bit 7
-			//InfoVal[26]
-			unsigned char CcsTT_CONNECTOR_INFO:1;			//bit 0
-			unsigned char CcsTT_RTC_INFO:1;				//bit 1
-			unsigned char CcsTP_RTC_INFO:1;			//bit 2
-			unsigned char CcsTP_EVSE_PRECHARGE_INFO:1;		//bit 3
-			unsigned char CcsTT_EVSE_PRECHARGE_INFO:1;			//bit 4
-			unsigned char CcsMSG_Sequence:1;			//bit 5
-			unsigned char CcsCAN_MSG_Unrecognized_CMD_ID:1;			//bit 6
-			unsigned char CcsDIN_Msg_Decode_Error:1;			//bit 7
-			//InfoVal[27]
-			unsigned char CcsDIN_Msg_Encode_Error:1;			//bit 0
-			unsigned char CcsISO1_Msg_Decode_Error:1;			//bit 1
-			unsigned char CcsISO1_Msg_Encode_Error:1;			//bit 2
-			unsigned char CcsISO2_Msg_Decode_Error:1;			//bit 3
-			unsigned char CcsISO2_Msg_Encode_Error:1;			//bit 4
-			unsigned char CcsCpStatus_Error:1;					//bit 5
-			unsigned char CcsUnexpectVolBeforeCharing_Error:1;	//bit 6
-			unsigned char CcsSeccNotReadyForCharging:1;			//bit 7 reserved
-			//InfoVal[28]
-			unsigned char CcsSeccTimeoutQCA7000Comm:1;			//bit 0
-			unsigned char CcsSeccFailForQCA7000SetKey:1;		//bit 1
-			unsigned char :6;									//bit 2~7 reserved
-			//InfoVal[29]
-			unsigned char ERROR_CODE_GBT_LOS_CC1 :1;									//bit 0
-			unsigned char ERROR_CODE_GBT_CONNECTOR_LOCK_FAIL :1;						//bit 1
-			unsigned char ERROR_CODE_GBT_BATTERY_INCOMPATIBLE :1;						//bit 2
-			unsigned char ERROR_CODE_GBT_BMS_BROAA_TIMEOUT :1;							//bit 3
-			unsigned char ERROR_CODE_GBT_CSU_PRECHARGE_TIMEOUT :1;						//bit 4
-			unsigned char ERROR_CODE_GBT_BMS_PRESENT_VOLTAGE_FAULT :1;					//bit 5
-			unsigned char ERROR_CODE_GBT_BMS_VOLTAGE_OVER_RANGE :1;						//bit 6
-			unsigned char ERROR_CODE_GBT_BSM_CHARGE_ALLOW_00_10MIN_COUUNTDONE :1;		//bit 7
-			//InfoVal[30]
-			unsigned char ERROR_CODE_GBT_WAIT_GROUNDFAULT_TIMEOUT :1;					//bit 0
-			unsigned char ERROR_CODE_GBT_ADC_MORE_THAN_10V :1;							//bit 1
-			unsigned char ERROR_CODE_GBT_ADC_MORE_THAN_60V :1;							//bit 2
-			unsigned char ERROR_CODE_GBT_CHARGER_GET_NORMAL_STOP_CMD :1;				//bit 3
-			unsigned char ERROR_CODE_GBT_CHARGER_GET_EMERGENCY_STOP_CMD :1;				//bit 4
-			unsigned char ERROR_CODE_GBT_ISOLATION_RESULT_FAIL :1;						//bit 5
-			unsigned char ERROR_CODE_GBT_MOTHER_BOARD_MISS_LINK :1;						//bit 6
-			unsigned char ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_LIMIT :1;				//bit 7
-			//InfoVal[31]
-			unsigned char ERROR_CODE_GBT_REQ_CURRENT_MORE_THAN_LIMIT :1;				//bit 0
-			unsigned char ERROR_CODE_GBT_OUTPUT_VOLTAGE_MORE_THAN_10_PERCENT :1;		//bit 1
-			unsigned char ERROR_CODE_GBT_OUTPUT_VOLTAGE_DIFF_BCS_5_PERCENT :1;			//bit 2
-			unsigned char ERROR_CODE_GBT_STOP_ADC_MORE_THAN_10V :1;						//bit 3
-			unsigned char :4;															//bit 4 ~ 7 reserved
-			//InfoVal[32]
-			unsigned char :6;															//bit 0 ~ 5 reserved
-			unsigned char ERROR_CODE_CEM_BHM_TIMEOUT :1;								//bit 6
-			unsigned char ERROR_CODE_CEM_BRM_TIMEOUT :1;								//bit 7
-			//InfoVal[33]
-			unsigned char ERROR_CODE_CEM_BCP_TIMEOUT :1;								//bit 0
-			unsigned char ERROR_CODE_CEM_BRO_TIMEOUT :1;								//bit 1
-			unsigned char ERROR_CODE_CEM_BCL_TIMEOUT :1;								//bit 2
-			unsigned char ERROR_CODE_CEM_BCS_TIMEOUT :1;								//bit 3
-			unsigned char ERROR_CODE_CEM_BSM_TIMEOUT :1;								//bit 4
-			unsigned char ERROR_CODE_CEM_BST_TIMEOUT :1;								//bit 5
-			unsigned char ERROR_CODE_CEM_BSD_TIMEOUT :1;								//bit 6
-			unsigned char ERROR_CODE_CEM_BEM_OTHER_TIMEOUT :1;							//bit 7
-			//InfoVal[34]
-			unsigned char ERROR_CODE_BEM_CRM_TIMEOUT :1;			//bit 0
-			unsigned char ERROR_CODE_BEM_CRMAA_TIMEOUT :1;			//bit 1
-			unsigned char ERROR_CODE_BEM_CTS_CML_TIMEOUT :1;		//bit 2
-			unsigned char ERROR_CODE_BEM_CRO_TIMEOUT :1;			//bit 3
-			unsigned char ERROR_CODE_BEM_CCS_TIMEOUT :1;			//bit 4
-			unsigned char ERROR_CODE_BEM_CST_TIMEOUT :1;			//bit 5
-			unsigned char ERROR_CODE_BEM_CSD_TIMEOUT :1;			//bit 6
-			unsigned char ERROR_CODE_BEM_BEM_OTHER_TIMEOUT :1;		//bit 7
-			//InfoVal[35]
-			unsigned char :2;										//bit 0 ~ 1
-			unsigned char ERROR_CODE_BST_SOC_GOAL :1;				//bit 2
-			unsigned char ERROR_CODE_BST_TOTAL_VOLTAGE_GOAL :1;		//bit 3
-			unsigned char ERROR_CODE_BST_CELL_VOLTAGE_GOAL :1;		//bit 4
-			unsigned char ERROR_CODE_BST_GET_CST :1;				//bit 5
-			unsigned char ERROR_CODE_BST_ISOLATION :1;				//bit 6
-			unsigned char ERROR_CODE_BST_OUTPUT_CONNECTOR_OTP :1;	//bit 7
-			//InfoVal[36]
-			unsigned char ERROR_CODE_BST_COMPONENT :1;				//bit 0
-			unsigned char ERROR_CODE_BST_CHARGE_CONNECTOR :1;		//bit 1
-			unsigned char ERROR_CODE_BST_OTP :1;					//bit 2
-			unsigned char ERROR_CODE_BST_OTHER :1;					//bit 3
-			unsigned char ERROR_CODE_BST_HIGH_V :1;					//bit 4
-			unsigned char ERROR_CODE_BST_CC2 :1;					//bit 5
-			unsigned char ERROR_CODE_BST_CURRENT :1;				//bit 6
-			unsigned char ERROR_CODE_BST_VOLTAGE :1;				//bit 7
-			//InfoVal[37]
-			unsigned char ERROR_CODE_GET_BST_NO_REASON :1;			//bit 0
-			unsigned char :5;										//bit 1 ~ 5 reserved
-			unsigned char ERROR_CODE_BSM_CELL_OVER_VOLTAGE :1;		//bit 6
-			unsigned char ERROR_CODE_BSM_CELL_UNDER_VOLTAGE :1;		//bit 7
-			//InfoVal[38]
-			unsigned char ERROR_CODE_BSM_OVER_SOC :1;				//bit 0
-			unsigned char ERROR_CODE_BSM_UNDER_SOC :1;				//bit 1
-			unsigned char ERROR_CODE_BSM_CURRENT :1;				//bit 2
-			unsigned char ERROR_CODE_BSM_TEMPERATURE :1;			//bit 3
-			unsigned char ERROR_CODE_BSM_ISOLATE :1;				//bit 4
-			unsigned char ERROR_CODE_BSM_OUTPUT_CONNECTOR :1;		//bit 5
-			unsigned char :2;										//bit 6 ~ 7	reserved
-			//InfoVal[39]
-			unsigned char BackendDisconnectedViaEthernet:1;			//bit 0
-			unsigned char BackendDisconnectViaWiFi:1;				//bit 1
-			unsigned char BackendDisconnectVia4G:1;					//bit 2
-			unsigned char BackendRemoteStart:1;						//bit 3
-			unsigned char BackendRemoteStop:1;						//bit 4
-			unsigned char BackendRemoteReset:1;						//bit 5
-			unsigned char AuthorizationFailed:1;					//bit 6
-			unsigned char :1;										//bit 7	reserved
-		}bits;
-	}InfoEvents;
-};
-
-struct StatusCodeData
-{
-	struct FaultCodeData	FaultCode;
-	struct AlarmCodeData	AlarmCode;
-	struct InfoCodeData		InfoCode;
-};
-/**************************************************************************************/
-/**************************PSU Share memory***************************************/
-/**************************************************************************************/
-struct PsuModuleVer
-{
-	unsigned char 		FwPrimaryVersion[16];
-	unsigned char 		FwSecondVersion[16];
-};
-
-/*Following are the information for each PSU module*/
-struct PsuModuleData
-{
-	unsigned char 		AssignID;
-	unsigned char 		PhysicalID;
-	unsigned char 		GroupID;
-	unsigned char 		Address;
-	unsigned char 		FireWireIndex;
-	unsigned char 		FwVersion[16];
-	unsigned char 		SerialNumber[32];
-	unsigned char 		StateMachine;			//0: Identification,  1:Operation,  2: Alarm,  3: Failure,  s4:Upgrade
-	unsigned char 		OutputPowerSwitch;	//0: D.D normal OFF,  1: D.D emergency OFF,  2: D.D ON
-	unsigned short 	FanSpeed_1;			//RPM
-	unsigned short 	FanSpeed_2;			//RPM
-	unsigned short 	FanSpeed_3;			//RPM
-	unsigned short 	FanSpeed_4;			//RPM
-	unsigned short 	InputVoltage_Type;	//0x00 = Line to Line Vol, 0x01 = Line to Neutral Vol
-	unsigned short 	InputVoltageL1;		//abcd=abc.d volt
-	unsigned short 	InputVoltageL2;		//abcd=abc.d volt
-	unsigned short 	InputVoltageL3;		//abcd=abc.d volt
-	unsigned short 	InputCurrentL1;		//abcd=abc.d amp
-	unsigned short 	InputCurrentL2;		//abcd=abc.d amp
-	unsigned short 	InputCurrentL3;		//abcd=abc.d amp
-	unsigned short 	PresentOutputVoltage;	//abcd=abc.d volt
-	unsigned short 	PresentOutputCurrent;	//abcd=abc.d amp
-	unsigned short 	AvailableCurrent;		//abcd=abc.d amp
-	unsigned int 		AvailablePower;		//abcd=abc.d kWatt
-	char 				CriticalTemp1;			//0x00: -60ツ「XC  ~  0xFE: 194ツ「XC, resolution: 1ツ「XC, offset: -60ツ「XC, 0xFF: invalid
-	char 				CriticalTemp2;			//0x00: -60ツ「XC  ~  0xFE: 194ツ「XC, resolution: 1ツ「XC, offset: -60ツ「XC, 0xFF: invalid
-	char 				CriticalTemp3;			//0x00: -60ツ「XC  ~  0xFE: 194ツ「XC, resolution: 1ツ「XC, offset: -60ツ「XC, 0xFF: invalid
-	char 				ExletTemp;			//0x00: -60ツ「XC  ~  0xFE: 194ツ「XC, resolution: 1ツ「XC, offset: -60ツ「XC, 0xFF: invalid
-	char 				InletTemp_1;			//0x00: -60ツ「XC  ~  0xFE: 194ツ「XC, resolution: 1ツ「XC, offset: -60ツ「XC, 0xFF: invalid
-	char 				InletTemp_2;			//0x00: -60ツ「XC  ~  0xFE: 194ツ「XC, resolution: 1ツ「XC, offset: -60ツ「XC, 0xFF: invalid
-	char 				InletTemp;			//0x00: -60ツ「XC  ~  0xFE: 194ツ「XC, resolution: 1ツ「XC, offset: -60ツ「XC, 0xFF: invalid
-	char 				OutletTemp;			//0x00: -60ツ「XC  ~  0xFE: 194ツ「XC, resolution: 1ツ「XC, offset: -60ツ「XC, 0xFF: invalid
-	unsigned int 		AlarmCode;
-	unsigned int 		FaultCode;			//
-	unsigned int 		IAvailableCurrent;		//abcd=abc.d amp
-};
-
-/*Following are the information for each PSU Group*/
-struct PsuGroupData
-{
-	unsigned char 			GroupPresentPsuQuantity;
-	unsigned char 			GroupOutputPowerSwitch;		//0: D.D normal OFF,  1: D.D emergency OFF,  2: D.D ON
-	unsigned short 		GroupTargetOutputVoltage;		//abcd=abc.d volt
-	unsigned short 		GroupTargetOutputCurrent;		//abcd=abc.d amp
-	unsigned short 		GroupAvailableCurrent;			//abcd=abc.d amp
-	unsigned int 			GroupAvailablePower;			//abcd=abc.d kWatt
-	unsigned int		GroupRealOutputPower;		//Watt
-	unsigned short 		GroupPresentOutputVoltage; 	//abcd=abc.d volt
-	unsigned short 		GroupPresentOutputCurrent;		//abcd=abc.d Amps
-	unsigned int		GroupPresentOutputPower;	//Watt
-	struct PsuModuleData 	PsuModule[MAX_PSU_QUANTITY];
-};
-
-/*Following is the information for system all PSU*/
-struct PsuData
-{
-	unsigned char 			SystemPresentPsuQuantity;
-	unsigned short 		SystemAvailableCurrent;			//abcd=abc.d amp
-	unsigned int 			SystemAvailablePower;			//Watt
-	struct PsuGroupData 	PsuGroup[4];
-	unsigned char 			GroupCount;
-	unsigned char 			Work_Step;
-	struct PsuModuleVer		PsuVersion[MAX_PSU_QUANTITY];
-};
-
-/************************************************************************************/
-/**************************CHAdeMO protocol Share memory*********************/
-/**************************************************************************************/
-struct CHAdeMOEvData
-{
-	unsigned char  SupportDynamicControl;	//110.0
-										//					bit0=1:supported
-	unsigned char  SupportHighCurrent;		//110.0
-										//					bit1=1:supported
-	unsigned char  MiniChargeCurrent;		//100.0				0~200(A) (unit:1A)
-										//					0x00: request for current equivalent to 1.5kW
-										//					0x01: no request
-										//					0x02: request of 1A and following are the same rule
-	unsigned short MaxiBatteryVoltage;		//100.5,100.4 			0~600(V) (unit:1V)
-	unsigned short MaxiChargingTime;			//101.2,101.1			10(sec.)~255(min.)	(Unit:sec)
-										//					Set 0xFF to 101.1 (Unit: 10sec) in case 101.2 (Unit: 1min) is used
-	unsigned char  EstimatChargingTime;		//101.3				0~254(min.)	(Unit:sec)
-										//					Display Only
-	unsigned short TotalBatteryCapacity;		//101.6,101.5 			0.1~6553.5(kWh)	(unit:0.1 kWh)
-	unsigned char  ProtocolVersion;			//102.0				0~255
-										//					0x02: CHAdeMO specification ver.1.2
-	unsigned short TargetBatteryVoltage;		//102.2,102.1 			0~600(V) (unit:1V)
-	unsigned short ChargingCurrentRequest;	//102.3				0~200(A) (unit:1A)
-										//110.2,110.1 			0~1023(A) (unit:1A)
-	unsigned char  BatteryAlarm;				//102.4				>0:alarm
-										//					bit0=1:Battery overvoltage
-										//					bit1=1:Battery undervoltage
-										//					bit2=1:Battery current deviation error
-										//					bit3=1:High battery temperature
-										//					bit4=1:Battery voltage deviation error
-	unsigned char  EvDetection;				//102.5
-										//					bit0=0:Vehicle charging disabled,	(stop charging)
-										//					bit0=1:Vehicle charging enabled,
-										//					bit1=0:ツ。ツァParkingツ。ツィ position
-										//					bit1=1:other position				(stop charging)
-										//					bit2=0:Charging system normal
-										//					bit2=1:Charging system error		(stop charging)
-										//					bit3=0:EV contactor close or during welding detection
-										//					bit3=1:EV contactor open or termination of welding detection (stop charging)
-										//					bit4=0:No stop request before charging
-										//					bit4=1:Normal stop request before charging	(stop charging)
-	unsigned char  SOC;					//102.6				0~100(%) (unit:%)
-										//					Display Only
-	unsigned char  Communicating;			//					it is true if receive EV CAN message within every 1500ms
-	unsigned char  PresentMsgFlowStatus;	//
-};
-
-struct CHAdeMOEvseData
-{
-	unsigned char 	SelfTest_Comp;
-	unsigned char	version[16];									//Chademo firmware version
-	unsigned char  SupportDynamicControl;	//118.0
-										//					bit0=1:supported
-	unsigned char  SupportHighCurrent;		//118.0
-										//					bit1=1:supported
-	unsigned short  AvailableOutputVoltage;	//108.2,108.1 			0~600(V) (unit:1V)
-	unsigned short  AvailableOutputCurrent;	//108.3				0~255(A) (unit:1A)
-										//118.2,118.1 			0~1023(A) (unit:1A)
-	unsigned short  ThresholdVoltage;			//108.5,108.4 			0~600(V) (unit:1V)
-	unsigned char   ConnectorTemperatureP;	//108.6				-40~215(degC) (unit:degC) //value 0=-40	[NISSAN customized]
-	unsigned char   ConnectorTemperatureN;	//108.7				-40~215(degC) (unit:degC) //value 0=-40	[NISSAN customized]
-	unsigned char   ProtocolVersion;			//109.0				0~255
-										//					0x00: CHAdeMO specification 0.9 and earlier
-										//					0x01: CHAdeMO specification 0.9 and 0.9.1
-										//					0x02: CHAdeMO specification 1.0.0, 1.0.1, 1.1 and 1.2
-	unsigned short  PresentOutputVoltage;		//109.2,109.1	 		0~600(V) (unit:1V)
-	unsigned short   PresentOutputCurrent;		//109.3				0~255(A) (unit:1A)
-										//118.4,118.3			0~1023(A) (unit:1A)
-	unsigned char   EvseDetection;			//109.5
-										//					bit0=0:not charging state now
-										//					bit0=1:charging state now
-										//					bit1=0:EVSE normal
-										//					bit1=1:EVSE error
-										//					bit2=0:Not Energizing state
-										//					bit2=1:Energizing state
-										//					bit3=0:No Battery incompatibility
-										//					bit3=1:Battery incompatibility
-										//					bit4=0:No Charging system error
-										//					bit4=1:Charging system error
-										//					bit5=0:No Charging stop control
-										//					bit5=1:Charging stop control
-	unsigned short RemainChargingTime;		//109.7,109.6			10(sec.)~255(min.)	(Unit:sec)
-										//					Set 0xFF to 109.6 (Unit: 10sec) in case 109.7 (Unit: 1min) is used
-	unsigned char  HighPowerCondition;		//118.5
-										//					bit0=0:Present charging current Hツ。ツヲ118.3,Hツ。ツヲ118.4ツ。ツィ is less than or equal to rated current of a charging cable
-										//					bit0=1:Present charging current Hツ。ツヲ118.3,Hツ。ツヲ118.4ツ。ツィ is exceeds to rated current of a charging cable
-										//					bit1=1:charging cable Cooling function Operating Installed
-										//					bit2=1:charging cable Current limiting function
-										//					bit3=1:charging connector Cooling function Operating
-										//					bit4=1:charging connector Current limiting function Installed
-										//					bit5=1:charging connector Over-temperature protection Installed
-										//					bit6=1:Functional safety Applied
-	unsigned int 	MaxiGroupPower;			//					XXXXXXXX (Unit:Watt)depend on which group to be used
-	unsigned int 	MaxiGroupCurrent;			//					XXXXXXXX (unit:1A)depend on which group to be used
-	unsigned short  ApplyOutputVoltage;		// 					0~600(V) (unit:1V)
-	unsigned short  ElapseChargingTime;		//					(Unit:sec)
-	unsigned short  ElapseEnergy;				//					(Unit:10xkWh)
-	unsigned char	EvboardStatus;			// 	0 : init
-};
-
-struct CHAdeMOData
-{
-	struct CHAdeMOEvData 		ev[CHAdeMO_QUANTITY];
-	struct CHAdeMOEvseData 	evse[CHAdeMO_QUANTITY];
-};
-
-/************************************************************************************/
-/**************************GBT protocol Share memory*********************/
-/**************************************************************************************/
-struct GBTEvData
-{
-	unsigned short MaxiBatteryVoltage;		// 0~600(V) (unit:1V)
-	unsigned short MaxiChargingTime;		// 10(sec.)~255(min.)	(Unit:sec)
-
-	unsigned char  EstimatChargingTime;		// 0~254(min.)	(Unit:sec)
-
-	unsigned short TotalBatteryCapacity;	// 0.1~6553.5(kWh)	(unit:0.1 kWh)
-	unsigned char  ProtocolVersion;			// 0~255
-
-	unsigned short TargetBatteryVoltage;	// 0~600(V) (unit:1V)
-	unsigned short ChargingCurrentRequest;	// 0~200(A) (unit:1A)
-											// 0~1023(A) (unit:1A)
-
-	unsigned char  EvDetection;				//102.5
-										//					bit0=0:Vehicle charging disabled,	(stop charging)
-										//					bit0=1:Vehicle charging enabled,
-										//					bit1=0:ツ。ツァParkingツ。ツィ position
-										//					bit1=1:other position				(stop charging)
-										//					bit2=0:Charging system normal
-										//					bit2=1:Charging system error		(stop charging)
-										//					bit3=0:EV contactor close or during welding detection
-										//					bit3=1:EV contactor open or termination of welding detection (stop charging)
-										//					bit4=0:No stop request before charging
-										//					bit4=1:Normal stop request before charging	(stop charging)
-	unsigned char  SOC;					//102.6				0~100(%) (unit:%)
-										//					Display Only
-	unsigned char  PresentMsgFlowStatus;	//
-};
-
-struct GBTEvseData
-{
-	unsigned char 	SelfTest_Comp;
-	unsigned char	version[16];				// GBT firmware version
-
-	unsigned short  AvailableOutputVoltage;		// 0~600(V) (unit:1V)
-	unsigned short  AvailableOutputCurrent;		// 0~255(A) (unit:1A)
-
-	unsigned char   ConnectorTemperatureP;	// -40~215(degC) (unit:degC) //value 0=-40	[NISSAN customized]
-	unsigned char   ConnectorTemperatureN;	// -40~215(degC) (unit:degC) //value 0=-40	[NISSAN customized]
-
-	unsigned short  PresentOutputVoltage;		// 0~600(V) (unit:1V)
-	unsigned short  PresentOutputCurrent;		// 0~255(A) (unit:1A)
-
-	unsigned short RemainChargingTime;		//109.7,109.6			10(sec.)~255(min.)	(Unit:sec)
-	unsigned char	EvboardStatus;			// 	0 : init
-};
-
-struct GBTData
-{
-	struct GBTEvData 		ev[GB_QUANTITY];
-	struct GBTEvseData 		evse[GB_QUANTITY];
-};
-
-/************************************************************************************/
-/**************************CCS protocol Share memory***************************/
-/**************************DIN70121: 201412***************************************/
-/**************************ISO15118_2014: 2014************************************/
-/**************************ISO15118_2018: 2018************************************/
-/************************************************************************************/
-typedef enum boolean { FALSE, TRUE } BOOL;
-enum ResponseCodeType_DIN70121		{ OK_DIN70121 = 0, OK_NewSessionEstablished_DIN70121 = 1, OK_OldSessionJoined_DIN70121 = 2, OK_CertificateExpiresSoon_DIN70121 = 3,
-									   FAILED_DIN70121 = 4, FAILED_SequenceError_DIN70121 = 5, FAILED_ServiceIDInvalid_DIN70121 = 6, FAILED_UnknownSession_DIN70121 = 7,
-									   FAILED_ServiceSelectionInvalid_DIN70121 = 8, FAILED_PaymentSelectionInvalid_DIN70121 = 9, FAILED_CertificateExpired_DIN70121 = 10,
-									   FAILED_SignatureError_DIN70121 = 11, FAILED_NoCertificateAvailable_DIN70121 = 12, FAILED_CertChainError_DIN70121 = 13, FAILED_ChallengeInvalid_DIN70121 = 14,
-									   FAILED_ContractCanceled_DIN70121 = 15, FAILED_WrongChargeParameter_DIN70121 = 16, FAILED_PowerDeliveryNotApplied_DIN70121 = 17,
-									   FAILED_TariffSelectionInvalid_DIN70121 = 18, FAILED_ChargingProfileInvalid_DIN70121 = 19, FAILED_EVSEPresentVoltageToLow_DIN70121 = 20,
-									   FAILED_MeteringSignatureNotValid_DIN70121 = 21, FAILED_WrongEnergyTransferType_DIN70121 = 22};
-enum ResponseCodeType_ISO15118_2014	{ OK_ISO15118_2014 = 0, OK_NewSessionEstablished_ISO15118_2014 = 1, OK_OldSessionJoined_ISO15118_2014 = 2, OK_CertificateExpiresSoon_ISO15118_2014 = 3,
-									   FAILED_ISO15118_2014 = 4, FAILED_SequenceError_ISO15118_2014 = 5, FAILED_ServiceIDInvalid_ISO15118_2014 = 6, FAILED_UnknownSession_ISO15118_2014 = 7,
-									   FAILED_ServiceSelectionInvalid_ISO15118_2014 = 8, FAILED_PaymentSelectionInvalid_ISO15118_2014 = 9, FAILED_CertificateExpired_ISO15118_2014 = 10,
-									   FAILED_SignatureError_ISO15118_2014 = 11, FAILED_NoCertificateAvailable_ISO15118_2014 = 12, FAILED_CertChainError_ISO15118_2014 = 13, FAILED_ChallengeInvalid_ISO15118_2014 = 14,
-									   FAILED_ContractCanceled_ISO15118_2014 = 15, FAILED_WrongChargeParameter_ISO15118_2014 = 16, FAILED_PowerDeliveryNotApplied_ISO15118_2014 = 17,
-									   FAILED_TariffSelectionInvalid_ISO15118_2014 = 18, FAILED_ChargingProfileInvalid_ISO15118_2014 = 19, FAILED_MeteringSignatureNotValid_ISO15118_2014 = 20,
-									   FAILED_NoChargeServiceSelected_ISO15118_2014 = 21, FAILED_WrongEnergyTransferMode_ISO15118_2014 = 22, FAILED_ContactorError_ISO15118_2014 = 23,
-									   FAILED_CertificateNotAllowedAtThisEVSE_ISO15118_2014 = 24, FAILED_CertificateRevoked_ISO15118_2014 = 25  };
-enum ResponseCodeType_ISO15118_2018	{ OK_ISO15118_2018 = 0, OK_NewSessionEstablished_ISO15118_2018 = 1, OK_OldSessionJoined_ISO15118_2018 = 2, OK_CertificateExpiresSoon_ISO15118_2018 = 3,
-									   OK_IsolationValid_ISO15118_2018 = 4, OK_IsolationWarning_ISO15118_2018 = 5, WARNING_CertificateExpired_ISO15118_2018 = 6, WARNING_NoCertificateAvailable_ISO15118_2018 = 7,
-									   WARNING_CertValidationError_ISO15118_2018 = 8, WARNING_CertVerificationError_ISO15118_2018 = 9, WARNING_ContractCanceled_ISO15118_2018 = 10,
-									   FAILED_ISO15118_2018 = 11, FAILED_SequenceError_ISO15118_2018 = 12, FAILED_ServiceIDInvalid_ISO15118_2018 = 13, FAILED_UnknownSession_ISO15118_2018 = 14,
-									   FAILED_ServiceSelectionInvalid_ISO15118_2018 = 15, FAILED_SignatureError_ISO15118_2018 = 16, FAILED_IdentificationSelectionInvalid_ISO15118_2018 = 17,
-									   FAILED_ChallengeInvalid_ISO15118_2018 = 18, FAILED_WrongChargeParameter_ISO15118_2018 = 19, FAILED_IsolationFault_ISO15118_2018 = 20,
-									   FAILED_PowerDeliveryNotApplied_ISO15118_2018 = 21, FAILED_TariffSelectionInvalid_ISO15118_2018 = 22, FAILED_ChargingProfileInvalid_ISO15118_2018 = 23,
-									   FAILED_MeteringSignatureNotValid_ISO15118_2018 = 24, FAILED_NoChargeServiceSelected_ISO15118_2018 = 25, FAILED_WrongEnergyTransferMode_ISO15118_2018 = 26,
-									   FAILED_ContactorError_ISO15118_2018 = 27, FAILED_CertificateRevoked_ISO15118_2018 = 28, FAILED_CertificateNotYetValid_ISO15118_2018 = 29 };
-enum EVSENotificationType		 		{ None = 0, StopCharging = 1, ReNegotiation = 2};
-enum ServiceCategoryType 				{ EVCharging = 0, Internet = 1, ContractCertificate = 2, OtherCustom = 3};
-enum PaymentOptionType 		      		{ Contract = 0, ExternalPayment = 1};
-/*enum EVSESupportedEnergyTransferType 	{ AC_single_phase_core = 0, AC_three_phase_core = 1, DC_core = 2, DC_extended = 3,
-									  DC_combo_core = 4, DC_dual = 5, AC_core1p_DC_extended = 6, AC_single_DC_core = 7,
-									  AC_single_phase_three_phase_core_DC_extended = 8, AC_core3p_DC_extended = 9};*/
-enum EnergyTransferModeType			{ AC_single_phase_core = 0, AC_three_phase_core = 1, DC_core = 2, DC_extended = 3,
-									  DC_combo_core = 4, DC_unique = 5};
-//enum identificationOptionType 			{ Contract = 0, ExternalIdentification = 1};
-enum unitSymbolType_DIN70121			{ h_DIN70121 = 0, m_DIN70121 = 1, s_DIN70121 = 2, A_DIN70121 = 3, Ah_DIN70121 = 4, V_DIN70121 = 5, VA_DIN70121 = 6, W_DIN70121 = 7, Ws_DIN70121 = 8, Wh_DIN70121 = 9};
-enum unitSymbolType_ISO15118_2014		{ h_ISO15118_2014 = 0, m_ISO15118_2014 = 1, s_ISO15118_2014 = 2, A_ISO15118_2014 = 3, V_ISO15118_2014 = 4, W_ISO15118_2014 = 5, Wh_ISO15118_2014 = 6};
-enum ProcessingType					{ Finished = 0, Ongoing = 1, Ongoing_WaitingForCustomerInteraction = 2};
-enum EVSEProcessingType_DIN70121		{ Finished_DIN70121 = 0, Ongoing_DIN70121 = 1};
-enum EVSEProcessingType_ISO15118_2014	{ Finished_ISO15118_2014 = 0, Ongoing_ISO15118_2014 = 1, Ongoing_WaitingForCustomerInteraction_ISO15118_2014=2 };
-enum DC_EVErrorCodeType 		  		{ NO_ERROR = 0, FAILED_RESSTemperatureInhibit = 1, FAILED_EVShiftPosition = 2, FAILED_ChargerConnectorLockFault = 3,
-									  FAILED_EVRESSMalfunction = 4, FAILED_ChargingCurrentdifferential = 5, FAILED_ChargingVoltageOutOfRange = 6,
-									  Reserved_A = 7, Reserved_B = 8, Reserved_C = 9, FAILED_ChargingSystemIncompatibility = 10, NoData = 11};
-enum IsolationLevelType_DIN70121 		{ Invalid_DIN70121 = 0, Valid_DIN70121 = 1, Warning_DIN70121 = 2, Fault_DIN70121 = 3};
-enum IsolationLevelType_ISO15118_2014		{ Invalid_ISO15118_2014 = 0, Valid_ISO15118_2014 = 1, Warning_ISO15118_2014 = 2, Fault_ISO15118_2014 = 3, No_IMD_ISO15118_2014	 = 4};
-enum DC_EVSEStatusCodeType			{ EVSE_NotReady = 0, EVSE_Ready = 1, EVSE_Shutdown = 2, EVSE_UtilityInterruptEvent = 3,
-						 			  EVSE_IsolationMonitoringActive = 4, EVSE_EmergencyShutdown = 5, EVSE_Malfunction = 6,
-						 			  Reserved_8 = 7, Reserved_9 = 8};
-enum ScheduleOriginType				{ EV = 0, SA = 1};
-enum ChargeProgressType_ISO15118_2014	{start_ISO15118_2014 = 0, Stop_ISO15118_2014 = 1, Renegotiate_ISO15118_2014 = 2};
-enum ChargeProgressType_ISO15118_2018	{start_ISO15118_2018 = 0, Renegotiate_ISO15118_2018 = 1, Standby_ISO15118_2018 = 2, Stop_ISO15118_2018 = 3};
-enum evOperationType					{Charge = 0, Discharge = 1, Standby = 2};
-enum mechanicalChargingDeviceStatusType {Home = 0, Moving = 1, EndPosition = 2};
-enum EV_CP_StatusType					{A = 0, B = 1, C = 2, D = 3, E = 4, F = 5};
-enum EV_Error_Status_CodeType			{ No_EV_Error = 0, EV_FAILED_EmergencyEvent = 1, EV_FAILED_Breaker = 2, EV_FAILED_RESSTemperatureInhibit = 3,
-						 			  EV_FAILED_RESS = 4, EV_FAILED_ChargingCurrentDifferential = 5, EV_FAILED_ChargingVoltageOutOfRange = 6,
-						 			  Reserved_by_ISO_1 = 7,  Reserved_by_ISO_2 = 8, Reserved_by_ISO_3 = 9, OEM1 = 10,
-						 			  OEM2 = 11,  OEM3 = 12, OEM4 = 13};
-enum IsolationStatusType				{ Invalid = 0, Safe = 1, Warning = 2, Fault = 3};
-enum ChargingSessionType				{ Terminate = 0, Pause = 1};
-enum CostKindType						{ relativePricePercentage = 0, RenewableGenerationPercentage = 1, CarbonDioxideEmission = 2};
-
-
-
-struct PhysicalValueType_DIN70121 				//The final physical value is determined by: Value * 10 ^ Multiplier [Unit]
-{
-	int									Multiplier;			//range: -3..+3
-	enum unitSymbolType_DIN70121			Unit;
-	short 								Value;
-};
-struct PhysicalValueType_ISO15118_2014			//The final physical value is determined by: Value * 10 ^ Multiplier [Unit]
-{
-	int									Multiplier;			//range: -3..+3
-	enum unitSymbolType_ISO15118_2014		Unit;
-	short 								Value;
-};
-struct PhysicalValueType_ISO15118_2018			//The final physical value is determined by: Value * 10 ^ Exponent [Unit]
-{
-	int									Exponent;		//range: -3..+3
-	short 								Value;
-};
-struct AppProtocolType
-{
-	unsigned char	ProtocolNamespace[100];
-	unsigned int	VersionNumberMajor;
-	unsigned int	VersionNumberMinor;
-	unsigned char	SchemaID;
-	unsigned char	Priority;					//range 1..20
-};
-struct ACD_SSEnergyTransferModeType
-{
-	unsigned char	EVID[20];
-};
-struct EVSEStatusType
-{
-	unsigned short				NotificationMaxDelay;	//in seconds
-	enum EVSENotificationType	EVSENotification;
-};
-struct ServiceIDListType
-{
-	unsigned short	ServiceID[10];	//refer to chapter 8.6.2.1 Table 192
-};
-struct PaymentOptionListType
-{
-	enum PaymentOptionType	PaymentOption[2];
-};
-struct ServiceTagType
-{
-	unsigned short				ServiceID;
-	unsigned char				ServiceName[32];//Optional Element
-	enum ServiceCategoryType	ServiceCategory;
-	unsigned char				ServiceScope[32];//Optional Element
-};
-struct ServiceType_DIN70121
-{
-	struct ServiceTagType		ServiceTag;
-	BOOL					FreeService;
-};
-struct ServiceType_ISO15118_2014
-{
-	unsigned short				ServiceID;
-	unsigned char				ServiceName[32];	//Optional
-	enum ServiceCategoryType	ServiceCategory;
-	unsigned char				ServiceScope[64];	//Optional
-	BOOL					FreeService;
-};
-/*struct ServiceType_ISO15118_2018
-{
-	unsigned short				ServiceID;
-	BOOL					FreeService;
-}; */
-struct SupportedEnergyTransferModeType
-{
-	enum EnergyTransferModeType	EnergyTransferMode[6];
-};
-struct ServiceChargeType
-{
-	struct ServiceType_DIN70121				Services;
-	//enum EVSESupportedEnergyTransferType		EnergyTransferType;
-	enum EnergyTransferModeType			EnergyTransferType;
-};
-
-struct ChargeServiceType
-{
-	struct ServiceType_ISO15118_2014			Services;
-	struct SupportedEnergyTransferModeType	SupportedEnergyTransferMode;
-};
-struct ServiceListType
-{
-	struct ServiceType_ISO15118_2014			Service[8];
-};
-struct IdentificationOptionListType
-{
-	enum PaymentOptionType				IdentificationOption[2];
-};
-struct ParameterType
-{
-	unsigned char							Name[32];
-	struct PhysicalValueType_ISO15118_2014		PhysicalValue_ISO15118_2014;
-	struct PhysicalValueType_ISO15118_2018		PhysicalValue_ISO15118_2018;
-};
-struct ParameterSetType
-{
-	short 				ParameterSetID;
-	struct ParameterType	Parameter[16];
-};
-struct ServiceParameterListType
-{
-	struct ParameterSetType		ParameterSet[255];
-};
-struct WPT_SDlEnergyTransferModeType
-{
-	struct ServiceParameterListType	ServiceParameterList;
-};
-struct SelectedServiceType
-{
-	unsigned short			ServiceID;
-	short					ParameterSetID;
-};
-struct SelectedServiceListType
-{
-	struct SelectedServiceType	SelectedService[16];
-};
-
-struct CertificateChainType
-{
-	unsigned char 				Id[32];				//Optional
-	unsigned char 				Certificate[800];		//check size again
-	unsigned char				SubCertificates[4][800];	//Optional, 	check size again
-};
-struct PNC_AReqIdentificationModeType
-{
-	unsigned char 			GenChallenge[16];					//DIN70121=> None,	ISO15118_2014=>None,	ISO15118_2018=>Optional
-	unsigned char 			Id[32];							//DIN70121=> None,	ISO15118_2014=>None,	ISO15118_2018=>Optional
-};
-struct AC_EVChargeParameterType
-{
-	unsigned int 								DepartureTime;		//Optional
-	struct PhysicalValueType_ISO15118_2014			EAmount;
-	struct PhysicalValueType_ISO15118_2014			EVMaxVoltage;
-	struct PhysicalValueType_ISO15118_2014			EVMaxCurrent;
-	struct PhysicalValueType_ISO15118_2014			EVMinCurrent;
-};
-struct DC_EVStatusType_DIN70121
-{
-	BOOL						EVReady;
-	BOOL						EVCabinConditioning;
-	BOOL						EVRESSConiditioning;
-	enum DC_EVErrorCodeType		EVErrorCode;
-	unsigned char 					EVRESSSOC;		/*0-100 percentage*/
-};
-struct DC_EVChargeParameterType_DIN70121
-{
-	struct DC_EVStatusType_DIN70121			DC_EVStatus;
-	struct PhysicalValueType_DIN70121		EVMaximumCurrentLimit;
-	struct PhysicalValueType_DIN70121		EVMaximumPowerLimit;			//Optional
-	struct PhysicalValueType_DIN70121		EVMaximumVoltageLimit;
-	struct PhysicalValueType_DIN70121		EVEnergyCapacity;				//Optional
-	struct PhysicalValueType_DIN70121		EVEnergyRequest;				//Optional
-	unsigned char							FullSOC;/*0-100 percentage*/	//Optional
-	unsigned char							BulkSOC;/*0-100 percentage*/	//Optional
-};
-struct DC_EVStatusType_ISO15118_2014
-{
-	BOOL						EVReady;
-	enum DC_EVErrorCodeType		EVErrorCode;
-	unsigned char 					EVRESSSOC;		/*0-100 percentage*/
-};
-struct DC_EVChargeParameterType_ISO15118_2014
-{
-	unsigned int 								DepartureTime;				//Optional
-	struct DC_EVStatusType_ISO15118_2014			DC_EVStatus;
-	struct PhysicalValueType_ISO15118_2014 			EVMaximumCurrentLimit;
-	struct PhysicalValueType_ISO15118_2014			EVMaximumPowerLimit;			//Optional
-	struct PhysicalValueType_ISO15118_2014			EVMaximumVoltageLimit;
-	struct PhysicalValueType_ISO15118_2014			EVEnergyCapacity;				//Optional
-	struct PhysicalValueType_ISO15118_2014			EVEnergyRequest;				//Optional
-	unsigned char								FullSOC;/*0-100 percentage*/		//Optional
-	unsigned char								BulkSOC;/*0-100 percentage*/	//Optional
-};
-struct Dynamic_CPDReqControlModeType
-{
-	unsigned int 								DepartureTime;
-};
-struct RelativeTimeIntervalType
-{
-	unsigned int 	duration;			//Optional
-	unsigned int	start;
-};
-struct PMaxScheduleEntryType
-{
-	struct RelativeTimeIntervalType	RelativeTimeInterval;
-	unsigned short					PMax;
-};
-struct PMaxScheduleType
-{
-	unsigned short					PMaxScheduleID;			//no this itme in ISO15118_2014
-	struct PMaxScheduleEntryType		PMaxScheduleEntry[1024];
-};
-struct CostType
-{
-	unsigned int 					amount;
-	enum CostKindType				costKind;
-	int 							amountMultiplier;		//Optional , range: -3..+3
-};
-struct ConsumptionCostType
-{
-	struct CostType						Cost[3];
-	struct PhysicalValueType_ISO15118_2014		startValue;
-};
-struct SalesTariffEntryType
-{
-	struct RelativeTimeIntervalType	RelativeTimeInterval;
-	unsigned char 					EPriceLevel;			//Optional
-	struct ConsumptionCostType		ConsumptionCost[3];	//Optional
-};
-struct SalesTariffType
-{
-	unsigned char 					Id[32];					//Optional
-	short 						SalesTariffID;
-	unsigned char 					SalesTariffDescription[32];	//Optional
-	unsigned char 					NumEPriceLevels;			//Optional
-	struct SalesTariffEntryType			SalesTariffEntry[1024];
-};
-struct SAScheduleTupleType
-{
-	short 						SAScheduleTupleID;
-	struct PMaxScheduleType			PMaxSchedule;
-	struct SalesTariffType				SalesTariff;				//Optional
-};
-struct ScheduleListType
-{
-	enum ScheduleOriginType					ScheduleOrigin;
-	struct SAScheduleTupleType					ScheduleTuple[3];
-};
-struct Scheduled_CPDReqControlModeType
-{
-	enum ProcessingType						EVProcessing;
-	unsigned int 								DepartureTime;		//Optional
-	unsigned short 							MaxSupportingPoints;
-	struct ScheduleListType						ScheduleList;			//Optional
-};
-struct AC_CPDReqEnergyTransferModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVTargetEnergyRequest;			//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMaximumEnergyRequest;		//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMinimumEnergyRequest;		//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMaximumChargePower;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumVoltage;
-};
-struct DC_CPDReqEnergyTransferModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVMaximumChargePower;			//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMinimumChargePower;			//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMaximumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumVoltage;
-	struct PhysicalValueType_ISO15118_2018			EVTargetEnergyRequest;				//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMaximumEnergyRequest;			//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMinimumEnergyRequest;			//Optional
-	unsigned char								TargetSOC;						//Optional
-	unsigned char								BulkSOC;							//Optional
-};
-struct BPT_AC_CPDReqEnergyTransferModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVMaximumChargePower;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumDischargePower;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumDischargePower;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumDischargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumDischargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVTargetEnergyRequest;				//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMinimumEnergyRequest;			//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMaximumEnergyRequest;			//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMaximumVoltage;
-};
-struct BPT_DC_CPDReqEnergyTransferModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVMaximumChargePower;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumChargePower;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumDischargePower;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumDischargePower;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumDischargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumDischargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumVoltage;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumVoltage;
-	struct PhysicalValueType_ISO15118_2018			EVTargetEnergyRequest;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumEnergyRequest;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumEnergyRequest;
-	unsigned char								TargetSOC;					//Optional
-	unsigned char								BulkSOC;						//Optional
-};
-struct WPT_CPDReqEnergyTransferModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVMaximumPower;				//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMinimumPower;				//Optional
-	struct PhysicalValueType_ISO15118_2018			EVTargetEnergyRequest;			//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMaximumEnergyRequest;		//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMinimumEnergyRequest;		//Optional
-};
-struct ACD_CPDReqEnergyTransferModeType
-{
-	//cannot be found in standard
-};
-struct SAScheduleListType
-{
-	struct SAScheduleTupleType		SAScheduleTuple[3];
-};
-struct DC_EVSEStatusType_DIN70121
-{
-	enum IsolationLevelType_DIN70121			EVSEIsolationStatus;			//Optional
-	enum DC_EVSEStatusCodeType			EVSEStatusCode;
-	unsigned int							NotificationMaxDelay;
-	enum EVSENotificationType				EVSENotification;
-};
-struct DC_EVSEChargeParameterType_DIN70121
-{
-	struct DC_EVSEStatusType_DIN70121		DC_EVSEStatus;
-	struct PhysicalValueType_DIN70121			EVSEMaximumCurrentLimit;
-	struct PhysicalValueType_DIN70121			EVSEMaximumPowerLimit;			//Optional
-	struct PhysicalValueType_DIN70121			EVSEMaximumVoltageLimit;
-	struct PhysicalValueType_DIN70121			EVSEMinimumCurrentLimit;
-	struct PhysicalValueType_DIN70121			EVSEMinimumVoltageLimit;
-	struct PhysicalValueType_DIN70121			EVSECurrentRegulationTolerance;		//Optional
-	struct PhysicalValueType_DIN70121			EVSEPeakCurrentRipple;
-	struct PhysicalValueType_DIN70121			EVSEEnergyToBeDelivered;			//Optional
-};
-struct AC_EVSEStatusType
-{
-	BOOL							  		RCD;
-	unsigned short 							NotificationMaxDelay;
-	enum EVSENotificationType					EVSENotification;		//need to be confirmed
-};
-struct AC_EVSEChargeParameterType
-{
-	struct AC_EVSEStatusType					AC_EVSEStatus;
-	struct PhysicalValueType_ISO15118_2014			EVSENominalVoltage;
-	struct PhysicalValueType_ISO15118_2014			EVSEMaxCurrent;
-};
-struct DC_EVSEStatusType_ISO15118_2014
-{
-	unsigned short								NotificationMaxDelay;
-	enum EVSENotificationType					EVSENotification;
-	enum IsolationLevelType_ISO15118_2014			EVSEIsolationStatus;					//Optional
-	enum DC_EVSEStatusCodeType				DC_EVSEStatusCode;
-};
-struct DC_EVSEChargeParameterType_ISO15118_2014
-{
-	struct DC_EVSEStatusType_ISO15118_2014		DC_EVSEStatus;
-	struct PhysicalValueType_ISO15118_2014			EVSEMaximumCurrentLimit;
-	struct PhysicalValueType_ISO15118_2014			EVSEMaximumPowerLimit;
-	struct PhysicalValueType_ISO15118_2014			EVSEMaximumVoltageLimit;
-	struct PhysicalValueType_ISO15118_2014			EVSEMinimumCurrentLimit;
-	struct PhysicalValueType_ISO15118_2014			EVSEMinimumVoltageLimit;
-	struct PhysicalValueType_ISO15118_2014			EVSECurrentRegulationTolerance;		//Optional
-	struct PhysicalValueType_ISO15118_2014			EVSEPeakCurrentRipple;
-	struct PhysicalValueType_ISO15118_2014			EVSEEnergyToBeDelivered;			//Optional
-};
-struct Scheduled_CPDResControlModeType
-{
-	struct ScheduleListType						ScheduleList;
-};
-struct AC_CPDResEnergyTransferModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumChargeCurrent[3];
-	struct PhysicalValueType_ISO15118_2018			EVSENominalVoltage;
-	struct PhysicalValueType_ISO15118_2018			EVSENominalFrequency;
-};
-struct DC_CPDResEnergyTransferModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumChargePower;
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVSEMinimumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumVoltage;
-	struct PhysicalValueType_ISO15118_2018			EVSEMinimumVoltage;
-};
-struct BPT_AC_CPDResEnergyTransferModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumChargeCurrent[3];
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumDischargeCurrent[3];
-	struct PhysicalValueType_ISO15118_2018			EVSENominalVoltage;
-	struct PhysicalValueType_ISO15118_2018			EVSENominalFrequency;
-};
-struct BPT_DC_CPDResEnergyTransferModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumChargePower;
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumDischargePower;
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumDischargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVSEMinimumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVSEMinimumDischargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumVoltage;
-	struct PhysicalValueType_ISO15118_2018			EVSEMinimumVoltage;
-};
-struct WPT_CPDResEnergyTransferModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumPower;
-	struct PhysicalValueType_ISO15118_2018			EVSEMinimumPower;
-};
-struct ACD_CPDResEnergyTransferModeType
-{
-	//not found in ISO15118_2018
-};
-struct ProfileEntryType_DIN70121
-{
-	unsigned int 				ChargingProfileEntryStart;
-	short						ChargingProfileEntryMaxPower;
-};
-struct ChargingProfileType_DIN70121
-{
-	short 							SAScheduleTupleID;
-	struct ProfileEntryType_DIN70121		ProfileEntry[24];
-};
-struct DC_EVPowerDeliveryParameterType_DIN70121
-{
-	struct DC_EVStatusType_DIN70121			DC_EVStatus;
-	BOOL								BulkChargingComplete;		//Optional
-	BOOL								ChargingComplete;
-};
-struct ProfileEntryType_ISO15118_2014
-{
-	unsigned int 								ChargingProfileEntryStart;
-	struct PhysicalValueType_ISO15118_2018			ChargingProfileEntryMaxPower;
-	unsigned char 								ChargingProfileEntryMaxNumberOfPhasesInUse;	//Optional
-};
-struct ChargingProfileType_ISO15118_2014
-{
-	struct ProfileEntryType_ISO15118_2014			ProfileEntry[24];
-};
-struct DC_EVPowerDeliveryParameterType_ISO15118_2014
-{
-	struct DC_EVStatusType_ISO15118_2014 			DC_EVStatus;
-	BOOL									BulkChargingComplete;		//Optional
-	BOOL									ChargingComplete;
-};
-struct TimeInterval
-{
-	unsigned int 								start;
-	unsigned int 								duration;				//Optional
-};
-struct PowerScheduleEntryType
-{
-	struct TimeInterval							TimeInterval;
-	struct PhysicalValueType_ISO15118_2018			Power[3];
-};
-struct EVPowerProfileType
-{
-	struct PowerScheduleEntryType				EVPowerProfileEntry[2048];
-};
-struct Scheduled_PDReqControlModeType
-{
-	unsigned char 								ScheduleTupleID;
-	struct EVPowerProfileType					EVPowerProfile;
-};
-struct BPT_Scheduled_PDReqControlModeType
-{
-	unsigned char 								ScheduleTupleID;
-	struct EVPowerProfileType					EVPowerProfile;			//Optional
-	enum evOperationType						EVOperation;
-};
-struct ListOfRootCertificateIDsType
-{
-	unsigned char 								RootCertificateID[20][40];
-};
-struct ContractSignatureEncryptedPrivateKeyType
-{
-	unsigned char 								Id[32];
-};
-struct DiffieHellmanPublickeyType
-{
-	unsigned char 								Id[32];
-};
-struct ContractCertificateEncryptedPrivateKeyType
-{
-	unsigned char 								Id[32];
-};
-struct EVTechnicalStatusType
-{
-	BOOL									EV_Status_ReadyToCharge;
-	BOOL									EV_Status_ImmobilizationRequest;		//Optional
-	BOOL									EV_Status_Immobilized;
-	struct PhysicalValueType_ISO15118_2018			EV_Status_WLAN_Strength;
-	enum EV_CP_StatusType						EV_CP_Status;
-	unsigned char								EV_Status_RESSSOC;					//0~100%
-	enum EV_Error_Status_CodeType				EV_Error_Status_Code;
-	BOOL									EVSE_Timeout;
-};
-struct MeterInfoType_ISO15118_2014
-{
-	unsigned char								MeterID[32];
-	unsigned long 								MeterReading;						//Optional
-	unsigned char								SigMeterReading[64];				//Optional
-	short 									MeterStatus;						//Optional
-	short 									TMeter;							//Optional
-};
-struct Scheduled_MRReqControlModeType
-{
-	unsigned char 								ScheduleTupleID;
-};
-struct MeterInfoType_ISO15118_2018
-{
-	unsigned char								MeterID[32];
-	unsigned long 								MeterReadingWhCharged;			//Optional
-	unsigned long 								MeterReadingWhDischarged;			//Optional
-	unsigned long 								MeterReadingVARhLeading;			//Optional
-	unsigned long 								MeterReadingVARhLagging;			//Optional
-	unsigned char								SignatureMeterReading[64];			//Optional
-	short 									MeterStatus;						//Optional
-	short 									TimeStampMeter;					//Optional
-	BOOL									ReceiptRequired;					//Optional
-};
-struct PnC_CLReqIdentificationModeType
-{
-	BOOL									MeteringReceiptRequested;
-};
-struct Dynamic_CSReqControlModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVTargetEnergyRequest;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumEnergyRequest;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumEnergyRequest;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumChargePower;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumChargeCurrent;
-	struct PhysicalValueType_ISO15118_2018			EVMinimumChargeCurrent;
-};
-struct Scheduled_CSReqControlModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVTargetEnergyRequest;				//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMaximumEnergyRequest;			//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMinimumEnergyRequest;			//Optional
-	BOOL									Standby;
-	struct PhysicalValueType_ISO15118_2018			EVMaximumChargePower;			//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMaximumChargeCurrent;			//Optional
-	struct PhysicalValueType_ISO15118_2018			EVMinimumChargeCurrent;			//Optional
-};
-struct DisplayParametersType
-{
-	unsigned short 							CurrentRange;
-	unsigned char	 							CurrentSOC;						//0~100%
-	unsigned char	 							MinimumSOC;						//0~100%
-	struct PhysicalValueType_ISO15118_2018			RemainingTimeToMaximumSOC;
-	struct PhysicalValueType_ISO15118_2018			RemainingTimeToTargetSOC;
-	struct PhysicalValueType_ISO15118_2018			RemainingTimeToBulkSOC;
-	struct PhysicalValueType_ISO15118_2018			RemainingTimeToMinimumSOC;
-	BOOL									ChargingComplete;
-	BOOL									BulkChargingComplete;
-	BOOL									InletHot;
-};
-struct PnC_CLResIdentificationModeType
-{
-	struct MeterInfoType_ISO15118_2018			MeterInfo;
-};
-struct Dynamic_CSResControlModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVSETargetActivePower;
-};
-struct Scheduled_CDResControlModeType
-{
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumChargePower;		//Optional
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumChargeCurrent;	//Optional
-	struct PhysicalValueType_ISO15118_2018			EVSEMaximumVoltage;			//Optional
-};
-struct LFA_EVFinePositioningSetupParametersType
-{
-	unsigned char 								NumberOfSensors;
-	//NOT complete yet,  to be continue.....
-};
-
-/****SupportedAppProtocolRequest****/
-struct SupportedAppProtocolRequest_DIN70121
-{
-	struct AppProtocolType	AppProtocol[20];
-};
-struct SupportedAppProtocolRequest_ISO15118_2014
-{
-	struct AppProtocolType	AppProtocol[20];
-};
-struct SupportedAppProtocolRequest_ISO15118_2018
-{
-	struct AppProtocolType	AppProtocol[20];
-};
-/****SupportedAppProtocolResponse****/
-struct SupportedAppProtocolResponse_DIN70121
-{
-	enum ResponseCodeType_DIN70121		ResponseCode;
-	unsigned char							SchemaID;				//Optional
-};
-struct SupportedAppProtocolResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014	ResponseCode;
-	unsigned char							SchemaID;				//Optional
-};
-struct SupportedAppProtocolResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018	ResponseCode;
-	unsigned char							SchemaID;					//Optional
-};
-/****SessionSetupRequest****/
-struct SessionSetupRequest_DIN70121
-{
-	unsigned char						EVCCID[8];						//the MAC address of the EVCC in Hex
-};
-struct SessionSetupRequest_ISO15118_2014
-{
-	unsigned char						EVCCID[8];						//the MAC address of the EVCC in Hex
-};
-struct SessionSetupRequest_ISO15118_2018
-{
-	unsigned char						EVCCID[8];						//the MAC address of the EVCC in Hex
-	struct ACD_SSEnergyTransferModeType	ACD_SSEnergyTransferMode;			//For ACD mandatory, optional for rest
-};
-/****SessionSetupResponse****/
-struct SessionSetupResponse_DIN70121
-{
-	enum ResponseCodeType_DIN70121		ResponseCode;
-	unsigned char							EVSEID[40];					//DIN70121=>Max length:32,	ISO15118=>min length:7, max length:37
-	unsigned int							EVSETimeStamp;				//EPOCH format, Optional
-};
-struct SessionSetupResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014	ResponseCode;
-	unsigned char							EVSEID[40];					//DIN70121=>Max length:32,	ISO15118=>min length:7, max length:37
-	unsigned int							EVSETimeStamp;				//EPOCH format, Optional
-};
-struct SessionSetupResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018	ResponseCode;
-	unsigned char							EVSEID[40];					//DIN70121=>Max length:32,	ISO15118=>min length:7, max length:37
-	struct EVSEStatusType					EVSEStatus;					//Optional
-};
-/****ServiceDiscoveryRequest****/
-struct ServiceDiscoveryRequest_DIN70121
-{
-	unsigned char				ServiceScope[32];		//Optional
-	enum ServiceCategoryType	ServiceCategory;		//Optional
-};
-struct ServiceDiscoveryRequest_ISO15118_2014
-{
-	unsigned char				ServiceScope[32];		//Optional
-	enum ServiceCategoryType	ServiceCategory;		//Optional
-};
-struct ServiceDiscoveryRequest_ISO15118_2018
-{
-	struct ServiceIDListType		SupportedServiceIDs;	//Optional
-};
-/****ServiceDiscoveryResponse****/
-struct ServiceDiscoveryResponse_DIN70121
-{
-	enum ResponseCodeType_DIN70121		ResponseCode;
-	struct PaymentOptionListType				PaymentOptions;
-	struct ServiceChargeType				ChargeService_DIN70121;
-};
-struct ServiceDiscoveryResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014	ResponseCode;
-	struct PaymentOptionListType				PaymentOptions;
-	struct ChargeServiceType				ChargeService;
-	struct ServiceListType					ServiceList;					//Optional
-};
-struct ServiceDiscoveryResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018	ResponseCode;
-	struct EVSEStatusType					EVSEStatus;					//Optional
-	struct IdentificationOptionListType			IdentificationOptionList;
-	struct ServiceListType					EnergyTransferServiceList;
-	struct ServiceListType					VASList;						//Optional
-};
-/****ServiceDetailRequest****/
-//Only in ISO15118_2014 and ISO15118_2018
-struct ServiceDetailRequest_ISO15118_2014
-{
-	unsigned short						ServiceID;
-};
-struct ServiceDetailRequest_ISO15118_2018
-{
-	unsigned short						ServiceID;
-	struct WPT_SDlEnergyTransferModeType	WPT_SDlEnergyTransferMode;
-};
-/****ServiceDetailResponse****/
-struct ServiceDetailResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014	ResponseCode;
-	unsigned short							ServiceID;
-	struct ServiceParameterListType 			ServiceParameterList;
-};
-struct ServiceDetailResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018	ResponseCode;
-	unsigned short							ServiceID;
-	struct ServiceParameterListType 			ServiceParameterList;
-	struct EVSEStatusType					EVSEStatus;					//Optional
-};
-/****ServiceAndPaymentSelectionRequest / ServiceSelectionRequest****/
-struct ServiceAndPaymentSelectionRequest_DIN70121
-{
-	enum PaymentOptionType		SelectedPaymentOption;
-	struct SelectedServiceListType		SelectedServiceList;
-};
-struct ServiceAndPaymentSelectionRequest_ISO15118_2014
-{
-	enum PaymentOptionType		SelectedPaymentOption;
-	struct SelectedServiceListType		SelectedServiceList;
-};
-struct ServiceSelectionRequest_ISO15118_2018
-{
-	enum PaymentOptionType			SelectedPaymentOption;
-	struct SelectedServiceType			SelectedEnergyTransferService;
-	struct SelectedServiceListType			SelectedVASList;
-	enum ProcessingType				EVProcessing;
-};
-/****ServiceAndPaymentSelectionResponse / ServiceSelectionResponse****/
-struct ServiceAndPaymentSelectionResponse_DIN70121
-{
-	enum ResponseCodeType_DIN70121		ResponseCode;
-};
-struct ServiceAndPaymentSelectionResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014	ResponseCode;
-};
-struct ServiceSelectionResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018	ResponseCode;
-	struct EVSEStatusType					EVSEStatus;					//Optional
-};
-/****PaymentDetailsRequest / IdentificationDetailsRequest****/
-struct PaymentDetailsRequest_ISO15118_2014
-{
-	unsigned char 					eMAID[16];
-	struct CertificateChainType		ContractSignatureCertChain;
-};
-struct IdentificationDetailsRequest_ISO15118_2018
-{
-	struct CertificateChainType		ContractSignatureCertChain;
-};
-/****PaymentDetailsResponse  / IdentificationDetailsResponse ****/
-struct PaymentDetailsResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014	ResponseCode;
-	unsigned char 							GenChallenge[16];
-	long 								EVSETimeStamp;
-};
-struct IdentificationDetailsResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018	ResponseCode;
-	struct EVSEStatusType					EVSEStatus;						//Optional
-	unsigned char 							GenChallenge[16];
-	enum ProcessingType					EVSEProcessing;
-};
-/****ContractAuthenticationRequest / AuthorizationRequest****/
-struct ContractAuthenticationRequest_DIN70121
-{
-	//None
-};
-struct AuthorizationRequest_ISO15118_2014
-{
-	unsigned char 			GenChallenge[16];					//Optional
-	unsigned char 			Id[32];							//Optional
-};
-struct AuthorizationRequest_ISO15118_2018
-{
-	struct PNC_AReqIdentificationModeType		PNC_AReqIdentificationMode;	//Optional
-};
-/****ContractAuthenticationResponse  / AuthorizationResponse****/
-struct ContractAuthenticationResponse_DIN70121
-{
-	enum ResponseCodeType_DIN70121		ResponseCode;
-	enum EVSEProcessingType_DIN70121		EVSEProcessing;
-};
-struct AuthorizationResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014	ResponseCode;
-	enum EVSEProcessingType_ISO15118_2014	EVSEProcessing;
-};
-struct AuthorizationResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018	ResponseCode;
-	enum ProcessingType					EVSEProcessing;
-	struct EVSEStatusType					EVSEStatus;						//Optional
-};
-/****ChargeParameterDiscoveryRequest****/
-struct ChargeParameterDiscoveryRequest_DIN70121
-{
-	enum EnergyTransferModeType					EVRequestedEnergyTransferType;
-	struct DC_EVChargeParameterType_DIN70121		DC_EVChargeParameter;
-};
-struct ChargeParameterDiscoveryRequest_ISO15118_2014
-{
-	unsigned short										MaxEntriesSAScheduleTuple;			//Optional
-	enum EnergyTransferModeType						RequestedEnergyTransferMode;
-	struct AC_EVChargeParameterType					AC_EVChargeParameter;
-	struct DC_EVChargeParameterType_ISO15118_2014		DC_EVChargeParameter;
-};
-struct ChargeParameterDiscoveryRequest_ISO15118_2018
-{
-	struct Dynamic_CPDReqControlModeType			Dynamic_CPDReqControlMode;
-	struct Scheduled_CPDReqControlModeType			Scheduled_CPDReqControlMode;
-	struct AC_CPDReqEnergyTransferModeType			AC_CPDReqEnergyTransferMode;
-	struct DC_CPDReqEnergyTransferModeType			DC_CPDReqEnergyTransferMode;
-	struct BPT_AC_CPDReqEnergyTransferModeType		BPT_AC_CPDReqEnergyTransferMode;
-	struct BPT_DC_CPDReqEnergyTransferModeType		BPT_DC_CPDReqEnergyTransferMode;
-	struct WPT_CPDReqEnergyTransferModeType			WPT_CPDReqEnergyTransferMode;
-	struct ACD_CPDReqEnergyTransferModeType			ACD_CPDReqEnergyTransferMode;
-};
-/****ChargeParameterDiscoveryResponse****/
-struct ChargeParameterDiscoveryResponse_DIN70121
-{
-	enum ResponseCodeType_DIN70121					ResponseCode;
-	enum EVSEProcessingType_DIN70121					EVSEProcessing;
-	struct SAScheduleListType 							SAScheduleList;
-	struct DC_EVSEChargeParameterType_DIN70121			DC_EVSEChargeParameter;
-};
-struct ChargeParameterDiscoveryResponse_ISO15118_2014
-{
-	enum EVSEProcessingType_ISO15118_2014				EVSEProcessing;
-	enum ResponseCodeType_ISO15118_2014				ResponseCode;
-	struct SAScheduleListType 							SAScheduleList;
-	struct AC_EVSEChargeParameterType					AC_EVSEChargeParameter;
-	struct DC_EVSEChargeParameterType_ISO15118_2014		DC_EVSEChargeParameter;
-};
-struct ChargeParameterDiscoveryResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018				ResponseCode;
-	struct EVSEStatusType								EVSEStatus;					//Optional
-	enum ProcessingType								EVSEProcessing;
-	struct Scheduled_CPDResControlModeType				Scheduled_CPDResControlMode;	//Optional
-	struct AC_CPDResEnergyTransferModeType				AC_CPDResEnergyTransferMode;
-	struct DC_CPDResEnergyTransferModeType				DC_CPDResEnergyTransferMode;
-	struct BPT_AC_CPDResEnergyTransferModeType			BPT_AC_CPDResEnergyTransferMode;
-	struct BPT_DC_CPDResEnergyTransferModeType			BPT_DC_CPDResEnergyTransferMode;
-	struct WPT_CPDResEnergyTransferModeType				WPT_CPDResEnergyTransferMode;
-	struct ACD_CPDResEnergyTransferModeType				ACD_CPDResEnergyTransferMode;
-};
-/****PowerDeliveryRequest****/
-struct PowerDeliveryRequest_DIN70121
-{
-	BOOL											ReadyToChargeState;
-	struct ChargingProfileType_DIN70121					ChargingProfile;
-	struct DC_EVPowerDeliveryParameterType_DIN70121		DC_EVPowerDeliveryParameter;
-};
-struct PowerDeliveryRequest_ISO15118_2014
-{
-	enum ChargeProgressType_ISO15118_2014				ChargeProgress;
-	short 											SAScheduleTupleID;
-	struct ChargingProfileType_ISO15118_2014 				ChargingProfile;
-	struct DC_EVPowerDeliveryParameterType_ISO15118_2014	DC_EVPowerDeliveryParameter;
-};
-struct PowerDeliveryRequest_ISO15118_2018
-{
-	enum ChargeProgressType_ISO15118_2018				ChargeProgress;
-	struct Scheduled_PDReqControlModeType				Scheduled_PDReqControlMode;
-	struct BPT_Scheduled_PDReqControlModeType			BPT_Scheduled_PDReqControlMode;
-};
-/****PowerDeliveryResponse****/
-struct PowerDeliveryResponse_DIN70121
-{
-	enum ResponseCodeType_DIN70121				ResponseCode;
-	struct DC_EVSEStatusType_DIN70121				DC_EVSEStatus;
-};
-struct PowerDeliveryResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014				ResponseCode;
-	struct AC_EVSEStatusType							AC_EVSEStatus;
-	struct DC_EVSEStatusType_ISO15118_2014				DC_EVSEStatus;
-};
-struct PowerDeliveryResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018				ResponseCode;
-	struct EVSEStatusType								EVSEStatus;			//Optional
-};
-/****CertificateUpdateRequest****/
-struct CertificateUpdateRequest_ISO15118_2014
-{
-	unsigned char 										Id[32];
-	struct CertificateChainType							ContractSignatureCertChain;
-	unsigned char 										eMAID[16];
-	struct ListOfRootCertificateIDsType						ListOfRootCertificateIDs;
-};
-/****CertificateUpdateResponse****/
-struct CertificateUpdateResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014				ResponseCode;
-	struct CertificateChainType							SAProvisioningCertificateChain;
-	struct CertificateChainType							ContractSignatureCertChain;
-	struct ContractSignatureEncryptedPrivateKeyType			ContractSignatureEncryptedPrivateKey;
-	struct DiffieHellmanPublickeyType						DHpublickey;
-	unsigned char 										eMAID[16];
-	short 											RetryCounter;							//Optional
-};
-/****CertificateInstallationRequest****/
-struct CertificateInstallationRequest_ISO15118_2014
-{
-	unsigned char 										Id[32];
-	unsigned char 										OEMProvisioningCert[800];
-	struct ListOfRootCertificateIDsType						ListOfRootCertificateIDs;
-};
-struct CertificateInstallationRequest_ISO15118_2018
-{
-	unsigned char 										Id[32];
-	struct CertificateChainType							OEMProvisioningCertChain;
-	struct ListOfRootCertificateIDsType						ListOfRootCertificateIDs;
-	unsigned short										MaxSupportedCerts;
-};
-/****CertificateInstallationResponse****/
-struct CertificateInstallationResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014				ResponseCode;
-	struct CertificateChainType							SAProvisioningCertificateChain;
-	struct CertificateChainType							ContractSignatureCertChain;
-	struct ContractSignatureEncryptedPrivateKeyType			ContractSignatureEncryptedPrivateKey;
-	struct DiffieHellmanPublickeyType						DHpublickey;
-	unsigned char 										eMAID[16];
-};
-struct CertificateInstallationResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018				ResponseCode;
-	struct EVSEStatusType								EVSEStatus;					//Optional
-	struct CertificateChainType							SAProvisioningCertificateChain;
-	struct CertificateChainType							ContractCertificateChain;
-	struct ContractCertificateEncryptedPrivateKeyType		ContractEncryptedPrivateKey;
-	struct DiffieHellmanPublickeyType						DHpublickey;
-	enum ProcessingType								EVSEProcessing;
-	unsigned short 									RemainingContractCertificateChains;
-};
-/****SystemStatusRequest****/
-struct SystemStatusRequest_ISO15118_2018
-{
-	enum mechanicalChargingDeviceStatusType			EVMechanicalChargingDeviceStatus;
-	struct EVTechnicalStatusType							EVTechnicalStatus;
-	unsigned char 										EV_OEMStatus[800];					//Optional
-};
-/****SystemStatusResponse****/
-struct SystemStatusResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018				ResponseCode;
-	enum mechanicalChargingDeviceStatusType			EVSEMechanicalChargingDeviceStatus;
-	BOOL											EVSE_ReadyToCharge;
-	enum IsolationStatusType							EVSE_IsolationStatus;
-	BOOL											EVSE_Disabled;
-	BOOL											EVSE_UtilityInterruptEvent;
-	BOOL											EVSE_EmergencyShutdown;
-	BOOL											EVSE_Malfunction;
-	BOOL											EV_InChargePosition;
-	BOOL											EV_AssociationStatus;
-};
-/****SessionStopRequest****/
-struct SessionStopRequest_DIN70121
-{
-	//No member in standard
-};
-struct SessionStopRequest_ISO15118_2014
-{
-	enum ChargingSessionType							ChargingSession;
-};
-struct SessionStopRequest_ISO15118_2018
-{
-	enum ChargingSessionType							ChargingSession;
-};
-/****SessionStopResponse****/
-struct SessionStopResponse_DIN70121
-{
-	enum ResponseCodeType_DIN70121					ResponseCode;
-};
-struct SessionStopResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014				ResponseCode;
-};
-struct SessionStopResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018				ResponseCode;
-	struct EVSEStatusType								EVSEStatus;					//Optional
-};
-/****MeteringReceiptRequest****/
-struct MeteringReceiptRequest_ISO15118_2014
-{
-	unsigned char 										Id[32];						//Optional
-	unsigned char 										SessionID[8];
-	short 											SAScheduleTupleID;				//Optional
-	struct MeterInfoType_ISO15118_2014					MeterInfo;
-};
-struct MeteringReceiptRequest_ISO15118_2018
-{
-	unsigned char 										Id[32];						//Optional
-	unsigned char 										SessionID[8];
-	struct Scheduled_MRReqControlModeType				Schedule_MRReqControlMode;
-	struct MeterInfoType_ISO15118_2018					MeterInfo;
-};
-/****MeteringReceiptResponse****/
-struct MeteringReceiptResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014				ResponseCode;
-	struct AC_EVSEStatusType							AC_EVSEStatus;
-	struct DC_EVSEStatusType_ISO15118_2014				DC_EVSEStatus;
-};
-struct MeteringReceiptResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018				ResponseCode;
-	struct EVSEStatusType								EVSEStatus;					//Optional
-};
-/****ChargingStatusRequest (AC Only)****/
-struct ChargingStatusRequest_ISO15118_2014
-{
-	//No member in standard
-};
-struct ChargingStatusRequest_ISO15118_2018
-{
-	struct PnC_CLReqIdentificationModeType				PnC_CLReqIdentificationMode;
-	struct Dynamic_CSReqControlModeType				Dynamic_CSReqControlMode;
-	struct Scheduled_CSReqControlModeType				Scheduled_CSReqControlMode;
-	struct DisplayParametersType							DisplayParameters;
-};
-/****ChargingStatusResponse (AC Only)****/
-struct ChargingStatusResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014				ResponseCode;
-	unsigned char										EVSEID[40];			//DIN70121=>Max length:32,	ISO15118=>min length:7, max length:37
-	short 											SAScheduleTupleID;
-	struct PhysicalValueType_ISO15118_2014					EVSEMaxCurrent;		//Optional
-	struct MeterInfoType_ISO15118_2014					MeterInfo;			//Optional
-	BOOL											ReceiptRequired;		//Optional
-	struct AC_EVSEStatusType							AC_EVSEStatus;
-};
-struct ChargingStatusResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018				ResponseCode;
-	struct EVSEStatusType								EVSEStatus;					//Optional
-	unsigned char										EVSEID[40];					//DIN70121=>Max length:32,	ISO15118=>min length:7, max length:37
-	struct PhysicalValueType_ISO15118_2018					EVSETargetFrequency;			//Optional
-	struct PnC_CLResIdentificationModeType				PnC_CLResIdentificationMode;
-	struct Dynamic_CSResControlModeType					Dynamic_CSResControlMode;
-	struct Scheduled_CSReqControlModeType				Scheduled_CSReqControlMode;
-};
-/****CableCheckRequest (DC Only)****/
-struct CableCheckRequest_DIN70121
-{
-	struct DC_EVStatusType_DIN70121						DC_EVStatus;
-};
-struct CableCheckRequest_ISO15118_2014
-{
-	struct DC_EVStatusType_ISO15118_2014 					DC_EVStatus;
-};
-struct CableCheckRequest_ISO15118_2018
-{
-	//No member in standard
-};
-/****CableCheckResponse (DC Only)****/
-struct CableCheckResponse_DIN70121
-{
-	enum ResponseCodeType_DIN70121					ResponseCode;
-	struct DC_EVSEStatusType_DIN70121					DC_EVSEStatus;
-	enum EVSEProcessingType_DIN70121					EVSEProcessing;
-};
-struct CableCheckResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014				ResponseCode;
-	struct DC_EVSEStatusType_ISO15118_2014				DC_EVSEStatus;
-	enum EVSEProcessingType_ISO15118_2014				EVSEProcessing;
-};
-struct CableCheckResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018				ResponseCode;
-	struct EVSEStatusType								EVSEStatus;					//Optional
-	enum ProcessingType								EVSEProcessing;
-};
-/****PreChargeRequest (DC Only)****/
-struct PreChargeRequest_DIN70121
-{
-	struct DC_EVStatusType_DIN70121						DC_EVStatus;
-	struct PhysicalValueType_DIN70121						EVTargetVoltage;
-	struct PhysicalValueType_DIN70121						EVTargetCurrent;
-};
-struct PreChargeRequest_ISO15118_2014
-{
-	struct DC_EVStatusType_ISO15118_2014 					DC_EVStatus;
-	struct PhysicalValueType_ISO15118_2014					EVTargetVoltage;
-	struct PhysicalValueType_ISO15118_2014					EVTargetCurrent;
-};
-struct PreChargeRequest_ISO15118_2018
-{
-	struct PhysicalValueType_ISO15118_2018					EVTargetVoltage;
-	struct PhysicalValueType_ISO15118_2018					EVTargetCurrent;
-};
-/****PreChargeResponse (DC Only)****/
-struct PreChargeResponse_DIN70121
-{
-	enum ResponseCodeType_DIN70121					ResponseCode;
-	struct DC_EVSEStatusType_DIN70121					DC_EVSEStatus;
-	struct PhysicalValueType_DIN70121						EVSEPresentVoltage;
-};
-struct PreChargeResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014				ResponseCode;
-	struct DC_EVSEStatusType_ISO15118_2014				DC_EVSEStatus;
-	struct PhysicalValueType_ISO15118_2014					EVSEPresentVoltage;
-};
-struct PreChargeResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018				ResponseCode;
-	struct EVSEStatusType								EVSEStatus;					//Optional
-	struct PhysicalValueType_ISO15118_2018					EVSEPresentVoltage;
-};
-/****CurrentDemandRequest (DC Only)****/
-struct CurrentDemandRequest_DIN70121
-{
-	struct DC_EVStatusType_DIN70121						DC_EVStatus;
-	struct PhysicalValueType_DIN70121						EVTargetCurrent;
-	struct PhysicalValueType_DIN70121						EVMaximumVoltageLimit;		//Optional
-	struct PhysicalValueType_DIN70121						EVMaximumCurrentLimit;		//Optional
-	struct PhysicalValueType_DIN70121						EVMaximumPowerLimit;			//Optional
-	BOOL											BulkChargingComplete;			//Optional
-	BOOL											ChargingComplete;
-	struct PhysicalValueType_DIN70121						RemainingTimeToFullSoC;		//Optional
-	struct PhysicalValueType_DIN70121						RemainingTimeToBulkSoC;		//Optional
-	struct PhysicalValueType_DIN70121						EVTargetVoltage;
-};
-struct CurrentDemandRequest_ISO15118_2014
-{
-	struct DC_EVStatusType_ISO15118_2014 					DC_EVStatus;
-	struct PhysicalValueType_ISO15118_2014					EVTargetCurrent;
-	struct PhysicalValueType_ISO15118_2014					EVMaximumVoltageLimit;		//Optional
-	struct PhysicalValueType_ISO15118_2014					EVMaximumCurrentLimit;		//Optional
-	struct PhysicalValueType_ISO15118_2014					EVMaximumPowerLimit;			//Optional
-	BOOL											BulkChargingComplete;			//Optional
-	BOOL											ChargingComplete;
-	struct PhysicalValueType_ISO15118_2014					RemainingTimeToFullSoC;		//Optional
-	struct PhysicalValueType_ISO15118_2014					RemainingTimeToBulkSoC;		//Optional
-	struct PhysicalValueType_ISO15118_2014					EVTargetVoltage;
-};
-struct CurrentDemandRequest_ISO15118_2018
-{
-	struct DisplayParametersType							DisplayParameters;				//Optional
-	struct PnC_CLReqIdentificationModeType				PnC_CLReqIdentificationMode;
-	struct Dynamic_CSReqControlModeType				Dynamic_CDReqControlMode;
-	struct Scheduled_CSReqControlModeType				Scheduled_CDReqControlMode;
-};
-/****CurrentDemandResponse (DC Only)****/
-struct CurrentDemandResponse_DIN70121
-{
-	enum ResponseCodeType_DIN70121					ResponseCode;
-	struct DC_EVSEStatusType_DIN70121					DC_EVSEStatus;
-	struct PhysicalValueType_DIN70121						EVSEPresentVoltage;
-	struct PhysicalValueType_DIN70121						EVSEPresentCurrent;
-	BOOL											EVSECurrentLimitAchieved;
-	BOOL											EVSEVoltageLimitAchieved;
-	BOOL											EVSEPowerLimitAchieved;
-	struct PhysicalValueType_DIN70121						EVSEMaximumVoltageLimit;		//Optional
-	struct PhysicalValueType_DIN70121						EVSEMaximumCurrentLimit;		//Optional
-	struct PhysicalValueType_DIN70121						EVSEMaximumPowerLimit;		//Optional
-};
-struct CurrentDemandResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014				ResponseCode;
-	struct DC_EVSEStatusType_ISO15118_2014				DC_EVSEStatus;
-	struct PhysicalValueType_ISO15118_2014					EVSEPresentVoltage;
-	struct PhysicalValueType_ISO15118_2014					EVSEPresentCurrent;
-	BOOL											EVSECurrentLimitAchieved;
-	BOOL											EVSEVoltageLimitAchieved;
-	BOOL											EVSEPowerLimitAchieved;
-	struct PhysicalValueType_ISO15118_2014					EVSEMaximumVoltageLimit;		//Optional
-	struct PhysicalValueType_ISO15118_2014					EVSEMaximumCurrentLimit;		//Optional
-	struct PhysicalValueType_ISO15118_2014					EVSEMaximumPowerLimit;		//Optional
-	unsigned char										EVSEID[40];			//DIN70121=>Max length:32,	ISO15118=>min length:7, max length:37
-	short 											SAScheduleTupleID;
-	struct MeterInfoType_ISO15118_2014					MeterInfo;			//Optional
-	BOOL											ReceiptRequired;		//Optional
-};
-struct CurrentDemandResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018				ResponseCode;
-	struct EVSEStatusType								EVSEStatus;						//Optional
-	struct PhysicalValueType_ISO15118_2018					EVSEPresentVoltage;
-	struct PhysicalValueType_ISO15118_2018					EVSEPresentCurrent;
-	BOOL											EVSECurrentLimitAchieved;
-	BOOL											EVSEVoltageLimitAchieved;
-	BOOL											EVSEPowerLimitAchieved;
-	struct PhysicalValueType_ISO15118_2018					EVSEMaximumChargeVoltage;		//Optional
-	struct PhysicalValueType_ISO15118_2018					EVSEMaximumChargeCurrent;		//Optional
-	struct PhysicalValueType_ISO15118_2018					EVSEMaximumChargePower;			//Optional
-	unsigned char										EVSEID[40];						//DIN70121=>Max length:32,	ISO15118=>min length:7, max length:37
-	struct PnC_CLResIdentificationModeType				PnC_CLResIdentificationMode;
-	struct Scheduled_CDResControlModeType				Scheduled_CDResControlMode;
-};
-/****WeldingDetectionRequest (DC Only)*****/
-struct WeldingDetectionRequest_DIN70121
-{
-	struct DC_EVStatusType_DIN70121						DC_EVStatus;
-};
-struct WeldingDetectionRequest_ISO15118_2014
-{
-	struct DC_EVStatusType_ISO15118_2014 					DC_EVStatus;
-};
-struct WeldingDetectionRequest_ISO15118_2018
-{
-	//No member in Standard
-};
-/****WeldingDetectionResponse (DC Only)****/
-struct WeldingDetectionResponse_DIN70121
-{
-	enum ResponseCodeType_DIN70121					ResponseCode;
-	struct DC_EVSEStatusType_DIN70121					DC_EVSEStatus;
-	struct PhysicalValueType_DIN70121						EVSEPresentVoltage;
-};
-struct WeldingDetectionResponse_ISO15118_2014
-{
-	enum ResponseCodeType_ISO15118_2014				ResponseCode;
-	struct DC_EVSEStatusType_ISO15118_2014				DC_EVSEStatus;
-	struct PhysicalValueType_ISO15118_2014					EVSEPresentVoltage;
-};
-struct WeldingDetectionResponse_ISO15118_2018
-{
-	enum ResponseCodeType_ISO15118_2018				ResponseCode;
-	struct EVSEStatusType								EVSEStatus;						//Optional
-	struct PhysicalValueType_ISO15118_2018					EVSEPresentVoltage;
-};
-/****FinePositioningSetupRequest (WPT Only)****/
-struct FinePositioningSetupRequest_ISO15118_2018
-{
-	struct LFA_EVFinePositioningSetupParametersType			LFA_EVFinePositioningSetupParameters;	//Optional
-};
-/****FinePositioningSetupResponse (WPT Only)****/
-struct FinePositioningSetupResponse_ISO15118_2018
-{
-	//NOT complete yet,  to be continue.....
-};
-
-
-struct V2GMessageType_DIN70121
-{
-	unsigned char 	SelfTest_Comp;
-	unsigned char	version[16];
-	unsigned char											PresentMsgFlowStatus;
-														/* 0: Idle(wait B2 state), 1: CM_SLAC_PARM.REQ, 2: CM_SLAC_PARM.CNF, 3: CM_START_ATTEN_CHAR.IND
-														    4: CM_MNBC_SOUND.IND, 5: CM_ATTEN_CHAR.IND, 6: CM_ATTEN_CHAR.RSP, 7: CM_VALIDATE.REQ
-														    8: CM_VALIDATE.CNF, 9: CM_SLAC_MATCH.REQ, 10: CM_SLAC_MATCH.CNF, 11: CM_AMP_MAP.REQ
-														    12: CM_AMP_MAP.CNF, 13: SLACC/SDP/TCP connection,
-														    16: SupportedAppProtocolRequest, 17: SupportedAppProtocolResponse, 18: SessionSetupRequest
-														    19: SessionSetupResponse, 20: ServiceDiscoveryRequest, 21: ServiceDiscoveryResponse
-														    22: ServiceDetailRequest, 23: ServiceDetailResponse
-														    24: ServiceAndPaymentSelectionRequest/ServiceSelectionRequest, 25: ServiceAndPaymentSelectionResponse/ServiceSelectionResponse
-														    26: PaymentDetailsRequest/IdentificationDetailsRequest;, 27: PaymentDetailsResponse/IdentificationDetailsResponse,
-														     28: AuthorizationRequest, 29: AuthorizationResponse,
-														    30: CertificateUpdateRequest, 31: CertificateUpdateResponse, 32:CertificateInstallationRequest, 33: CertificateInstallationResponse
-														    34: ChargeParameterDiscoveryRequest, 35: ChargeParameterDiscoveryResponse
-														    36: CableCheckRequest, 37: CableCheckResponse, 38: PreChargeRequest, 39: PreChargeResponse
-														    40: PowerDeliveryRequest start, 41: PowerDeliveryResponse start, 42: ChargingStatusRequest, 43: ChargingStatusResponse
-														    44: CurrentDemandRequest, 45: CurrentDemandResponse, 46: MeteringReceiptRequest, 47: MeteringReceiptResponse
-														    48: PowerDeliveryRequest end, 49: PowerDeliveryRequest end, 50: WeldingDetectionRequest, 51: WeldingDetectionResponse,
-														    52: SessionStopRequest, 53: SessionStopResponse
-														   253: Performance Timeout, 254: Sequence Timeout, 255: Fault
-														*/
-	struct SupportedAppProtocolRequest_DIN70121 			SupportedAppProtocolRequest;
-	struct SupportedAppProtocolResponse_DIN70121 			SupportedAppProtocolResponse;
-	struct SessionSetupRequest_DIN70121  					SessionSetupRequest;
-	struct SessionSetupResponse_DIN70121   				SessionSetupResponse;
-	struct ServiceDiscoveryRequest_DIN70121    				ServiceDiscoveryRequest;
-	struct ServiceDiscoveryResponse_DIN70121    				ServiceDiscoveryResponse;
-	struct ServiceAndPaymentSelectionRequest_DIN70121		ServiceAndPaymentSelectionRequest;
-	struct ServiceAndPaymentSelectionResponse_DIN70121		ServiceAndPaymentSelectionResponse;
-	struct ContractAuthenticationRequest_DIN70121			ContractAuthenticationRequest;
-	struct ContractAuthenticationResponse_DIN70121	 		ContractAuthenticationResponse;
-	struct ChargeParameterDiscoveryRequest_DIN70121		ChargeParameterDiscoveryRequest;
-	struct ChargeParameterDiscoveryResponse_DIN70121		ChargeParameterDiscoveryResponse;
-	struct CableCheckRequest_DIN70121					CableCheckRequest;
-	struct CableCheckResponse_DIN70121					CableCheckResponse;
-	struct PreChargeRequest_DIN70121					PreChargeRequest;
-	struct PreChargeResponse_DIN70121 					PreChargeResponse;
-	struct PowerDeliveryRequest_DIN70121					PowerDeliveryRequest;
-	struct PowerDeliveryResponse_DIN70121	   				PowerDeliveryResponse;
-	struct CurrentDemandRequest_DIN70121 				CurrentDemandRequest;
-	struct CurrentDemandResponse_DIN70121				CurrentDemandResponse;
-	struct WeldingDetectionRequest_DIN70121 				WeldingDetectionRequest;
-	struct WeldingDetectionResponse_DIN70121  			WeldingDetectionResponse;
-	struct SessionStopRequest_DIN70121					SessionStopRequest;
-	struct SessionStopResponse_DIN70121	    				SessionStopResponse;
-};
-
-struct V2GMessageType_ISO15118_2014
-{
-	unsigned char											PresentMsgFlowStatus;
-														/* 0: Idle(wait B2 state), 1: CM_SLAC_PARM.REQ, 2: CM_SLAC_PARM.CNF, 3: CM_START_ATTEN_CHAR.IND
-														    4: CM_MNBC_SOUND.IND, 5: CM_ATTEN_CHAR.IND, 6: CM_ATTEN_CHAR.RSP, 7: CM_VALIDATE.REQ
-														    8: CM_VALIDATE.CNF, 9: CM_SLAC_MATCH.REQ, 10: CM_SLAC_MATCH.CNF, 11: CM_AMP_MAP.REQ
-														    12: CM_AMP_MAP.CNF, 13: SLACC/SDP/TCP connection,
-														    16: SupportedAppProtocolRequest, 17: SupportedAppProtocolResponse, 18: SessionSetupRequest
-														    19: SessionSetupResponse, 20: ServiceDiscoveryRequest, 21: ServiceDiscoveryResponse
-														    22: ServiceDetailRequest, 23: ServiceDetailResponse
-														    24: ServiceAndPaymentSelectionRequest/ServiceSelectionRequest, 25: ServiceAndPaymentSelectionResponse/ServiceSelectionResponse
-														    26: PaymentDetailsRequest/IdentificationDetailsRequest;, 27: PaymentDetailsResponse/IdentificationDetailsResponse,
-														     28: AuthorizationRequest, 29: AuthorizationResponse,
-														    30: CertificateUpdateRequest, 31: CertificateUpdateResponse, 32:CertificateInstallationRequest, 33: CertificateInstallationResponse
-														    34: ChargeParameterDiscoveryRequest, 35: ChargeParameterDiscoveryResponse
-														    36: CableCheckRequest, 37: CableCheckResponse, 38: PreChargeRequest, 39: PreChargeResponse
-														    40: PowerDeliveryRequest start, 41: PowerDeliveryResponse start, 42: ChargingStatusRequest, 43: ChargingStatusResponse
-														    44: CurrentDemandRequest, 45: CurrentDemandResponse, 46: MeteringReceiptRequest, 47: MeteringReceiptResponse
-														    48: PowerDeliveryRequest end, 49: PowerDeliveryRequest end, 50: WeldingDetectionRequest, 51: WeldingDetectionResponse,
-														    52: SessionStopRequest, 53: SessionStopResponse
-														   253: Performance Timeout, 254: Sequence Timeout, 255: Fault
-														*/
-	struct SupportedAppProtocolRequest_ISO15118_2014 			SupportedAppProtocolRequest;
-	struct SupportedAppProtocolResponse_ISO15118_2014 			SupportedAppProtocolResponse;
-	struct SessionSetupRequest_ISO15118_2014  					SessionSetupRequest;
-	struct SessionSetupResponse_ISO15118_2014   				SessionSetupResponse;
-	struct ServiceDiscoveryRequest_ISO15118_2014    				ServiceDiscoveryRequest;
-	struct ServiceDiscoveryResponse_ISO15118_2014    				ServiceDiscoveryResponse;
-	struct ServiceDetailRequest_ISO15118_2014 					ServiceDetailRequest;
-	struct ServiceDetailResponse_ISO15118_2014					ServiceDetailResponse;
-	struct ServiceAndPaymentSelectionRequest_ISO15118_2014 		ServiceAndPaymentSelectionRequest;
-	struct ServiceAndPaymentSelectionResponse_ISO15118_2014  	ServiceAndPaymentSelectionResponse;
-	struct PaymentDetailsRequest_ISO15118_2014 				PaymentDetailsRequest;
-	struct PaymentDetailsResponse_ISO15118_2014 				PaymentDetailsResponse;
-	struct AuthorizationRequest_ISO15118_2014					AuthorizationRequest;
-	struct AuthorizationResponse_ISO15118_2014					AuthorizationResponse;
-	struct CertificateUpdateRequest_ISO15118_2014				CertificateUpdateRequest;
-	struct CertificateUpdateResponse_ISO15118_2014				CertificateUpdateResponse;
-	struct CertificateInstallationRequest_ISO15118_2014			CertificateInstallationRequest;
-	struct CertificateInstallationResponse_ISO15118_2014			CertificateInstallationResponse;
-	struct ChargeParameterDiscoveryRequest_ISO15118_2014 		ChargeParameterDiscoveryRequest;
-	struct ChargeParameterDiscoveryResponse_ISO15118_2014  		ChargeParameterDiscoveryResponse;
-	struct CableCheckRequest_ISO15118_2014 					CableCheckRequest;
-	struct CableCheckResponse_ISO15118_2014  					CableCheckResponse;
-	struct PreChargeRequest_ISO15118_2014 					PreChargeRequest;
-	struct PreChargeResponse_ISO15118_2014					PreChargeResponse;
-	struct PowerDeliveryRequest_ISO15118_2014					PowerDeliveryRequest;
-	struct PowerDeliveryResponse_ISO15118_2014					PowerDeliveryResponse;
-	struct ChargingStatusRequest_ISO15118_2014	  				ChargingStatusRequest;
-	struct ChargingStatusResponse_ISO15118_2014				ChargingStatusResponse;
-	struct CurrentDemandRequest_ISO15118_2014	 			CurrentDemandRequest;
-	struct CurrentDemandResponse_ISO15118_2014				CurrentDemandResponse;
-	struct MeteringReceiptRequest_ISO15118_2014				MeteringReceiptRequest;
-	struct MeteringReceiptResponse_ISO15118_2014				MeteringReceiptResponse;
-	struct WeldingDetectionRequest_ISO15118_2014 				WeldingDetectionRequest;
-	struct WeldingDetectionResponse_ISO15118_2014  			WeldingDetectionResponse;
-	struct SessionStopRequest_ISO15118_2014 					SessionStopRequest;
-	struct SessionStopResponse_ISO15118_2014					SessionStopResponse;
-};
-struct V2GMessageType_ISO15118_2018
-{
-	unsigned char										PresentMsgFlowStatus;
-													/* 0: Idle(wait B2 state), 1: CM_SLAC_PARM.REQ, 2: CM_SLAC_PARM.CNF, 3: CM_START_ATTEN_CHAR.IND
-													    4: CM_MNBC_SOUND.IND, 5: CM_ATTEN_CHAR.IND, 6: CM_ATTEN_CHAR.RSP, 7: CM_VALIDATE.REQ
-													    8: CM_VALIDATE.CNF, 9: CM_SLAC_MATCH.REQ, 10: CM_SLAC_MATCH.CNF, 11: CM_AMP_MAP.REQ
-													    12: CM_AMP_MAP.CNF, 13: SLACC/SDP/TCP connection,
-													    16: SupportedAppProtocolRequest, 17: SupportedAppProtocolResponse, 18: SessionSetupRequest
-													    19: SessionSetupResponse, 20: ServiceDiscoveryRequest, 21: ServiceDiscoveryResponse
-													    22: ServiceDetailRequest, 23: ServiceDetailResponse
-													    24: ServiceAndPaymentSelectionRequest/ServiceSelectionRequest, 25: ServiceAndPaymentSelectionResponse/ServiceSelectionResponse
-													    26: PaymentDetailsRequest/IdentificationDetailsRequest;, 27: PaymentDetailsResponse/IdentificationDetailsResponse,
-													     28: AuthorizationRequest, 29: AuthorizationResponse,
-													    30: CertificateUpdateRequest, 31: CertificateUpdateResponse, 32:CertificateInstallationRequest, 33: CertificateInstallationResponse
-													    34: ChargeParameterDiscoveryRequest, 35: ChargeParameterDiscoveryResponse
-													    36: CableCheckRequest, 37: CableCheckResponse, 38: PreChargeRequest, 39: PreChargeResponse
-													    40: PowerDeliveryRequest start, 41: PowerDeliveryResponse start, 42: ChargingStatusRequest, 43: ChargingStatusResponse
-													    44: CurrentDemandRequest, 45: CurrentDemandResponse, 46: MeteringReceiptRequest, 47: MeteringReceiptResponse
-													    48: PowerDeliveryRequest end, 49: PowerDeliveryRequest end, 50: WeldingDetectionRequest, 51: WeldingDetectionResponse,
-													    52: SessionStopRequest, 53: SessionStopResponse
-													   253: Performance Timeout, 254: Sequence Timeout, 255: Fault
-													*/
-	struct SupportedAppProtocolRequest_ISO15118_2018			SupportedAppProtocolRequest;
-	struct SupportedAppProtocolResponse_ISO15118_2018 			SupportedAppProtocolResponse;
-	struct SessionSetupRequest_ISO15118_2018					SessionSetupRequest;
-	struct SessionSetupResponse_ISO15118_2018  					SessionSetupResponse;
-	struct ServiceDiscoveryRequest_ISO15118_2018    				ServiceDiscoveryRequest;
-	struct ServiceDiscoveryResponse_ISO15118_2018    				ServiceDiscoveryResponse;
-	struct ServiceDetailRequest_ISO15118_2018 					ServiceDetailRequest;
-	struct ServiceDetailResponse_ISO15118_2018					ServiceDetailResponse;
-	struct ServiceSelectionRequest_ISO15118_2018				ServiceSelectionRequest;
-	struct ServiceSelectionResponse_ISO15118_2018				ServiceSelectionResponse;
-	struct IdentificationDetailsRequest_ISO15118_2018  			IdentificationDetailsRequest;
-	struct IdentificationDetailsResponse_ISO15118_2018  			IdentificationDetailsResponse;
-	struct AuthorizationRequest_ISO15118_2018  					AuthorizationRequest;
-	struct AuthorizationResponse_ISO15118_2018					AuthorizationResponse;
-	struct CertificateInstallationRequest_ISO15118_2018			CertificateInstallationRequest;
-	struct CertificateInstallationResponse_ISO15118_2018			CertificateInstallationResponse;
-	struct ChargeParameterDiscoveryRequest_ISO15118_2018 		ChargeParameterDiscoveryRequest;
-	struct ChargeParameterDiscoveryResponse_ISO15118_2018  		ChargeParameterDiscoveryResponse;
-	struct CableCheckRequest_ISO15118_2018 					CableCheckRequest;
-	struct CableCheckResponse_ISO15118_2018 					CableCheckResponse;
-	struct PreChargeRequest_ISO15118_2018 					PreChargeRequest;
-	struct PreChargeResponse_ISO15118_2018					PreChargeResponse;
-	struct PowerDeliveryRequest_ISO15118_2018					PowerDeliveryRequest;
-	struct PowerDeliveryResponse_ISO15118_2018					PowerDeliveryResponse;
-	struct ChargingStatusRequest_ISO15118_2018	  				ChargingStatusRequest;
-	struct ChargingStatusResponse_ISO15118_2018				ChargingStatusResponse;
-	struct CurrentDemandRequest_ISO15118_2018	 			CurrentDemandRequest;
-	struct CurrentDemandResponse_ISO15118_2018				CurrentDemandResponse;
-	struct MeteringReceiptRequest_ISO15118_2018				MeteringReceiptRequest;
-	struct MeteringReceiptResponse_ISO15118_2018				MeteringReceiptResponse;
-	struct WeldingDetectionRequest_ISO15118_2018 				WeldingDetectionRequest;
-	struct WeldingDetectionResponse_ISO15118_2018  			WeldingDetectionResponse;
-	struct SessionStopRequest_ISO15118_2018 					SessionStopRequest;
-	struct SessionStopResponse_ISO15118_2018					SessionStopResponse;
-};
-
-struct CcsData
-{
-	unsigned char 							CommProtocol;	// 1: V2GMessage_DIN70121, 2:V2GMessage_ISO15118_2014, 3:V2GMessage_ISO15118_2018
-	struct V2GMessageType_DIN70121			V2GMessage_DIN70121[CCS_QUANTITY];
-	struct V2GMessageType_ISO15118_2014  		V2GMessage_ISO15118_2014[CCS_QUANTITY];
-	struct V2GMessageType_ISO15118_2018  		V2GMessage_ISO15118_2018[CCS_QUANTITY];
-};
-/**************************************************************************************/
-/***************STM32F407 Communication Share memory**************************/
-/**************************************************************************************/
-struct PrimaryMcuData
-{
-	unsigned char 	SelfTest_Comp;
-	unsigned char	version[16];									//STM32F407 firmware version
-	unsigned int 	InputVoltage;									//value comes from external meter
-	unsigned int 	InputCurrent;									//value comes from external meter
-	union
-	{
-		unsigned char OutputDrvValue[1];
-		struct
-		{
-			//OutputDrvValue[0]
-			unsigned char OnButtonLedDrv:1;                     //bit 0,    H: ON,      L:OFF
-			unsigned char OffButtonLedDrv:1;                    //bit 1,    H: ON,      L:OFF
-			unsigned char SystemLed1Drv:1;                      //bit 2,    H: ON,      L:OFF
-			unsigned char SystemLed2Drv:1;                      //bit 3,    H: ON,      L:OFF
-			unsigned char SystemLed3Drv:1;                      //bit 4,    H: ON,      L:OFF
-			unsigned char SystemLed4Drv:1;                      //bit 5,    H: ON,      L:OFF
-			unsigned char AcContactorDrv:1;                     //bit 6,    H: ON,      L:OFF
-			unsigned char:1;                                    //bit 7 reserved
-		}bits;
-	}OutputDrv;
-	union
-	{
-		unsigned char InputDetValue[2];
-		struct
-		{
-			//InputDetValue[0]
-		    unsigned char AcContactorDetec:1;					//bit 0,	H: ON, 		L:OFF
-			unsigned char AcMainBreakerDetec:1;					//bit 1,	H: ON, 		L:OFF
-			unsigned char SpdDetec:1; 							//bit 2,	H: ON, 		L:OFF
-			unsigned char DoorOpen:1;							//bit 3,	H: Open,		L:Close
-			unsigned char Gfd1:1;								//bit 4,	H: Trigger,		L:Normal
-			unsigned char Gfd2:1;								//bit 5,	H: Trigger,		L:Normal
-			unsigned char Button1:1;								//bit 6 ,	H: Push, 		L:Release
-			unsigned char Button2:1;								//bit 7,	H: Push, 		L:Release
-			//InputDetValue[1]
-			unsigned char EmergencyButton:1;						//bit 0,	H: Push, 		L:Release
-			unsigned char Key0:1; 								//bit 1,	H: ON, 		L:OFF
-			unsigned char Key1:1; 								//bit 2,	H: ON, 		L:OFF
-			unsigned char Key2:1;								//bit 3,	H: ON, 		L:OFF
-			unsigned char Key3:1; 								//bit 4,	H: ON, 		L:OFF
-			unsigned char :3;									//bit 5~7,	Reserved
-		}bits;
-	}InputDet;
-};
-/**************************************************************************************/
-/*************Fan power module Communication Share memory******************/
-/**************************************************************************************/
-struct FanModuleData
-{
-	unsigned char  SelfTest_Comp;
-	unsigned char	version[16];			//fan power module firmware version
-	unsigned short	PresentFan1Speed;		//RPM
-	unsigned short	PresentFan2Speed;		//RPM
-	unsigned short	PresentFan3Speed;		//RPM
-	unsigned short	PresentFan4Speed;		//RPM
-	unsigned short	SetFan1Speed;			//RPM
-	unsigned short	SetFan2Speed;			//RPM
-	unsigned short	SetFan3Speed;			//RPM
-	unsigned short	SetFan4Speed;			//RPM
-	unsigned short	TestFanSpeed;			//RPM
-	unsigned char	DiffOfAirPressure;		//pa
-	unsigned char	UpdateFW;			//1:do update
-};
-
-/**************************************************************************************/
-/***********Relay control module Communication Share memory******************/
-/**************************************************************************************/
-struct RelayModuleData
-{
-	unsigned char 	SelfTest_Comp;
-	unsigned char	version[16];				//relay module firmware version
-	unsigned short	InputL1Volt;				//XXXXX.x volt
-	unsigned short	InputL2Volt;				//XXXXX.x volt
-	unsigned short	InputL3Volt;				//XXXXX.x volt
-	unsigned short	Gun1FuseOutputVolt;		//XXXXX.x volt
-	unsigned short	Gun2FuseOutputVolt;		//XXXXX.x volt
-	unsigned short	Gun1RelayOutputVolt;		//XXXXX.x volt
-	unsigned short	Gun2RelayOutputVolt;		//XXXXX.x volt
-	unsigned short	Gun1OutputCurrent;		//XXXXX.x amp
-	unsigned short	Gun2OutputCurrent;		//XXXXX.x amp
-	unsigned char	UpdateFW;				//1:do update
-};
-
-/**************************************************************************************/
-/***********Led control module Communication Share memory******************/
-/**************************************************************************************/
-struct LedModuleData
-{
-	unsigned char 	SelfTest_Comp;
-	unsigned char	version[16];				//led module firmware version
-	unsigned short	Connect_1_Status;			// Idle : 0, Charging : 1, Alarm : 2
-	unsigned short	Connect_2_Status;			// Idle : 0, Charging : 1, Alarm : 2
-	unsigned short	EnableFunc;					// reserved
-};
-
-/**************************************************************************************/
-/************************OCPP Share memory***************************************/
-/**************************************************************************************/
-struct StructIdTagInfo
-{
-	unsigned char 	ExpiryDate[28];
-	unsigned char 	ParentIdTag[20];
-	unsigned char 	Status[16];		//Accepted, Blocked, Expired, Invalid, ConcurrentTx
-};
-struct StructLocalAuthorizationList
-{
-	unsigned char 			IdTag[20];
-	struct StructIdTagInfo	IdTagInfo;
-};
-struct StructSampledValue
-{
-	unsigned char 			Value[128];
-	unsigned char 			Context[30];//Interruption.Begin, Interruption.End, Sample.Clock, Sample.Periodic, Transaction.Begin, Transaction.End, Trigger, Other
-	unsigned char 			Format[16];//Raw,SignedData
-	unsigned char 			Measurand[40];/*	"Energy.Active.Export.Register",
-										"Energy.Active.Import.Register",
-										"Energy.Reactive.Export.Register",
-										"Energy.Reactive.Import.Register",
-										"Energy.Active.Export.Interval",
-										"Energy.Active.Import.Interval",
-										"Energy.Reactive.Export.Interval",
-										"Energy.Reactive.Import.Interval",
-										"Power.Active.Export",
-										"Power.Active.Import",
-										"Power.Offered",
-										"Power.Reactive.Export",
-										"Power.Reactive.Import",
-										"Power.Factor",
-										"Current.Import",
-										"Current.Export",
-										"Current.Offered",
-										"Voltage",
-										"Frequency",
-										"Temperature",
-										"SoC",
-										"RPM"
-										*/
-
-	unsigned char 			Phase[10];	/*		"L1",
-										"L2",
-										"L3",
-										"N",
-										"L1-N",
-										"L2-N",
-										"L3-N",
-										"L1-L2",
-										"L2-L3",
-										"L3-L1"
-								*/
-
-	unsigned char 			Location[10];		//Cable,EV,Inlet,Outlet,Body
-	unsigned char 			Unit[20];	/*		"Wh",
-										"kWh",
-										"varh",
-										"kvarh",
-										"W",
-										"kW",
-										"VA",
-										"kVA",
-										"var",
-										"kvar",
-										"A",
-										"V",
-										"K",
-										"Celcius",
-										"Fahrenheit",
-										"Percent"
-								*/
-};
-struct StructMeterValue
-{
-	unsigned char 				TimeStamp[28];
-	struct StructSampledValue	SampledValue[20];
-};
-struct StructConfigurationKeyItems
-{
-	unsigned char 	Item[50];
-};
-struct StructConfigurationKey
-{
-	unsigned char 	Key[50];
-	unsigned char 	ReadOnly[8];	//boolean
-	unsigned char 	Value[500];
-};
-struct StructChargingSchedulePeriod
-{
-	int		StartPeriod;
-	float 	Limit;//0.1;
-	int		NumberPhases;
-};
-struct StructChargingSchedule
-{
-	int											Duration;
-	unsigned char 								StartSchedule[28];
-	unsigned char 								ChargingRateUnit[4];		//A, W
-	struct StructChargingSchedulePeriod			ChargingSchedulePeriod[10];
-	float 										MinChargingRate;			//0.1;
-};
-struct StructChargingProfile
-{
-	int								ChargingProfileId;
-	int								TransactionId;
-	int								StackLevel;
-	unsigned char 					ChargingProfilePurpose[24];	//ChargePointMaxProfile, TxDefaultProfile, TxProfile
-	unsigned char 					ChargingProfileKind[12];		//Absolute, Recurring, Relative
-	unsigned char 					RecurrencyKind[8];			//Daily, Weekly
-	unsigned char 					ValidFrom[28];
-	unsigned char 					ValidTo[28];
-	struct StructChargingSchedule	ChargingSchedule;
-};
-
-struct StructBootNotification
-{
-	unsigned char CpVendor[20];				//chargePointVendor				//mandatory
-	unsigned char CpModel[20];				//chargePointModel				//mandatory
-	unsigned char CpSN[25];					//chargePointSerialNumber
-	unsigned char CbSN[25];					//chargeBoxSerialNumber
-	unsigned char CpFwVersion[50];			//firmwareVersion
-	unsigned char CpIccid[22];				//iccid
-	unsigned char CpImsi[20];				//imsi
-	unsigned char CpMeterType[25];			//meterType
-	unsigned char CpMeterSerialNumber[25];	//meterSerialNumber
-	unsigned char ResponseStatus[16];			//Accepted, Pending, Rejected
-	unsigned char ResponseCurrentTime[28];	//currentTime					//mandatory
-	int 			ResponseHeartbeatInterval;	//interval						//mandatory
-
-};
-struct StructHeartbeat
-{
-	unsigned char 				ResponseCurrentTime[28];
-};
-struct StructAuthorize
-{
-	unsigned char 				IdTag[20];
-	struct StructIdTagInfo		ResponseIdTagInfo;
-};
-struct StructStartTransaction
-{
-	int 						ConnectorId;
-	unsigned char 				IdTag[20];
-	int 						MeterStart;
-	int 						ReservationId;
-	unsigned char 				Timestamp[28];
-	struct StructIdTagInfo		ResponseIdTagInfo;
-	int 						ResponseTransactionId;
-};
-struct StructStopTransaction
-{
-	unsigned char 				IdTag[20];
-	int 						MeterStop;
-	unsigned char 				Timestamp[28];
-	int 						TransactionId;
-	unsigned char 				StopReason[20];				/*	"EmergencyStop",
-															"EVDisconnected",
-															"HardReset",
-															"Local",
-															"Other",
-															"PowerLoss",
-															"Reboot",
-															"Remote",
-															"SoftReset",
-															"UnlockCommand",
-															"DeAuthorized"
-														*/
-	struct StructMeterValue		TransactionData[1];
-	struct StructIdTagInfo		ResponseIdTagInfo;
-};
-
-struct StructStatusNotification
-{
-	int 			ConnectorId;
-	unsigned char 	ErrorCode[25];				/*	"ConnectorLockFailure",
-								                "EVCommunicationError",
-								                "GroundFailure",
-								                "HighTemperature",
-								                "InternalError",
-								                "LocalListConflict",
-								                "NoError",
-								                "OtherError",
-								                "OverCurrentFailure",
-								                "PowerMeterFailure",
-								                "PowerSwitchFailure",
-								                "ReaderFailure",
-								                "ResetFailure",
-								                "UnderVoltage",
-								                "OverVoltage",
-								                "WeakSignal"
-								            */
-
-	unsigned char 	Info[50];
-	unsigned char 	Status[20];					/*	"Available",
-								                "Preparing",
-								                "Charging",
-								                "SuspendedEVSE",
-								                "SuspendedEV",
-								                "Finishing",
-								                "Reserved",
-								                "Unavailable",
-								                "Faulted"
-								            */
-
-	unsigned char 	Timestamp[28];
-	unsigned char 	VendorId[256];
-	unsigned char 	VendorErrorCode[50];
-};
-
-
-struct StructCancelReservation
-{
-	int 				ReservationId;
-	unsigned char 		ResponseStatus[16];		//Accepted, Rejected
-	unsigned char 		guid[37];
-};
-struct StructChangeAvailability
-{
-	int 				ConnectorId;
-	unsigned char 		Type[16];					//Inoperative, Operative
-	unsigned char 		ResponseStatus[16];		//Accepted, Rejected, Scheduled
-	unsigned char 		guid[37];
-};
-struct StructChangeConfiguration
-{
-	unsigned char Key[50];
-	unsigned char Value[500];
-	unsigned char ResponseStatus[16];		//Accepted, Rejected, RebootRequired, NotSupported
-};
-struct StructClearCache
-{
-	unsigned char ResponseStatus[16];		//Accepted, Rejected
-};
-struct StructClearChargingProfile
-{
-	int			 			Id;
-	int						ConnectorId;
-	unsigned char 			ChargingProfilePurpose[24];	//ChargePointMaxProfile, TxDefaultProfile, TxProfile
-	int			 			StackLevel;
-	unsigned char 			ResponseStatus[16];			//Accepted, Unknown
-};
-struct StructDataTransfer
-{
-	unsigned char VendorId[256];
-	unsigned char MessageId[52];
-	unsigned char Data[512];
-	unsigned char ResponseStatus[18];	//Accepted, Rejected,UnknownMessageId,UnknownVendorId
-	unsigned char ResponseData[256];
-};
-struct StructDiagnosticsStatusNotification
-{
-	unsigned char Status[16];		//Idle,Uploaded,UploadFailed,Uploading
-};
-struct StructFirmwareStatusNotification
-{
-	unsigned char Status[20];			//Downloaded,DownloadFailed,Downloading,Idle,InstallationFailed,Installing,Installed
-};
-struct StructGetCompositeSchedule
-{
-	int 							ConnectorId;
-	int 							Duration;
-	unsigned char					ChargingRateUnit[4];		//A,W
-	unsigned char 					ResponseStatus[12];			//Accepted,Rejected
-	int 							ResponseConnectorId;
-	unsigned char					ResponseScheduleStart[28];
-	struct StructChargingSchedule	ResponseChargingSchedule;
-};
-struct StructGetConfiguration
-{
-	struct StructConfigurationKeyItems 			*Key;
-	struct StructConfigurationKey			 	*ResponseConfigurationKey;
-	struct StructConfigurationKeyItems 			*ResponseUnknownKey;
-
-};
-struct StructGetDiagnostics
-{
-	unsigned char 			Location[256];
-	int 					Retries;
-	int						RetryInterval;
-	unsigned char 			StartTime[28];
-	unsigned char 			StopTime[28];
-	unsigned char 			ResponseFileName[256];
-};
-struct StructGetLocalListVersion
-{
-	int ResponseListVersion;
-};
-struct StructMeterValues
-{
-	int					 			ConnectorId;
-	int 							TransactionId;
-	struct StructMeterValue			MeterValue[1];
-};
-struct StructRemoteStartTransaction
-{
-	int								ConnectorId;
-	unsigned char 					IdTag[20];
-	struct StructChargingProfile	ChargingProfile;
-	unsigned char 					ResponseStatus[10];	//Accepted,	Rejected
-	unsigned char 					guid[37];
-};
-struct StructRemoteStopTransaction
-{
-	int 				TransactionId;
-	unsigned char 		ResponseStatus[10];	//Accepted,	Rejected
-};
-struct StructReserveNow
-{
-	int			 		ConnectorId;
-	unsigned char 		ExpiryDate[28];
-	unsigned char 		IdTag[20];
-	unsigned char 		ParentIdTag[20];
-	int					ReservationId;
-	unsigned char 		ResponseStatus[12];		//Accepted, Faulted, Occupied, Rejected, Unavailable
-	unsigned char 		guid[37];   			//OCPP Server request message uuid
-};
-struct StructReset
-{
-	unsigned char		Type[8];			//Hard,	Soft
-	unsigned char 		ResponseStatus[10];	//Accepted,	Rejected
-	unsigned char 		guid[37];   		//OCPP Server request message uuid
-};
-struct StructSendLocalList
-{
-	int										ListVersion;
-	unsigned char 							UpdateType[16];	//Differential,	Full
-	struct StructLocalAuthorizationList		*LocalAuthorizationList;
-	unsigned char 							ResponseStatus[16];	//Accepted,	Failed, NotSupported, VersionMismatch
-};
-struct StructSetChargingProfile
-{
-	int 								ConnectorId;
-	struct StructChargingProfile		ChargingProfile;
-	unsigned char				 		ResponseStatus[16];	//Accepted,	Rejected, NotSupported
-};
-struct StructTriggerMessage
-{
-	unsigned char 		RequestedMessage[32];	/*
-											"BootNotification",
-											"DiagnosticsStatusNotification",
-											"FirmwareStatusNotification",
-											"Heartbeat",
-											"MeterValues",
-											"StatusNotification"
-										*/
-	int					ConnectorId;
-	unsigned char 		ResponseStatus[16];	//Accepted,	Rejected, NotImplemented
-};
-struct StructUnlockConnector
-{
-	int					ConnectorId;
-	unsigned char 		ResponseStatus[16];	//Unlocked,	UnlockFailed, NotSupported
-	unsigned char 		guid[37];   		//OCPP Server request message uuid
-};
-struct StructUpdateFirmware
-{
-	unsigned char 		Location[256];
-	int					Retries;
-	unsigned char 		RetrieveDate[28];
-	int 				RetryInterval;
-};
-
-struct OCPP16ConfigurationItem
-{
-	unsigned char 		ItemName[64];
-	unsigned char 		ItemAccessibility;//0:RO, 1:RW
-	unsigned char 		ItemData[128];
-};
-
-struct OCPP16ConfigurationTable
-{
-	//please refer to OCPP 1.6 chapter 9
-	struct OCPP16ConfigurationItem 			CoreProfile[_CoreProfile_CNT];
-	struct OCPP16ConfigurationItem 			LocalAuthListManagementProfile[3];
-	struct OCPP16ConfigurationItem 			ReservationProfile[1];
-	struct OCPP16ConfigurationItem 			SmartChargingProfile[5];
-};
-
-struct OCPP16Data
-{
-        unsigned char                           OcppServerURL[512];     //http: non-secure OCPP 1.5-S, https: secure OCPP 1.5-S, ws: non-secure OCPP 1.6-J, wss: secure OCPP 1.6-J"
-        unsigned char                           ChargeBoxId[128];
-        unsigned char                           OcppConnStatus;         //0: disconnected, 1: connected
-        unsigned int                            Timeout_Secs;
-        unsigned short                          Ping_Pong_Interval;
-        union
-        {
-            //Operations Initiated by Charge Point
-            unsigned char CpMsgValue[CONNECTOR_QUANTITY];
-            struct
-            {
-                //CpMsgValue[0]
-                unsigned char DataTransferReq:1;        //bit 0,
-                unsigned char DataTransferConf:1;       //bit 1,
-                unsigned char StartTransactionReq:1;    //bit 2,
-                unsigned char StartTransactionConf:1;   //bit 3,
-                unsigned char StopTransactionReq:1;     //bit 4,
-                unsigned char StopTransactionConf:1;    //bit 5,
-                unsigned char :2;                       //bit 6,7 , reserved
-            } bits[CONNECTOR_QUANTITY];
-        }CpMsg;
-
-        union
-        {
-            //Operations Initiated by Sequence Point
-            unsigned char SpMsgValue[1];
-            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,
-            } bits;
-        } SpMsg;
-
-        union
-        {
-            //Operations Initiated by Central System
-            unsigned char CsMsgValue[3 * (CONNECTOR_QUANTITY)];
-            struct
-            {
-                //CsMsgValue[0]
-                unsigned char CancelReservationReq :1;      //bit 0,
-                unsigned char CancelReservationConf :1;     //bit 1,
-                unsigned char ChangeAvailabilityReq :1;     //bit 2,
-                unsigned char ChangeAvailabilityConf :1;    //bit 3,
-                unsigned char ReserveNowReq :1;             //bit 4,
-                unsigned char ReserveNowConf :1;            //bit 5,
-                unsigned char SetChargingProfileReq :1;     //bit 6,
-                unsigned char SetChargingProfileConf :1;    //bit 7,
-                //CsMsgValue[1]
-                unsigned char TriggerMessageReq :1;         //bit 0,
-                unsigned char TriggerMessageConf :1;        //bit 1,
-                unsigned char UnlockConnectorReq :1;        //bit 2,
-                unsigned char UnlockConnectorConf :1;       //bit 3,
-                unsigned char RemoteStartTransactionReq :1; //bit 4,
-                unsigned char RemoteStartTransactionConf :1;//bit 5,
-                unsigned char RemoteStopTransactionReq :1;  //bit 6,
-                unsigned char RemoteStopTransactionConf :1; //bit 7,
-                //CsMsgValue[2]
-                unsigned char ClearChargingProfileReq :1;   //bit 0,
-                unsigned char ClearChargingProfileConf :1;  //bit 1,
-                unsigned char DataTransferReq :1;           //bit 2,
-                unsigned char DataTransferConf :1;          //bit 3,
-                unsigned char GetCompositeScheduleReq :1;   //bit 4,
-                unsigned char GetCompositeScheduleConf :1;  //bit 5,
-                unsigned char :2;                           //bit 6,7
-            } bits[CONNECTOR_QUANTITY];
-        }CsMsg;
-
-        union
-        {
-            //Operations Initiated by Main System
-            unsigned char MsMsgValue[2];
-            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,
-                //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,
-            } bits;
-        } MsMsg;
-
-        union
-        {
-            //Operations triggered by CSU
-            unsigned char CSUMsgValue[CONNECTOR_QUANTITY];
-            struct
-            {
-                //CSUMsgValue[0]
-                unsigned char ChargingProfileReq:1;     //bit 0,
-                unsigned char ChargingProfileConf:1;    //bit 0,
-                unsigned char :6;                       //bit 1,2,3,4,5,6,7 , reserved
-            } 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];
-};
-
-
-/**************************************************************************************/
-/************************* OCPP 2.0 Share memory **************************************/
-/**************************************************************************************/
-/*
- * =============== Enum variable content ===============
- */
-enum AlignedDataCtrlrVariable
-{
-	AlignedDataCtrlr_Enabled=0,
-	AlignedDataCtrlr_Available,
-	AlignedDataCtrlr_Measurands,
-	AlignedDataCtrlr_Interval,
-	AlignedDataCtrlr_SendDuringIdle,
-	AlignedDataCtrlr_SignReadings,
-	AlignedDataCtrlr_TxEndedMeasurands,
-	AlignedDataCtrlr_TxEndedInterval,
-	AlignedDataCtrlr_CNT
-};
-
-enum AuthCtrlrVariable
-{
-	AuthCtrlr_Enabled=0,
-	AuthCtrlr_AdditionalInfoItemsPerMessage,
-	AuthCtrlr_OfflineTxForUnknownIdEnabled,
-	AuthCtrlr_AuthorizeRemoteStart,
-	AuthCtrlr_LocalAuthorizeOffline,
-	AuthCtrlr_LocalPreAuthorize,
-	AuthCtrlr_MasterPassGroupId,
-	AuthCtrlr_CNT
-};
-
-enum AuthCacheCtrlrVariable
-{
-	AuthCacheCtrlr_Enabled=0,
-	AuthCacheCtrlr_Available,
-	AuthCacheCtrlr_LifeTime,
-	AuthCacheCtrlr_Storage,
-	AuthCacheCtrlr_Policy,
-	AuthCacheCtrlr_CNT
-};
-
-enum ClockCtrlrVariable
-{
-	ClockCtrlr_DateTime=0,
-	ClockCtrlr_NtpSource,
-	ClockCtrlr_NtpServerUri,
-	ClockCtrlr_TimeOffset,
-	ClockCtrlr_NextTimeOffsetTransitionDateTime,
-	ClockCtrlr_NextTransition_TimeOffset,
-	ClockCtrlr_TimeSource,
-	ClockCtrlr_TimeZone,
-	ClockCtrlr_CNT
-};
-
-enum ChargingStationVariable
-{
-	ChargingStation_Available=0,
-	ChargingStation_AvailabilityState,
-	ChargingStation_SupplyPhases,
-	ChargingStation_CNT
-};
-
-enum ConnectorVariable
-{
-	Connector_Available=0,
-	Connector_ConnectorType,
-	Connector_SupplyPhases,
-	Connector_CNT
-};
-
-enum CustomizationCtrlrVariable
-{
-	CustomizationCtrlr_CustomImplementationEnabled=0,
-	CustomizationCtrlr_CNT
-};
-
-enum DeviceDataCtrlrVariable
-{
-	DeviceDataCtrlr_GetReport_ItemsPerMessage=0,
-	DeviceDataCtrlr_GetVariables_ItemsPerMessage,
-	DeviceDataCtrlr_GetReport_BytesPerMessage,
-	DeviceDataCtrlr_GetVariables_BytesPerMessage,
-	DeviceDataCtrlr_ConfigurationValueSize,
-	DeviceDataCtrlr_ReportingValueSize,
-	DeviceDataCtrlr_SetVariables_ItemsPerMessage,
-	DeviceDataCtrlr_SetVariables_BytesPerMessage,
-	DeviceDataCtrlr_CNT
-};
-
-enum DisplayMessageCtrlrVariable
-{
-	DisplayMessageCtrlr_Enabled=0,
-	DisplayMessageCtrlr_Available,
-	DisplayMessageCtrlr_DisplayMessages,
-	DisplayMessageCtrlr_SupportedFormats,
-	DisplayMessageCtrlr_SupportedPriorities,
-	DisplayMessageCtrlr_CNT
-};
-
-enum EVSEVariable
-{
-	EVSE_Available=0,
-	EVSE_AvailabilityState,
-	EVSE_SupplyPhases,
-	EVSE_Power,
-	EVSE_CNT
-};
-
-enum LocalAuthListCtrlrVariable
-{
-	LocalAuthListCtrlr_Enabled=0,
-	LocalAuthListCtrlr_Entries,
-	LocalAuthListCtrlr_Available,
-	LocalAuthListCtrlr_ItemsPerMessage,
-	LocalAuthListCtrlr_BytesPerMessage,
-	LocalAuthListCtrlr_Storage,
-	LocalAuthListCtrlr_CNT
-};
-
-enum MonitoringCtrlrVariable
-{
-	MonitoringCtrlr_Enabled=0,
-	MonitoringCtrlr_Available,
-	MonitoringCtrlr_ClearVariableMonitoring_ItemsPerMessage,
-	MonitoringCtrlr_SetVariableMonitoring_ItemsPerMessage,
-	MonitoringCtrlr_ClearVariableMonitoring_BytesPerMessage,
-	MonitoringCtrlr_SetVariableMonitoring_BytesPerMessage,
-	MonitoringCtrlr_OfflineQueuingSeverity,
-	MonitoringCtrlr_CNT
-};
-
-enum OCPPCommCtrlrVariable
-{
-	OCPPCommCtrlr_ActiveNetworkProfile=0,
-	OCPPCommCtrlr_MessageTimeout,
-	OCPPCommCtrlr_FileTransferProtocols,
-	OCPPCommCtrlr_HeartbeatInterval,
-	OCPPCommCtrlr_NetworkConfigurationPriority,
-	OCPPCommCtrlr_NetworkProfileConnectionAttempts,
-	OCPPCommCtrlr_OfflineThreshold,
-	OCPPCommCtrlr_QueueAllMessages,
-	OCPPCommCtrlr_MessageAttempts,
-	OCPPCommCtrlr_MessageAttemptInterval,
-	OCPPCommCtrlr_UnlockOnEVSideDisconnect,
-	OCPPCommCtrlr_WebSocketPingInterval,
-	OCPPCommCtrlr_ResetRetries,
-	OCPPCommCtrlr_PublicKeyWithSignedMeterValue,
-	OCPPCommCtrlr_CNT
-};
-
-enum ReservationCtrlrVariable
-{
-	ReservationCtrlr_Enabled=0,
-	ReservationCtrlr_Available,
-	ReservationCtrlr_NonEvseSpecific,
-	ReservationCtrlr_CNT
-};
-
-enum SampledDataCtrlrVariable
-{
-	SampledDataCtrlr_Enabled=0,
-	SampledDataCtrlr_Available,
-	SampledDataCtrlr_SignReadings,
-	SampledDataCtrlr_TxEndedMeasurands,
-	SampledDataCtrlr_TxEndedInterval,
-	SampledDataCtrlr_TxStartedMeasurands,
-	SampledDataCtrlr_TxUpdatedMeasurands,
-	SampledDataCtrlr_TxUpdatedInterval,
-	SampledDataCtrlr_CNT
-};
-
-enum SecurityCtrlrVariable
-{
-	SecurityCtrlr_BasicAuthPassword=0,
-	SecurityCtrlr_Identity,
-	SecurityCtrlr_OrganizationName,
-	SecurityCtrlr_CertificateEntries,
-	SecurityCtrlr_SecurityProfile,
-	SecurityCtrlr_AdditionalRootCertificateCheck,
-	SecurityCtrlr_CNT
-};
-
-enum SmartChargingCtrlrVariable
-{
-	SmartChargingCtrlr_Enabled=0,
-	SmartChargingCtrlr_Available,
-	SmartChargingCtrlr_ACPhaseSwitchingSupported,
-	SmartChargingCtrlr_ProfileStackLevel,
-	SmartChargingCtrlr_RateUnit,
-	SmartChargingCtrlr_PeriodsPerSchedule,
-	SmartChargingCtrlr_ExternalControlSignalsEnabled,
-	SmartChargingCtrlr_NotifyChargingLimitWithSchedules,
-	SmartChargingCtrlr_Phases3to1,
-	SmartChargingCtrlr_Entries,
-	SmartChargingCtrlr_LimitChangeSignificance,
-	SmartChargingCtrlr_CNT
-};
-
-enum TariffCostCtrlrVariable
-{
-	Tariff_Enabled=0,
-	Tariff_Available,
-	Tariff_TariffFallbackMessage,
-	Cost_Enabled,
-	Cost_Available,
-	Cost_TotalCostFallbackMessage,
-	Cost_Currency,
-	TariffCostCtrlr_CNT
-};
-
-
-enum TxCtrlrVariable
-{
-	TxCtrlr_ChargingBeforeAcceptedEnabled=0,
-	TxCtrlr_EVConnectionTimeOut,
-	TxCtrlr_StopTxOnEVSideDisconnect,
-	TxCtrlr_TxBeforeAcceptedEnabled,
-	TxCtrlr_TxStartPoint,
-	TxCtrlr_TxStopPoint,
-	TxCtrlr_MaxEnergyOnInvalidId,
-	TxCtrlr_StopTxOnInvalidId,
-	TxCtrlr_CNT
-};
-
-/*
- * =============== Common class ===============
- */
-struct ACChargingParametersType
-{
-	int energyAmount;											// Required, Amount of energy requested (in Wh). This includes energy required for preconditioning.
-	int evMinCurrent;											// Required. Minimum current (amps) supported by the electric vehicle (per phase).
-	int evMaxCurrent;											// Required. Maximum current (amps) supported by the electric vehicle (per phase). Includes cable capacity.
-	int evMaxVoltage;											// Required. Maximum voltage supported by the electric vehicle
-};
-
-struct DCChargingParametersType
-{
-	int evMaxCurrent;											// Required. Maximum current (amps) supported by the electric vehicle. Includes cable capacity.
-	int evMaxVoltage;											// Required. Maximum voltage supported by the electric vehicle
-	int energyAmount;											// Optional. Amount of energy requested (in Wh). This inludes energy required for preconditioning.
-	int evMaxPower;												// Optional. Maximum power (in W) supported by the electric vehicle. Required for DC charging.
-	unsigned char stateOfCharge;								// Optional. Energy available in the battery (in percent of the battery capacity)
-	int evEnergyCapacity;										// Optional. Capacity of the electric vehicle battery (in Wh)
-	unsigned char fullSoC;										// Optional. Percentage of SoC at which the EV considers the battery fully charged. (possible values: 0 - 100)
-	unsigned char bulkSoC;										// Optional. Percentage of SoC at which the EV considers a fast charging process to end. (possible values: 0 - 100)
-};
-
-struct AdditionalInfoType
-{
-	unsigned char	additionalIdToken[36];						// Required. This field specifies the additional IdToken.
-	unsigned char	type[50];									// Required. This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties.
-};
-
-struct APNType
-{
-	unsigned char apn[512];										// Required. The Access Point Name as an URL.
-	unsigned char apnUserName[20];								// Optional. APN user name.
-	unsigned char apnPassword[20];								// Optional. APN Password.
-	short int	simPin;											// Optional. SIM card pin code.
-	unsigned char	preferredNetwork[6];						// Optional. Preferred network, written as MCC and MNC concatenated. See note.
-	unsigned char useOnlyPreferredNetwork;						// Optional. Default: false. Use only the preferred Network, do not dial in when not available. See Note.
-	short int apnAuthentication[8];								// Required. Authentication method.
-};
-
-struct VPNType
-{
-	unsigned char server[512];									// Required. VPN Server Address
-	unsigned char user[20];										// Required. VPN User
-	unsigned char group[20];									// Optional. VPN group.
-	unsigned char password[20];									// Required. VPN Password.
-	unsigned char key[255];										// Required. VPN shared secret.
-	unsigned char type[8];										// Required. Type of VPN
-};
-
-struct GroupIdTokenType
-{
-	unsigned char idToken[36];									// Required. IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.
-	unsigned char type[16];										// Required. Enumeration of possible idToken types.
-};
-
-struct MessageContentType
-{
-	unsigned char format[8];									// Required. Format of the message.
-	unsigned char	language[8];								// Optional. Message language identifier. Contains a language code as defined in [RFC5646].
-	unsigned char content[512];									// Required. Message contents.
-};
-
-struct IdTokenInfoType
-{
-	unsigned char status[32];									// Required. Current status of the ID Token.
-	unsigned char cacheExpiryDateTime[28];						// Optional. Date and Time after which the token must be considered invalid.
-	short int	chargingPriority;								// Optional. Priority from a business point of view. Default priority is 0, The range is from -9 to 9. Higher values indicate a higher priority.
-	unsigned char language1[8];									// Optional. Preferred user interface language of identifier user. Contains a language code as defined in [RFC5646].
-	unsigned int evseId[100];									// Optional. Only used when the IdToken is only valid for one or more specific EVSEs, not for the entire Charging Station.
-	unsigned char language2[8];									// Optional. Second preferred user interface language of identifier user. Don?冲 use when language1 is omitted, has to be different from language1.
-	struct GroupIdTokenType groupIdToken;						// Optional. This contains the group identifier.
-	struct MessageContentType personalMessage;					// Optional. Personal message that can be shown to the EV Driver and can be used for tariff information, user greetings etc.
-};
-
-struct IdTokenType
-{
-	unsigned char idToken[36];									// Required. IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.
-	unsigned char	type[16];									// Required. Enumeration of possible idToken types.
-	struct AdditionalInfoType additionalInfo[10];				// Optional. AdditionalInfo can be used to send extra information which can be validated by the CSMS in addition to the regular authorization with IdToken.
-};
-
-struct AuthorizationData
-{
-	struct IdTokenInfoType idTokenInfo;							// Optional. Required when UpdateType is Full. This contains information about authorization status, expiry and group id.
-	struct IdTokenType idToken;									// Required. This contains the identifier which needs to be stored for authorization.
-};
-
-struct CertificateHashDataType
-{
-	unsigned char hashAlgorithm[8];								// Required. Used algorithms for the hashes provided.
-	unsigned char issuerNameHash[128];							// Required. hashed value of the IssuerName.
-	unsigned char issuerKeyHash[128];							// Required. Hashed value of the issuers public key
-	unsigned char serialNumber[40];								// Required. The serial number of the certificate.
-};
-
-struct CertificateHashDataChainType
-{
-	unsigned char certificateType[32];							// Required. Indicates the type of the requested certificate(s).
-	struct CertificateHashDataType certificateHashData;			// Required. Information to identify a certificate.
-	struct CertificateHashDataType childCertificateHashData[4]; // Optional. Information to identify the child certificate(s).
-};
-
-
-struct ChargingLimitType
-{
-	unsigned char chargingLimitSource[8];						// Required. Represents the source of the charging limit.
-	unsigned char isGridCritical;								// Optional. Indicates whether the charging limit is critical for the grid.
-};
-
-struct ChargingNeedsType
-{
-	unsigned char requestedEnergyTransfer[32];					// Required. Mode of energy transfer requested by the EV.
-	unsigned char departureTime[28];							// Optional. Estimated departure time of the EV.
-	struct ACChargingParametersType acChargingParameters;		// Optional. EV AC charging parameters.
-	struct DCChargingParametersType dcChargingParameters;		// Optional. EV DC charging parameters
-};
-
-struct ChargingProfileCriterionType
-{
-	unsigned char chargingProfilePurpose[36];					// Optional. Defines the purpose of the schedule transferred by this profile
-	unsigned short int stackLevel;								// Optional. Value determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0.
-	unsigned short int chargingProfileId[10];					// Optional. List of all the chargingProfileIds requested. Any ChargingProfile that matches one of these profiles will be reported.
-	unsigned char chargingLimitSource[4][8];					// Optional. For which charging limit sources, charging profiles SHALL be reported. If omitted, the Charging Station SHALL not filter on chargingLimitSource.
-};
-
-struct RelativeTimeIntervalTypeOCPP
-{
-	unsigned int start;											// Required. Start of the interval, in seconds from NOW.
-	unsigned int duration;										// Optional. Duration of the interval, in seconds.
-};
-
-struct CostTypeOCPP
-{
-	unsigned char costKind[36];									// Required. The kind of cost referred to in the message element amount
-	int amount;													// Required. The estimated or actual cost per kWh
-};
-
-struct ConsumptionCostTypeOCPP
-{
-	float startValue;											// Required. The lowest level of consumption that defines the starting point of this consumption block. The block interval extends to the start of the next interval.
-	struct CostTypeOCPP cost[3];								// Required. This field contains the cost details.
-};
-
-struct SalesTariffEntryTypeOCPP
-{
-	unsigned short int ePriceLevel;								// Optional. Defines the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a more expensive TariffEntry.
-	struct RelativeTimeIntervalTypeOCPP relativeTimeInterval;	// Required. Defines the time interval the SalesTariffEntry is valid for, based upon relative times.
-	struct ConsumptionCostTypeOCPP consumptionCost[3];			// Optional. Defines additional means for further relative price information and/or alternative costs.
-};
-
-struct SalesTariffTypeOCPP
-{
-	unsigned short int id;										// Required. SalesTariff identifier used to identify one sales tariff. An SAID remains a unique identifier for one schedule throughout a charging session.
-	unsigned char salesTariffDescription[32];					// Optional. A human readable title/short description of the sales tariff e.g. for HMI display purposes.
-	unsigned short int numEPriceLevels;							// Optional. Defines the overall number of distinct price levels used across all provided SalesTariff elements.
-	struct SalesTariffEntryTypeOCPP salesTariffEntry[1024];		// Required. Encapsulating element describing all relevant details for one time interval of the SalesTariff. The number of SalesTariffEntry elements is limited by the parameter maxScheduleTuples.
-};
-
-struct ChargingSchedulePeriodType
-{
-	int startPeriod;											// Required. Start of the period, in seconds from the start of schedule. The value of StartPeriod also defines the stop time of the previous period.
-	float limit;												// Required. Charging rate limit during the schedule period, in the applicable chargingRateUnit, for example in Amperes (A) or Watts (W). Accepts at most one digit fraction (e.g. 8.1).
-	unsigned char	numberPhases;								// Optional. The number of phases that can be used for charging. If a number of phases is needed, numberPhases=3 will be assumed unless another number is given.
-	unsigned char phaseToUse;									// Optional. Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase connected to theEV, i.e. ACPhaseSwitchingSupported is defined and true.
-};
-
-struct ChargingScheduleType
-{
-	unsigned char startSchedule[28];							// Optional. Starting point of an absolute schedule. If absent the schedule will be relative to start of charging.
-	unsigned int duration;										// Optional. Duration of the charging schedule in seconds.
-	unsigned char chargingRateUnit[8];							// Required. The unit of measure Limit is expressed in.
-	float minChargingRate;										// Optional. Minimum charging rate supported by the EV.
-	unsigned short int id;										// Required. Identifies the ChargingSchedule.
-	struct ChargingSchedulePeriodType chargingSchedulePeriod[1024];	// Required. List of ChargingSchedulePeriod elements defining maximum power or current usage over time.
-	struct SalesTariffTypeOCPP salesTariff;						// Optional. Sales tariff associated with this charging schedule.
-};
-
-struct ChargingProfileType
-{
-	unsigned short int id;											// Required. Id of ChargingProfile.
-	unsigned short int stackLevel;									// Required. Value determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0.
-	unsigned char chargingProfilePurpose[36];						// Required. Defines the purpose of the schedule transferred by this profile
-	unsigned char chargingProfileKind[16];							// Required. Indicates the kind of schedule.
-	unsigned char recurrencyKind[8];								// Optional. Indicates the start point of a recurrence.
-	unsigned char validFrom[28];									// Optional. Point in time at which the profile starts to be valid. If absent, the profile is valid as soon as it is received by the Charging Station.
-	unsigned char validTo[28];										// Optional. Point in time at which the profile stops to be valid. If absent, the profile is valid until it is replaced by another profile.
-	unsigned char transactionId[36];								// Optional. SHALL only be included if ChargingProfilePurpose is set to TxProfile. The transactionId is used to match the profile to a specific transaction.
-	struct ChargingScheduleType chargingSchedule[3];				// Required. Schedule that contains limits for the available power or current over time. In order to support ISO 15118 schedule negotiation, it supports at most three schedules with associated tariff to choose from.
-};
-
-struct ModemType
-{
-	unsigned char iccid[20];										// Optional. This contains the ICCID of the modem?冱 SIM card.
-	unsigned char imsi[20];											// Optional. This contains the IMSI of the modem?冱 SIM card.
-};
-
-struct ChargingStationType
-{
-	unsigned char serialNumber[25];									// Optional. Vendor-specific device identifier.
-	unsigned char model[20];										// Required. Defines the model of the device.
-	unsigned char vendorName[50];									// Required. Identifies the vendor (not necessarily in a unique manner).
-	unsigned char firmwareVersion[50];								// Optional. This contains the firmware version of the Charging Station.
-	struct ModemType modem;											// Optional. Defines the functional parameters of a communication link.
-};
-
-struct ClearChargingProfileType
-{
-	unsigned int evseId;											// Optional. Specifies the id of the EVSE for which to clear charging profiles.
-	unsigned char chargingProfilePurpose[36];						// Optional. Specifies to purpose of the charging profiles that will be cleared, if they meet the other criteria in the request.
-	unsigned short int stackLevel;									// Optional. Specifies the stackLevel for which charging profiles will be cleared, if they meet the other criteria in the request.
-};
-
-struct ClearMonitoringResultType
-{
-	unsigned short int id;											// Required. Id of the monitor of which a clear was requested.
-	unsigned char status[16];										// Required. Result of the clear request for this monitor, identified by its Id.
-};
-
-struct EVSEType
-{
-	unsigned int id;												// Required. EVSE Identifier. This contains a number (> 0) designating an EVSE of the Charging Station.
-	unsigned char connectorId;										// Optional. An id to designate a specific connector (on an EVSE) by connector index number.
-};
-
-struct VariableType
-{
-	unsigned char name[50];											// Required. Name of the variable.
-	unsigned char instance[50];										// Optional. Name of instance in case the variable exists as multiple instances.
-};
-
-struct VariableAttributeType
-{
-	unsigned char type[8];											// Optional. Attribute: Actual, MinSet, MaxSet, etc. Defaults to Actual if absent.
-	unsigned char value[2500];										// Optional. Value of the attribute. May only be omitted when mutability is set to 'WriteOnly'.
-	unsigned char mutability[16];									// Optional. Defines the mutability of this attribute. Default is ReadWrite when omitted.
-	unsigned char persistent;										// Optional. If true, value will be persistent across system reboots or power down. Default when omitted is false.
-	unsigned char constant;											// Optional. If true, value that will never be changed by the Charging Station at runtime. Default when omitted is false.
-};
-
-struct VariableCharacteristicsType
-{
-	unsigned char unit[16];											// Optional. Unit of the variable. When the transmitted value has a unit, this field SHALL be included.
-	unsigned char dataType[16];										// Required. Data type of this variable.
-	float 	minLimit;												// Optional. Minimum possible value of this variable.
-	float 	maxLimit;												// Optional. Maximum possible value of this variable.
-	unsigned char valuesList[1000];									// Optional. Allowed values when variable is Option/Member/SequenceList.
-	unsigned char supportsMonitoring;								// Required. Flag indicating if this variable supports monitoring.
-};
-
-struct ComponentType
-{
-	unsigned char name[50];											// Required. Name of the component.
-	unsigned char instance[50];										// Optional. Name of instance in case the component exist as multiple instances.
-	struct EVSEType evse;											// Optional. Specifies the EVSE when component is located at EVSE level, also specifies the connector when component is located at Connector level.
-};
-
-struct ComponentVariableType
-{
-	struct ComponentType component;									// Required. Component for which a report of Variable is requested.
-	struct VariableType variable;									// Optional. Variable(s) for which the report is requested.
-};
-
-struct CompositeScheduleType
-{
-	unsigned char startDateTime[28];								// Required. Date and time at which the schedule becomes active.
-	struct ChargingScheduleType chargingSchedule;					// Required. Charging schedule structure defines a list of charging periods.
-};
-
-struct EventDataType
-{
-	unsigned int eventId;											// Required. Identifies the event. This field can be referred to as a cause by other events.
-	unsigned char timestamp[28];									// Required. Timestamp of the moment the report was generated.
-	unsigned char trigger[16];										// Required. Type of monitor that triggered this event, e.g. exceeding a threshold value.
-	unsigned int cause;												// Optional. Refers to the Id of an event that is considered to be the cause for this event.
-	unsigned char actualValue[2500];								// Required. Actual value (attributeType Actual) of the variable.
-	unsigned char techcode[50];										// Optional. Technical (error) code as reported by component.
-	unsigned char techInfo[500];									// Optional. Technical detail information as reported by component.
-	unsigned char cleared;											// Optional. Cleared is set to true to report the clearing of a monitored situation, i.e. a 'return to normal'.
-	unsigned char transactionId[36];								// Optional. If an event notification is linked to a specific transaction, this field can be used to specify its transactionId.
-	unsigned int variableMonitoringId;								// Optional. Identifies the VariableMonitoring which triggered the event.
-	unsigned char eventNotificationType[32];						// Required. Specifies the event notification type of the message.
-	struct ComponentType component;									// Required. Component for which event is notified.
-	struct VariableType variable;									// Required. Variable for which event is notified.
-};
-
-struct FirmwareType
-{
-	unsigned char location[512];									// Required. URI defining the origin of the firmware.
-	unsigned char retrieveDateTime[28];								// Required. Date and time at which the firmware shall be retrieved.
-	unsigned char installDateTime[28];								// Optional. Date and time at which the firmware shall be installed.
-	unsigned char signingCertificate[5500];							// Optional. Certificate with which the firmware was signed. X.509 certificate, first DER encoded into binary, and then Base64 encoded.
-	unsigned char signature[800];									// Optional. Base64 encoded firmware signature.
-};
-
-struct GetVariableDataType
-{
-	unsigned char attributeType[8];									// Optional. Attribute type for which value is requested. When absent, default Actual is assumed.
-	struct ComponentType component;									// Required. Component for which the Variable is requested.
-	struct VariableType variable;									// Required. Variable for which the attribute value is requested.
-};
-
-struct GetVariableResultType
-{
-	unsigned char attributeStatus[32];								// Required. Result status of getting the variable.
-	unsigned char attributeType[8];									// Optional. Attribute type for which value is requested. When absent, default Actual is assumed.
-	unsigned char attributeValue[2500];								// Optional. Value of requested attribute type of component- variable.
-	struct ComponentType component;									// Required. Component for which the Variable is requested.
-	struct VariableType variable;									// Required. Variable for which the attribute value is requested.
-};
-
-struct LogParametersType
-{
-	unsigned char remoteLocation[512];								// Required. The URL of the location at the remote system where the log should be stored.
-	unsigned char oldestTimestamp[28];								// Optional. This contains the date and time of the oldest logging information to include in the diagnostics.
-	unsigned char latestTimestamp[28];								// Optional. This contains the date and time of the latest logging information to include in the diagnostics.
-};
-
-struct MessageInfoType
-{
-	unsigned int id;												// Required. Master resource identifier, unique within an exchange context. It is defined within the OCPP context as a positive Integer value (greater or equal to zero).
-	unsigned char priority[16];										// Required. With what priority should this message be shown
-	unsigned char state[16];										// Optional. During what state should this message be shown. When omitted this message should be shown in any state of the Charging Station.
-	unsigned char startDateTime[28];								// Optional. From what date-time should this message be shown. If omitted: directly.
-	unsigned char endDateTime[28];									// Optional. Until what date-time should this message be shown, after this date/time this message SHALL be removed.
-	unsigned char transactionId[36];								// Optional. During which transaction shall this message be shown. Message SHALL be removed by the Charging Station after transaction has ended.
-	struct MessageContentType message;								// Required. Contains message details for the message to be displayed on a Charging Station.
-	struct ComponentType display;									// Optional. When a Charging Station has multiple Displays, this field can be used to define to which Display this message belongs.
-};
-
-struct SignedMeterValueType
-{
-	unsigned char signedMeterData[2500];							// Required. Base64 encoded, contains the signed data which might contain more then just the meter value. It can contain information like timestamps, reference to a customer etc.
-	unsigned char signingMethod[50];								// Required. Method used to create the digital signature.
-	unsigned char encodingMethod[50];								// Required. Method used to encode the meter values before applying the digital signature algorithm.
-	unsigned char publicKey[2500];									// Required. Base64 encoded, sending depends on configuration variable PublicKeyWithSignedMeterValue.
-};
-
-struct UnitOfMeasureType
-{
-	unsigned char uint[20];											// Optional. Unit of the value. Default = "Wh" if the (default) measurand is an "Energy" type.
-	unsigned short int multiplier;									// Optional. Multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 raised to the 3rd power. Default is 0.
-};
-
-struct SampledValueType
-{
-	float value;													// Required. Indicates the measured value.
-	unsigned char context[32];										// Optional. Type of detail value: start, end or sample. Default = "Sample.Periodic"
-	unsigned char measurand[32];									// Optional. Type of measurement. Default = "Energy.Active.Import.Register"
-	unsigned char phase[8];											// Optional. Indicates how the measured value is to be interpreted.
-	unsigned char location[8];										// Optional. Indicates where the measured value has been sampled. Default = "Outlet"
-	struct SignedMeterValueType signedMeterValue;					// Optional. Contains the MeterValueSignature with sign/encoding method information.
-	struct UnitOfMeasureType unitOfMeasure;							// Optional. Represents a UnitOfMeasure including a multiplier
-};
-
-struct MeterValueType
-{
-	unsigned char timestamp[28];									// Required. Timestamp for measured value(s).
-	struct SampledValueType sampledValue[10];							// Required. One or more measured values
-};
-
-struct VariableMonitoringType
-{
-	unsigned int id;												// Required. Identifies the monitor.
-	float value;													// Required. Value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the interval in seconds.
-	unsigned char type[32];											// Required. The type of this monitor, e.g. a threshold, delta or periodic monitor.
-	unsigned char severity;											// Required. The severity that will be assigned to an event that is triggered by this monitor.
-	unsigned char transaction;										// Required. Monitor only active when a transaction is ongoing on a component relevant to this transaction.
-};
-
-struct MonitoringDataType
-{
-	struct ComponentType component;									// Required. Component for which monitoring report was requested.
-	struct VariableType variable;									// Required. Variable for which monitoring report was requested.
-	struct VariableMonitoringType variableMonitoring[10];			// Required. List of monitors for this Component-Variable pair.
-};
-
-struct NetworkConnectionProfileType
-{
-	unsigned char ocppVersion[8];									// Required. Defines the OCPP version used for this communication function.
-	unsigned char ocppTransport[8];									// Required. Defines the transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in OCPP 2.0, but is supported by other versions of OCPP.
-	unsigned char ocppCsmsUrl[512];									// Required. URL of the CSMS(s) that this Charging Station communicates with.
-	unsigned int messageTimeout;									// Required. Duration in seconds before a message send by the Charging Station via this network connection times- out. The best setting depends on the underlying network and response times of the CSMS. If you are looking for a some guideline: use 30 seconds as a starting point.
-	unsigned char ocppInterface[16];								// Required. Applicable Network Interface.
-	struct VPNType vpn;												// Optional. Settings to be used to set up the VPN connection
-	struct APNType apn;												// Optional. Collection of configuration data needed to make a data-connection over a cellular network.
-};
-
-struct OCSPRequestDataType
-{
-	unsigned char hashAlgorithm[8];									// Required. Used algorithms for the hashes provided.
-	unsigned char issuerNameHash[128];								// Required. hashed value of the IssuerName.
-	unsigned char issuerKeyHash[128];								// Required. Hashed value of the issuers public key
-	unsigned char serialNumber[40];									// Required. The serial number of the certificate.
-	unsigned char responderURL[512];								// Required. This contains the responder URL (Case insensitive).
-};
-
-struct ReportDataType
-{
-	struct ComponentType component;									// Required. Component for which a report of Variable is requested.
-	struct VariableType variable;									// Required. Variable for which report is requested.
-	struct VariableAttributeType variableAttribute[4];				// Required. Attribute data of a variable.
-	struct VariableCharacteristicsType variableCharacteristics;		// Optional. Fixed read-only parameters of a variable.
-};
-
-struct SetMonitoringDataType
-{
-	unsigned int id;												// Optional. An id SHALL only be given to replace an existing monitor. The Charging Station handles the generation of id?冱 for new monitors.
-	float value;													// Required. Value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the interval in seconds.
-	unsigned char type[32];											// Required. The type of this monitor, e.g. a threshold, delta or periodic monitor.
-	unsigned char severity;											// Required. The severity that will be assigned to an event that is triggered by this monitor.
-	unsigned char transaction;										// Optional. Monitor only active when a transaction is ongoing on a component relevant to this transaction. Default = false.
-	struct ComponentType component;									// Required. Component for which monitor is set.
-	struct VariableType variable;									// Required. Variable for which monitor is set.
-};
-
-struct SetMonitoringResultType
-{
-	unsigned int id;												// Optional. Id given to the VariableMonitor by the Charging Station.
-	unsigned char type[32];											// Required. The type of this monitor, e.g. a threshold, delta or periodic monitor.
-	unsigned char severity;											// Required. The severity that will be assigned to an event that is triggered by this monitor.
-	unsigned char status[32];										// Required. Status is OK if a value could be returned.
-	struct ComponentType component;									// Required. Component for which status is returned.
-	struct VariableType variable;									// Required. Variable for which status is returned.
-};
-
-struct SetVariableDataType
-{
-	unsigned char attributeType[8];									// Optional. Type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted.
-	unsigned char attributeValue[1000];								// Required. Value to be assigned to attribute of variable.
-	struct ComponentType component;									// Required. The component for which the variable data is set.
-	struct VariableType variable;									// Required. Specifies the that needs to be set.
-};
-
-struct SetVariableResultType
-{
-	unsigned char attributeType[8];									// Optional. Type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted.
-	unsigned char attributeStatus[32];								// Required. Result status of setting the variable.
-	struct ComponentType component;									// Required. The component for which result is returned.
-	struct VariableType variable;									// Required. The variable for which the result is returned.
-};
-
-struct TransactionType
-{
-	unsigned char transactionId[36];								// Required. This contains the Id of the transaction.
-	unsigned char chargingState[16];								// Optional. Current charging state, is required when state has changed. Omitted when there is no communication between EVSE and EV, because no cable is plugged in.
-	unsigned int timeSpentCharging;									// Optional. Contains the total time that energy flowed from EVSE to EV during the transaction (in seconds). Note that timeSpentCharging is smaller or equal to the duration of the transaction.
-	unsigned char stoppedReason[20];								// Optional. This contains the reason why the transaction was stopped. MAY only be omitted when Reason is "Local".
-	unsigned int remoteStartId;										// Optional. The ID given to remote start request (RequestStartTransactionRequest.
-};
-
-/*
- * =============== Message ===============
- */
-struct Authorize_20
-{
-	struct IdTokenType idToken;										// Required. This contains the identifier that needs to be authorized.
-	struct OCSPRequestDataType iso15118CertificateHashData[4];		// Optional. Contains the information needed to verify the EV Contract Certificate via OCSP.
-	unsigned char Response_certificateStatus[32];					// Optional. Certificate status information. - if all certificates are valid: return 'Accepted'. - if one of the certificates was revoked, return 'CertificateRevoked'.
-	struct IdTokenInfoType Response_idTokenInfo;					// Required. This contains information about authorization status, expiry and group id.
-};
-
-struct BootNotification_20
-{
-	unsigned char reason[20];										// Required. This contains the reason for sending this message to the CSMS.
-	struct ChargingStationType chargingStation;						// Required. Identifies the Charging Station
-	unsigned char Response_currentTime[28];							// Required. This contains the CSMS?冱 current time.
-	unsigned int Response_interval;									// Required. When Status is Accepted, this contains the heartbeat interval in seconds. If the CSMS returns something other than Accepted, the value of the interval field indicates the minimum wait time before sending a next BootNotification request.
-	unsigned char Response_status[16];								// Required. This contains whether the Charging Station has been registered within the CSMS.
-};
-
-struct CancelReservation_20
-{
-	int reservationId;												// Required. Id of the reservation to cancel.
-	unsigned char Response_status[16];								// Required. This indicates the success or failure of the canceling of a reservation by CSMS.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct CertificateSigned_20
-{
-	unsigned char certificate[10][5500];							// Required. The signed X.509 certificate, first DER encoded into binary, and then Base64 encoded. This can also contain the necessary sub CA certificates. In that case, the order should follow the certificate chain, starting from the leaf certificate.
-	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.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct ChangeAvailability_20
-{
-	unsigned char operationalStatus[16];							// Required. This contains the type of availability change that the Charging Station should perform.
-	struct EVSEType evse;											// Optional. Contains Id?冱 to designate a specific EVSE/connector by index numbers. When omitted, the message refers to the Charging Station as a whole.
-	unsigned char Response_status[16];								// Required. This indicates whether the Charging Station is able to perform the availability change.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct ClearCache_20
-{
-	unsigned char Response_status[16];								// Required. Accepted if the Charging Station has executed the request, otherwise rejected.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct ClearChargingProfile_20
-{
-	unsigned int chargingProfileId;									// Optional. The Id of the charging profile to clear.
-	struct  ClearChargingProfileType chargingProfileCriteria;		// Optional. Specifies the charging profile.
-	unsigned char Response_status[16];								// Required. Indicates if the Charging Station was able to execute the request.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct ClearDisplayMessage_20
-{
-	unsigned int id;												// Required. Id of the message that SHALL be removed from the Charging Station.
-	unsigned char Response_status[16];								// Required. Returns whether the Charging Station has been able to remove the message.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct ClearedChargingLimit_20
-{
-	unsigned char chargingLimitSource[8];							// Required. Source of the charging limit.
-	unsigned int evseId;											// Optional. EVSE Identifier.
-};
-
-struct ClearVariableMonitoring_20
-{
-	unsigned int id[10];										 	// Required. List of the monitors to be cleared, identified by there Id.
-	struct ClearMonitoringResultType Response_clearMonitoringResult[10];// Required. List of result statuses per monitor.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct CostUpdated_20
-{
-	float totalCost;												// Required. Current total cost, based on the information known by the CSMS, of the transaction including taxes. In the currency configured with the configuration Variable: [Currency]
-	unsigned char transactionId[36];								// Required. Transaction Id of the transaction the current cost are asked for.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct CustomerInformation_20
-{
-	unsigned int requestId;											// Required. The Id of the request.
-	unsigned char report;											// Required. Flag indicating whether the Charging Station should return NotifyCustomerInformationRequest messages containing information about the customer referred to.
-	unsigned char clear;											// Required. Flag indicating whether the Charging Station should clear all information about the customer referred to.
-	unsigned char customerIdentifier[64];							// Optional. A (e.g. vendor specific) identifier of the customer this request refers to. This field contains a custom identifier other than IdToken and Certificate. One of the possible identifiers (customerIdentifier, customerIdToken or customerCertificate) should be in the request message.
-	struct IdTokenType idToken;										// Optional. The IdToken of the customer this request refers to. One of the possible identifiers (customerIdentifier, customerIdToken or customerCertificate) should be in the request message.
-	struct CertificateHashDataType customerCertificate;				// Optional. The Certificate of the customer this request refers to. One of the possible identifiers (customerIdentifier, customerIdToken or customerCertificate) should be in the request message.
-	unsigned char Response_status[16];								// Required. Indicates whether the request was accepted.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct DataTransfer_20
-{
-	unsigned char messageId[50];									// Optional. May be used to indicate a specific message or implementation.
-	unsigned char data[512];										// Optional. Data without specified length or format. This needs to be decided by both parties (Open to implementation).
-	unsigned char vendorId[255];									// Required. This identifies the Vendor specific implementation
-	unsigned char Response_status[20];								// Required. This indicates the success or failure of the data transfer.
-	unsigned char Response_data[512];								// Optional. Data without specified length or format, in response to request.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct DeleteCertificate_20
-{
-	struct CertificateHashDataType certificateHashData;				// Required. Indicates the certificate of which deletion is requested.
-	unsigned char Response_status[16];								// Required. Charging Station indicates if it can process the request.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct FirmwareStatusNotification_20
-{
-	unsigned char status[32];										// Required. This contains the progress status of the firmware installation.
-	unsigned int requestId;											// Optional. The request id that was provided in the UpdateFirmwareRequest that started this firmware update. This field is mandatory, unless the message was triggered by a TriggerMessageRequest AND there is no firmware update ongoing.
-};
-
-struct Get15118EVCertificate_20
-{
-	unsigned char iso15118SchemaVersion[50];						// Required. Schema version currently used for the 15118 session between EV and Charging Station. Needed for parsing of the EXI stream by the CSMS.
-	unsigned char action[16];										// Required. Defines whether certificate needs to be installed or updated.
-	unsigned char exiRequest[5600];									// Required. Raw CertificateInstallationReq request from EV, Base64 encoded.
-	unsigned char Response_status[16];								// Required. Indicates whether the message was processed properly.
-	unsigned char Response_exiResponse[5600];						// Required. Raw CertificateInstallationRes response for the EV, Base64 encoded.
-};
-
-struct GetBaseReport_20
-{
-	unsigned int requestId;											// Required. The Id of the request.
-	unsigned char reportBase[32];									// Required. This field specifies the report base.
-	unsigned char Response_status[16];								// Required. This indicates whether the Charging Station is able to accept this request.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct GetCertificateStatus_20
-{
-	struct OCSPRequestDataType ocspRequestData;						// Required. Indicates the certificate of which the status is requested.
-	unsigned char Response_status[16];								// Required. This indicates whether the charging station was able to retrieve the OCSP certificate status.
-	unsigned char Response_ocspResult[5500];						// Optional. OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), and then base64 encoded. MAY only be omitted when status is not Accepted.
-};
-
-struct GetChargingProfiles_20
-{
-	unsigned int requestId;											// Required. Reference identification that is to be used by the Charging Station in the ReportChargingProfilesRequest when provided.
-	unsigned int evseId;											// Optional. For which EVSE installed charging profiles SHALL be reported. If 0, only charging profiles installed on the Charging Station itself (the grid connection) SHALL be reported. If omitted, all installed charging profiles SHALL be reported.
-	struct ChargingProfileCriterionType chargingProfile;			// Required. Specifies the charging profile.
-	unsigned char Response_status[16];								// Required. This indicates whether the Charging Station is able to process this request and will send ReportChargingProfilesRequest messages.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct GetCompositeSchedule_20
-{
-	unsigned int duration;											// Required. Length of the requested schedule in seconds.
-	unsigned char chargingRateUnit[8];								// Optional. Can be used to force a power or current profile.
-	unsigned int evseId;											// Required. The ID of the EVSE for which the schedule is requested. When evseid=0, the Charging Station will calculate the expected consumption for the grid connection.
-	unsigned char Response_status[16];								// Required. The Charging Station will indicate if it was able to process the request
-	struct CompositeScheduleType Response_schedule;					// Optional. This field contains the calculated composite schedule. It may only be omitted when this message contains status Rejected.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct GetDisplayMessages_20
-{
-	unsigned int id[10];											// Optional. If provided the Charging Station shall return Display Messages of the given ids. This field SHALL NOT contain more ids than set in NumberOfDisplayMessages.maxLimit
-	unsigned int requestId;											// Required. The Id of this request.
-	unsigned char	priority[16];									// Optional. If provided the Charging Station shall return Display Messages with the given priority only.
-	unsigned char state[16];										// Optional. If provided the Charging Station shall return Display Messages with the given state only.
-	unsigned char Response_status[16];								// Required. Indicates if the Charging Station has Display Messages that match the request criteria in the GetDisplayMessagesRequest
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct GetInstalledCertificateIds_20
-{
-	unsigned char certificateType[10][32];										// Optional. Indicates the type of certificates requested. When omitted, all certificate types are requested.
-	unsigned char Response_status[16];											// Required. Charging Station indicates if it can process the request.
-	struct CertificateHashDataChainType Response_certificateHashDataChain[10];	// Optional. The Charging Station includes the Certificate information for each available certificate.
-	unsigned char guid[37];														// Save guid from server request
-};
-
-struct GetLocalListVersion_20
-{
-	int Response_versionNumber;										// Required. This contains the current version number of the local authorization list in the Charging Station.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct GetLog_20
-{
-	unsigned char logType[16];										// Required. This contains the type of log file that the Charging Station should send.
-	unsigned int requestId;											// Required. The Id of this request
-	unsigned char retries;											// Optional. This specifies how many times the Charging Station must try to upload the log before giving up. If this field is not present, it is left to Charging Station to decide how many times it wants to retry.
-	unsigned int retryInterval;										// Optional. The interval in seconds after which a retry may be attempted. If this field is not present, it is left to Charging Station to decide how long to wait between attempts.
-	struct LogParametersType log;									// Required. This field specifies the requested log and the location to which the log should be sent.
-	unsigned char Response_status[20];								// Required. This field indicates whether the Charging Station was able to accept the request.
-	unsigned char Response_filename[255];							// Optional. This contains the name of the log file that will be uploaded. This field is not present when no logging information is available.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct GetMonitoringReport_20
-{
-	unsigned int requestId;											// Required. The Id of the request.
-	unsigned char monitoringCriteria[3][32];						// Optional. This field contains criteria for components for which a monitoring report is requested
-	struct ComponentVariableType componentVariable[10];				// Optional. This field specifies the components and variables for which a monitoring report is requested.
-	unsigned char Response_status[20];								// Required. This field indicates whether the Charging Station was able to accept the request.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct GetReport_20
-{
-	unsigned int requestId;											// Required. The Id of the request.
-	unsigned char componentCriteria[4][16];							// Optional. This field contains criteria for components for which a report is requested
-	struct ComponentVariableType componentVariable[10];				// Optional. This field specifies the components and variables for which a report is requested.
-	unsigned char Response_status[20];								// Required. This field indicates whether the Charging Station was able to accept the request.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct GetTransactionStatus_20
-{
-	unsigned char transactionId[36];								// Optional. The Id of the transaction for which the status is requested.
-	unsigned char Response_ongoingIndicator;						// Optional. Whether the transaction is still ongoing.
-	unsigned char Response_messagesInQueue;							// Required. Whether there are still message to be delivered.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct GetVariables_20
-{
-	struct GetVariableDataType getVariableData[AlignedDataCtrlr_CNT +
-											   AuthCacheCtrlr_CNT +
-											   AuthCtrlr_CNT +
-											   ChargingStation_CNT +
-											   ClockCtrlr_CNT +
-											   Connector_CNT +
-											   CustomizationCtrlr_CNT +
-											   DeviceDataCtrlr_CNT +
-											   DisplayMessageCtrlr_CNT +
-											   EVSE_CNT +
-											   LocalAuthListCtrlr_CNT +
-											   MonitoringCtrlr_CNT +
-											   OCPPCommCtrlr_CNT +
-											   ReservationCtrlr_CNT +
-											   SampledDataCtrlr_CNT +
-											   SecurityCtrlr_CNT +
-											   SmartChargingCtrlr_CNT +
-											   TariffCostCtrlr_CNT +
-											   TxCtrlr_CNT];				// Required. List of requested variables.
-	struct GetVariableResultType Response_getVariableResult[121];	// Required. List of requested variables and their values.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct Heartbeat_20
-{
-	unsigned char Response_currentTime[28];							// Required. Contains the current time of the CSMS.
-};
-
-struct InstallCertificate_20
-{
-	unsigned char certificateType[32];								// Required. Indicates the certificate type that is sent.
-	unsigned char certificate[5500];								// Required. A X.509 certificate, first DER encoded into binary, and then Base64 encoded.
-	unsigned char Response_status[16];								// Required. Charging Station indicates if installation was successful.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct LogStatusNotification_20
-{
-	unsigned char status[32];										// Required. This contains the status of the log upload.
-	unsigned int requestId;											// Optional. The request id that was provided in GetLogRequest that started this log upload. This field is mandatory, unless the message was triggered by a TriggerMessageRequest AND there is no log upload ongoing.
-};
-
-struct MeterValues_20
-{
-	unsigned int evseId;											// Required. This contains a number (>0) designating an EVSE of the Charging Station. ????(zero) is used to designate the main power meter.
-	struct MeterValueType meterValue[10];							// Required. The sampled meter values with timestamps.
-};
-
-struct NotifyChargingLimit_20
-{
-	unsigned int evseId;											// Optional. The charging schedule contained in this notification applies to an EVSE. evseId must be > 0.
-	struct ChargingLimitType chargingLimit;							// Required. This contains the source of the charging limit and whether it is grid critical.
-	struct ChargingScheduleType chargingSchedule[1];				// Optional. Contains limits for the available power or current over time, as set by the external source.
-};
-
-struct NotifyCustomerInformation_20
-{
-	unsigned char data[512];										// Required. (Part of) the requested data. No format specified in which the data is returned. Should be human readable.
-	unsigned char tbc;												// Optional. ?徼o be continued??indicator. Indicates whether another part of the monitoringData follows in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false.
-	unsigned int seqNo;												// Required. Sequence number of this message. First message starts at 0.
-	unsigned char generatedAt[28];									// Required. Timestamp of the moment this message was generated at the Charging Station.
-	unsigned int requestId;											// Required. The Id of the request.
-};
-
-struct NotifyDisplayMessages_20
-{
-	unsigned int requestId;                                         // Required. The id of the GetDisplayMessagesRequest that requested this message.
-	unsigned char tbc;												// Optional. "to be continued" indicator. Indicates whether another part of the report follows in an upcoming NotifyDisplayMessagesRequest message. Default value when omitted is false.
-	struct MessageInfoType messageInfo[10];							// Optional. The requested display message as configured in the Charging Station.
-};
-
-struct NotifyEVChargingNeeds_20
-{
-	unsigned int maxScheduleTuples;									// Optional. Contains the maximum schedule tuples the car supports per SASchedule (both Pmax and Tariff).
-	unsigned int evseId;											// Required. Defines the EVSE and connector to which the EV is connected. EvseId may not be 0.
-	struct ChargingNeedsType chargingNeeds;							// Required. The characteristics of the energy delivery required.
-	unsigned char Response_status[16];								// Required. Returns whether the CSMS has been able to process the message successfully. It does not imply that the evChargingNeeds can be met with the current charging profile.
-};
-
-struct NotifyEVChargingSchedule_20
-{
-	unsigned char timeBase[28];										// Required. Periods contained in the charging profile are relative to this point in time.
-	unsigned int evseId;											// Required. The charging schedule contained in this notification applies to an EVSE. EvseId must be > 0.
-	struct ChargingScheduleType chargingSchedule;					// Required. Planned energy consumption of the EV over time. Always relative to timeBase.
-	unsigned char Response_status[16];								// Required. Returns whether the CSMS has been able to process the message successfully. It does not imply any approval of the charging schedule.
-};
-
-struct NotifyEvent_20
-{
-	unsigned char generatedAt[28];									// Required. Timestamp of the moment this message was generated at the Charging Station.
-	unsigned char tbc;												// Optional. ?徼o be continued??indicator. Indicates whether another part of the report follows in an upcoming notifyEventRequest message. Default value when omitted is false.
-	unsigned int seqNo;												// Required. Sequence number of this message. First message starts at 0.
-	struct EventDataType eventData[10];								// Required. List of EventData.
-};
-
-struct NotifyMonitoringReport_20
-{
-	unsigned int requestId;											// Required. The id of the GetMonitoringRequest that requested this report.
-	unsigned char tbc;												// Optional. ?徼o be continued??indicator.
-	unsigned int seqNo;												// Required. Sequence number of this message. First message starts at 0.
-	unsigned char generatedAt[28];									// Required. Timestamp of the moment this message was generated at the Charging Station.
-	struct MonitoringDataType monitor[10];							// Optional. List of MonitoringData containing monitoring settings.
-};
-
-struct NotifyReport_20
-{
-	unsigned int requestId;											// Required. The id of the GetReportRequest or GetBaseReportRequest that requested this report
-	unsigned char generatedAt[28];									// Required. Timestamp of the moment this message was generated at the Charging Station.
-	unsigned char tbc;												// Optional. ?徼o be continued??indicator.
-	unsigned int seqNo;												// Required. Sequence number of this message. First message starts at 0.
-	struct ReportDataType reportData[10];							// Optional. List of ReportData.
-};
-
-struct PublishFirmware_20
-{
-	unsigned char location[512];									// Required. This contains a string containing a URI pointing to a location from which to retrieve the firmware.
-	unsigned char retries;											// Optional. This specifies how many times Charging Station must try to download the firmware before giving up. If this field is not present, it is left to Charging Station to decide how many times it wants to retry.
-	unsigned char checksum[32];										// Required. The MD5 checksum over the entire firmware file as a hexadecimal string of length 32.
-	unsigned int requestId;											// Required. The Id of the request.
-	unsigned int retryInterval;										// Optional. The interval in seconds after which a retry may be attempted. If this field is not present, it is left to Charging Station to decide how long to wait between attempts.
-	unsigned char Response_status[16];								// Required. Indicates whether the request was accepted.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct PublishFirmwareStatusNotification_20
-{
-	unsigned char status[32];										// Required. This contains the progress status of the publishfirmware installation.
-	unsigned char location[10][512];                                // Optional. Required if status is Published. Can be multiple URI?冱, if the Local Controller supports e.g. HTTP, HTTPS, and FTP.
-	unsigned int requestId;											// Optional. The request id that was provided in the PublishFirmwareRequest which triggered this action.
-};
-
-struct ReportChargingProfiles_20
-{
-	unsigned int requestId;											// Required. Id used to match the GetChargingProfilesRequest message with the resulting ReportChargingProfilesRequest messages
-	unsigned char chargingLimitSource[8];							// Required. Source that has installed this charging profile.
-	unsigned char tbc;												// Optional. To Be Continued. Default value when omitted: false. false indicates that there are no further messages as part of this report.
-	unsigned int evseId;											// Required. The evse to which the charging profile applies. If evseId = 0, the message contains an overall limit for the Charging Station.
-	struct ChargingProfileType chargingProfile[3];					// Required. The charging profile as configured in the Charging Station.
-};
-
-struct RequestStartTransaction_20
-{
-	unsigned int evseId;											// Optional. Number of the EVSE on which to start the transaction. EvseId SHALL be > 0
-	unsigned int remoteStartId;										// Required. Id given by the server to this start request.
-	struct IdTokenType idToken;										// Required. The identifier that the Charging Station must use to start a transaction.
-	struct ChargingProfileType chargingProfile;						// Optional. Charging Profile to be used by the Charging Station for the requested transaction.
-	struct IdTokenType groupIdToken;								// Optional. The group identifier that the Charging Station must use to start a transaction.
-	unsigned char Response_status[16];								// Required. Status indicating whether the Charging Station accepts the request to start a transaction.
-	unsigned char Response_transactionId[36];						// Optional. When the transaction was already started by the Charging Station before the RequestStartTransactionRequest was received, for example: cable plugged in first. This contains the transactionId of the already started transaction.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct RequestStopTransaction_20
-{
-	unsigned char transactionId[36];								// Required. The identifier of the transaction which the Charging Station is requested to stop.
-	unsigned char Response_status[16];								// Required. Status indicating whether Charging Station accepts the request to stop a transaction.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct ReservationStatusUpdate_20
-{
-	int reservationId;												// Required. The ID of the reservation.
-	unsigned char reservationUpdateStatus[8];						// Required. The updated reservation status.
-};
-
-struct ReserveNow_20
-{
-	unsigned int id;												// Required. Id of reservation.
-	unsigned char expiryDateTime[28];								// Required. Date and time at which the reservation expires.
-	unsigned char connectorType[16];								// Optional. This field specifies the connector type.
-	unsigned int evseId;											// Optional. This contains ID of the evse to be reserved.
-	struct IdTokenType idToken;										// Required. The identifier for which the reservation is made.
-	struct IdTokenType groupIdToken;								// Optional. The group identifier for which the reservation is made.
-	unsigned char Response_status[16];								// Required. This indicates the success or failure of the reservation.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct Reset_20
-{
-	unsigned char type[16];											// Required. This contains the type of reset that the Charging Station or EVSE should perform.
-	unsigned int evseId;											// Optional. This contains the ID of a specific EVSE that needs to be reset, instead of the entire Charging Station.
-	unsigned char Response_status[16];								// Required. This indicates whether the Charging Station is able to perform the reset.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct SecurityEventNotification_20
-{
-	unsigned char type[50];											// Required. Type of the security event. This value should be taken from the Security events list.
-	unsigned char timestamp[28];									// Required. Date and time at which the event occurred.
-	unsigned char techinfo[255];									// Optional. Additional information about the occurred security event.
-};
-
-struct SendLocalList_20
-{
-	unsigned int versionNumber;										// Required. In case of a full update this is the versio number of the full list. In case of a differential update it i the version number of the list after the update has bee applied.
-	unsigned char updateType[32];									// Required. This contains the type of update (full or differential) of this request.
-	struct AuthorizationData localAuthorizationList[500];			// Optional. This contains the Local Authorization List entries.
-	unsigned char Response_status[16];								// Required. This indicates whether the Charging Station has successfully received and applied the update of the Local Authorization List.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct SetChargingProfile_20
-{
-	unsigned int evseId;											// Required. The EVSE to which the charging profile applies. If evseId = 0, the message contains an overall limit for the Charging Station.
-	struct ChargingProfileType chargingProfile;						// Required. The charging profile to be set at the Charging Station.
-	unsigned char Response_status[16];								// Required. Returns whether the Charging Station has been able to process the message successfully. This does not guarantee the schedule will be followed to the letter. There might be other constraints the Charging Station may need to take into account.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct SetDisplayMessage_20
-{
-	struct MessageInfoType message;									// Required. Message to be configured in the Charging Station, to be displayed.
-	unsigned char Response_status[32];								// Required. This indicates whether the Charging Station is able to display the message.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct SetMonitoringBase_20
-{
-	unsigned char monitoringBase[16];								// Required. Specify which monitoring base will be set
-	unsigned char Response_status[16];								// Required. Indicates whether the Charging Station was able to accept the request.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct SetMonitoringLevel_20
-{
-	unsigned int severity;											// Required. The Charging Station SHALL only report events with a severity number lower than or equal to this severity.
-	unsigned char Response_status[16];         						// Required. Indicates whether the Charging Station was able to accept the request.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct SetNetworkProfile_20
-{
-	unsigned int configurationSlot;									// Required. Slot in which the configuration should be stored.
-	struct NetworkConnectionProfileType connectionData;				// Required. Connection details.
-	unsigned char Response_status[16];									// Required. Result of operation.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct SetVariableMonitoring_20
-{
-	struct SetMonitoringDataType setMonitoringData[10];				// Required. List of MonitoringData containing monitoring settings.
-	struct SetMonitoringResultType Response_setMonitoringResult[10];// Required. List of result statuses per monitor.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct SetVariables_20
-{
-	struct SetVariableDataType setVariableData[10];					// Required. List of Component-Variable pairs and attribute values to set.
-	struct SetVariableResultType Response_setVariableResult[10];	// Required. List of result statuses per Component-Variable.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct SignCertificate_20
-{
-	unsigned char csr[5500];										// 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 StatusNotification_20
-{
-	unsigned char timestamp[28];									// Required. The time for which the status is reported. If absent time of receipt of the message will be assumed.
-	unsigned char connectorStatus[16];								// Required. This contains the current status of the Connector.
-	unsigned int evseId;											// Required. The id of the EVSE to which the connector belongs for which the the status is reported.
-	unsigned char connectorId;										// Required. The id of the connector within the EVSE for which the status is reported.
-};
-
-struct TransactionEvent_20
-{
-	unsigned char eventType[16];									// Required. This contains the type of this event. The first TransactionEvent of a transaction SHALL contain: "Started" The last TransactionEvent of a transaction SHALL contain: "Ended" All others SHALL contain: "Updated"
-	unsigned char timestamp[28];									// Required. The date and time at which this transaction event occurred.
-	unsigned char triggerReason[32];								// Required. Reason the Charging Station sends this message to the CSMS
-	unsigned int seqNo;												// Required. Incremental sequence number, helps with determining if all messages of a transaction have been received.
-	unsigned char offline;											// Optional. Indication that this transaction event happened when the Charging Station was offline. Default = false, meaning: the event occurred when the Charging Station was online.
-	unsigned char numberOfPhasesUsed;								// Optional. If the Charging Station is able to report the number of phases used, then it SHALL provide it. When omitted the CSMS may be able to determine the number of phases used via device management.
-	float cableMaxCurrent;											// Optional. The maximum current of the connected cable in Ampere (A).
-	int reservationId;												// Optional. This contains the Id of the reservation that terminates as a result of this transaction.
-	struct TransactionType transactionInfo;							// Required. Contains transaction specific information.
-	struct IdTokenType idToken;										// Optional. This contains the identifier for which a transaction has to be/was started.
-	struct EVSEType evse;											// Optional. This identifies which evse (and connector) of the Charging Station is used.
-	struct MeterValueType meterValue[10];							// Optional. This contains the relevant meter values.
-	float Response_totalCost;										// Optional. SHALL only be sent when charging has ended. Final total cost of this transaction, including taxes.
-	int Response_chargingPriority;									// Optional. Priority from a business point of view. Default priority is 0,
-	struct IdTokenInfoType Response_idTokenInfo;					// Optional. This contains information about authorization status, expiry and group id. Is required when the transactionEventRequest contained an idToken.
-	struct MessageContentType Response_updatedPersonalMessage;		// Optional. This can contain updated personal message that can be shown to the EV Driver. This can be used to provide updated tariff information
-};
-
-struct TriggerMessage_20
-{
-	unsigned char requestedMessage[32];								// Required. Type of message to be triggered.
-	struct EVSEType evse;											// Optional. Can be used to specifiy the EVSE and Connector if required for the message which needs to be sent.
-	unsigned char Response_status[16];								// Required. Indicates whether the Charging Station will send the requested notification or not.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct UnlockConnector_20
-{
-	unsigned int evseId;											// Required. This contains the identifier of the EVSE for which a connector needs to be unlocked.
-	unsigned char connectorId;										// Required. This contains the identifier of the connector that needs to be unlocked.
-	unsigned char Response_status[32];								// Required. This indicates whether the Charging Station has unlocked the connector.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct UnpublishFirmware_20
-{
-	unsigned char checksum[32];										// Required. The MD5 checksum over the entire firmware file as a hexadecimal string of length 32.
-	unsigned char Response_status[16];								// Required. Indicates whether the Local Controller succeeded in unpublishing the firmware.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-struct UpdateFirmware_20
-{
-	unsigned char retries;											// Optional. This specifies how many times Charging Station must try to download the firmware before giving up. If this field is not present, it is left to Charging Station to decide how many times it wants to retry.
-	unsigned int retryInterval;										// Optional. The interval in seconds after which a retry may be attempted. If this field is not present, it is left to Charging Station to decide how long to wait between attempts.
-	unsigned int requestId;											// Required. The Id of this request
-	struct FirmwareType firmware;									// Required. Specifies the firmware to be updated on the Charging Station.
-	unsigned char Response_status[32];								// Required. This field indicates whether the Charging Station was able to accept the request.
-	unsigned char guid[37];											// Save guid from server request
-};
-
-/*
- *  =============== Controller component ===============
- */
-struct OCPP20ControllerConponent
-{
-	struct ReportDataType AlignedDataCtrlr[AlignedDataCtrlr_CNT];
-	struct ReportDataType AuthCacheCtrlr[AuthCacheCtrlr_CNT];
-	struct ReportDataType AuthCtrlr[AuthCtrlr_CNT];
-	struct ReportDataType ChargingStation[ChargingStation_CNT];
-	struct ReportDataType ClockCtrlr[ClockCtrlr_CNT];
-	struct ReportDataType Connector[Connector_CNT];
-	struct ReportDataType CustomizationCtrlr[CustomizationCtrlr_CNT];
-	struct ReportDataType DeviceDataCtrlr[DeviceDataCtrlr_CNT];
-	struct ReportDataType DisplayMessageCtrlr[DisplayMessageCtrlr_CNT];
-	struct ReportDataType EVSE[EVSE_CNT];
-	struct ReportDataType LocalAuthListCtrlr[LocalAuthListCtrlr_CNT];
-	struct ReportDataType MonitoringCtrlr[MonitoringCtrlr_CNT];
-	struct ReportDataType OCPPCommCtrlr[OCPPCommCtrlr_CNT];
-	struct ReportDataType ReservationCtrlr[ReservationCtrlr_CNT];
-	struct ReportDataType SampledDataCtrlr[SampledDataCtrlr_CNT];
-	struct ReportDataType SecurityCtrlr[SecurityCtrlr_CNT];
-	struct ReportDataType SmartChargingCtrlr[SmartChargingCtrlr_CNT];
-	struct ReportDataType TariffCostCtrlr[TariffCostCtrlr_CNT];
-	struct ReportDataType TxCtrlr[TxCtrlr_CNT];
-};
-
-struct OCPP20Data
-{
-	unsigned char 							OcppServerURL[512];		//http: non-secure OCPP 1.5-S, https: secure OCPP 1.5-S, ws: non-secure OCPP 1.6-J, wss: secure OCPP 1.6-J"
-	unsigned char 							ChargeBoxId[128];
-	unsigned char 							OcppConnStatus;			//0: disconnected, 1: connected
-	unsigned int 							Timeout_Secs;
-	unsigned short 							Ping_Pong_Interval;
-	struct OCPP20ControllerConponent 		ControllerComponent;
-
-	union
-	{
-		//Operations Initiated by Charge Point
-		unsigned char CpMsgValue[CONNECTOR_QUANTITY];
-		struct
-		{
-			unsigned char DataTransferReq:1;
-			unsigned char DataTransferConf:1;
-			unsigned char ReservationStatusUpdateReq :1;
-			unsigned char ReservationStatusUpdateConf :1;
-			unsigned char TransactionEventReq :1;
-			unsigned char TransactionEventConf :1;
-			unsigned char :2;	//bit 6,7 , reserved
-		} bits[CONNECTOR_QUANTITY];
-	}CpMsg;
-
-	union
-	{
-		//Operations Initiated by Sequence Point
-		unsigned char SpMsgValue[4];
-		struct
-		{
-			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 FirmwareStatusNotificationReq :1; //bit 6,
-			unsigned char FirmwareStatusNotificationConf :1; //bit 7,
-			unsigned char Get15118EVCertificateReq :1;
-			unsigned char Get15118EVCertificateConf :1;
-
-			unsigned char GetCertificateStatusReq :1;
-			unsigned char GetCertificateStatusConf :1;
-			unsigned char LogStatusNotificationReq :1;
-			unsigned char LogStatusNotificationConf :1;
-			unsigned char NotifyChargingLimitReq :1;
-			unsigned char NotifyChargingLimitConf :1;
-			unsigned char NotifyDisplayMessagesReq :1;
-			unsigned char NotifyDisplayMessagesConf :1;
-
-			unsigned char NotifyEVChargingNeedsReq :1;
-			unsigned char NotifyEVChargingNeedsConf :1;
-			unsigned char NotifyEVChargingScheduleReq :1;
-			unsigned char NotifyEVChargingScheduleConf :1;
-			unsigned char NotifyEventReq :1;
-			unsigned char NotifyEventConf :1;
-			unsigned char NotifyMonitoringReportReq :1;
-			unsigned char NotifyMonitoringReportConf :1;
-
-			unsigned char NotifyReportReq :1;
-			unsigned char NotifyReportConf :1;
-			unsigned char ReportChargingProfilesReq :1;
-			unsigned char ReportChargingProfilesConf :1;
-			unsigned char SecurityEventNotificationReq :1;
-			unsigned char SecurityEventNotificationConf :1;
-			unsigned char SignCertificateReq :1;
-			unsigned char SignCertificateConf :1;
-
-		} bits;
-	} SpMsg;
-
-	union
-	{
-		//Operations Initiated by Central System
-		unsigned char CsMsgValue[3 * (CONNECTOR_QUANTITY)];
-		struct
-		{
-			unsigned char CancelReservationReq :1;	//bit 0,
-			unsigned char CancelReservationConf :1;	//bit 1,
-			unsigned char ChangeAvailabilityReq :1; //bit 2,
-			unsigned char ChangeAvailabilityConf :1;	//bit 3,
-			unsigned char ClearChargingProfileReq :1;	//bit 0,
-			unsigned char ClearChargingProfileConf :1;	//bit 1,
-			unsigned char DataTransferReq :1; //bit 2,
-			unsigned char DataTransferConf :1;	//bit 3,
-
-			unsigned char PublishFirmwareStatusNotificationReq :1;
-			unsigned char PublishFirmwareStatusNotificationConf :1;
-			unsigned char RequestStartTransactionReq :1;
-			unsigned char RequestStartTransactionConf :1;
-			unsigned char RequestStopTransactionReq :1;
-			unsigned char RequestStopTransactionConf :1;
-			unsigned char ReserveNowReq :1;	//bit 4,
-			unsigned char ReserveNowConf :1;	//bit 5,
-
-			unsigned char TriggerMessageReq :1;		//bit 0,
-			unsigned char TriggerMessageConf :1;	//bit 1,
-			unsigned char UnlockConnectorReq :1; 	//bit 2,
-			unsigned char UnlockConnectorConf :1;	//bit 3,
-			unsigned char :4;						//bit 6,7 , reserved
-
-		} bits[CONNECTOR_QUANTITY];
-	}CsMsg;
-
-	union
-	{
-		//Operations Initiated by Main System
-		unsigned char MsMsgValue[8];
-		struct
-		{
-			//CsMsgValue[0]
-			unsigned char CertificateSignedReq :1;
-			unsigned char CertificateSignedConf :1;
-			unsigned char ClearCacheReq :1;	//bit 2,
-			unsigned char ClearCacheConf :1;	//bit 3,
-			unsigned char ClearDisplayMessageReq :1;
-			unsigned char ClearDisplayMessageConf :1;
-			unsigned char ClearedChargingLimitReq :1;
-			unsigned char ClearedChargingLimitConf :1;
-
-			unsigned char ClearVariableMonitoringReq :1;
-			unsigned char ClearVariableMonitoringConf :1;
-			unsigned char CostUpdatedReq :1;
-			unsigned char CostUpdatedConf :1;
-			unsigned char CustomerInformationReq :1;
-			unsigned char CustomerInformationConf :1;
-			unsigned char DeleteCertificateReq :1;
-			unsigned char DeleteCertificateConf :1;
-
-			unsigned char GetBaseReportReq :1;
-			unsigned char GetBaseReportConf :1;
-			unsigned char GetChargingProfilesReq :1;
-			unsigned char GetChargingProfilesConf :1;
-			unsigned char GetCompositeScheduleReq :1;	//bit 4,
-			unsigned char GetCompositeScheduleConf :1;	//bit 5,
-			unsigned char GetDisplayMessagesReq :1;
-			unsigned char GetDisplayMessagesConf :1;
-
-			unsigned char GetInstalledCertificateIdsReq :1;
-			unsigned char GetInstalledCertificateIdsConf :1;
-			unsigned char GetLocalListVersionReq :1; //bit 2,
-			unsigned char GetLocalListVersionConf :1;	//bit 3,
-			unsigned char GetLogReq :1;
-			unsigned char GetLogConf :1;
-			unsigned char GetMonitoringReportReq :1;
-			unsigned char GetMonitoringReportConf :1;
-
-			unsigned char GetReportReq :1;
-			unsigned char GetReportConf :1;
-			unsigned char GetTransactionStatusReq :1;
-			unsigned char GetTransactionStatusConf :1;
-			unsigned char GetVariablesReq :1;
-			unsigned char GetVariablesConf :1;
-			unsigned char InstallCertificateReq :1;
-			unsigned char InstallCertificateConf :1;
-
-			unsigned char PublishFirmwareReq :1;
-			unsigned char PublishFirmwareConf :1;
-			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 SetChargingProfileReq :1;	//bit 6,
-			unsigned char SetChargingProfileConf :1;	//bit 7,
-
-			unsigned char SetDisplayMessageReq :1;
-			unsigned char SetDisplayMessageConf :1;
-			unsigned char SetMonitoringBaseReq :1;
-			unsigned char SetMonitoringBaseConf :1;
-			unsigned char SetMonitoringLevelReq :1;
-			unsigned char SetMonitoringLevelConf :1;
-			unsigned char SetNetworkProfileReq :1;
-			unsigned char SetNetworkProfileConf :1;
-
-			unsigned char SetVariableMonitoringReq :1;
-			unsigned char SetVariableMonitoringConf :1;
-			unsigned char SetVariablesReq :1;
-			unsigned char SetVariablesConf :1;
-			unsigned char UnpublishFirmwareReq :1;
-			unsigned char UnpublishFirmwareConf :1;
-			unsigned char UpdateFirmwareReq :1;	//bit 6,
-			unsigned char UpdateFirmwareConf :1;	//bit 7,
-		} bits;
-	} MsMsg;
-
-	union
-	{
-		//Operations triggered by CSU
-		unsigned char CSUMsgValue[CONNECTOR_QUANTITY];
-		struct
-		{
-			//CSUMsgValue[0]
-			unsigned char ChargingProfileReq:1;	//bit 0,
-			unsigned char ChargingProfileConf:1;	//bit 0,
-			unsigned char :6;	//bit 1,2,3,4,5,6,7 , reserved
-		} bits[CONNECTOR_QUANTITY];
-	}CSUMsg;
-
-	struct Authorize_20 						Authorize;
-	struct BootNotification_20 					BootNotification;
-	struct CancelReservation_20					CancelReservation[CONNECTOR_QUANTITY];
-	struct CertificateSigned_20					CertificateSigned;
-	struct ChangeAvailability_20				ChangeAvailability[CONNECTOR_QUANTITY];
-	struct ClearCache_20						ClearCache;
-	struct ClearChargingProfile_20				ClearChargingProfile[CONNECTOR_QUANTITY];
-	struct ClearDisplayMessage_20				ClearDisplayMessage;
-	struct ClearedChargingLimit_20				ClearedChargingLimit[CONNECTOR_QUANTITY];
-	struct ClearVariableMonitoring_20			ClearVariableMonitoring;
-	struct CostUpdated_20						CostUpdated;
-	struct CustomerInformation_20				CustomerInformation;
-	struct DataTransfer_20						DataTransfer[CONNECTOR_QUANTITY];
-	struct DeleteCertificate_20					DeleteCertificate;
-	struct FirmwareStatusNotification_20		FirmwareStatusNotification;
-	struct Get15118EVCertificate_20				Get15118EVCertificate;
-	struct GetBaseReport_20						GetBaseReport;
-	struct GetCertificateStatus_20				GetCertificateStatus;
-	struct GetChargingProfiles_20				GetChargingProfiles[CONNECTOR_QUANTITY];
-	struct GetCompositeSchedule_20				GetCompositeSchedule[CONNECTOR_QUANTITY];
-	struct GetDisplayMessages_20				GetDisplayMessages;
-	struct GetInstalledCertificateIds_20		GetInstalledCertificateIds;
-	struct GetLocalListVersion_20				GetLocalListVersion;
-	struct GetLog_20							GetLog;
-	struct GetMonitoringReport_20				GetMonitoringReport;
-	struct GetReport_20							GetReport;
-	struct GetTransactionStatus_20				GetTransactionStatus[CONNECTOR_QUANTITY];
-	struct GetVariables_20						GetVariables;
-	struct Heartbeat_20							Heartbeat;
-	struct InstallCertificate_20				InstallCertificate;
-	struct LogStatusNotification_20				LogStatusNotification;
-	struct MeterValues_20						MeterValues[CONNECTOR_QUANTITY];
-	struct NotifyChargingLimit_20				NotifyChargingLimit[CONNECTOR_QUANTITY];
-	struct NotifyCustomerInformation_20			NotifyCustomerInformation;
-	struct NotifyDisplayMessages_20				NotifyDisplayMessages;
-	struct NotifyEVChargingNeeds_20				NotifyEVChargingNeeds[CONNECTOR_QUANTITY];
-	struct NotifyEVChargingSchedule_20			NotifyEVChargingSchedule[CONNECTOR_QUANTITY];
-	struct NotifyEvent_20						NotifyEvent;
-	struct NotifyMonitoringReport_20			NotifyMonitoringReport;
-	struct NotifyReport_20						NotifyReport;
-	struct PublishFirmware_20					PublishFirmware;
-	struct PublishFirmwareStatusNotification_20	PublishFirmwareStatusNotificatio;
-	struct ReportChargingProfiles_20			ReportChargingProfiles[CONNECTOR_QUANTITY];
-	struct RequestStartTransaction_20			RequestStartTransaction[CONNECTOR_QUANTITY];
-	struct RequestStopTransaction_20			RequestStopTransaction[CONNECTOR_QUANTITY];
-	struct ReservationStatusUpdate_20			ReservationStatusUpdate[CONNECTOR_QUANTITY];
-	struct ReserveNow_20						ReserveNow[CONNECTOR_QUANTITY];
-	struct Reset_20								Reset;
-	struct SecurityEventNotification_20			SecurityEventNotification;
-	struct SendLocalList_20						SendLocalList;
-	struct SetChargingProfile_20				SetChargingProfile[CONNECTOR_QUANTITY];
-	struct SetDisplayMessage_20					SetDisplayMessage;
-	struct SetMonitoringBase_20					SetMonitoringBase;
-	struct SetMonitoringLevel_20				SetMonitoringLevel;
-	struct SetNetworkProfile_20					SetNetworkProfile;
-	struct SetVariableMonitoring_20				SetVariableMonitoring;
-	struct SetVariables_20						SetVariables;
-	struct SignCertificate_20					SignCertificate;
-	struct StatusNotification_20				StatusNotification[CONNECTOR_QUANTITY];
-	struct TransactionEvent_20					TransactionEvent[CONNECTOR_QUANTITY];
-	struct TriggerMessage_20					TriggerMessage;
-	struct UnlockConnector_20					UnlockConnector[CONNECTOR_QUANTITY];
-	struct UnpublishFirmware_20					UnpublishFirmware;
-	struct UpdateFirmware_20					UpdateFirmware;
-	struct ChargingProfileType                  SmartChargingProfile[CONNECTOR_QUANTITY];
-};
-
-#endif // DEFINE_H_
-
-
-
-
-

+ 2 - 2
EVSE/Projects/DD360Audi/Apps/init.sh

@@ -4,8 +4,8 @@ chmod 777 Module_LcmControl
 chmod 777 Module_InternalComm
 chmod 777 Module_EventLogging
 chmod 777 Module_EvComm
-#chmod 777 Module_PsuComm
+chmod 777 Module_PsuComm
 chmod 777 OcppBackend
 chmod 777 kill.sh
 chmod 777 ReadCmdline
-chmod 777 DoComm
+

+ 2 - 0
EVSE/Projects/DD360Audi/Apps/kill.sh

@@ -33,5 +33,7 @@ ipcrm -M 0x000003f0
 ipcrm -M 0x000003f3
 ipcrm -M 0x000003f1
 ipcrm -M 0x000003f6
+ipcrm -M 0x000003eb
+ipcrm -M 0x000003f2
 
 ipcs

File diff suppressed because it is too large
+ 161 - 475
EVSE/Projects/DD360Audi/Apps/main.c


+ 15 - 14
EVSE/Projects/DD360Audi/Apps/timeout.h

@@ -35,21 +35,21 @@
 #define CONN_PLUG_TIME_OUT          40
 
 enum Timeout_flag {
-    Timeout_None                   = 0,
-    Timeout_SelftestChk            = 1,
-    Timeout_Authorizing            = 2,
-    Timeout_VerifyFail             = 3,
-    Timeout_VerifyComp             = 4,
-    Timeout_WaitPlug               = 5,
+    Timeout_None =                      0,
+    Timeout_SelftestChk =               1,
+    Timeout_Authorizing =               2,
+    Timeout_VerifyFail =                3,
+    Timeout_VerifyComp =                4,
+    Timeout_WaitPlug =                  5,
 
-    Timeout_Preparing              = 6,
-    Timeout_EvChargingDet          = 7,
-    Timeout_EvseChargingDet        = 8,
-    Timeout_EvseCompleteDet        = 9,
-    Timeout_ForCcsPrechargeDet     = 10,
-    Timeout_ReturnToChargingGunDet = 11,
-    Timeout_AuthorizingForStop     = 12,
-    Timeout_SelectGun              = 13,
+    Timeout_Preparing =                 6,
+    Timeout_EvChargingDet =             7,
+    Timeout_EvseChargingDet =           8,
+    Timeout_EvseCompleteDet =           9,
+    Timeout_ForCcsPrechargeDet =        10,
+    Timeout_ReturnToChargingGunDet =    11,
+    Timeout_AuthorizingForStop =        12,
+    Timeout_SelectGun =                 13,
 };
 
 // for timeout fork
@@ -59,4 +59,5 @@ unsigned short _connectionTimeout;
 // for main
 struct timeval _cmdMainPriority_time;
 struct timeval _toAverage_time;
+unsigned char _ocppProfileChkFlag;
 #endif /* TIMEOUT_H_ */

+ 1 - 1
EVSE/Projects/DD360Audi/Apps/web.sh

@@ -1 +1 @@
-/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf  -m /lib
+/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf  -m /lib

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


BIN
EVSE/Projects/DD360Audi/output/DoComm


BIN
EVSE/Projects/DD360Audi/output/FactoryConfig


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/UnsafetyOutputTask


+ 2 - 2
EVSE/Projects/DD360Audi/output/init.sh

@@ -4,8 +4,8 @@ chmod 777 Module_LcmControl
 chmod 777 Module_InternalComm
 chmod 777 Module_EventLogging
 chmod 777 Module_EvComm
-#chmod 777 Module_PsuComm
+chmod 777 Module_PsuComm
 chmod 777 OcppBackend
 chmod 777 kill.sh
 chmod 777 ReadCmdline
-chmod 777 DoComm
+

+ 2 - 0
EVSE/Projects/DD360Audi/output/kill.sh

@@ -33,5 +33,7 @@ ipcrm -M 0x000003f0
 ipcrm -M 0x000003f3
 ipcrm -M 0x000003f1
 ipcrm -M 0x000003f6
+ipcrm -M 0x000003eb
+ipcrm -M 0x000003f2
 
 ipcs

BIN
EVSE/Projects/DD360Audi/output/main


+ 1 - 1
EVSE/Projects/DD360Audi/output/web.sh

@@ -1 +1 @@
-/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf  -m /lib
+/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf  -m /lib

+ 4 - 4
EVSE/Projects/define.h

@@ -101,18 +101,18 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
     #define ONE_CONNECTOR_USE       0
 #elif DD360
     #define MAX_PSU_QUANTITY        62
-    #define CHAdeMO_QUANTITY        0
+    #define CHAdeMO_QUANTITY        2
     #define CCS_QUANTITY            2
-    #define GB_QUANTITY             0
+    #define GB_QUANTITY             2
     #define AC_QUANTITY             0
     #define GENERAL_GUN_QUANTITY	0
     #define PSU_QUANTITY            2
     #define ONE_CONNECTOR_USE       0
 #elif DD360Audi
     #define MAX_PSU_QUANTITY        62
-    #define CHAdeMO_QUANTITY        0
+    #define CHAdeMO_QUANTITY        2
     #define CCS_QUANTITY            2
-    #define GB_QUANTITY             0
+    #define GB_QUANTITY             2
     #define AC_QUANTITY             0
     #define GENERAL_GUN_QUANTITY	0
     #define PSU_QUANTITY            2

Some files were not shown because too many files changed in this diff