Переглянути джерело

2020.12.14 / Jerry Wang

Actions:
1. 2020/12/11 Kaohisung Audi with noodoe test backup.
2. Debug LCM QR code url and station ID issue.
3. Debug can't return complete page issue.

Files:
1. As follow commit history

Image version: V1.01.XX.XXXX.XX
Image checksum: XXXXXXXX
Jerry_Wang 4 роки тому
батько
коміт
422fbb1731

+ 2 - 1
EVSE/Projects/DD360Audi/Apps/Module_LcmContro.h

@@ -59,7 +59,8 @@ struct FanModuleData            *ShmFanModuleData;
 #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-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,

+ 46 - 16
EVSE/Projects/DD360Audi/Apps/Module_LcmControl.c

@@ -396,7 +396,7 @@ void ChangeQrCode_Idle(char *input)
 {
     int len = strlen(input) + 3;
     int loop = 0;
-    int i = 0, j = 0;
+    int i = 0, j = 0, k = 0, l = 0;
     uint8_t qrUrl[128] = {0};
     uint16_t urlLen = 0;
     uint8_t cmd[len];
@@ -407,19 +407,33 @@ void ChangeQrCode_Idle(char *input)
 
     while (input[loop] != '\0') {
         cmd[i++] = input[loop++];
+        l = loop - 1;
+        if (len >= 25) {
+            if (i >= 16 && i <= 19) {
+                tmpBuf[k++] = input[l];
+                //printf("tmpBuf = %s\r\n", tmpBuf);
+            } else if (i >= 21 && i <= 23) {
+                tmpBuf[k++] = input[l];
+            }
+        }
     }
-
+    tmpBuf[k] = '\0';
+    //printf("tmpBuf = %s\r\n", tmpBuf);
     j += sprintf((char *)&cmd[i], ":%d", ShmSysConfigAndInfo->SysInfo.CurGunSelected); ////For Audi
     cmd[len - 1] = '\0';
     urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
+    qrUrl[urlLen] = '\0';
+    //printf("qr url = %s\r\n", qrUrl);
     DisplayValueToLcm(__qr_code, qrUrl, urlLen);
 
     j = 0;
-    j += sprintf((char *)&cmd[i], "0%d", ShmSysConfigAndInfo->SysInfo.CurGunSelected); ////For Audi
-    cmd[len - 1] = '\0';
+    j += sprintf((char *)&tmpBuf[k], "0%d", ShmSysConfigAndInfo->SysInfo.CurGunSelected); ////For Audi
+    tmpBuf[k + j] = '\0';
 
-    strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
-    tmpBuf[tmpLen] = '\0';
+    if (len < 25) {
+        strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
+    }
+    //tmpBuf[tmpLen] = '\0';
     DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
 
     /*if (len > sizeof(tmpBuf)) {
@@ -458,7 +472,9 @@ void ChangeQrCode_Charge(char *input)
 {
     int len = strlen(input) + 3;
     int loop = 0;
-    int i = 0, j = 0;
+    int i = 0, j = 0, k = 0, l = 0;
+    uint8_t qrUrl[128] = {0};
+    uint16_t urlLen = 0;
     uint8_t cmd[len];
     uint8_t tmpBuf[15] = {0};
     uint8_t tmpLen = sizeof(tmpBuf) - 1;
@@ -467,18 +483,32 @@ void ChangeQrCode_Charge(char *input)
 
     while (input[loop] != '\0') {
         cmd[i++] = input[loop++];
+        l = loop - 1;
+        if (len >= 25) {
+            if (i >= 16 && i <= 19) {
+                tmpBuf[k++] = input[l];
+                //printf("tmpBuf = %s\r\n", tmpBuf);
+            } else if (i >= 21 && i <= 23) {
+                tmpBuf[k++] = input[l];
+            }
+        }
     }
-
+    tmpBuf[k] = '\0';
+    //printf("tmpBuf = %s\r\n", tmpBuf);
     j += sprintf((char *)&cmd[i], ":%d", ShmSysConfigAndInfo->SysInfo.CurGunSelected); ////For Audi
     cmd[len - 1] = '\0';
-    DisplayValueToLcm(__qr_code, cmd, len);
+    urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
+    qrUrl[urlLen] = '\0';
+    DisplayValueToLcm(__qr_code, qrUrl, urlLen);
 
     j = 0;
-    j += sprintf((char *)&cmd[i], "0%d", ShmSysConfigAndInfo->SysInfo.CurGunSelected); ////For Audi
-    cmd[len - 1] = '\0';
+    j += sprintf((char *)&tmpBuf[k], "0%d", ShmSysConfigAndInfo->SysInfo.CurGunSelected); ////For Audi
+    tmpBuf[k + j] = '\0';
 
-    strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
-    tmpBuf[tmpLen] = '\0';
+    if (len < 25) {
+        strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
+    }
+    //tmpBuf[tmpLen] = '\0';
     DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
     /*if (len > sizeof(tmpBuf)) {
         strncpy((char *)tmpBuf, (char *)cmd, sizeof(tmpBuf));
@@ -612,7 +642,7 @@ static void ChangeBalanceValue(uint16_t addr, uint8_t index) ////For Audi
     float balance = gAudiCustInfo->PricesInfo[index].Balance;
 
     if ((balance) == (FAIL_BALANCE_PRICES)) {
-        balance = 0.0;
+        balance = 0.00;
     }
 
     len += sprintf((char *) value, "%.2f", balance);
@@ -819,7 +849,7 @@ void DisplayMoneyCur(byte *cur)
 
     *(cur + 3) = '\0';
     memset(cmd, 0x00, sizeof(cmd));
-    len = sprintf((char *) buf, "%s/KWh", cur);
+    len = sprintf((char *) buf, "%s/kWh", cur);
     buf[len] = '\0';
     string2ByteArray(buf, cmd);
     DisplayValueToLcm(__money_rate, cmd, sizeof(cmd));
@@ -1357,7 +1387,7 @@ void ChangeDisplayMoneyInfo()
         tmCSU = localtime(&csuTime.time);
 
         ChangeDisplay2Value(__money_rate_map, _charging_money);
-        if (gAudiCustInfo->PricesInfo[curGun].UserPrices != 0.0) { //Jerry add
+        if (gAudiCustInfo->PricesInfo[curGun].UserPrices != 0.00) { //Jerry add
             DisplayMoneyRate(gAudiCustInfo->PricesInfo[curGun].UserPrices);
         } else {
             if (tmCSU->tm_hour <= 23) {

+ 66 - 27
EVSE/Projects/DD360Audi/Apps/ReDoComm.c

@@ -398,22 +398,29 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
                       tm->tm_min);
 
     //copy QR code string
-    if (strncmp((char *)localTime, (char *)&data[0], timeLen) != 0) {
+    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);
     }
 
-    if ((char *)&data[len] == '\0') {
-        DEBUG_ERROR("power cabinet system date error\r\n");
-        return FAIL;
-    }
+    //if ((char *)&data[len] == '\0') {
+    //    DEBUG_ERROR("power cabinet system date error\r\n");
+    //    return FAIL;
+    //}
 
     //set system date
-    if (strncmp((char *)localTime, (char *)&data[len], timeLen) != 0) {
-        sprintf(cmdBuf, "date -s \"%s\" >> /dev/null", (char *)&data[len]);
-        system(cmdBuf);
-        DEBUG_INFO("local time = %s, data time =  %s\r\n", localTime, (char *)&data[len]);
-    }
+    //if (strncmp((char *)localTime, (char *)&data[len], timeLen) != 0) {
+    //    sprintf(cmdBuf, "date -s \"%s\" >> /dev/null", (char *)&data[len]);
+    //    system(cmdBuf);
+    //    DEBUG_INFO("local time = %s, data time = %s\r\n", localTime, (char *)&data[len]);
+    //    ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
+    //    strcpy((char *)ShmOCPP16Data->Reset.Type, "Soft");
+    //    sleep(3);
+    //    //gDoCommGblData.DisConnCount = CHECK_NETWORK_FAIL_COUNT;
+    //}
 
     return PASS;
 }
@@ -486,6 +493,9 @@ 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) {
+                    clearMiscCommand();
+                }
                 break;
             }
 
@@ -516,6 +526,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
 
         case MISC_CMD_DEFAULT_CURRENCY:
             if (value < 0) {
+                clearMiscCommand();
                 return FAIL;
             }
 
@@ -526,6 +537,12 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
 
         case MISC_CMD_ACCOUNT_BALANCE:
             if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (id - 1)) {
+                clearMiscCommand();
+                break;
+            }
+
+            if (getConfirmSelectedGun(id - 1) == FAIL) {
+                DEBUG_INFO("Remote start not select gun\r\n");
                 break;
             }
 
@@ -537,6 +554,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
         //--- Control Dispenser ---
         case MISC_CMD_HARDWARE_REBOOT:
             if (value != YES) {
+                clearMiscCommand();
                 break;
             }
 
@@ -548,6 +566,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
 
         case MISC_CMD_SOFTWARE_RESTART:
             if (value != YES) {
+                clearMiscCommand();
                 break;
             }
 
@@ -559,28 +578,32 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
 
         case MISC_CMD_REMOTE_START_CHARGING:
             if (value != YES) {
+                if (id == 2) {
+                    clearMiscCommand();
+                }
                 break;
             }
             DEBUG_INFO("Remote start charging id = %d\r\n", id);
 
-            //if (getConfirmSelectedGun(id - 1) == FAIL) {
-            //    DEBUG_INFO("Remote start not select gun\r\n");
-            //    break;
-            //}
-
-            if (getSelGunWaitToAuthor(id - 1) == FAIL) {
-                DEBUG_ERROR("Remote start gun already charging\r\n");
+            if (getConfirmSelectedGun(id - 1) == FAIL) {
+                DEBUG_INFO("Remote start not select gun\r\n");
                 break;
             }
 
-            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (id - 1)) {
-                ShmSysConfigAndInfo->SysInfo.CurGunSelected = (id - 1);
-                ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
-            }
+            //if (getSelGunWaitToAuthor(id - 1) == FAIL) {
+            //    DEBUG_ERROR("Remote start gun already charging\r\n");
+            //    break;
+            //}
+
+            //if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (id - 1)) {
+            //    ShmSysConfigAndInfo->SysInfo.CurGunSelected = (id - 1);
+            //    ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
+            //}
 
-            setConfirmSelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
+            //setConfirmSelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
 
             ShmOCPP16Data->CsMsg.bits[id - 1].RemoteStartTransactionReq = YES;
+            gAudiCustInfo->PricesInfo[id - 1].Balance = 0.00;
             if (id == 2) {
                 clearMiscCommand();
             }
@@ -704,15 +727,17 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     }
 
     for (count = 0; count < dataLen; count += WARNING_CODE_SIZE) {
-        //printf("status code = %s\r\n", &data[count]);
-
         // misc command status code handle
         if (strcmp((char *)&data[count], MISC_ST_MISC_CMD) == 0) {
-            gDoCommGblData.MiscCmd = REG_MISC_CONTROL;
+            if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
+                gDoCommGblData.MiscCmd = REG_MISC_CONTROL;
+            }
             memset((char *)&data[count], 0, WARNING_CODE_SIZE);
             continue;
         } else if (strcmp((char *)&data[count], MISC_ST_VERSION) == 0) {
-            gDoCommGblData.MiscCmd = REG_REPORT_CSU_VERSION;
+            if (gDoCommGblData.MiscCmd != REG_REPORT_CSU_VERSION) {
+                gDoCommGblData.MiscCmd = REG_REPORT_CSU_VERSION;
+            }
             memset((char *)&data[count], 0, WARNING_CODE_SIZE);
             continue;
         }
@@ -1517,7 +1542,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
                 if ((writeCsuModuleVersion(fd) == PASS) &&
                         (writeOtherModuleVersion(fd) == PASS) &&
                         (readPowerCabinetSystemID(fd) == PASS)) {
-                    gDoCommGblData.DisConnCount = 0;
+                    //gDoCommGblData.DisConnCount = 0;
                     isContinue = 0;
                 }
             }
@@ -1546,6 +1571,10 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         //    break;
 
         default:
+            DEBUG_ERROR("error curReg = %x\r\n", curReg);
+            gDoCommGblData.MiscCmd = 0;
+            gDoCommGblData.DisConnCount = CHECK_NETWORK_FAIL_COUNT;
+            isContinue = 0;
             break;
         }
 
@@ -1557,6 +1586,15 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
     return ret;
 }
 
+static bool isDetectPlugin()
+{
+    if (ShmSysConfigAndInfo->SysInfo.WaitForPlugit == YES) {
+        return YES;
+    }
+
+    return NO;
+}
+
 static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
 {
     struct timeb AuthNowTime = {0};
@@ -1828,5 +1866,6 @@ int main(int argc, char *argv[])
 
             initDone = DISPENER_INIT_FAIL;
         }
+        usleep(1000);
     }
 }

+ 17 - 3
EVSE/Projects/DD360Audi/Apps/main.c

@@ -155,7 +155,7 @@ bool isModelNameMatch = true;
 
 int rfidFd = -1;
 char *rfidPortName = "/dev/ttyS2";
-char *fwVersion = "V1.00.00.0000.00"; // "V0.16.00.0000.00";
+char *fwVersion = "V1.01.00.0000.00"; // "V0.16.00.0000.00";
 
 sqlite3 *localDb;
 bool isDb_ready;
@@ -207,6 +207,7 @@ static void destroySelGun(uint8_t curGun)
         if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf != NO) {
             ClearAuthorizedFlag();
         }
+
         DEBUG_INFO_MSG("destroy left gun, cur page = %d\r\n", getCurLcmPage());
         if (getCurLcmPage() == ShmSysConfigAndInfo->SysInfo.SystemPage) {
             DEBUG_INFO_MSG("clear left balance\r\n");
@@ -217,7 +218,7 @@ static void destroySelGun(uint8_t curGun)
 
     if ((curGun == RIGHT_GUN_NUM) && (gAudiCustInfo->SelGunInfo.RightGun != SEL_GUN_RELEASE)) {
         if (gAudiCustInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM ||
-                gAudiCustInfo->SelGunInfo.LeftGun == SEL_GUN_ATHOR) {
+                gAudiCustInfo->SelGunInfo.RightGun == SEL_GUN_ATHOR) {
             changeLcmPage(_LCM_SELECT_GUN);
         }
         gAudiCustInfo->SelGunInfo.RightGun = SEL_GUN_RELEASE;
@@ -225,6 +226,7 @@ static void destroySelGun(uint8_t curGun)
         if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf != NO) {
             ClearAuthorizedFlag();
         }
+
         DEBUG_INFO_MSG("destroy right gun, cur page = %d\r\n", getCurLcmPage());
         if (getCurLcmPage() == ShmSysConfigAndInfo->SysInfo.SystemPage) {
             DEBUG_INFO_MSG("clear right balance\r\n");
@@ -3516,6 +3518,11 @@ void CreateTimeoutFork()
                 break;
             case Timeout_ReturnToChargingGunDet: {
                 if (GetTimeoutValue(ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer) / uSEC_VAL >= RETURN_TO_CHARGING_PAGE) {
+                    if (getCurLcmPage() != _LCM_PRE_CHARGE &&
+                            getCurLcmPage() != _LCM_CHARGING &&
+                            getCurLcmPage() != _LCM_COMPLETE) {
+                        destroySelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected); //jerry add
+                    }
                     DisplayChargingInfo();
                     StopSystemTimeoutDet();
                 }
@@ -3576,7 +3583,7 @@ void CreateTimeoutFork()
 
                 case Timeout_SelectGun: //Jerry add
                     if (GetTimeoutValue(chargingInfo[gun_index]->TimeoutTimer) / uSEC_VAL >= SEL_GUN_TIMEOUT) {
-                        printf("Timeout_SelectGun\r\n");
+                        DEBUG_INFO_MSG("Timeout_SelectGun\r\n");
                         StopGunInfoTimeoutDet(gun_index);
                         destroySelGun(gun_index); //jerry add
                     }
@@ -5247,6 +5254,9 @@ int main(void)
                     setChargerMode(gun_index, MODE_CCS_PRECHARGE_STEP1);
                 }
 
+                if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
+                    ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_PRE_CHARGE;
+                }
                 break;
             }
             case S_CCS_PRECHARGE_ST1: {
@@ -5270,6 +5280,10 @@ int main(void)
                     chargingInfo[gun_index]->PrechargeStatus = PRECHARGE_READY;
                     setChargerMode(gun_index, MODE_CHARGING);
                 }
+
+                if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == gun_index) {
+                    ShmSysConfigAndInfo->SysInfo.ConnectorPage = _LCM_PRE_CHARGE;
+                }
                 break;
             }
             }

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


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


Різницю між файлами не показано, бо вона завелика
+ 502 - 469
EVSE/Projects/define.h


Деякі файли не було показано, через те що забагато файлів було змінено