Quellcode durchsuchen

Merge remote-tracking branch 'origin/DD360Tcci'

FolusWen vor 2 Jahren
Ursprung
Commit
2c4b0bf795

+ 9 - 7
EVSE/Projects/DD360Tcci/Apps/CSU/RFID.c

@@ -501,7 +501,7 @@ void CreateRfidFork(void)
                 if (checkRemoteStart(gunIndex) && ShmDcCommonData->AuthPass_flag[gunIndex] &&
                     !ShmDcCommonData->PayPass_flag[gunIndex]) {
                     RemoteStartCancelPreAuth(gunIndex);
-                    ShmDcCommonData->PayPass_flag[gunIndex] = TRUE;
+                    ShmDcCommonData->AuthPass_flag[gunIndex] = FALSE;
                 }
 
                 if (ShmDcCommonData->StopCharge[gunIndex] == TRUE && pDcChargingInfo->Replug_flag == TRUE) {
@@ -509,12 +509,15 @@ void CreateRfidFork(void)
                     if (ShmDcCommonData->DebugFlag == TRUE ||
                         ShmDcCommonData->is_RemoteStart[gunIndex] == TRUE ||
                         ShmDcCommonData->is_AutoStart[gunIndex] == TRUE) {
-                        pSysInfo->SystemPage = _PAGE_PLUGOUT;
+                        if (pSysInfo->CurGunSelected == gunIndex)
+                            pSysInfo->SystemPage = _PAGE_PLUGOUT;
                         ShmDcCommonData->PayPass_flag[gunIndex] = TRUE;
+                        ShmDcCommonData->StopCharge[gunIndex] = FALSE;
                         continue;
                     }
                     ShmDcCommonData->StopCharge[gunIndex] = FALSE;
                     log_info("Gun %d Not Into Charging cancel Trade",gunIndex);
+            
                     StopGunInfoTimeoutDet(gunIndex);
                     ShmDcCommonData->TradeCancel = TRUE;
                     pSysInfo->SystemPage = _PAGE_SENSING;
@@ -532,11 +535,10 @@ void CreateRfidFork(void)
                         StopGunInfoTimeoutDet(gunIndex); //Timeout_FinalCost
 
                         // Remote Start of AutoStart ByPass Credit Card Reader
-                        if (ShmDcCommonData->DebugFlag == TRUE ||
-                            checkRemoteStart(gunIndex) ||
+                        if (ShmDcCommonData->DebugFlag == TRUE || checkRemoteStart(gunIndex) ||
                             ShmDcCommonData->is_AutoStart[gunIndex]) {
-                            pSysInfo->SystemPage = _PAGE_COMPLETE;
                             ShmDcCommonData->PayPass_flag[gunIndex] = TRUE;
+                            pSysInfo->SystemPage = _PAGE_COMPLETE;
                             continue;
                         }
                         // 實際扣款
@@ -610,7 +612,7 @@ void CreateRfidFork(void)
             }
 
             if ((is_idle == TRUE &&
-                (pSysInfo->SystemPage == _PAGE_IDLE || pSysInfo->SystemPage == _PAGE_SELECT_GUN) &&
+                pSysInfo->SystemPage == _PAGE_IDLE  &&
                 ShmDcCommonData->RoutineReduct == FALSE) || ShmDcCommonData->Exe_ReDeduct) {
 
                 ReDeductProcess(fd);
@@ -620,7 +622,7 @@ void CreateRfidFork(void)
             }
 
             // 每日晚上11點30分結帳
-            if (is_idle == TRUE && (pSysInfo->SystemPage == _PAGE_IDLE || pSysInfo->SystemPage == _PAGE_SELECT_GUN) &&
+            if (is_idle == TRUE && pSysInfo->SystemPage == _PAGE_IDLE  &&
                 ((tm->tm_hour == 15 && tm->tm_min > 30  && ShmDcCommonData->RoutineSettlement == FALSE) ||
                     ShmDcCommonData->UnionSettlement)) {
                 StopSystemTimeoutDet();

+ 52 - 54
EVSE/Projects/DD360Tcci/Apps/CSU/main.c

@@ -82,8 +82,8 @@ uint8_t bd0_2_status = 0;
 uint8_t bd1_1_status = 0;
 uint8_t bd1_2_status = 0;
 
-char *fwVersion = "V2.12.00.0000.00"; // Phihong version
-char* DebugVersion = "v2.12.01";      // Software debug version
+char *fwVersion = "V2.13.00.0000.00"; // Phihong version
+char* DebugVersion = "V2.13.01";      // Software debug version
 //sqlite3 *localDb;
 bool isDb_ready;
 
@@ -292,7 +292,7 @@ static void GetFirmwareVersion(void)
 {
     // Get CSU root file system version
     sprintf((char *)pSysInfo->CsuRootFsFwRev, fwVersion);
-
+    sprintf((char*)ShmDcCommonData->DebugVersion, DebugVersion);
     uint8_t count = 0, chademo = 0, ccs = 0, gb = 0;
     for (uint8_t idx = 0; idx < 3; idx++) {
         if (pSysConfig->ModelName[7 + idx] == 'J') {
@@ -2766,18 +2766,11 @@ void CreateTimeoutFork(void)
                 		if (ShmDcCommonData->finalcost_flag[gunIndex] == FALSE) {
                             if (ShmDcCommonData->is_AutoStart[gunIndex] || ShmDcCommonData->is_RemoteStart[gunIndex]) {
                                 ShmDcCommonData->PayPass_flag[gunIndex] = FALSE;
-                                pSysInfo->SystemPage = _PAGE_PAYFAIL;
                                 ShmDcCommonData->finalcost_flag[gunIndex] = TRUE;
                             } else {
                                 log_info("Not Get Final Cost");
                                 ShmDcCommonData->PayPass_flag[gunIndex] = FALSE;
                                 pSysInfo->SystemPage = _PAGE_PAYFAIL;
-                                /*
-                                ShmDcCommonData->TransactionInfo[gunIndex].Amount = pDcChargingInfo->PresentChargedEnergy * ShmDcCommonData->ChargingRate;
-                                if (ShmDcCommonData->TransactionInfo[gunIndex].Amount < 1)
-                                    ShmDcCommonData->TransactionInfo[gunIndex].Amount = 1;
-                                ShmDcCommonData->finalcost_flag[gunIndex] = TRUE;
-                                */
                             }
                 		}
                 	}
@@ -3927,7 +3920,7 @@ void ResetIdleData(uint8_t gunIndex)
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
     ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
     ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
-
+    float powerconsumption = ShmDcCommonData->pGunInfo[gunIndex].PowerConsumption;
     pDcChargingInfo->PresentChargedDuration = 0;
     pDcChargingInfo->RemainChargingDuration = 0;
     pDcChargingInfo->PresentChargingVoltage = 0;//DS60-120 add
@@ -3944,7 +3937,7 @@ void ResetIdleData(uint8_t gunIndex)
     memset(&ShmSelectGunInfo->PricesInfo[gunIndex], 0, sizeof(PricesInfo));
     memset(&ShmDcCommonData->TransactionInfo[gunIndex], 0, sizeof(RecordTransactionInfo));
     memset(&ShmDcCommonData->pGunInfo[gunIndex], 0, sizeof(GunInfo));
-    DB_Get_PowerConsumption(gunIndex);
+    ShmDcCommonData->pGunInfo[gunIndex].PowerConsumption = powerconsumption;
     ShmDcCommonData->finalcost_flag[gunIndex] = FALSE;
     ShmDcCommonData->AuthPass_flag[gunIndex] = FALSE;
     ShmDcCommonData->PayPass_flag[gunIndex] = FALSE;
@@ -4262,11 +4255,8 @@ int main(void)
         isDb_ready = true;
         for (int _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
-
             pDcChargingInfo->IsAvailable = DB_Get_Operactive(_index);
-            if (!DB_Get_PowerConsumption(_index)) {
-                DB_Insert_PowerConsumption(_index, 0);
-            }
+
         }
         DB_Reboot_Record();
     }
@@ -4275,14 +4265,22 @@ int main(void)
         log_info("Power DB_Open fail. ");
         isDb_ready = false;
     } else {
+        int _retry = 0;
         isDb_ready = true;
         for (int _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
             pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(_index);
-
-            if (!DB_Get_PowerConsumption(_index)) {
-                DB_Insert_PowerConsumption(_index, 0);
-            }
-        }
+            while (_retry < 3) {
+                if (DB_Get_PowerConsumption(_index)) {
+                    break;
+                } else {
+                    sleep(1);
+                    _retry++;
+                    if (_retry == 3) {
+                        DB_Insert_PowerConsumption(_index, 0);
+                    }
+                }
+            } // while
+        } // for
     }
     log_info("===== Create DB End ===== ");
 
@@ -4407,7 +4405,7 @@ int main(void)
                 // 讀卡邏輯
                 if (!ShmDcCommonData->TradeCancel && pSysInfo->CurGunSelected == gunIndex)
                     ScannerCardProcess(gunIndex);
-                if (pSysInfo->SystemPage == _PAGE_SELECT_GUN) {
+                if (pSysInfo->SystemPage == _PAGE_SELECT_GUN || pSysInfo->SystemPage == _PAGE_IDLE) {
                 	//ShmDcCommonData->LineStatus[gunIndex] = 0;
                 	StopGunInfoTimeoutDet(gunIndex);
 				}
@@ -4492,8 +4490,8 @@ int main(void)
                     break;
                 }
                 if (pDcChargingInfo->SystemStatus == S_FAULT) {
-                    systemPageRestoreInit();
                     setChargerMode(gunIndex, MODE_IDLE);
+                    systemPageRestoreInit();
                 }
 
                 break;
@@ -4512,9 +4510,7 @@ int main(void)
                 }
                 if (isDetectPlugin(gunIndex)) {
                     StartGunInfoTimeoutDet(gunIndex, Timeout_WaitPlug);
-                    if (pSysInfo->CurGunSelected == gunIndex) {
-                        pSysInfo->SystemPage = _PAGE_PLUGIN;
-                    }
+
                     // 卡號驗證成功後,等待充電槍插入充電車
                     if (pDcChargingInfo->RemoteStartFlag == YES) {
                         if (pDcChargingInfo->ConnectorPlugIn == YES &&
@@ -4858,29 +4854,32 @@ int main(void)
                         StartGunInfoTimeoutDet(gunIndex, Timeout_ExitPage);
                     }
                 }
+                if (pDcChargingInfo->Replug_flag == TRUE && pSysInfo->CurGunSelected == gunIndex) {
+                    pSysInfo->SystemPage = _PAGE_PLUGOUT;
+                    break;
+                }
                 // Remote start
                 if (ShmDcCommonData->is_RemoteStart[gunIndex] && pSysInfo->CurGunSelected == gunIndex) {
-                    if (pDcChargingInfo->Replug_flag == TRUE)
-                        pSysInfo->SystemPage = _PAGE_PLUGOUT;
-                    else {
-                        if (ShmDcCommonData->finalcost_flag[gunIndex]) {
+
+                    if (ShmDcCommonData->finalcost_flag[gunIndex]) {
+                        if (ShmDcCommonData->PayPass_flag[gunIndex]) {
                             pSysInfo->SystemPage = _PAGE_COMPLETE;
+                            //log_info("_PAGE_COMPLETE");
                         } else {
-                            pSysInfo->SystemPage = _PAGE_PAYING;
+                            pSysInfo->SystemPage = _PAGE_PAYFAIL;
+                            //log_info("_PAGE_PAYFAIL");
                         }
+                    } else {
+                        pSysInfo->SystemPage = _PAGE_PAYING;
                     }
                     break;
                 }
                 if (pSysInfo->CurGunSelected == gunIndex && 
                     pSysInfo->SystemPage != _PAGE_PAYING && pSysInfo->SystemPage != _PAGE_SENSING) {
-                    if (pDcChargingInfo->Replug_flag == TRUE)
-                        pSysInfo->SystemPage = _PAGE_PLUGOUT;
-                    else {
-                        if (ShmDcCommonData->PayPass_flag[gunIndex] == TRUE)
-                            pSysInfo->SystemPage = _PAGE_COMPLETE;
-                        else
-                            pSysInfo->SystemPage = _PAGE_PAYFAIL;
-                    }
+                    if (ShmDcCommonData->PayPass_flag[gunIndex] == TRUE)
+                        pSysInfo->SystemPage = _PAGE_COMPLETE;
+                    else
+                        pSysInfo->SystemPage = _PAGE_PAYFAIL;
                 }
 
                 break;
@@ -4934,28 +4933,27 @@ int main(void)
                         StartGunInfoTimeoutDet(gunIndex, Timeout_ExitPage);
                     }
                 }
+                if (pDcChargingInfo->Replug_flag == TRUE && pSysInfo->CurGunSelected == gunIndex) {
+                    pSysInfo->SystemPage = _PAGE_PLUGOUT;
+                    break;
+                }
                 // Remote start
                 if (ShmDcCommonData->is_RemoteStart[gunIndex] && pSysInfo->CurGunSelected == gunIndex) {
-                    if (pDcChargingInfo->Replug_flag == TRUE)
-                        pSysInfo->SystemPage = _PAGE_PLUGOUT;
-                    else {
-                        if (ShmDcCommonData->finalcost_flag[gunIndex]) {
+                    if (ShmDcCommonData->finalcost_flag[gunIndex]) {
+                        if (ShmDcCommonData->PayPass_flag[gunIndex])
                             pSysInfo->SystemPage = _PAGE_COMPLETE;
-                        } else {
-                            pSysInfo->SystemPage = _PAGE_PAYING;
-                        }
+                        else
+                            pSysInfo->SystemPage = _PAGE_PAYFAIL;
+                    } else {
+                        pSysInfo->SystemPage = _PAGE_PAYING;
                     }
                     break;
                 }
                 if (pSysInfo->CurGunSelected == gunIndex && pSysInfo->SystemPage != _PAGE_PAYING ) {
-                	if (pDcChargingInfo->Replug_flag == TRUE)
-                		pSysInfo->SystemPage = _PAGE_PLUGOUT;
-                	else {
-                		if (ShmDcCommonData->PayPass_flag[gunIndex] == TRUE)
-							pSysInfo->SystemPage = _PAGE_COMPLETE;
-						else
-							pSysInfo->SystemPage = _PAGE_PAYFAIL;
-                	}
+                	if (ShmDcCommonData->PayPass_flag[gunIndex] == TRUE)
+						pSysInfo->SystemPage = _PAGE_COMPLETE;
+					else
+						pSysInfo->SystemPage = _PAGE_PAYFAIL;
 				}
 
                 break;

+ 2 - 0
EVSE/Projects/DD360Tcci/Apps/Config.h

@@ -580,6 +580,8 @@ typedef struct StDcCommonInfo {
     uint8_t tccdev;
     uint8_t TaiwanEast;
     uint8_t lcmtest;
+    char DebugVersion[32];
+    uint8_t BackLight;
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 5 - 5
EVSE/Projects/DD360Tcci/Apps/DataBase/DataBase.c

@@ -67,7 +67,7 @@ int DB_Open(void)
         log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
     } else {
-        log_info( "Local charging record database open successfully.");
+        //log_info( "Local charging record database open successfully.");
 
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
@@ -168,14 +168,14 @@ int DB_Update_Operactive(uint8_t gunIndex, uint8_t IsAvailable)
         log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
     } else {
-        log_info( "Local charging record database open successfully (%d).", IsAvailable);
+        //log_info( "Local charging record database open successfully (%d).", IsAvailable);
 
         //sprintf(sqlStr, "insert or replace into config (IsAvailable, connector, val) values('IsAvailable', %d, %d);", gunIndex, IsAvailable);
         sprintf(sqlStr,
                 "insert or replace into config (item, connector, val) values('IsAvailable', %d, %d);",
                 gunIndex,
                 IsAvailable); //DS60-120 add
-        log_info("sqlStr= %s", sqlStr);
+        //log_info("sqlStr= %s", sqlStr);
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             log_info( "update config error message: %s", errMsg);
@@ -239,7 +239,7 @@ int DB_Reboot_Record(void)
         log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
     } else {
-        log_info( "Local charging record database open successfully.");
+        //log_info( "Local charging record database open successfully.");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             log_info( "Insert reboot record error message: %s", errMsg);
@@ -899,7 +899,7 @@ int DB_Get_PowerConsumption(uint8_t gunIndex)
         log_info("Can't open database: %s", sqlite3_errmsg(powerDb));
         sqlite3_close(powerDb);
     } else {
-        log_info("Local config query database open successfully.");
+        //log_info("Local config query database open successfully.");
         sqlite3_get_table(powerDb, sqlStr, &rs, &rows, &cols, &errMsg);
         if (rows > 0) {
             for (int idxRow = 1; idxRow <= rows; idxRow++) {

+ 4 - 4
EVSE/Projects/DD360Tcci/Apps/Log/log.h

@@ -2,11 +2,11 @@
 #define _LOG_H_
 
 //------------------------------------------------------------------------------
-#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
 
-#define event_info(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args) //DS60-120 add
+#define event_info(format, args...) StoreEventLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args) //DS60-120 add
 //------------------------------------------------------------------------------
 int StoreLogMsg(const char *fmt, ...);
 int StoreEventLogMsg(const char *fmt, ...);

+ 5 - 2
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.c

@@ -1417,13 +1417,13 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
         ShmDcCommonData->Location = atoi(_stationInfo.StationName);
 
         CheckTaiwanEastWest(ShmDcCommonData->Location);
-        /*
+        
         log_info("Station Name: %s, ID: %d, Weather: %d, Temperature: %.1f",
                 _stationInfo.StationName,
                 _stationInfo.StationID,
                 _stationInfo.WeatherID,
                 _stationInfo.Temperature);
-        */
+        
         break;
 
     case REG_DEDUCT_INFO:
@@ -2262,6 +2262,9 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
 					ShmDcCommonData->TransactionInfo[plugNum].Amount = pDcChargingInfo->ChargingFee;
 					ShmDcCommonData->finalcost_flag[plugNum] = TRUE;
 					log_info("Gun %d get final cost %f", plugNum, ShmDcCommonData->TransactionInfo[plugNum].Amount);
+                    if (ShmDcCommonData->is_RemoteStart[plugNum] || ShmDcCommonData->is_AutoStart[plugNum]) {
+                        ShmDcCommonData->PayPass_flag[plugNum] = TRUE;
+                    }
                 }
             }
             curReg = REG_PLUG_IN_STATE;

+ 3 - 3
EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/Module_InternalComm.h

@@ -85,9 +85,9 @@
 #define AC_ROTARY_SWITCH_FAULT                  (131072)
 #define AC_RELAY_DRIVE_FAULT                    (262144)
 
-#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
+#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)), __LINE__, __FUNCTION__, ##args)
 
 //------------------------------------------------------------------------------
 

+ 26 - 17
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -235,6 +235,9 @@ void ReadMsgFromLcm(uint8_t* msg, uint8_t readLen)
                 strcpy((char*)pSysInfo->LcmHwRev, moduleName);
             if (key == 0x0014)
                 _currentPage = *(msg + 8);
+            if (key == 0x0031) {
+                log_info("Get LCM Backlight change to 0x%x", *(msg + 8));
+            }
             if (key >= _Touch_IDLE && key <= _Touch_Pay_LinePay) {
 
                 _btn_press_id = key;
@@ -449,6 +452,7 @@ void CheckConfirmGun(uint8_t gunIndex)
         log_info("Reservation can't select");
         return;
     }
+    //log_info("Confirm Gun%d",gunIndex);
 	pSysInfo->CurGunSelected = gunIndex;
 	pSysInfo->SystemPage = _PAGE_BILL;
 }
@@ -617,7 +621,7 @@ void CheckLCMPressed()
     pid_t Pid = fork();
     if ( Pid == 0 ) {
         while (1) {
-        	if (pSysInfo->SystemPage != _PAGE_SELECT_GUN) {
+        	if (pSysInfo->SystemPage != _PAGE_SELECT_GUN && pSysInfo->SystemPage != _PAGE_IDLE) {
 				CheckTouchPress(_Touch_Show_Left);
 				CheckTouchPress(_Touch_Show_Right);
         	}
@@ -727,26 +731,22 @@ void ChangeToOtherPage(short newPage)
     ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
 }
 
-void ChangeBackLight(bool islight)
+void ChangeBackLight(uint8_t value)
 {
-    uint8_t value = 0x01;
+    //uint8_t value = 0x01;
     uint8_t msg[9];
     memset(msg, 0x00, sizeof(msg));
 
-    // 0x00 ~ 0x40
-    if (islight)
-    {
-        value = 0x20;
-    }
     uint8_t cmd[7];
     memset(cmd, 0x00, sizeof(cmd));
 
     cmd[0] = CMD_TITLE_1;
     cmd[1] = CMD_TITLE_2;
-    cmd[2] = 0x03;
-    cmd[3] = CMD_READ;
-    cmd[4] = CMD_BACKLIGHT;
-    cmd[5] = value;
+    cmd[2] = 0x05;
+    cmd[3] = CMD_MULTI_WRITE;
+    cmd[4] = 0x00;
+    cmd[5] = 0x82;
+    cmd[6] = value;
 
     WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
     usleep(10000);
@@ -1321,8 +1321,12 @@ void ProcessPageInfo()
     for (uint8_t i = 0; i < pSysConfig->TotalConnectorCount; i++) {
 
         if (pSysInfo->CurGunSelected == i) {
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+            pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(i);
 
+            if (pDcChargingInfo->SystemStatus == S_IDLE) {
+                _everyPageRollChange = 0;
+                _Text_Running_Count = 1;
+            }
             switch (pSysInfo->SystemPage) {
             case _PAGE_IDLE:
                 ShowSelectGun();
@@ -1351,7 +1355,7 @@ void ProcessPageInfo()
 
 		        ChangeChargingRateValue((int)ShmDcCommonData->ChargingRate);
                 ShowAuthorizeCountDown();
-            	_Text_Running_Count = 1;
+
                 break;
             case _PAGE_SENSING:
                 if (ShmDcCommonData->TradeCancel == TRUE) {
@@ -1368,8 +1372,6 @@ void ProcessPageInfo()
                 ShowLineRegisterCountDown();
                 break;
             case _PAGE_PRECHARGE:
-            	//ChangeDisplay2Value(_Icon_Precharge,1);
-
             	RefreshProgressAnimation();
             	if (_everyPageRollChange == 0) {
             		ChangeDisplay2Value(_Icon_Precharge,_Text_Running_Count);
@@ -1762,7 +1764,9 @@ int main(void)
     _port = CreateCommunicationLcmPort();
     uint8_t changeWarningPriority = 0;
     uint8_t curWarningCount = 255;
-    ChangeBackLight(true);
+    uint8_t light = 0x64;
+    ShmDcCommonData->BackLight = light;
+    ChangeBackLight(light);
     _totalCount = pSysConfig->TotalConnectorCount;
     _everyPageRollChange = 0;
     //Initialization();
@@ -1791,6 +1795,11 @@ int main(void)
         } else {
             UpdateLcmFunction(ShmDcCommonData,_port);
 
+            if (ShmDcCommonData->BackLight != light) {
+                ChangeBackLight(ShmDcCommonData->BackLight);
+                light = ShmDcCommonData->BackLight;
+                log_info("Set Backlight:%d",light);
+            }
             /*
             // Warning 處理
             if (curWarningCount != pSysWarning->WarningCount) {

+ 0 - 2
EVSE/Projects/DD360Tcci/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -272,8 +272,6 @@ static void checkChillerStatus(Gpio_out *gpio)
 
         }
     }
-    if (ShmDcCommonData->DebugFlag == YES) 
-        _chillerNeedOn = ShmDcCommonData->chillerCtrl;
 
     if(_chiller.ChillerSwitch != _chillerNeedOn)
     {

+ 20 - 2
EVSE/Projects/DD360Tcci/Apps/ModuleUpdateFW/Module_UpdateFW.c

@@ -225,6 +225,14 @@ bool CreateBufferForLcmFile(char *file)
 
 	return result;
 }
+
+unsigned long long getAvailableMemory()
+{
+    long pages = sysconf(_SC_AVPHYS_PAGES);
+    long page_size = sysconf(_SC_PAGE_SIZE);
+    return pages * page_size;
+}
+
 static int CheckUpdateProcess(void)
 {
     //bool isPass = true;
@@ -246,6 +254,13 @@ static int CheckUpdateProcess(void)
     struct ChargingInfoData *pDcChargingInfo = NULL;
     
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
+
+    if (getAvailableMemory() < (200 * 1024 * 1024))
+    {
+        log_info("Available memory (%.2f Bytes) less than 200 MBytes, free cache first.\n", getAvailableMemory() / (1024 * 1024.0));
+        system("echo 3 > /proc/sys/vm/drop_caches");
+    }
+
     d = opendir("/mnt/");
     if (d) {
         log_info("Open /mnt success");
@@ -284,7 +299,7 @@ static int CheckUpdateProcess(void)
                         ((unsigned int)ptr[18]) << 8  |
                         ((unsigned int)ptr[19]));
                 log_info("Typed...%x ", Type);
-
+                free(ptr);
                 switch (Type) {
                 case 0x10000001:
                 case 0x10000002:
@@ -456,9 +471,12 @@ static int CheckUpdateProcess(void)
                     }
                     break;
                 }
+            } else { 
+                free(ptr);
             }
+
             free(new_str);
-            free(ptr);
+
         }
     }
     free(dir);

+ 26 - 1
EVSE/Projects/DD360Tcci/Apps/ReadCmdline.c

@@ -336,7 +336,20 @@ void GetFwVerProc(void)
                      "      ac\n"
                      "      exit | c | C\n"
                      "      help | ? | h\n";
-
+    printf("ModelName = %s\r\n", pSysConfig->ModelName);
+    printf("DC Main Version = %s \n", pSysInfo->CsuRootFsFwRev);
+    printf("DC Main Debug Version = %s \n", ShmDcCommonData->DebugVersion);
+    printf("407 FW Version = %s\n", ShmPrimaryMcuData->version);
+    printf("Gun 0 FW Version = %s \n", pSysInfo->Connector1FwRev);
+    printf("Gun 1 FW Version = %s \n", pSysInfo->Connector2FwRev);
+    printf("Relay Board Version = %s \n", pSysInfo->RelayModuleFwRev);
+    printf("FAN Version = %s \n", pSysInfo->FanModuleFwRev);
+    printf("LED Version = %s \n", pSysInfo->LedModuleFwRev);
+    printf("Dispenser Network Information checked: IP = % s Netmask = % s, Gateway = % s \n",
+        pSysConfig->Eth0Interface.EthIpAddress,
+        pSysConfig->Eth0Interface.EthSubmaskAddress,
+        pSysConfig->Eth0Interface.EthGatewayAddress);
+    /*
     while (isContinue) {
         if (readCmdKey(CMD_KEY_WAIT) == NO) {
             continue;
@@ -381,6 +394,7 @@ void GetFwVerProc(void)
         }
 
     }//while
+    */
 }
 
 void CreateOneError(char *v1)
@@ -527,6 +541,14 @@ void writeChillerStatus(char* v1)
     else
         printf("Please open Debug mode\n");
 }
+void writeBackLight(char* v1)
+{
+    uint8_t light = atoi(v1);
+    if (light >= 0 && light <= 0x64) {
+        ShmDcCommonData->BackLight = light;
+    } else
+        printf("Error para.");
+}
 void writeTccdev()
 {
     ShmDcCommonData->tccdev = !ShmDcCommonData->tccdev;
@@ -1310,6 +1332,7 @@ int main(void)
                      "       tccdev                            : print TCC dev QR Code\n"
                      "       lcmtest                           : Only For LCM Demo\n"
                      "       billtest                          : Rededuct Transcation id amount\n"
+                     "       backlight                         : Change Lcm Backlight\n"
                      "\r\n";
 
     if (CreateAllCsuShareMemory() == FAIL) {
@@ -1507,6 +1530,8 @@ int main(void)
                 continue;
             }
             setbilltest(newString[1], newString[2]);
+        } else if (strcmp(newString[0], "backlight") == 0) { //測試槍頭和水冷機溫度
+            writeBackLight(newString[1]);
         } else {
             printf("%s\n", usageMsg);
         }

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


BIN
EVSE/Projects/DD360Tcci/output/FactoryConfig


BIN
EVSE/Projects/DD360Tcci/output/Module_ChkSysTask


BIN
EVSE/Projects/DD360Tcci/output/Module_DoComm


BIN
EVSE/Projects/DD360Tcci/output/Module_EvComm


BIN
EVSE/Projects/DD360Tcci/output/Module_EventLogging


BIN
EVSE/Projects/DD360Tcci/output/Module_InternalComm


BIN
EVSE/Projects/DD360Tcci/output/Module_LcmControl


BIN
EVSE/Projects/DD360Tcci/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360Tcci/output/Module_UpdateFW


BIN
EVSE/Projects/DD360Tcci/output/ReadCmdline


BIN
EVSE/Projects/DD360Tcci/output/main