فهرست منبع

2020.12.21 / Jerry Wang

Actions:
1. DoComm add update firmware function.

Files:
ReDoComm.c

Image version: V1.02.XX.XXXX.XX
Image checksum: XXXXXXXX
Jerry_Wang 4 سال پیش
والد
کامیت
e4c3c8f437

+ 1 - 1
EVSE/Projects/DD360Audi/Apps/Module_EvComm.c

@@ -69,7 +69,7 @@ float _outCur_2 = 0;
 // CCS : 950V, 120A
 float maxChargingVol[2] = { 5000, 9500 };           // 限制最大充電電壓,如依照模塊則填上 0
 // 限制最大充電電流與能量透過 Web
-float maxChargingCur[2] = { 5000, 1200 };           // 限制最大充電電流,如依照模塊則填上 0
+float maxChargingCur[2] = { 5000, 2000 };           // 限制最大充電電流,如依照模塊則填上 0
 float maxChargingPow = 0;                           // 限制最大充電能量,如依照模塊則填上 0
 
 // 槍資訊

+ 123 - 39
EVSE/Projects/DD360Audi/Apps/ReDoComm.c

@@ -400,7 +400,6 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     //copy QR code string
     if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
         memset(ShmSysConfigAndInfo->SysConfig.SystemId, '\0', sizeof(ShmSysConfigAndInfo->SysConfig.SystemId));
-        //strncpy(ShmSysConfigAndInfo->SysConfig.SystemId, '\0', sizeof(ShmSysConfigAndInfo->SysConfig.SystemId));
         //printf("data =  %s\r\n", data);
         len = string2ByteArray((char *)data, (uint8_t *)ShmSysConfigAndInfo->SysConfig.SystemId);
         //printf("SystemId =  %s\r\n", ShmSysConfigAndInfo->SysConfig.SystemId);
@@ -427,6 +426,20 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
 
 static int updateFirmwareHandle(uint8_t *imgName)
 {
+    int ret = PASS;
+    char cmdBuf[1024] = {0};
+
+    sprintf(cmdBuf, "/mnt/%s", imgName);
+    DEBUG_INFO("Program ready to check file %s\n", cmdBuf);
+    if ( access(cmdBuf, F_OK) != -1) {
+        DEBUG_INFO("File '%s' exist.\n", cmdBuf);
+        ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = YES;
+    } else {
+        DEBUG_INFO("File '%s' doesn't exist.\n", cmdBuf);
+        ret = FAIL;
+    }
+
+#if 0
     char cmdBuf[1024] = {0};
     int status = 0;
 
@@ -457,8 +470,9 @@ static int updateFirmwareHandle(uint8_t *imgName)
     }
 
     system("rm -rf ./tftpUpdate.sh"); //刪除shell
+#endif //0
 
-    return PASS;
+    return ret;
 }
 
 static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
@@ -613,6 +627,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
             clearMiscCommand();
             break;
         }
+        usleep(128);
     }
 
     return ret;
@@ -620,10 +635,13 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
 
 static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
 {
+    uint8_t addr = 0;
     float MaxVolt, MaxCurrent, MaxPower;
+    static PricesInfo pricesInfo[2] = {0};
     CapabilityInfo *pCapabilityInfo = NULL;
     AccountInfo *pAccountInfo = NULL;
 
+    //--- charging capability information --------------------------------------
     pCapabilityInfo = (CapabilityInfo *)&data[0];
 
     MaxVolt = (float)(ntohs(pCapabilityInfo->OutputVoltage));
@@ -645,19 +663,27 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
     //MaxPower = (float)(data[4] << 8 | data[5]);
     //printf("MaxVolt=%f, MaxCurrent=%f, MaxPower=%f,\n", MaxVolt, MaxCurrent, MaxPower);
 
-    pAccountInfo = (AccountInfo *)&data[6];
+    //--- user prices information ----------------------------------------------
+    addr = (sizeof(CapabilityInfo) - 2); //2 byte reserved
+    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[gunID].UserPrices         = transPricesUnit(ntohl(pAccountInfo->UserPrices));
+    ChargingData[gunID]->ChargingFee                    = transPricesUnit(ntohl(pAccountInfo->TotalCost));
+    gAudiCustInfo->PricesInfo[gunID].Balance            = transPricesUnit(ntohl(pAccountInfo->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,
-               (uint8_t *)Currency[ShmSysConfigAndInfo->SysConfig.BillingData.Currency]);
+    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;
+
+        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,
+                   (uint8_t *)Currency[ShmSysConfigAndInfo->SysConfig.BillingData.Currency]);
+    }
 
     return PASS;
 }
@@ -684,6 +710,7 @@ static void removeFaultCodeToBuf(uint8_t *Code)
 
     // 把相關的錯誤碼一次移除,避免重複顯示
     while (find) {
+        usleep(128);
         find = 0x00;
         for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
             if (find == 0x00) {
@@ -714,6 +741,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
         DEBUG_ERROR("raw data len < 6 = %d\r\n", dataLen);
         if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 0) {
             for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+                usleep(128);
                 if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= 0x33) { //from backend or power cabinet
                     memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
                     memcpy(EventCodeTmp,
@@ -727,6 +755,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     }
 
     for (count = 0; count < dataLen; count += WARNING_CODE_SIZE) {
+        usleep(128);
         // misc command status code handle
         if (strcmp((char *)&data[count], MISC_ST_MISC_CMD) == 0) {
             if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
@@ -745,7 +774,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
         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) {
@@ -761,10 +790,12 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     }
 
     for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+        usleep(128);
         if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '3') { //from backend or power cabinet 0x33
             ret = 0;
 
             for (count = 0; count < (dataLen / WARNING_CODE_SIZE); count++) {
+                usleep(128);
                 if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0],
                            StatusArray[count],
                            WARNING_CODE_SIZE) == 0) {
@@ -837,12 +868,15 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t id, uint8_t reg
     case REG_SOFTWARE_UPDATE:
         pSoftwareUpd = (SoftwareUpdInfo *)&pCsuResult->Data.Data[0];
 
-        if ((pSoftwareUpd->ImgName == NULL) || (rawDataLen == 0)) {
+        if ((strcmp((char *)pSoftwareUpd->ImgName, "") == 0) ||
+                (rawDataLen == 0) ||
+                pSoftwareUpd->UpdateState != 1) {
             ret = FAIL;
             break;
         }
 
-        updateFirmwareHandle(pSoftwareUpd->ImgName);
+        ret = FAIL;
+        ret = updateFirmwareHandle(pSoftwareUpd->ImgName);
         break;
 
     case REG_PLUG_IN_STATE:
@@ -970,7 +1004,7 @@ static int writeWaitPlugItState(int fd, uint8_t id)
     return ret;
 }
 
-static int readPowerCabinetSystemID(int fd)
+static int readQRcodeURLAndSystemDate(int fd)
 {
     int ret = PASS;
 
@@ -1149,13 +1183,14 @@ static int writePlugInStatus(int fd, uint8_t plugNum, uint8_t id)
 static int readSoftwareUpdate(int fd)
 {
     int ret = PASS;
+    uint8_t dataBuf[2] = {ShmSysConfigAndInfo->SysInfo.FirmwareUpdate, 0};
 
     ret = composeSocketData(fd,
-                            ID_REGISTER,
+                            0x01,
                             OP_READ_DATA,
                             REG_SOFTWARE_UPDATE,
-                            0,
-                            NULL);
+                            1,
+                            &dataBuf[0]);
 
     return ret;
 }
@@ -1401,6 +1436,46 @@ static int InitShareMemory(void)
     return result;
 }
 
+static void updateFirmwareProcess(int fd, uint8_t totalConnCount)
+{
+    bool canUpdateFirmware = true;
+    uint8_t plugNum = 0;
+    uint8_t ackCount = 5;
+    struct timeb updateTime;
+
+    if (ShmSysConfigAndInfo->SysWarningInfo.Level != 2) {
+        for (plugNum = 0; plugNum < totalConnCount; plugNum++) {
+            if (ChargingData[plugNum]->SystemStatus != S_IDLE &&
+                    ChargingData[plugNum]->SystemStatus != S_RESERVATION &&
+                    ChargingData[plugNum]->SystemStatus != S_MAINTAIN) {
+                canUpdateFirmware = false;
+            }
+        }
+    }
+
+    if (canUpdateFirmware) {
+        ftime(&updateTime);
+        if (DiffTimeb(gRegTimeUp[0][REG_SOFTWARE_UPDATE], updateTime) > LOOP_RETRY_TIME * 5) {
+            readSoftwareUpdate(fd);
+            ftime(&gRegTimeUp[0][REG_SOFTWARE_UPDATE]);
+        }
+
+        if (ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == YES) {
+            while (ackCount != 0) {
+                ftime(&updateTime);
+                if (DiffTimeb(gRegTimeUp[0][REG_SOFTWARE_UPDATE], updateTime) > LOOP_RETRY_TIME / 2) {
+                    readSoftwareUpdate(fd);
+                    ftime(&gRegTimeUp[0][REG_SOFTWARE_UPDATE]);
+                    if (ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == NO) {
+                        ackCount--;
+                    }
+                }
+                usleep(128);
+            }
+        }
+    }
+}
+
 static void checkAuthorProcess(int fd, uint8_t plugNum)
 {
     int ret = 0;
@@ -1446,6 +1521,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
     struct timeb NowTime;
 
     while (isContinue) {
+        usleep(128);
         ftime(&NowTime);
 
         switch (curReg) {
@@ -1488,11 +1564,20 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         //    break;
 
         //case REG_SOFTWARE_UPDATE:
-        //    if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME) {
-        //        readSoftwareUpdate(fd);
-        //        ftime(&gRegTimeUp[plugNum][curReg]);
+        //    if (ChargingData[plugNum]->SystemStatus == S_IDLE) {
+        //        if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME * 10) {
+        //            readSoftwareUpdate(fd);
+        //            ftime(&gRegTimeUp[plugNum][curReg]);
+        //        }
+        //        while (ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == YES) {
+        //            ftime(&NowTime);
+        //            if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME) {
+        //                readSoftwareUpdate(fd);
+        //            }
+        //            usleep(128);
+        //        }
         //    }
-        //    curReg = REG_PLUG_IN_STATE;
+        //    isContinue = 0;
         //    break;
 
         case REG_PLUG_IN_STATE:
@@ -1541,7 +1626,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
                 //power up write dispenser version and get power cabinet system ID
                 if ((writeCsuModuleVersion(fd) == PASS) &&
                         (writeOtherModuleVersion(fd) == PASS) &&
-                        (readPowerCabinetSystemID(fd) == PASS)) {
+                        (readQRcodeURLAndSystemDate(fd) == PASS)) {
                     //gDoCommGblData.DisConnCount = 0;
                     isContinue = 0;
                 }
@@ -1554,12 +1639,12 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         case REG_QRCODE_URL_INFO:
             if (gunID == 1) {
                 if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > (LOOP_RETRY_TIME * 10)) {
-                    readPowerCabinetSystemID(fd);
+                    readQRcodeURLAndSystemDate(fd);
                     ftime(&gRegTimeUp[plugNum][curReg]);
                 }
             }
             isContinue = 0;
-            //curReg = REG_WAIT_PLUG_IT_STATE;
+            //curReg = REG_SOFTWARE_UPDATE;
             break;
 
         //case REG_WAIT_PLUG_IT_STATE:
@@ -1621,15 +1706,6 @@ static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
                 ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
             }
         }
-
-        //check update firmware
-        //if (ChargingData[plugNum]->SystemStatus == S_IDLE) {
-        //    ftime(&AuthNowTime);
-        //    if (DiffTimeb(gRegTimeUp[plugNum][REG_SOFTWARE_UPDATE], AuthNowTime) > LOOP_RETRY_TIME) {
-        //        readSoftwareUpdate(fd);
-        //        ftime(&gRegTimeUp[plugNum][REG_SOFTWARE_UPDATE]);
-        //    }
-        //}
         break;
 
     case S_PREPARNING: //get permission
@@ -1845,10 +1921,12 @@ int main(int argc, char *argv[])
                 gunID = (plugNum  + 1); //connector Id, 1 = left gun, 2 = right gun
                 systemStatusProcess(fd, plugNum, gunID);
 
-                if ((initDone = messageTrigger(fd,
-                                               plugNum,
-                                               gunID,
-                                               REG_POWER_CABINET_STATUS)) == DISPENSER_SOCKET_RECONN) {
+                initDone = messageTrigger(fd,
+                                          plugNum,
+                                          gunID,
+                                          REG_POWER_CABINET_STATUS);
+
+                if (initDone == DISPENSER_SOCKET_RECONN) {
                     break;
                 }
             }
@@ -1866,6 +1944,12 @@ int main(int argc, char *argv[])
 
             initDone = DISPENER_INIT_FAIL;
         }
+
+        //update dispenser firmware
+        if (initDone != DISPENER_INIT_FAIL) {
+            updateFirmwareProcess(fd, totalConnCount);
+        }
+
         usleep(1000);
     }
 }

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

@@ -83,7 +83,7 @@
 //--- dispenser result ---
 //------------------------------------------------------------------------------
 #define COMMAND_RESULT_OK                       0x01
-#define COMMAND_RESULT_NG                       0x02
+#define COMMAND_RESULT_NG                       0x02 //wait state
 
 //------------------------------------------------------------------------------
 //--- power cabinet misc status code ---
@@ -105,6 +105,9 @@
 #define MISC_CMD_SOFTWARE_RESTART               0x0102
 #define MISC_CMD_REMOTE_START_CHARGING          0x0103
 
+#define ST_UPDATE_FIRMWARE                      0x01
+#define ST_NO_UPDATE_FIRMWARE                   0x02
+
 //------------------------------------------------------------------------------
 #pragma pack(push)
 #pragma pack(1)
@@ -180,7 +183,8 @@ typedef struct StPresentChargingInfo {
 } PreChargingInfo;
 
 typedef struct StSoftwareUpdInfo {
-    uint8_t ImgName[249];
+    uint8_t UpdateState;         //1:update , 2: not update
+    uint8_t ImgName[248];
 } SoftwareUpdInfo;
 
 typedef struct StCapabilityInfo {

+ 118 - 56
EVSE/Projects/DD360Audi/Apps/main.c

@@ -49,7 +49,7 @@
 #define MtdBlockSize                            0x600000
 #define SYSFS_GPIO_DIR                          "/sys/class/gpio"
 #define UPGRADE_FAN                             0x02
-#define UPGRADE_RB                              0x03
+#define UPGRADE_RB                              0x09 //0x09 for dispenser //0x03 old module use
 #define UPGRADE_PRI                             0x04
 #define UPGRADE_AC                              0x05
 #define UPGRADE_LED                             0x06
@@ -155,7 +155,7 @@ bool isModelNameMatch = true;
 
 int rfidFd = -1;
 char *rfidPortName = "/dev/ttyS2";
-char *fwVersion = "V1.01.00.0000.00"; // "V0.16.00.0000.00";
+char *fwVersion = "V1.02.00.0000.00"; // "V0.16.00.0000.00";
 
 sqlite3 *localDb;
 bool isDb_ready;
@@ -3173,39 +3173,79 @@ void KillTask()
     system("killall Module_EvComm");
     system("killall Module_LcmControl");
     system("killall Module_InternalComm");
-    system("killall DoComm");
+    //system("killall DoComm");
     //system("killall Module_PsuComm");
     //system("killall OcppBackend &");
     //system("killall Module_4g &");
     //system("killall Module_Wifi &");
 }
 
-char CheckUpdateProcess()
+void KillAllTask()
 {
+    ChangeLcmByIndex(_LCM_FIX);
+    system("killall Module_EventLogging");
+    system("killall Module_PrimaryComm");
+    system("killall Module_EvComm");
+    system("killall Module_LcmControl");
+    system("killall Module_InternalComm");
+    system("killall DoComm");
+    //system("killall Module_PsuComm");
+    //system("killall OcppBackend &");
+    //system("killall Module_4g &");
+    //system("killall Module_Wifi &");
+}
+
+int CheckUpdateProcess(void)
+{
+    //bool isPass = true;
+    uint8_t retSucc = 0;
+    uint8_t retFail = 0;
+    byte index = 0;
+    byte target = 0;
+    char *new_str = NULL;
+    unsigned char *ptr = NULL;
+    int fd = 0;
+    int CanFd = 0;
+    int uartFd = 0;
+    unsigned int Type = 0;
+    long int MaxLen = 48 * 1024 * 1024, ImageLen = 0;
     DIR *d;
     struct dirent *dir;
-    d = opendir("/mnt/");
 
+    d = opendir("/mnt/");
     if (d) {
-        long int MaxLen = 48 * 1024 * 1024, ImageLen = 0;
         while ((dir = readdir(d)) != NULL) {
-            char *new_str;
-            new_str = malloc(strlen("/mnt/") + strlen(dir->d_name) + 1);
-            new_str[0] = '\0';
+            if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0) {
+                continue;
+            }
+
+            new_str = calloc(strlen("/mnt/") + strlen(dir->d_name) + 1, sizeof(char));
+            //new_str[0] = '\0';
             strcat(new_str, "/mnt/");
             strcat(new_str, dir->d_name);
-            int fd = open(new_str, O_RDONLY);
+            DEBUG_INFO_MSG("%s%s\r\n", "/mnt/", dir->d_name);
+            fd = open(new_str, O_RDONLY);
             if (fd < 0) {
                 return FAIL;
             }
 
-            unsigned char *ptr = malloc(MaxLen); //-48 is take out the header
-            memset(ptr, 0xFF, MaxLen);  //-48 is take out the header
+            ptr = calloc(MaxLen, sizeof(char)); //-48 is take out the header
+            //memset(ptr, 0xFF, MaxLen);  //-48 is take out the header
+
             //get the image length
             ImageLen = read(fd, ptr, MaxLen);
+            for (byte i = 0; i < 16; i++) {
+                if (ShmSysConfigAndInfo->SysConfig.ModelName[i] != ptr[i]) {
+                    return FAIL;
+                }
+            }
 
+            PRINTF_FUNC("model name check pass. \n");
             if (ImageLen > 20) {
-                unsigned int Type = (((unsigned int)ptr[16]) << 24 | ((unsigned int)ptr[17]) << 16 | ((unsigned int)ptr[18]) << 8 | ((unsigned int)ptr[19]));
+                Type = (((unsigned int)ptr[16]) << 24 |
+                        ((unsigned int)ptr[17]) << 16 |
+                        ((unsigned int)ptr[18]) << 8  |
+                        ((unsigned int)ptr[19]));
                 PRINTF_FUNC("Typed...%x \r\n", Type);
 
                 switch (Type) {
@@ -3213,48 +3253,58 @@ char CheckUpdateProcess()
                 case 0x10000002:
                 case 0x10000003:
                 case 0x10000004:
-                case 0x10000005: {
+                case 0x10000005:
                     if (Upgrade_Flash(Type, new_str, (char *)ShmSysConfigAndInfo->SysConfig.ModelName) == PASS) {
-                        return PASS;
+                        //return PASS;
+                        retSucc++;
                     } else {
-                        return FAIL;
+                        PRINTF_FUNC("Upgrade %x Failed\r\n", Type);
+                        //return FAIL;
+                        retFail++;
                     }
-                }
-                break;
+                    break;
+
                 case 0x10000007:
                 case 0x10000008:
                 case 0x10000009:
-                case 0x1000000A: {
-                    bool isPass = true;
-                    int CanFd = InitCanBus();
-
+                case 0x1000000A:
+                    //isPass = true;
+                    CanFd = InitCanBus();
                     if (CanFd > 0) {
-                        for (byte index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++) {
-                            if (!isPass) {
-                                break;
-                            }
+                        for (index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++) {
+                            //if (!isPass) {
+                            //    break;
+                            //}
 
                             if (chargingInfo[index]->Type == _Type_CCS_2) {
                                 if (Upgrade_CCS(CanFd, Type, chargingInfo[index]->Evboard_id, new_str, (char *)ShmSysConfigAndInfo->SysConfig.ModelName) == FAIL) {
-                                    isPass = false;
+                                    //isPass = false;
+                                    PRINTF_FUNC("Upgrade %x Failed\r\n", Type);
+                                    retFail++;
                                 }
                             }
                         }
                     } else {
                         printf("Upgrade CCS open CAN FD fail.\n");
-                        isPass = false;
+                        //isPass = false;
+                        return FAIL;
                     }
 
-                    return isPass;
-                }
-                break;
+                    if (retFail != 0) {
+                        break;
+                    } else {
+                        retSucc++;
+                    }
+                    //return isPass;
+                    break;
+
                 case 0x10000006:
                 case 0x1000000D:
                 case 0x1000000E:
                 case 0x20000002:
-                case 0x10000014: {
+                case 0x10000014:
                     // CSU_PRIMARY_CONTROLLER : 0x10000006
-                    byte target = 0x00;
+                    target = 0x00;
 
                     if (Type == 0x10000006) {
                         target = UPGRADE_PRI;
@@ -3268,47 +3318,54 @@ char CheckUpdateProcess()
                         target = UPGRADE_LED;
                     }
 
-                    int fd = InitComPort(target);
+                    uartFd = InitComPort(target);
 
-                    if (Upgrade_UART(fd, Type, target, new_str, (char *)ShmSysConfigAndInfo->SysConfig.ModelName) == PASS) {
-                        return PASS;
+                    if (Upgrade_UART(uartFd, Type, target, new_str, (char *)ShmSysConfigAndInfo->SysConfig.ModelName) == PASS) {
+                        //return PASS;
+                        retSucc++;
                     } else {
+                        PRINTF_FUNC("Upgrade %x Failed\r\n", Type);
+                        //return FAIL;
                         return FAIL;
                     }
 
-                    close(fd);
-                }
-                break;
+                    if (uartFd > 0) {
+                        close(uartFd);
+                    }
+                    break;
+
                 case 0x1000000B:
-                case 0x1000000C: {
+                case 0x1000000C:
                     // CHAdeMO_BOARD : 0x1000000B, GBT : 0x1000000C
-                    bool isPass = true;
-                    int CanFd = InitCanBus();
-
+                    //bool isPass = true;
+                    CanFd = InitCanBus();
                     if (CanFd > 0) {
-                        for (byte index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++) {
-                            if (!isPass) {
-                                break;
-                            }
+                        for (index = 0; index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; index++) {
+                            //if (!isPass) {
+                            //    break;
+                            //}
 
                             if ((Type == 0x1000000B && chargingInfo[index]->Type == _Type_Chademo) ||
                                     (Type == 0x1000000C && chargingInfo[index]->Type == _Type_GB)) {
                                 if (Upgrade_CAN(CanFd, Type, chargingInfo[index]->Evboard_id, new_str, (char *)ShmSysConfigAndInfo->SysConfig.ModelName) == PASS) {
-                                    return PASS;
+                                    //isPass = PASS;
+                                    retSucc++;
                                 } else {
-                                    return FAIL;
+                                    PRINTF_FUNC("Upgrade %x Failed\r\n", Type);
+                                    //isPass = FAIL;
+                                    retFail++;
                                 }
                             }
                         }
                     } else {
                         PRINTF_FUNC("Upgrad FD fail. \n");
-                        isPass = false;
+                        //isPass = false;
+                        return FAIL;
                     }
 
-                    return isPass;
+                    //return isPass;
                     break;
                 }
-                }
             }
             free(new_str);
             free(ptr);
@@ -3316,7 +3373,12 @@ char CheckUpdateProcess()
     }
     free(dir);
     closedir(d);
-    return FAIL;
+
+    if (retFail != 0) {
+        return FAIL;
+    }
+
+    return PASS;
 }
 
 void CreateRfidFork()
@@ -3763,7 +3825,7 @@ void CheckOcppStatus()
                 ShmOCPP16Data->MsMsg.bits.ResetConf = YES;
                 sleep(3);
                 system("killall OcppBackend &");
-                KillTask();
+                KillAllTask();
                 system("/usr/bin/run_evse_restart.sh");
             }
         }
@@ -4571,7 +4633,7 @@ int main(void)
         // Module Name 與硬體對應不正確
         DEBUG_ERROR_MSG("Module Name & HW info none match. \n");
         sleep(3);
-        KillTask();
+        KillAllTask();
         StopProcessingLoop();
     }
     CreateTimeoutFork();
@@ -4590,7 +4652,7 @@ int main(void)
         }
         ChangeLcmByIndex(_LCM_FIX);
         sleep(3);
-        KillTask();
+        KillAllTask();
         StopProcessingLoop();
     } else {
         for (byte gun_index = 0; gun_index < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; gun_index++) {

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


BIN
EVSE/Projects/DD360Audi/Images/root/DoComm


BIN
EVSE/Projects/DD360Audi/Images/root/Module_EvComm


BIN
EVSE/Projects/DD360Audi/Images/root/Module_EventLogging


BIN
EVSE/Projects/DD360Audi/Images/root/Module_InternalComm


BIN
EVSE/Projects/DD360Audi/Images/root/main


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


BIN
EVSE/Projects/DD360Audi/output/main