Browse Source

2022-04-15 / Simon Xue

Action:
1. [Modify] Credit Card response time.
2. [Bug] Complete show wrong gun.
3. [Modify] CCS Gun plugout need continue 3 sec.

Files
As the following commit history files

Image Version: V2.10.XX.XXXX.XX
Simon Xue 2 years ago
parent
commit
03148f044b

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

@@ -287,6 +287,9 @@ void AuthorizeToCharge()
 
         } else {
             log_info("LCM => Authorize fail");
+            ShmDcCommonData->TradeCancel = TRUE;
+            ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
+            ShmDcCommonData->PreAuth_Result = 0;
             pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
             strcpy((char *)pSysConfig->UserId, "");
         }
@@ -304,8 +307,7 @@ void ScannerCardProcess(void)
     if (!isDetectPlugin() && (pSysInfo->SystemPage == _PAGE_SENSING ||
     		pSysInfo->SystemPage == _PAGE_AUTHORIZE ) &&
     		pDcChargingInfo->SystemStatus == S_IDLE &&
-            pSysWarning->Level != WARN_LV_ER /*&&
-            pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE*/) {
+            pSysWarning->Level != WARN_LV_ER ) {
     	//setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
         isCardScan = true;
         // 處理刷卡及驗證卡號的動作
@@ -352,7 +354,7 @@ void PreAuthCompleteToCardReader(int fd,uint8_t gunIndex)
         ShmDcCommonData->TransactionInfo[gunIndex].Amount = 1;
     }
     storePayResult(gunIndex);
-
+    log_info("Start Auth Complete");
 	result = CreditCardPreAuthComplete(fd,(int)ShmDcCommonData->TransactionInfo[gunIndex].Amount, &pSysConfig->ModelName[0],
 											&ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard.VemData[0],
 											&ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard);
@@ -408,11 +410,12 @@ void ReDeductProcess(int fd)
     int rededuct_num = 0;
     rededuct_num = DB_GetMultiReDeductInfo(&rededuct_gunIndex[0], &deductInfo[0]);
 
-    if (rededuct_num == 0)
-        log_info("No Rededuct Information");
-    else {
+    if (rededuct_num == 0) {
+        //log_info("No Rededuct Information");
+    } else {
         log_info("Rededuct Total Number:%d", rededuct_num);
         for (j = 0; j < rededuct_num; j++) {
+            sleep(10);
             if (pSysInfo->SystemPage != _PAGE_IDLE && !ShmDcCommonData->Exe_ReDeduct) {
                 ShmDcCommonData->RoutineReduct = FALSE;
                 break;
@@ -441,7 +444,6 @@ void ReDeductProcess(int fd)
                 result = CreditCardPreAuthComplete(fd, (int)deductInfo[j].Amount, &pSysConfig->ModelName[0],
                     &deductInfo[j].pCreditCard.VemData[0],
                     &ShmDcCommonData->TransactionInfo[0].pCreditCard);
-                sleep(7);
                 if (result > 0) {
                     deductInfo[j].DeductResult = _DEDUCT_COMPLETE_PASS;
                     log_info("Backgroud PreAuthComplete OK");
@@ -538,7 +540,7 @@ void CreateRfidFork(void)
             is_idle = TRUE;
 			for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
 				pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
-				if (pDcChargingInfo->SystemStatus != S_IDLE) {
+				if (pDcChargingInfo->SystemStatus != S_IDLE && pDcChargingInfo->SystemStatus != S_FAULT ) {
 					is_idle = FALSE;
 				}
                 if (ShmDcCommonData->StopCharge[gunIndex] == TRUE && pDcChargingInfo->Replug_flag == TRUE) {
@@ -628,7 +630,11 @@ void CreateRfidFork(void)
             }
 
             // 每日晚上11點進行補扣款
-            if ((is_idle == TRUE && (tm->tm_hour == 15 && tm->tm_min < 30) &&
+            if (tm->tm_min %5 == 0 && tm->tm_sec == 0) {
+                ShmDcCommonData->RoutineReduct = FALSE;
+            }
+
+            if ((is_idle == TRUE &&
                 pSysInfo->SystemPage == _PAGE_IDLE &&
                 ShmDcCommonData->RoutineReduct == FALSE) || ShmDcCommonData->Exe_ReDeduct) {
                 ReDeductProcess(fd);

+ 2 - 2
EVSE/Projects/DD360Tcci/Apps/CSU/SelfTest.c

@@ -74,7 +74,7 @@ void SelfTestRun(void)
         case _STEST_VERSION:
             if(isRelayBypass == YES && ShmRelayModuleData->SelfTest_Comp != YES)
             {
-                //log_info("Relay Board Bypass");
+                log_info("Relay Board Bypass");
                 ShmRelayModuleData->SelfTest_Comp = YES;
             }
             if ((strlen((char *)pSysInfo->RelayModuleFwRev) != 0 ||
@@ -101,7 +101,7 @@ void SelfTestRun(void)
                     ShmPrimaryMcuData->version[0] != '\0') &&
                     (ShmPrimaryMcuData->SelfTest_Comp != YES)
                ) {
-                //log_info("Primary FW Rev = %s", pSysInfo->CsuPrimFwRev);
+                log_info("Primary Board Pass");
                 ShmPrimaryMcuData->SelfTest_Comp = YES;
             }
 

+ 38 - 61
EVSE/Projects/DD360Tcci/Apps/CSU/main.c

@@ -178,7 +178,7 @@ void destroySelGun(uint8_t curGun)
     if ((curGun == LEFT_GUN_NUM) && (ShmSelectGunInfo->SelGunInfo.LeftGun != SEL_GUN_RELEASE)) {
         if (ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM ||
                 ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_ATHOR) {
-            changeLcmPage(_PAGE_SELECT_GUN);
+            //changeLcmPage(_PAGE_SELECT_GUN);
         }
         ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_RELEASE;
         StopGunInfoTimeoutDet(LEFT_GUN_NUM);
@@ -197,7 +197,7 @@ void destroySelGun(uint8_t curGun)
     if ((curGun == RIGHT_GUN_NUM) && (ShmSelectGunInfo->SelGunInfo.RightGun != SEL_GUN_RELEASE)) {
         if (ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM ||
                 ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_ATHOR) {
-            changeLcmPage(_PAGE_SELECT_GUN);
+            //changeLcmPage(_PAGE_SELECT_GUN);
         }
         ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_RELEASE;
         StopGunInfoTimeoutDet(RIGHT_GUN_NUM);
@@ -2554,27 +2554,11 @@ void CreateTimeoutFork(void)
                 }
                 break;
             case Timeout_VerifyFail:
-
                 if (GetClockTimeoutValue(pSysInfo->SystemTimeoutTimer) / uSEC_VAL >= AUTHORIZE_FAIL_TIMEOUT) {
                     log_info("Timeout_VerifyFail");
-                    /*if (pSysInfo->SystemPage ==_LCM_START_AUTHORIZE_FAIL ) {
-                        StopSystemTimeoutDet();
-                        _AutoReturnTimeout();
-                        //destroySelGun(pSysInfo->CurGunSelected);
-
-                        if (ShmSelectGunInfo->AuthorStateFromCabinet[pSysInfo->CurGunSelected] == YES) { //DoComm no ask cabinet balance
-                            ShmSelectGunInfo->AuthorStateFromCabinet[pSysInfo->CurGunSelected] = NO;
-                            pAlarmCode->AlarmEvents.bits.DisconnectedFromDo = ABNORMAL;
-                            log_error("Author timeout restart DoComm");
-                            system("killall Module_DoComm");
-                            //sleep(1);
-                            //system("/root/Module_DoComm &");
-                        }
-                    } else*/ if (pSysInfo->SystemPage ==_PAGE_AUTHORIZE_FAIL ) {
-                        StopSystemTimeoutDet();
-                        pSysInfo->SystemPage = _PAGE_SELECT_GUN;
-                        setChargerMode(pSysInfo->CurGunSelected, S_IDLE);
-                    }
+                    StopSystemTimeoutDet();
+                    pSysInfo->SystemPage = _PAGE_SELECT_GUN;
+                    setChargerMode(pSysInfo->CurGunSelected, S_IDLE);
                 }
                 break;
                 /*
@@ -2739,7 +2723,8 @@ void CreateTimeoutFork(void)
                         setChargerMode(gunIndex, MODE_IDLE);
                         destroySelGun(gunIndex); //Jerry add
                         StopGunInfoTimeoutDet(gunIndex);
-                        systemPageRestoreInit();
+                        if (pSysInfo->CurGunSelected == gunIndex)
+                            systemPageRestoreInit();
                     }
                     break;
                 case Timeout_FinalCost:
@@ -2771,22 +2756,6 @@ void CreateTimeoutFork(void)
                         StartGunInfoTimeoutDet(gunIndex, Timeout_PlugOutGun);
                     }
                     break;
-                    /*
-                case Timeout_SelectGun: //Jerry add 
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= SEL_GUN_TIMEOUT) {
-                        log_info("Timeout_SelectGun");
-                        StopGunInfoTimeoutDet(gunIndex);
-                        destroySelGun(gunIndex); //jerry add
-                    }
-                    break;
-                    */
-                    /*
-                case Timeout_DetailView:
-                    if (GetTimeoutValue(pDcChargingInfo->TimeoutTimer) / uSEC_VAL >= DETAILVIEW_TIMEOUT) {
-                        StopGunInfoTimeoutDet(gunIndex);
-                        pSysInfo->SystemPage = _LCM_VIEW;
-                    }
-                    break;*/
                 }
             }
             sleep(1);
@@ -3937,6 +3906,7 @@ void ResetIdleData(uint8_t gunIndex)
     ShmDcCommonData->is_AutoStart[gunIndex] = FALSE;
     ShmDcCommonData->is_exit[gunIndex] = FALSE;
     ShmDcCommonData->StopCharge[gunIndex] = FALSE;
+    ShmDcCommonData->is_plugout[gunIndex] = FALSE;
 
     ShmSelectGunInfo->PricesInfo[gunIndex].Balance = FAIL_BALANCE_PRICES;
     destroySelGun(gunIndex);
@@ -3946,7 +3916,8 @@ void ResetIdleData(uint8_t gunIndex)
     }
     //strcpy((char *)ShmOCPP16Data->StatusNotification[gunIndex].VendorErrorCode, "");
     ReleaseAlarmCode(gunIndex);
-    if (pSysInfo->SystemPage != _PAGE_SELECT_GUN && pSysInfo->SystemPage != _PAGE_SELECT_PAY)
+    if (pSysInfo->SystemPage != _PAGE_SELECT_GUN && pSysInfo->SystemPage != _PAGE_SELECT_PAY &&
+        pSysInfo->CurGunSelected == gunIndex)
     	pSysInfo->SystemPage = _PAGE_IDLE;
 }
 void CheckErrorCode(uint8_t gunIndex)
@@ -4021,7 +3992,6 @@ int main(void)
     bool isModelNameMatch = true;
     uint8_t _ocppProfileChkFlag;
     uint8_t gunIndex = 0;
-    uint8_t cancelcount = 0;
 
     if (CreateAllCsuShareMemory() == FAIL) {
         log_error("create share memory error");
@@ -4235,12 +4205,11 @@ int main(void)
 
                 if (pDcChargingInfo->RemoteStartFlag == YES && pDcChargingInfo->IsAvailable) {
 					log_info("-------- IDLE Remote Start(%d) --------", gunIndex);
-					ChangeGunSelectByIndex(gunIndex);
+					//ChangeGunSelectByIndex(gunIndex);
 					setChargerMode(gunIndex, MODE_AUTHORIZING);
 					break;
                 }
                 autoStartCharging(gunIndex);
-                cancelcount = 0;
                 // 讀卡邏輯
                 if (!ShmDcCommonData->TradeCancel)
                     ScannerCardProcess();
@@ -4334,7 +4303,7 @@ CheckStatus:
                 	StartGunInfoTimeoutDet(gunIndex,Timeout_WaitPlug);
                 }
                 if (pSysInfo->SystemPage == _PAGE_PLUGOUT) {
-                	StartSystemTimeoutDet(Timeout_VerifyFail);
+                	StartSystemTimeoutDet(Timeout_PlugOutGun);
                 }
                 if (isDetectPlugin()) {
                     // 卡號驗證成功後,等待充電槍插入充電車
@@ -4345,7 +4314,7 @@ CheckStatus:
                             pDcChargingInfo->RemoteStartFlag = NO;
                             pDcChargingInfo->isRemoteStart = YES; //DS60-120
                             
-                            ChangeGunSelectByIndex(gunIndex);
+                            //ChangeGunSelectByIndex(gunIndex);
                             //AddPlugInTimes(gunIndex);
                             setChargerMode(gunIndex, MODE_REASSIGN_CHECK);
                             strcpy((char *)pDcChargingInfo->StartUserId, "");
@@ -4381,7 +4350,13 @@ CheckStatus:
                     		pSysInfo->SystemPage != _PAGE_AUTHORIZE_FAIL &&
                     		pSysInfo->SystemPage != _PAGE_SENSING) {
                         pSysInfo->SystemPage = _PAGE_PLUGIN;
+                    } else if (!GetIsCardScan() && pSysInfo->SystemPage == _PAGE_IDLE &&
+                        pDcChargingInfo->RemoteStartFlag == YES) {
+                        pSysInfo->CurGunSelected = gunIndex;
                     }
+                } else if (ShmDcCommonData->AuthPass_flag[gunIndex] && pSysInfo->CurGunSelected == gunIndex &&
+                    pSysInfo->SystemPage != _PAGE_AUTHORIZE_FAIL) {
+                    pSysInfo->SystemPage = _PAGE_SENSING;
                 }
                 break;
 
@@ -4657,7 +4632,6 @@ CheckStatus:
                         StopSystemTimeoutDet();
                     if (ShmDcCommonData->is_AutoStart[gunIndex] == TRUE && pSysInfo->CurGunSelected == gunIndex)
                         pSysInfo->SystemPage = _PAGE_COMPLETE;
-                    ShmDcCommonData->StopCharge[gunIndex] = TRUE;
                 }
 
                 //if (pSysInfo->SystemPage == _LCM_ERROR) {
@@ -4668,9 +4642,14 @@ CheckStatus:
                 	pSysInfo->SystemPage = _PAGE_EXIT;
                 	break;
                 }
-                if (pSysInfo->CurGunSelected == gunIndex && pDcChargingInfo->ConnectorPlugIn == NO &&
-                    (pSysInfo->SystemPage != _PAGE_PAYING && pSysInfo->SystemPage != _PAGE_SENSING)) {
-                    StartGunInfoTimeoutDet(gunIndex, Timeout_ExitPage);
+
+                if (pDcChargingInfo->ConnectorPlugIn == NO && 
+                    pSysInfo->SystemPage != _PAGE_PAYING && pSysInfo->SystemPage != _PAGE_SENSING) {
+                    if (pSysInfo->CurGunSelected == gunIndex) {
+                        StartGunInfoTimeoutDet(gunIndex, Timeout_ExitPage);
+                    } else {
+                        StartGunInfoTimeoutDet(gunIndex, Timeout_PlugOutGun);
+                    }
                 }
 
                 if (pSysInfo->CurGunSelected == gunIndex && 
@@ -4716,28 +4695,25 @@ CheckStatus:
 						}
                     }
                 }
-                /*
-                if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_CANCEL && 
-                    ShmDcCommonData->PreAuth_Result != 0 && cancelcount < 30) {
-                    sleep(1);
-                    cancelcount++;
-                    //log_info("Cancel Not Complete yet");
-                    break;
-                }
-                */
+
                 if (pSysWarning->Level == WARN_LV_ER) {
 					pSysInfo->SystemPage = _PAGE_MAINTAIN;
-
 					continue;
 				}
+
                 if (pSysInfo->CurGunSelected == gunIndex && ShmDcCommonData->is_exit[gunIndex]) {
                     pSysInfo->SystemPage = _PAGE_EXIT;
                     break;
                 }
+                
 
-                if (pSysInfo->CurGunSelected == gunIndex && pDcChargingInfo->ConnectorPlugIn == NO &&
-                    (pSysInfo->SystemPage != _PAGE_PAYING && pSysInfo->SystemPage != _PAGE_SENSING)) {
-                    StartGunInfoTimeoutDet(gunIndex, Timeout_ExitPage);
+                if (pDcChargingInfo->ConnectorPlugIn == NO &&
+                    pSysInfo->SystemPage != _PAGE_PAYING && pSysInfo->SystemPage != _PAGE_SENSING) {
+                    if (pSysInfo->CurGunSelected == gunIndex) {
+                        StartGunInfoTimeoutDet(gunIndex, Timeout_ExitPage);
+                    } else {
+                        StartGunInfoTimeoutDet(gunIndex, Timeout_PlugOutGun);
+                    }
                 }
 
                 if (pSysInfo->CurGunSelected == gunIndex && pSysInfo->SystemPage != _PAGE_PAYING ) {
@@ -4750,6 +4726,7 @@ CheckStatus:
 							pSysInfo->SystemPage = _PAGE_PAYFAIL;
                 	}
 				}
+
                 break;
             case S_MAINTAIN:
                 if (isModeChange(gunIndex)) {

+ 1 - 0
EVSE/Projects/DD360Tcci/Apps/CSU/main.h

@@ -54,6 +54,7 @@
 #define TCC_SCANCARD_TIMEOUT					(30)
 #define TCC_TRADECANCEL_TIMEOUT                 (60)
 #define TCC_EXITPAGE_TIMEOUT                    (10)
+#define TCC_ISPLUGOUT_TIMEOUT                   (3)
 
 //#define log_info(format, args...) StoreLogMsg_1("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 //#define log_warn(format, args...) StoreLogMsg_1("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)

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

@@ -507,6 +507,7 @@ typedef struct StDcCommonInfo {
     int is_exit[2];
     time_t EVDisconnectTime[2];
     int EVDisconnectFlag[2];
+    int is_plugout[2];
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 1 - 2
EVSE/Projects/DD360Tcci/Apps/DataBase/DataBase.c

@@ -663,7 +663,7 @@ int DB_GetMultiDeductInfo(int deductResult, int uploadState, int *gunIndex, Reco
     }
     else if(deductResult >= 0 && uploadState < 0)
     {
-        sprintf(sqlStr, "select * from report_credit_deduct where isDeductResult IN (0,3) AND RedeductTime < 3;");
+        sprintf(sqlStr, "select * from report_credit_deduct where isDeductResult IN (0,3) AND RedeductTime < 10;");
     }
     else if(deductResult < 0 && uploadState >= 0)
     {
@@ -705,7 +705,6 @@ int DB_GetMultiDeductInfo(int deductResult, int uploadState, int *gunIndex, Reco
                 // 15: LineSN
                 deductInfo[idxRow - 1].Energy = atof(rs[(idxRow * cols) + 16]);
                 deductInfo[idxRow - 1].RedeductTime = atoi(rs[(idxRow * cols) + 17]);
-                log_info("Retry time:%d", deductInfo[idxRow - 1].RedeductTime);
                 if(idxRow >= 128)
                 {
                 	rows = 128;

+ 24 - 26
EVSE/Projects/DD360Tcci/Apps/Define/define.h

@@ -187,6 +187,7 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
 #define ShmOcpp20ModuleKey		1012
 #define ShmRelay2BdKey			1013
 #define ShmYesCustomKey         1014
+#define ShmOcppPHModuleKey		1015
 
 #define FaultCodeLength         5
 #define AlarmCodeLength         20
@@ -327,6 +328,10 @@ enum CoreProfile {
      MaintainServer,
      StatusNotificationPeriodically,
      StatusNotificationInterval,
+	 PreAuthAmount,
+	 isEnableLocalPowerSharing,
+	 PowerSharingServerIP,
+	 EVCCID_PREFIX,
      ConfigurationVersion,
 	 _CoreProfile_CNT
 };
@@ -340,10 +345,11 @@ enum OCPP_START_ID_TYPE {
     IdTokenType_Central=0,
     IdTokenType_eMAID,
     IdTokenType_ISO14443,
+	IdTokenType_ISO15693,
     IdTokenType_KeyCode,
     IdTokenType_Local,
-    IdTokenType_NoAuthorization,
-    IdTokenType_ISO15693
+	IdTokenType_MacAddress,
+    IdTokenType_NoAuthorization
 };
 /**************************************************************************************/
 /****structure SysConfigData => shall store the data to NAND flash****************/
@@ -460,7 +466,7 @@ struct TTIA
 
 struct LocalSharingInfo
 {
-    unsigned short      AvailableShargingCurrent;       // 0 ~ rating value amp,  Synchronize from local sharing server
+    unsigned short      AvailableShargingCurrent[4];    // 0 ~ rating value amp,  Synchronize from local sharing server
     unsigned char       isConnectedSharingServer:1;     // 0: Disconnected, 1: Connected
 };
 
@@ -571,7 +577,7 @@ struct SysConfigData
 	struct LED				LedInfo;					// LED configuration info
 	unsigned char			ShowInformation;
 	unsigned char           isReqFirstUpgrade;          //EVSE is request first upgrade from PH server
-	unsigned char           isEnableLocalPowerSharging; //0: Disable power sharing  1: Enable power sharing
+	unsigned char           isEnableLocalPowerSharing; //0: Disable power sharing  1: Master	2: Slave
 	unsigned char           StopChargingByButton;       //0: Disable  1: Enable
     struct LCD_NOUSE        Legacy_LcdOveride;          // LCD override info (no use anymore)
     struct TTIA             TTIA_Info;                  // TTIA configuration struct
@@ -584,6 +590,7 @@ struct SysConfigData
     unsigned char           MaintainServerURL[512];             // ws: non-secure OCPP 1.6-J, wss: secure OCPP 1.6-J"
     unsigned char           MaintainServerSecurityProfile;      // Maintain server security profile 0~3
     unsigned char           MaintainServerSecurityPassword[41]; // Maintain server AuthorizationKey for security profile
+    unsigned char			PowerSharingServerIP[512];			// Local power sharing server ip address
 };
 
 struct ChargingInfoData
@@ -623,7 +630,7 @@ struct ChargingInfoData
 	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, back-end, BLE.
-	unsigned char           StartIdType;                // 0: Central   1: eMAID    2: ISO14443 3: ISO15693 4: KeyCode  5: Local    6: MaxAddress   7: NoAuthorization
+	unsigned char           StartIdType;                // 0: Central   1: eMAID    2: ISO14443 3: ISO15693 4: KeyCode  5: Local    6: MacAddress   7: NoAuthorization
 	unsigned char			StartDateTime[32];			// Charging cycle start date time
 	unsigned char			StopDateTime[32];			// Charging cycle stop date time
 	unsigned char			StartMethod;
@@ -718,16 +725,7 @@ typedef union
         unsigned int FirmwareUpdateRequest:1;           // firmware update request
         unsigned int FirmwareUpdateConfirm:1;           // firmware update start
         unsigned int FirmwareUpdateCompleted:1;         // firmware update completed
-        unsigned int BackendStatusRequest:1;            // 0: no request,   1: backend connection status has changed            ( cabinet -> dispenser)
-        unsigned int EthernetStatusRequest:1;           // 0: no request,   1: ethernet connection status has changed           ( cabinet -> dispenser)
-        unsigned int WiFiStatusRequest:1;               // 0: no request,   1: wifi connection status has changed               ( cabinet -> dispenser)
-        unsigned int TelcomModemStatusRequest:1;        // 0: no request,   1: 4g connection status has changed                 ( cabinet -> dispenser)
-        unsigned int BillingStatusRequest:1;            // 0: no request,   1: billing status has changed                       ( cabinet -> dispenser)
-        unsigned int StopButtonStatusRequest:1;         // 0: no request,   1: stop charging button status has changed          ( cabinet -> dispenser)
-        unsigned int AuthModeConfigRequest:1;           // 0: no request,   1: AuthMode Config has changed                      ( cabinet -> dispenser)
-        unsigned int EVCCIDConfigRequest:1;             // 0: no request,   1: EVCCID Config has changed                        ( cabinet -> dispenser)
-        unsigned int LEDIntensityRequest:1;             // 0: no request,   1: LED Intensity has changed                        ( cabinet -> dispenser)
-        unsigned int res:12;
+        unsigned int res:21;
     }bits;
 }DispenserSettingFlag;
 
@@ -744,7 +742,7 @@ struct DispenserModule
     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   isRFID;                     //for AuthorisationMode=0; 0:false, 1:true; for Noodoe Credit Card +2^1:true
     unsigned char   QRCodeMadeMode;             //for isQRCode=1 ; 0: default	1:customized
     unsigned char   QRCodeContent[128];         //for QRCodeMadeMode=1
 
@@ -837,7 +835,7 @@ typedef union
         unsigned int  Disconnection:1;
         unsigned int  GfdDetection:1;                   // 0: stop,         1: start
         unsigned int  GetStartChargingSoc:1;            // 0: no effect,    1: get start soc
-        unsigned int  res:14;
+        unsigned int  res:13;
     }bits;
 }ConnectorParameter;
 
@@ -1509,7 +1507,7 @@ struct AlarmCodeData
             unsigned char PsuDcDcOtp:1;                             //bit 2
             unsigned char PsuDcDcOvp:1;                             //bit 3
             unsigned char :4;                                       //reserved bit 4 ~ bit 7
-    //AlarmVal[17]
+            //AlarmVal[17]
             unsigned char :8;                                       //reserved bit 0 ~ bit 7
             //AlarmVal[18]
             unsigned char MeterIcCommTimeout:1;                     //bit 0
@@ -2300,7 +2298,7 @@ struct PsuData
 	unsigned char           GroupCount;
 	unsigned char           Work_Step;
 	struct PsuModuleVer     PsuVersion[MAX_PSU_QUANTITY];
-	unsigned char 			PsuStopChargeFlag;
+	unsigned char           PsuStopChargeFlag;
 };
 
 /************************************************************************************/
@@ -4418,7 +4416,7 @@ struct OCPP16ConfigurationTable
 struct StrcutSetUserPrice
 {
     unsigned char   idToken[21];
-    unsigned char   price[256];
+    unsigned char   price[1024];
 };
 
 struct ChargingPrice
@@ -4462,13 +4460,13 @@ struct StrcutRunningCost
     struct IdlePrice        idlePrice;              // (optional) Price components while not charging. Optional if no idle fee is charged.
     struct NextPeriod       nextPeriod;             // (optional) Pricing for next period
     struct Triggers         triggerMeterValue;      // (optional) Triggers to request a new meter value. Optional if no idle fee charged.
-    unsigned char           description[256];       // Compatible California pricing V1.0
+    unsigned char           description[1024];       // Compatible California pricing V1.0
 };
 
 struct StrcutFinalCost
 {
     int             txId;
-    unsigned char   description[256];
+    unsigned char   description[1024];
 };
 
 struct StructCost
@@ -4617,8 +4615,8 @@ struct StructCreditDeductResult
 
 struct StructReaderStatus
 {
-	int readerStatus;
-	unsigned char creditNo[64];
+    int readerStatus;
+    unsigned char creditNo[64];
     unsigned char ReportReaderStatusReq:1;
 };
 
@@ -4630,7 +4628,7 @@ struct StructTcciCustomData
     struct StructReaderStatus ReaderStatus[CONNECTOR_QUANTITY];
     unsigned char TriggerReaderReq[3];
     unsigned char SerialNo[CONNECTOR_QUANTITY][37];
-	unsigned char VEMData[CONNECTOR_QUANTITY][65];
+    unsigned char VEMData[CONNECTOR_QUANTITY][65];
 
     unsigned char ReportCreditDeductReq:1;
     unsigned char ChargerInfoReq:1;
@@ -5144,7 +5142,7 @@ struct ChargingScheduleType
 
 struct ChargingProfileType
 {
-	unsigned short int id;											// Required. Id of ChargingProfile.
+	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.

+ 39 - 4
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.c

@@ -157,6 +157,23 @@ static int string2ByteArray(char *input, uint8_t *output)
     return loop + 1;
 }
 
+int string2Date(char* input, uint8_t* output)
+{
+    int loop = 0;
+    int i = 0;
+
+    while (input[loop] != '\0') {
+        loop++;
+    }
+    loop++;
+
+    while (input[loop] != '\0') {
+        output[i++] = input[loop++];
+    }
+    output[loop] = '\0';
+
+    return loop + 1;
+}
 static void unixSocketSigPipeHandle(int sig)
 {
     log_error("socket packet error %x", sig);
@@ -427,7 +444,15 @@ static void clearMiscCommand(void)
 {
     gDoCommGblData.MiscCmd = 0;
 }
-
+int timecmp(uint8_t* time1, uint8_t* time2)
+{
+    for (int i = 0; i < strlen(time1); i++) {
+        if (time1[i] != time2[i]) {
+            return FALSE;
+        }
+    }
+    return TRUE;
+}
 static int qrCodeUrlInfoHandle(uint8_t *data)
 {
     //int len = 0;
@@ -436,7 +461,8 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     uint16_t timeLen = 0;
     struct timeb SeqEndTime;
     struct tm *tm;
-
+    char _setTime[50];
+    uint8_t cmdBuf[128];
     if ((char *)&data[0] == '\0') {
         log_error("QR code date error");
         return FAIL;
@@ -460,8 +486,16 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
         //len =
 
         string2ByteArray((char *)data, (uint8_t *)pSysConfig->SystemId);
+        string2Date((char*)data, (uint8_t*)_setTime);
         //printf("SystemId =  %s", pSysConfig->SystemId);
-        //log_info("SystemId:%s",pSysConfig->SystemId);
+        if (!timecmp(localTime, _setTime)) {
+            log_info("Set Timer:%s", _setTime);
+            sprintf((char*)cmdBuf, "date -u -s \"%s\" >> /dev/null &", _setTime);
+            system((char*)cmdBuf);
+            system("hwclock -w -u");
+            system("hwclock -s");
+        }
+        
     }
     sprintf(ShmDcCommonData->PresentTime, "%04d/%02d/%02d",
                       tm->tm_year + 1900,
@@ -729,7 +763,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 pSysInfo->CurGunSelectedByAc = NO_DEFINE;
             }
 #else
-            pSysInfo->CurGunSelected = (plugNum);
+            //pSysInfo->CurGunSelected = (plugNum);
             pSysInfo->CurGunSelectedByAc = NO_DEFINE;
 #endif //DD360Audi
             setConfirmSelGun(pSysInfo->CurGunSelected);
@@ -2807,6 +2841,7 @@ int main(int argc, char *argv[])
 
 
         if (pSysConfig->Eth0Interface.EthDhcpClient == 0) {
+            system("pgrep -f \"udhcpc -i eth0\" | xargs kill");
             sprintf(tmpbuf,
                     "/sbin/udhcpc -i eth0 -x hostname:CSU3_%s -s /root/dhcp_script/eth0.script > /dev/null &",
                     pSysConfig->SystemId);

+ 24 - 3
EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -303,6 +303,7 @@ void CANReceiver(int fd)
         uint8_t lastConnTemp[2] = {0, 0};
         struct can_frame frame;
         ChillerTemp chiilerTemp = {0};
+        time_t CCS_PlugoutTimer[2] = { 0 };
         struct ChargingInfoData *pDcChargingInfo = NULL;
 
         pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
@@ -318,13 +319,18 @@ void CANReceiver(int fd)
         ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();
 
         //log_info("Module_EvRXComm Child's PID is %d", getpid());
+        CCS_PlugoutTimer[0] = time((time_t*)NULL);
+        CCS_PlugoutTimer[1] = time((time_t*)NULL);
 
         while (isContinue) {
             memset(&frame, 0, sizeof(struct can_frame));
 
             for (_index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
+                pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(_index);
                 // 檢查是否有收到EV小板訊號
-                if ((time((time_t*)NULL) - ShmDcCommonData->EVDisconnectTime[_index]) > 3 && !ShmDcCommonData->EVDisconnectFlag[_index]) {
+                if ((time((time_t*)NULL) - ShmDcCommonData->EVDisconnectTime[_index]) > 3 &&
+                    !ShmDcCommonData->EVDisconnectFlag[_index] &&
+                    pDcChargingInfo->SystemStatus != S_UPDATE) {
                     ShmDcCommonData->EVDisconnectTime[_index] = time((time_t*)NULL);
                     ShmDcCommonData->EVDisconnectFlag[_index] = TRUE;
                     log_info("Not Get EV Board %d data in 3 sec.", _index);
@@ -402,7 +408,8 @@ void CANReceiver(int fd)
                             pSysInfo->CurGunSelected = targetGun;
 #endif                        
                     } else if (frame.data[0] == UNPLUG) {
-                        log_info("Conn %d, Unplug. ", targetGun);
+                        if (pDcChargingInfo->Type != _Type_CCS_2)
+                            log_info("Conn %d, Unplug. ", targetGun);
                         strcpy( (char *) pDcChargingInfo->EVCCID, "");
                     } else {
                         log_info("Conn %d, None Check. (%d) ", targetGun, frame.data[0]);
@@ -411,7 +418,20 @@ void CANReceiver(int fd)
                         pSysInfo->CurGunSelected = targetGun;
                     }
                 }
-
+                // CCS 小板確認拔除三秒
+                if (pDcChargingInfo->Type == _Type_CCS_2) {
+                    if (frame.data[0] == UNPLUG) {
+                        if ((time((time_t*)NULL) - CCS_PlugoutTimer[targetGun]) > 3) {
+                            if (pDcChargingInfo->ConnectorPlugIn != frame.data[0]) 
+                                log_info("CCS Conn %d, Unplug. ", targetGun);
+                        } else {
+                            frame.data[0] = PLUG;
+                        }
+                    } else {
+                        CCS_PlugoutTimer[targetGun] = time((time_t*)NULL);
+                        frame.data[0] = PLUG;
+                    }
+                }
                 pDcChargingInfo->ConnectorPlugIn = frame.data[0];
                 pDcChargingInfo->PilotVoltage = frame.data[1];
 
@@ -488,6 +508,7 @@ void CANReceiver(int fd)
 
                     if (frame.data[1] > pDcChargingInfo->EvBatterySoc) {
                         pDcChargingInfo->EvBatterySoc = frame.data[1];
+                        log_info("Gun%d SOC:%d", targetGun,pDcChargingInfo->EvBatterySoc);
                     }
                 }
                 //pDcChargingInfo->EvBatterySoc = frame.data[1]; //DS60-120 remove

+ 7 - 5
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -359,7 +359,6 @@ void CheckReturnPress()
         ShmDcCommonData->PreAuth_Result = 0;
         ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = FALSE;
         
-        log_info("Sensing Card vemdata:'%s need to cancel", ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].pCreditCard.VemData);
         if (strcmp(ShmDcCommonData->TransactionInfo[pSysInfo->CurGunSelected].pCreditCard.VemData, "") != 0) {
             ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
             ShmDcCommonData->PreAuth_Result = 0;
@@ -431,7 +430,7 @@ void CheckStopConfirmPress()
 	pDcChargingInfo->SystemStatus = S_TERMINATING;
 	pSysInfo->SystemPage = _PAGE_PAYING;
 	is_stop = FALSE;
-	ShmDcCommonData->StopCharge[pSysInfo->CurGunSelected] = TRUE;
+	//ShmDcCommonData->StopCharge[pSysInfo->CurGunSelected] = TRUE;
     if (ShmDcCommonData->is_AutoStart[pSysInfo->CurGunSelected] == TRUE) {
         pSysInfo->SystemPage = _PAGE_COMPLETE;
         return;
@@ -476,11 +475,14 @@ void CheckPayCreditCard()
     ShmDcCommonData->LineStatus[pSysInfo->CurGunSelected] = 0;
     ShmDcCommonData->TradeCancel = FALSE;
    	pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+
 	if (pDcChargingInfo->SystemStatus == S_IDLE && pSysInfo->SystemPage == _PAGE_SELECT_PAY &&
         ShmDcCommonData->PreAuth_Config == _CREDITCARD_IDLE) {
         ShmDcCommonData->PreAuth_Config = _CREDITCARD_PREAUTH;
         ShmDcCommonData->PreAuth_Result = 0;
 		pSysInfo->SystemPage = _PAGE_AUTHORIZE;
+        log_info("Press Credit card pay status:%d Page:%d Config:%d", pDcChargingInfo->SystemStatus,
+            pSysInfo->SystemPage, ShmDcCommonData->PreAuth_Config);
 	}
 }
 void CheckPayIcash()
@@ -657,7 +659,7 @@ void CheckLCMPressed()
             usleep(5000);
         } //while
     } // if pid
-    log_info("Create LCM fork:%d",Pid);
+    log_info("Create LCM fork:%d\n\n",Pid);
 }
 
 
@@ -939,7 +941,7 @@ void ShowSelectGun()
 {
 	pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(LEFT_GUN_NUM);
     if ((pDcChargingInfo->SystemStatus >= S_AUTHORIZING &&
-        pDcChargingInfo->SystemStatus <= S_CHARGING) ||
+        pDcChargingInfo->SystemStatus <= S_COMPLETE) ||
         pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST0 ||
         pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST1) {
 		if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||
@@ -968,7 +970,7 @@ void ShowSelectGun()
 	}
 	pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(RIGHT_GUN_NUM);
     if ((pDcChargingInfo->SystemStatus >= S_AUTHORIZING &&
-        pDcChargingInfo->SystemStatus <= S_CHARGING) ||
+        pDcChargingInfo->SystemStatus <= S_COMPLETE) ||
         pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST0 ||
         pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST1) {
 		if (pDcChargingInfo->CCSGunType == _TYPE_CCS1_Liquid ||

+ 1 - 0
EVSE/Projects/DD360Tcci/Apps/timeout.h

@@ -61,6 +61,7 @@ enum Timeout_flag {
 	Timeout_FinalCost			   = 24,
 	Timeout_ScanCard			   = 25,
     Timeout_ExitPage               = 26,
+    Timeout_isPlugout              = 27,
     Timeout_TradeCancel            = 28,
 };
 

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