Prechádzať zdrojové kódy

2022-01-13 / Simon Xue

Action:
1. finish simple charge flow (Remote Start & Remote stop)

Files
As the commit history

Image Version: v2.00.00.XX.XXXXX.XX
Simon Xue 3 rokov pred
rodič
commit
589cc54a23
43 zmenil súbory, kde vykonal 3652 pridanie a 8836 odobranie
  1. 94 70
      EVSE/Modularization/Module_RFID.c
  2. 2 109
      EVSE/Projects/DD360Tcci/Apps/CSU/Ethernet.c
  3. 65 467
      EVSE/Projects/DD360Tcci/Apps/CSU/Primary.c
  4. 89 108
      EVSE/Projects/DD360Tcci/Apps/CSU/RFID.c
  5. 5 28
      EVSE/Projects/DD360Tcci/Apps/CSU/SelfTest.c
  6. 105 441
      EVSE/Projects/DD360Tcci/Apps/CSU/main.c
  7. 10 8
      EVSE/Projects/DD360Tcci/Apps/CSU/main.h
  8. 71 23
      EVSE/Projects/DD360Tcci/Apps/Config.h
  9. 7 7
      EVSE/Projects/DD360Tcci/Apps/Define/define.c
  10. 71 29
      EVSE/Projects/DD360Tcci/Apps/Define/define.h
  11. 4 8
      EVSE/Projects/DD360Tcci/Apps/Makefile
  12. 0 1
      EVSE/Projects/DD360Tcci/Apps/ModuleChkSysTask/Module_ChkSysTask.c
  13. 1 1
      EVSE/Projects/DD360Tcci/Apps/ModuleChkSysTask/Module_ChkSysTask.h
  14. 336 34
      EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.c
  15. 44 1
      EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.h
  16. 25 21
      EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/Module_EvRxComm.c
  17. 33 32
      EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/Module_EvTxComm.c
  18. 3 3
      EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/AcPlug.c
  19. 2 2
      EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/LEDlight.c
  20. 30 30
      EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/Module_InternalCommOrg.c
  21. 50 42
      EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/RelayBoard.c
  22. 2 2
      EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/internalComm.h
  23. 415 0
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Lcm_Update.c
  24. 331 602
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c
  25. 0 2393
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c.Ph
  26. 0 2339
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c.test
  27. 306 30
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h
  28. 0 34
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h.Ph
  29. 0 234
      EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h.test
  30. 18 217
      EVSE/Projects/DD360Tcci/Apps/ModulePrimary/Module_PrimaryComm.c
  31. 16 12
      EVSE/Projects/DD360Tcci/Apps/ModuleUpdateFW/Module_UpdateFW.c
  32. 1427 1468
      EVSE/Projects/DD360Tcci/Apps/ReadCmdline.c
  33. 1 1
      EVSE/Projects/DD360Tcci/Apps/Readme.md
  34. 2 0
      EVSE/Projects/DD360Tcci/Apps/Script/copy_from_d.sh
  35. 2 0
      EVSE/Projects/DD360Tcci/Apps/Script/copy_to_D.sh
  36. 2 0
      EVSE/Projects/DD360Tcci/Apps/Script/copy_to_d.sh
  37. 4 4
      EVSE/Projects/DD360Tcci/Apps/Script/replaceOtherDD360Project.sh
  38. 26 17
      EVSE/Projects/DD360Tcci/Apps/ShareMemory/shmMem.c
  39. BIN
      EVSE/Projects/DD360Tcci/Apps/UnsafetyOutputTask
  40. 10 6
      EVSE/Projects/DD360Tcci/Apps/simulation.c
  41. 5 5
      EVSE/Projects/DD360Tcci/Apps/timeout.h
  42. 24 7
      EVSE/Projects/define.h
  43. 14 0
      build_rootfs_copy.sh

+ 94 - 70
EVSE/Modularization/Module_RFID.c

@@ -198,6 +198,25 @@ char ClaCheckSum(unsigned char *buffer, int len)
 	return chksum;
 }
 
+int chksumValid(unsigned char * buffer)
+{
+	int result = FAIL;
+	int chksum = 0;
+
+	if(buffer[0] > 2)
+	{
+		for(int idx=0;idx<(buffer[0]);idx++)
+		{
+			chksum ^= buffer[idx];
+		}
+
+		if(chksum == buffer[buffer[0]])
+			result = PASS;
+	}
+
+	return result;
+}
+
 bool getRequestCardSN(int Fd, int moduleType, RFID* rfid)
 {
 	bool isSuccess = false;
@@ -250,15 +269,14 @@ bool ISO14443A_REQUEST_SN(int Fd, int moduleType, unsigned char *data)
 {
 	bool isSuccess = false;
 	int tx_len = 4;
-	unsigned char txByte[tx_len];
-	unsigned char rxByte[254];
-	unsigned char tmp[254];
+	unsigned char txByte[4] 		= {0};
+	unsigned char rxByte[254] 		= {0};
 	
-	unsigned char TX_MESSAGE[254];
-	unsigned char RX_MESSAGE[254];
-	unsigned char TMP_MESSAGE[254];
-	unsigned char TX_LENGTH;
-	unsigned char RX_LENGTH;
+	unsigned char TX_MESSAGE[254] 	= {0};
+	unsigned char RX_MESSAGE[254] 	= {0};
+	unsigned char TMP_MESSAGE[254] 	= {0};
+	unsigned char TX_LENGTH 		= 0;
+	unsigned char RX_LENGTH			= 0;
 
 	switch(moduleType)
 	{
@@ -274,41 +292,42 @@ bool ISO14443A_REQUEST_SN(int Fd, int moduleType, unsigned char *data)
 
 			if(Fd > 0)
 			{
-				memset(rxByte, 0, sizeof (rxByte));
 				if(system_command(Fd, txByte, tx_len, rxByte) > 0)
 				{
-					memset(tmp, 0, sizeof tmp);
-					memcpy(tmp, rxByte, sizeof(rxByte));
-					if(tmp[1] == RFID_CMD_ISO1443A_REQUEST)
+					if(chksumValid(rxByte) == PASS)
 					{
-						if(tmp[0] == 0x09)
+						if((rxByte[1] == RFID_CMD_ISO1443A_REQUEST))
 						{
-							DEBUG_INFO_1("MIFARE CLASSIC.\n");
-
-							cardLength = LENGTH_4;
-							memcpy(data, rxByte+2, cardLength);
-
-							isSuccess = true;
+							if(rxByte[0] == 0x09)
+							{
+								cardLength = LENGTH_4;
+								memcpy(data, rxByte+2, cardLength);
+								DEBUG_INFO_1("MIFARE CLASSIC SN: %02X-%02X-%02X-%02X\n", data[0], data[1], data[2], data[3]);
+								isSuccess = true;
+							}
+							else if(rxByte[0] == 0x0C)
+							{
+								cardLength = LENGTH_7;
+								memcpy(data, rxByte+2, cardLength);
+								DEBUG_INFO_1("MIFARE PLUS SN: %02X-%02X-%02X-%02X-%02X-%02X-%02X\n", data[0], data[1], data[2], data[3], data[4], data[5], data[6]);
+
+								isSuccess = true;
+							}
+							else
+							{}
 						}
-						else if(tmp[0] == 0x0C)
+						else if (rxByte[1] == 0xDF)
 						{
-							DEBUG_INFO_1("MIFARE PLUS.\n");
-
-							cardLength = LENGTH_7;
-							memcpy(data, rxByte+2, cardLength);
-
-							isSuccess = true;
+							cardLength = LENGTH_0;
+							isSuccess = false;
 						}
 						else
 						{}
 					}
-					else if (tmp[1] == 0xDF)
+					else
 					{
-						cardLength = LENGTH_0;
-						isSuccess = false;
+						//DEBUG_ERROR_1("Response check sum mismatch.\n");
 					}
-					else
-					{}
 				}
 				else
 				{}
@@ -394,9 +413,8 @@ bool ISO14443B_REQUEST_SN(int Fd, int moduleType, unsigned char *data)
 	bool isSuccess = false;
 	int cardLength;
 	int tx_len = 5;
-	unsigned char txByte[tx_len];
-	unsigned char rxByte[254];
-	unsigned char tmp[254];
+	unsigned char txByte[5] 	= {0};
+	unsigned char rxByte[254] 	= {0};
 	
 	/*
 	unsigned char TX_MESSAGE[254];
@@ -421,27 +439,30 @@ bool ISO14443B_REQUEST_SN(int Fd, int moduleType, unsigned char *data)
 
 			if(Fd > 0)
 			{
-				memset(rxByte, 0, sizeof (rxByte));
 				if(system_command(Fd, txByte, tx_len, rxByte) > 0)
 				{
-					memset(tmp, 0, sizeof tmp);
-					memcpy(tmp, rxByte, sizeof(rxByte));
-					if(tmp[1] == RFID_CMD_ISO1443B_REQUEST)
+					if(chksumValid(rxByte) == PASS)
 					{
-						DEBUG_INFO_1("ISO14443 TYPE B.\n");
-
-						cardLength = LENGTH_4;
-						memcpy(data, rxByte+3, cardLength);
+						if((rxByte[1] == RFID_CMD_ISO1443B_REQUEST) && (rxByte[0] >= 12))
+						{
+							cardLength = LENGTH_4;
+							memcpy(data, rxByte+3, cardLength);
+							DEBUG_INFO_1("ISO14443-B SN: %02X-%02X-%02X-%02X\n", data[0], data[1], data[2], data[3]);
 
-						isSuccess = true;
+							isSuccess = true;
+						}
+						else if(rxByte[1] == 0x9F)
+						{
+							cardLength = LENGTH_0;
+							isSuccess = false;
+						}
+						else
+						{}
 					}
-					else if(tmp[1] == 0x9F)
+					else
 					{
-						cardLength = LENGTH_0;
-						isSuccess = false;
+						//DEBUG_ERROR_1("Response check sum mismatch.\n");
 					}
-					else
-					{}
 				}
 				else
 				{}
@@ -515,15 +536,14 @@ bool FELICA_REQUEST_SN(int Fd, int moduleType, unsigned char *data)
 	bool isSuccess = false;
 	int cardLength;
 	int tx_len = 9;
-	unsigned char txByte[tx_len];
-	unsigned char rxByte[254];
-	unsigned char tmp[254];
+	unsigned char txByte[9] 		= {0};
+	unsigned char rxByte[254]		= {0};
 	
-	unsigned char TX_MESSAGE[254];
-	unsigned char RX_MESSAGE[254];
-	unsigned char TMP_MESSAGE[254];
-	unsigned char TX_LENGTH;
-	unsigned char RX_LENGTH;
+	unsigned char TX_MESSAGE[254]	= {0};
+	unsigned char RX_MESSAGE[254]	= {0};
+	unsigned char TMP_MESSAGE[254]	= {0};
+	unsigned char TX_LENGTH			= 0;
+	unsigned char RX_LENGTH			= 0;
 
 	switch(moduleType)
 	{
@@ -547,24 +567,28 @@ bool FELICA_REQUEST_SN(int Fd, int moduleType, unsigned char *data)
 				memset(rxByte, 0, sizeof (rxByte));
 				if(system_command(Fd, txByte, tx_len, rxByte) > 0)
 				{
-					memset(tmp, 0, sizeof tmp);
-					memcpy(tmp, rxByte, sizeof(rxByte));
-					if(tmp[1] == RFID_CMD_FELICA_POLLING_REQUEST)
+					if(chksumValid(rxByte) == PASS)
 					{
-						DEBUG_INFO_1("FELICA.\n");
-
-						cardLength = LENGTH_6;
-						memcpy(data, rxByte+6, cardLength);
+						if((rxByte[1] == RFID_CMD_FELICA_POLLING_REQUEST) && (rxByte[0] >= 22))
+						{
+							cardLength = LENGTH_6;
+							memcpy(data, rxByte+6, cardLength);
+							DEBUG_INFO_1("FELICA SN: %02X-%02X-%02X-%02X-%02X-%02X\n", data[0], data[1], data[2], data[3], data[4], data[5]);
 
-						isSuccess = true;
+							isSuccess = true;
+						}
+						else if(rxByte[1] == 0xD0)
+						{
+							cardLength = LENGTH_0;
+							isSuccess = false;
+						}
+						else
+						{}
 					}
-					else if(tmp[1] == 0xD0)
+					else
 					{
-						cardLength = LENGTH_0;
-						isSuccess = false;
+						//DEBUG_ERROR_1("Response check sum mismatch.\n");
 					}
-					else
-					{}
 				}
 				else
 				{}
@@ -1023,4 +1047,4 @@ bool setDefaultOfAutomaticDetectingCard(int Fd, int moduleType, int Value)
 	}
 	
 	return isSuccess;
-}
+}

+ 2 - 109
EVSE/Projects/DD360Tcci/Apps/CSU/Ethernet.c

@@ -109,7 +109,6 @@ static int isReachableInternet(void)
 
     pclose(fp);
 
-#if defined DD360 ||defined DD360Audi || defined DD360ComBox
     if (pAlarmCode->AlarmEvents.bits.DisconnectedFromDo == NORMAL) {
         result = FAIL;
     } else {
@@ -117,31 +116,7 @@ static int isReachableInternet(void)
     }
 
     return result;
-#endif //defined DD360 || defined DD360Audi
-
-    memset(buf, 0x00, sizeof(buf));
-
-    for (idx = 0; idx < ARRAY_SIZE(valid_Internet); idx++) {
-        sprintf(cmd, "ping -c 1 -w 3 -I eth0 %s", valid_Internet[idx]);
-        fp = popen(cmd, "r");
-        if (fp != NULL) {
-            while (fgets(buf, sizeof(buf), fp) != NULL) {
-                if (strstr(buf, "transmitted") > 0) {
-                    //sscanf(buf, "%*s%*s%*s%*s%*s%*s%s", tmp);
-
-                    if (strstr(buf, "100%") != NULL) {
-                    } else {
-                        result = PASS;
-                    }
-                    //DEBUG_INFO("%s",buf);
-                    //DEBUG_INFO("%s",tmp);
-                }
-            }
-        }
-        pclose(fp);
-    }
 
-    return result;
 }
 
 void InitEthernet(void)
@@ -205,95 +180,13 @@ void InitEthernet(void)
 
     pid_t pid = fork();
     if (pid == 0) {
-        log_info("InitEthernet = %d", pid);
+        //log_info("InitEthernet = %d", pid);
 
         for (;;) {
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+
             isReachableInternet();
             sleep(5);
             continue;
-#endif //!defined DD360 && !defined DD360
-
-            if (isRouteFail()) {
-                //log_info("eth0 not in route, restart eht0. ");
-                system("/sbin/ifconfig eth0 down;/sbin/ifconfig eth0 up");
-
-                if (pSysConfig->Eth0Interface.EthDhcpClient == 0) {
-                    InitialDHCP();
-                }
-            }
-
-            if (isReachableInternet() == PASS) {
-                pSysInfo->ethInternetConn = YES;
-                cnt_pingDNS_Fail = 0;
-            } else {
-                if (++cnt_pingDNS_Fail > 3) {
-                    pSysInfo->ethInternetConn = NO;
-                }
-            }
-
-            ethResult = pSysInfo->ethInternetConn;
-
-            if (ethResult == YES) {
-                system("/sbin/ifmetric eth0 0");
-
-                if ((pSysConfig->ModelName[10] == 'W') ||
-                        (pSysConfig->ModelName[10] == 'D')) {
-                    system("/sbin/ifmetric mlan0 1");
-                }
-
-                if ((pSysConfig->ModelName[10] == 'T') ||
-                        (pSysConfig->ModelName[10] == 'D')) {
-                    system("/sbin/ifmetric ppp0 2");
-                }
-            }
-
-            if (!ethResult &&
-                    pSysConfig->AthInterface.WifiMode != _SYS_WIFI_MODE_DISABLE &&
-                    (pSysConfig->ModelName[10] == 'W' ||
-                     pSysConfig->ModelName[10] == 'D')) {
-                //ethResult = pSysConfig->AthInterface.WifiNetworkConn;
-                ethResult = pInfoCode->InfoEvents.bits.InternetDisconnectViaWiFi == YES ? NO : YES;
-
-                if (ethResult) {
-                    if ((pSysConfig->ModelName[10] == 'W') ||
-                            (pSysConfig->ModelName[10] == 'D')) {
-                        system("/sbin/ifmetric eth0 1");
-                        system("/sbin/ifmetric mlan0 0");
-                    }
-
-
-                    if ((pSysConfig->ModelName[10] == 'T') ||
-                            (pSysConfig->ModelName[10] == 'D')) {
-                        system("/sbin/ifmetric ppp0 2");
-                    }
-                }
-            }
-
-            if (!ethResult &&
-                    pSysConfig->TelecomInterface.TelcomEnabled == YES &&
-                    (pSysConfig->ModelName[10] == 'T' ||
-                     pSysConfig->ModelName[10] == 'D')) {
-                //ethResult = pSysConfig->TelecomInterface.TelcomNetworkConn;
-                ethResult = pInfoCode->InfoEvents.bits.InternetDisconnectVia4Gi == YES ? NO : YES;
-
-                if (ethResult) {
-                    if ((pSysConfig->ModelName[10] == 'W') ||
-                            (pSysConfig->ModelName[10] == 'D')) {
-                        system("/sbin/ifmetric mlan0 2");
-                    }
-
-                    if ((pSysConfig->ModelName[10] == 'T') ||
-                            (pSysConfig->ModelName[10] == 'D')) {
-                        system("/sbin/ifmetric eth0 1");
-                        system("/sbin/ifmetric ppp0 0");
-                    }
-                }
-            }
-
-            pSysInfo->InternetConn = ethResult;
-
-            sleep(5);
         }
     }
 

+ 65 - 467
EVSE/Projects/DD360Tcci/Apps/CSU/Primary.c

@@ -10,324 +10,37 @@
 
 #include "../SelectGun/SelectGun.h"
 #include "main.h"
-
+#include "../timeout.h"
+struct SysInfoData *pSysInfo = NULL;
+struct ChargingInfoData *pDcChargingInfo = NULL;
+struct SysConfigData *pSysConfig = NULL;
 //------------------------------------------------------------------------------
-typedef struct StLedConfig {
-    //OutputDrvValue[0]
-    uint8_t LeftButtonLed: 1;                   //bit 0,    H: ON,      L:OFF
-    uint8_t RightButtonLed: 1;                  //bit 1,    H: ON,      L:OFF
-    uint8_t GreenLED: 1;                        //bit 2,    H: ON,      L:OFF
-    uint8_t YellowLED: 1;                       //bit 3,    H: ON,      L:OFF
-    uint8_t RedLED: 1;                          //bit 4,    H: ON,      L:OFF
-    uint8_t SystemLed4: 1;                      //bit 5,    H: ON,      L:OFF
-    uint8_t AcContactor: 1;                     //bit 6,    H: ON,      L:OFF
-    uint8_t Reserved: 1;                        //bit 7 reserved
-} LedConfig;
 
 //------------------------------------------------------------------------------
-static uint8_t checkCabinetEthConnectState(LedConfig *ledConfig)
+void ChangeLCM(uint8_t page)
 {
-    uint8_t ret = NO;
-    LedConfig *pLedConfig = (LedConfig *)ledConfig;
-    struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
-
-    if (pAlarmCode->AlarmEvents.bits.DisconnectedFromDo == YES) {
-        ret = YES;
-        if (pLedConfig->RedLED == YES ||
-                pLedConfig->YellowLED == YES ||
-                pLedConfig->GreenLED == YES) {
-            pLedConfig->RedLED = NO;
-            pLedConfig->YellowLED = NO;
-            pLedConfig->GreenLED = NO;
-        } else {
-            pLedConfig->RedLED = YES;
-            pLedConfig->YellowLED = YES;
-            pLedConfig->GreenLED = YES;
-        }
-    }
-
-    return ret;
-}
-
-void PrimaryLedIndicatorCtrlFork(void)
-{
-#if !defined DD360ComBox
-    return;
-#endif //!defined DD360ComBox
-
-    pid_t pid = fork();
-    if (pid == 0) {
-        uint8_t gunIndex = 0;
-        int isContinue = 1;
-
-        struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-        struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-        struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
-        struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
-        struct ChargingInfoData *pDcChargingInfo = NULL;
-
-        LedConfig *pLedConfig = (LedConfig *)&ShmPrimaryMcuData->OutputDrv.OutputDrvValue[0];
-
-        while (isContinue) {
-            for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
-                pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
-
-                if (pSysWarning->Level == WARN_LV_ER) {
-                    if (checkCabinetEthConnectState(pLedConfig) == YES) {
-                        usleep(500000);
-                        continue;
-                    }
-
-                    pLedConfig->YellowLED = NO;
-                    pLedConfig->GreenLED = NO;
-                    pLedConfig->RedLED = YES;
-                    usleep(500000);
-                    continue;
-                }
-
-                //log_info("led indicator status = %d", pDcChargingInfo->SystemStatus);
-                //printf("level = %d", pSysWarning->Level);
-                switch (pDcChargingInfo->SystemStatus) {
-                case S_BOOTING:
-                    if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) {
-                        //Module_DoComm tcp disconnect
-                        if (pLedConfig->RedLED == YES ||
-                                pLedConfig->YellowLED == YES ||
-                                pLedConfig->GreenLED == YES) {
-                            pLedConfig->RedLED = NO;
-                            pLedConfig->YellowLED = NO;
-                            pLedConfig->GreenLED = NO;
-                        } else {
-                            pLedConfig->RedLED = YES;
-                            pLedConfig->YellowLED = YES;
-                            pLedConfig->GreenLED = YES;
-                        }
-                        break;
-                    }
-
-                    pLedConfig->RedLED = YES;
-                    pLedConfig->YellowLED = YES;
-                    pLedConfig->GreenLED = YES;
-                    break;
-
-                case S_IDLE:
-                    //Module_DoComm connected and system idle
-                    pLedConfig->RedLED = NO;
-                    pLedConfig->YellowLED = NO;
-                    pLedConfig->GreenLED = YES;
-                    break;
-
-                case S_RESERVATION:
-                case S_AUTHORIZING:
-                case S_REASSIGN_CHECK:
-                case S_REASSIGN:
-                case S_PREPARNING:
-                case S_PREPARING_FOR_EV:
-                case S_PREPARING_FOR_EVSE:
-                case S_CCS_PRECHARGE_ST0:
-                case S_CCS_PRECHARGE_ST1:
-                    //precharging status
-                    if (pLedConfig->GreenLED == YES) {
-                        pLedConfig->GreenLED = NO;
-                    } else {
-                        pLedConfig->GreenLED = YES;
-                    }
-                    break;
-
-                case S_CHARGING:
-                    pLedConfig->RedLED = NO;
-#ifdef DD360ComBox
-                    pLedConfig->YellowLED = YES;
-#else
-                    if (pLedConfig->YellowLED == YES) {
-                        pLedConfig->YellowLED = NO;
-                    } else {
-                        pLedConfig->YellowLED = YES;
-                    }
-#endif
-                    pLedConfig->GreenLED = NO;
-                    break;
-
-                case S_ALARM:
-                    pLedConfig->YellowLED = NO;
-                    pLedConfig->GreenLED = NO;
-
-                    if (checkCabinetEthConnectState(pLedConfig) == YES) {
-                        break;
-                    }
-
-                    pLedConfig->RedLED = YES;
-                    break;
-
-                case S_TERMINATING:
-                case S_COMPLETE:
-                    //if (pSysWarning->Level == WARN_LV_ER) {
-                    //    pLedConfig->YellowLED = NO;
-                    //    pLedConfig->GreenLED = NO;
-                    //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
-                    //        break;
-                    //    }
-                    //    pLedConfig->RedLED = YES;
-                    //} else {
-                    pLedConfig->RedLED = NO;
-#ifdef DD360ComBox
-                    if (pLedConfig->YellowLED == YES) {
-                        pLedConfig->YellowLED = NO;
-                    } else {
-                        pLedConfig->YellowLED = YES;
-                    }
-#else
-                        pLedConfig->YellowLED = YES;
-#endif
-                    pLedConfig->GreenLED = NO;
-                    //}
-                    break;
-
-                case S_MAINTAIN:
-                case S_FAULT:
-                case S_UPDATE:
-                    pLedConfig->YellowLED = NO;
-                    pLedConfig->GreenLED = NO;
-                    pLedConfig->RedLED = YES;
-                    //if (pSysWarning->Level == WARN_LV_ER) {
-                    //    if (checkCabinetEthConnectState(pLedConfig) == YES) {
-                    //        break;
-                    //    }
-                    //    pLedConfig->RedLED = YES;
-                    //}
-                    break;
-
-                case S_BOOKING:
-                case S_DEBUG:
-                case S_NONE:
-                    break;
-                }//switch
-            }//for
-            usleep(500000);
-        }//while
-    }//fork
+    pSysInfo->SystemPage = page;
 }
+// ***********************************
+// Enter LCM Page
+// ***********************************
 
-//------------------------------------------------------------------------------
-static void checkChargingInfoByDC(uint8_t systemStatus)
+void CheckLeftButton()
 {
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-    struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-
-    switch (systemStatus) {
-    case S_IDLE:
-        if (isDetectPlugin()) {
-            _DetectPlugInTimeout();
-            StopSystemTimeoutDet();
-            destroySelGun(pSysInfo->CurGunSelected);
-            
-        } else {
-            if( pSysConfig->isAuthrizeByEVCCID && pSysInfo->ConnectorPage == _LCM_PRE_CHARGE) {
-                _evccidlinktimeout(pSysInfo->CurGunSelected);
-                pDcChargingInfo->isEVCCIDVerify = true;
-                break;
-            }
-#if !defined DD360Audi
-            break;
-#endif //!defined DD360Audi
-
-            if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
-                //printf("destroy gun = %d", pSysInfo->CurGunSelected);
-                destroySelGun(pSysInfo->CurGunSelected);
-            } else {
-                confirmSelGun(pSysInfo->CurGunSelected);
-                log_info("confirm select gun ............................... %d ",
-                         pSysInfo->CurGunSelected);
-            }
-        }
-        break;
-
-    case S_REASSIGN_CHECK:
-    case S_REASSIGN:
-    case S_PREPARNING:
-    case S_PREPARING_FOR_EV:
-    case S_PREPARING_FOR_EVSE:
-    case S_CCS_PRECHARGE_ST0:
-    case S_CCS_PRECHARGE_ST1:
-        // 取消充電
-        if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
-            AcChargingTerminalProcess();
-        } else {
-            ChargingTerminalProcess(pSysInfo->CurGunSelected);
-        }
-        break;
-
-    case S_CHARGING:
-        if (pSysConfig->StopChargingByButton == YES ||
-                pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
-            // 停止充電
-            ChargingTerminalProcess(pSysInfo->CurGunSelected);
-        }
-        break;
-
-    case S_COMPLETE:
-        break;
-    }
+    pSysInfo->CurGunSelected = LEFT_GUN_NUM;
 }
-
-static void checkChargingInfoByAC(void)
+void CheckRightButton()
 {
-    struct ChargingInfoData *pAcChargingInfo = NULL;
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-
-    if (pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
-        return;
-    }
-
-    pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
-
-    switch (pAcChargingInfo->SystemStatus) {
-    case S_IDLE:
-        if (isDetectPlugin()) {
-            _DetectPlugInTimeout();
-            StopSystemTimeoutDet();
-        }
-        break;
-
-    case S_REASSIGN_CHECK:
-    case S_REASSIGN:
-    case S_PREPARNING:
-    case S_PREPARING_FOR_EV:
-    case S_PREPARING_FOR_EVSE:
-    case S_CCS_PRECHARGE_ST0:
-    case S_CCS_PRECHARGE_ST1:
-        // 取消充電
-        AcChargingTerminalProcess();
-        break;
-
-    case S_CHARGING:
-        if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
-            // 停止充電
-            AcChargingTerminalProcess();
-        }
-        break;
-
-    case S_COMPLETE:
-        break;
-    }
+    pSysInfo->CurGunSelected = RIGHT_GUN_NUM;
 }
-
-void ChkPrimaryStatus(void)
+void CheckPrimaryWarm(void)
 {
-    static bool leftBtnPush = false;
-    static bool rightBtnPush = false;
     uint8_t i = 0;
     uint8_t Rtn = 0;
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
     struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
     struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
     struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
-    struct ChargingInfoData *pDcChargingInfo = NULL;
     DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
-
     if (pSysWarning->WarningCount > 0) {
         Rtn = 0;
         for (i = 0; i < pSysWarning->WarningCount; i++) {
@@ -343,7 +56,11 @@ void ChkPrimaryStatus(void)
                 ShmDcCommonData->PowerAlarmState.StatusBit.DcInputOVP = YES;
                 EmcOccureByString("042327");
                 Rtn = 1;
-            }  else if (memcmp(&pSysWarning->WarningCode[i][0], "042200", 6) == 0) {
+            } else if (memcmp(&pSysWarning->WarningCode[i][0], "042328", 6) == 0) {
+			   ShmDcCommonData->PowerAlarmState.StatusBit.DcInputUVP = YES;
+			   EmcOccureByString("042328");
+			   Rtn = 1;
+		    } else if (memcmp(&pSysWarning->WarningCode[i][0], "042200", 6) == 0) {
                 ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = YES;
                 EmcOccureByString("042200");
                 Rtn = 1;
@@ -369,14 +86,16 @@ void ChkPrimaryStatus(void)
             ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
             ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
             ShmDcCommonData->PowerAlarmState.StatusBit.DcInputOVP = NO;
+            ShmDcCommonData->PowerAlarmState.StatusBit.DcInputUVP = NO;
             ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
             ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
             ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
             ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
             ReleaseEmsOccureByString(0, "042251");
             ReleaseEmsOccureByString(0, "042252");
-            ReleaseEmsOccureByString(0, "042327");
             ReleaseEmsOccureByString(0, "042200");
+            ReleaseEmsOccureByString(0, "042327");
+            ReleaseEmsOccureByString(0, "042328");
             ReleaseEmsOccureByString(0, "042201");
             ReleaseEmsOccureByString(0, "042202");
             ReleaseEmsOccureByString(0, "042267");
@@ -386,14 +105,16 @@ void ChkPrimaryStatus(void)
         ShmDcCommonData->PowerAlarmState.StatusBit.EmergencyStop = NO;
         ShmDcCommonData->PowerAlarmState.StatusBit.DoorOpen = NO;
         ShmDcCommonData->PowerAlarmState.StatusBit.DcInputOVP = NO;
+        ShmDcCommonData->PowerAlarmState.StatusBit.DcInputUVP = NO;
         ShmDcCommonData->PowerAlarmState.StatusBit.SystemL1InputOVP = NO;
         ShmDcCommonData->PowerAlarmState.StatusBit.SystemL2InputOVP = NO;
         ShmDcCommonData->PowerAlarmState.StatusBit.SystemL3InputOVP = NO;
         ShmDcCommonData->PowerAlarmState.StatusBit.PsuFailure = NO;
         ReleaseEmsOccureByString(0, "042251");
         ReleaseEmsOccureByString(0, "042252");
-        ReleaseEmsOccureByString(0, "042327");
         ReleaseEmsOccureByString(0, "042200");
+        ReleaseEmsOccureByString(0, "042327");
+        ReleaseEmsOccureByString(0, "042328");
         ReleaseEmsOccureByString(0, "042201");
         ReleaseEmsOccureByString(0, "042202");
         ReleaseEmsOccureByString(0, "042267");
@@ -426,171 +147,48 @@ void ChkPrimaryStatus(void)
     } else {
         ReleaseEmsOccureByString(0, "012252");
     }
+}
+void ChkPrimaryStatus(void)
+{
+    static bool leftBtnPush = false;
+    static bool rightBtnPush = false;
+    pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
+    struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
+    struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+    pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
+
+    // Check Primary Board status
+    CheckPrimaryWarm();
+    if ((pDcChargingInfo->SystemStatus == S_IDLE || pDcChargingInfo->SystemStatus == S_RESERVATION)
+            && pSysConfig->OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING) {
+        log_info("Offline policy no charge");
+        return;;
+    }
 
-    //DS60-120 add
-    //if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
-    //        ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS) {
-    //    pSysConfig->ShowInformation = YES;
-    //} else {
-    //    pSysConfig->ShowInformation = NO;
-    //}
-
+    // Show Version
     if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS &&
-            !leftBtnPush
-#if defined DD360Audi
-            &&
-            pSysInfo->SystemPage != _LCM_AUTHORIZING &&
-            pSysInfo->SystemPage != _LCM_AUTHORIZ_COMP &&
-            pSysInfo->SystemPage != _LCM_AUTHORIZ_FAIL
-#endif //defined DD360Audi
-       ) {
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-
-        if (!leftBtnPush) {
-            leftBtnPush = true;
-            log_info("left btn down...............................%x",
-                     pDcChargingInfo->SystemStatus);
-            checkChargingInfoByAC();
-            checkChargingInfoByDC(pDcChargingInfo->SystemStatus);
-#if 0
-            if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
-                pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
-
-                switch (pAcChargingInfo->SystemStatus) {
-                case S_IDLE:
-                    if (isDetectPlugin()) {
-                        _DetectPlugInTimeout();
-                        StopSystemTimeoutDet();
-                    }
-                    break;
-
-                case S_REASSIGN_CHECK:
-                case S_REASSIGN:
-                case S_PREPARNING:
-                case S_PREPARING_FOR_EV:
-                case S_PREPARING_FOR_EVSE:
-                case S_CCS_PRECHARGE_ST0:
-                case S_CCS_PRECHARGE_ST1:
-                    // 取消充電
-                    AcChargingTerminalProcess();
-                    break;
-
-                case S_CHARGING:
-                    if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
-                        // 停止充電
-                        AcChargingTerminalProcess();
-                    }
-                    break;
-
-                case S_COMPLETE:
-                    break;
-                }
-            }
-            switch (pDcChargingInfo->SystemStatus) {
-            case S_IDLE:
-                if (isDetectPlugin()) {
-                    _DetectPlugInTimeout();
-                    StopSystemTimeoutDet();
-                    destroySelGun(pSysInfo->CurGunSelected);
-                }             else {
-#if defined DD360Audi
-                    if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
-                        //printf("destroy gun = %d", pSysInfo->CurGunSelected);
-                        destroySelGun(pSysInfo->CurGunSelected);
-                    } else {
-                        confirmSelGun(pSysInfo->CurGunSelected);
-                        log_info("confirm select gun ............................... %d ",
-                                 pSysInfo->CurGunSelected);
-                    }
-
-#endif //defined DD360Audi
-                }
-                break;
-
-            case S_REASSIGN_CHECK:
-            case S_REASSIGN:
-            case S_PREPARNING:
-            case S_PREPARING_FOR_EV:
-            case S_PREPARING_FOR_EVSE:
-            case S_CCS_PRECHARGE_ST0:
-            case S_CCS_PRECHARGE_ST1:
-                // 取消充電
-                if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
-                    AcChargingTerminalProcess();
-                } else {
-                    ChargingTerminalProcess(pSysInfo->CurGunSelected);
-                }
-                break;
-
-            case S_CHARGING:
-                if (pSysConfig->StopChargingByButton == YES ||
-                        pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
-                    // 停止充電
-                    ChargingTerminalProcess(pSysInfo->CurGunSelected);
-                }
-                break;
-
-            case S_COMPLETE:
-                // 回 IDLE
-                //log_info("right btn down.................S_COMPLETE ");
-                //pDcChargingInfo->SystemStatus = S_IDLE;
-                break;
-            }
-#endif //0
-        }
-    } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
-        if (leftBtnPush) {
-            leftBtnPush = false;
-            //log_info("left btn up............................... ");
-        }
+            ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS )
+        pSysConfig->ShowInformation = YES;
+    else
+        pSysConfig->ShowInformation = NO;
+    if (pSysConfig->ShowInformation)
+        return;
+    // Press Left Button
+    if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_PRESS && !leftBtnPush ) {
+        leftBtnPush = true;
+        CheckLeftButton();
+        log_info("left btn down...............................%x %x %x",
+                pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus,pSysInfo->SystemPage);
+    } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE && leftBtnPush) {
+        leftBtnPush = false;
     }
-
-    if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS &&
-            !rightBtnPush
-#if defined DD360Audi
-            &&
-            pSysInfo->SystemPage != _LCM_IDLE &&
-            pSysInfo->SystemPage != _LCM_AUTHORIZING &&
-            pSysInfo->SystemPage != _LCM_AUTHORIZ_COMP &&
-            pSysInfo->SystemPage != _LCM_AUTHORIZ_FAIL &&
-            pSysInfo->SystemPage != _LCM_WAIT_FOR_PLUG
-#endif //defined DD360Audi
-       ) {
-        if (!rightBtnPush) {
-            rightBtnPush = true;
-            //log_info("right btn down............................... %d ", pSysInfo->CurGunSelected);
-            if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount &&
-                    pSysInfo->IsAlternatvieConf == NO) {
-                pSysInfo->CurGunSelected++;
-                ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
-            } else if (pSysConfig->AcConnectorCount > 0 &&
-                       pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
-                pSysInfo->CurGunSelectedByAc = DEFAULT_AC_INDEX;
-            } else if (pSysInfo->IsAlternatvieConf == YES) {
-                for (uint8_t _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
-                    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
-
-                    if (pDcChargingInfo->SystemStatus != S_BOOTING &&
-                            pDcChargingInfo->SystemStatus != S_IDLE &&
-                            pDcChargingInfo->SystemStatus != S_RESERVATION) {
-                        pSysInfo->CurGunSelected = _index;
-                        ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
-                        return;
-                    }
-                }
-                pSysInfo->CurGunSelected = 0;
-                ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
-            } else {
-                pSysInfo->CurGunSelected = 0;
-                ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
-            }
-        }
-        log_info("current select gun ............................... %d ",
-                 pSysInfo->CurGunSelected);
-    } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
-        if (rightBtnPush) {
-            rightBtnPush = false;
-            //log_info("right btn up............................... ");
-        }
+    // Press Right Button
+    if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_PRESS && !rightBtnPush ) {
+        rightBtnPush = true;
+        CheckRightButton();
+        log_info("right btn down...............................%x %x %x",
+               pSysInfo->CurGunSelected,pDcChargingInfo->SystemStatus, pSysInfo->SystemPage);
+    } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE && rightBtnPush) {
+        rightBtnPush = false;
     }
 }

+ 89 - 108
EVSE/Projects/DD360Tcci/Apps/CSU/RFID.c

@@ -38,28 +38,24 @@ static bool canStartCharging(void)
     return false;
 }
 
-static void isAutorCompleteHandle(uint8_t *authorizeIndex)
+bool isAutorCompleteHandle(/*uint8_t *authorizeIndex*/)
 {
-    uint8_t i = 0;
+   // uint8_t i = 0;
     struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    struct ChargingInfoData *pDcChargingInfo = NULL;
+    //struct ChargingInfoData *pDcChargingInfo = NULL;
+    //struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
 
     // 透過後臺停止充電的判斷
-    if (isAuthorizedComplete()
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-            || (pSysInfo->OcppConnStatus == NO &&
-                pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING)
-#endif //!defined DD360 && !defined DD360Audi
-       ) {
-
+    if (isAuthorizedComplete()) {
         // 判斷後台回覆狀態
         if (canStartCharging() == false) {
             strcpy((char *)pSysConfig->UserId, "");
             ClearAuthorizedFlag();
-
-            return;
         }
-
+        return true;
+    }
+    return false;
+/*
         if (*(authorizeIndex) != NO_DEFINE) {
             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(*(authorizeIndex));
 
@@ -78,7 +74,8 @@ static void isAutorCompleteHandle(uint8_t *authorizeIndex)
         }
 
         ClearAuthorizedFlag();
-    } else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
+
+    } /*else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
         // 白名單驗證
         for (i = 0; i < 10; i++) {
             if (strcmp((char *)pSysConfig->LocalWhiteCard[i], "") == EQUAL) {
@@ -93,9 +90,37 @@ static void isAutorCompleteHandle(uint8_t *authorizeIndex)
                 break;
             }
         }
-    }
+    }*/
 }
 
+bool RfidStopCharging(void)
+{
+    //當前沒有選槍
+    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
+    struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
+    if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == FAIL ) {
+        strcpy((char *)pSysConfig->UserId, "");
+        return false;
+    }
+    struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+    if (pDcChargingInfo->isRemoteStart) {
+
+    } else {
+        if (strcmp((char *)pSysConfig->UserId, (char *)pDcChargingInfo->StartUserId) == EQUAL) {
+
+            ChargingTerminalProcess(pSysInfo->CurGunSelected);
+            strcpy((char *)pSysConfig->UserId, "");
+            log_info("index = %d, card number = %s, UserId = %s ",
+                     pSysInfo->CurGunSelected,
+                     pDcChargingInfo->StartUserId,
+                     pSysConfig->UserId);
+            return true;
+        } else {
+            return false;
+        }
+    }
+    return false;
+}
 static void UserScanFunction(void)
 {
     bool idleReq = false;
@@ -111,7 +136,7 @@ static void UserScanFunction(void)
 
     // 當前非驗證的狀態
     if (IsAuthorizingMode()) {
-        isAutorCompleteHandle(&_authorizeIndex);
+        isAutorCompleteHandle(/*&_authorizeIndex*/);
     }
 
     //當前沒有選槍
@@ -119,20 +144,16 @@ static void UserScanFunction(void)
         strcpy((char *)pSysConfig->UserId, "");
         return;
     }
-    /*
-    if (pSysConfig->EVCCID_Authorize) {
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-        if (strcmp( (char *)pSysConfig->UserId, (char *) pDcChargingInfo->EVCCID) != EQUAL )
-            return;
-    }*/
+
     // 先判斷現在是否可以提供刷卡
     // 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能
     // 2. 停止充電
-    if (pSysInfo->PageIndex == _LCM_FIX) {
+    //if (pSysInfo->PageIndex == _LCM_ERROR) {
+    if (pSysInfo->SystemPage == _PAGE_MAINTAIN) {
         strcpy((char *)pSysConfig->UserId, "");
         return;
     }
-
+    /*
     for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
 
@@ -140,10 +161,10 @@ static void UserScanFunction(void)
             stopReq = i;
         }
 
-        if ((pDcChargingInfo->SystemStatus == S_IDLE &&
+        if ((pDcChargingInfo->SystemStatus == S_AUTHORIZING &&
                 pDcChargingInfo->IsAvailable == YES) ||
                 (pGunIndexInfo->AcGunIndex > 0 &&
-                 pAcChargingInfo->SystemStatus == S_IDLE &&
+                 pAcChargingInfo->SystemStatus == S_AUTHORIZING &&
                  pAcChargingInfo->IsAvailable)
            ) {
             idleReq = true;
@@ -155,14 +176,14 @@ static void UserScanFunction(void)
             pAcChargingInfo->SystemStatus == S_CHARGING) {
         stopReq = DEFAULT_AC_INDEX;
     }
-
+     */
     if (strlen((char *)pSysConfig->UserId) <= 0) {
         return;
     }
 
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
-
-    if (pGunIndexInfo->AcGunIndex > 0 &&
+    // Stop Charging For AC
+    /*if (pGunIndexInfo->AcGunIndex > 0 &&
             stopReq == DEFAULT_AC_INDEX &&
             pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
         log_info("ac stop charging ");
@@ -185,26 +206,9 @@ static void UserScanFunction(void)
                 (pGunIndexInfo->AcGunIndex > 0 &&
                  pSysInfo->CurGunSelectedByAc == NO_DEFINE))
               ) {
-        log_info("stop charging ");
-        log_info("index = %d, card number = %s, UserId = %s ",
-                 pSysInfo->CurGunSelected,
-                 pDcChargingInfo->StartUserId,
-                 pSysConfig->UserId);
-
-        memset(value, 0, sizeof(value));
-        memcpy(value,
-               (uint8_t *)pDcChargingInfo->StartUserId,
-               ARRAY_SIZE(pDcChargingInfo->StartUserId));
-
-        // 同一張卡直接停掉
-        if (strcmp((char *)pSysConfig->UserId, value) == EQUAL) {
-            ChargingTerminalProcess(pSysInfo->CurGunSelected);
-            strcpy((char *)pSysConfig->UserId, "");
-
+    	// Stop Charging
+        if (RfidStopCharging())
             return;
-        }
-
-        // 進驗證
         if (pGunIndexInfo->AcGunIndex > 0 &&
                 pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
             _authorizeIndex = pSysInfo->CurGunSelectedByAc;
@@ -212,15 +216,9 @@ static void UserScanFunction(void)
             _authorizeIndex = pSysInfo->CurGunSelected;
         }
 
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
         strcpy((char *)pSysConfig->UserId, "");
-
         return;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
-
-        StartSystemTimeoutDet(Timeout_AuthorizingForStop);
 
-        AuthorizingStart();
     } else if (idleReq) {
         if (pSysConfig->TotalConnectorCount > 1 &&
                 stopReq != 255 &&
@@ -229,19 +227,17 @@ static void UserScanFunction(void)
             strcpy((char *)pSysConfig->UserId, "");
         } else if ((pGunIndexInfo->AcGunIndex > 0 &&
                     pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) ||
-                   pDcChargingInfo->SystemStatus == S_IDLE) {
+                   pDcChargingInfo->SystemStatus == S_AUTHORIZING) {*/
+    if (pDcChargingInfo->SystemStatus == S_AUTHORIZING ) {
             log_info("// LCM => Authorizing");
 
             setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
 
             // LCM => Authorizing
-            pSysInfo->SystemPage = _LCM_AUTHORIZING;
+            pSysInfo->SystemPage = _PAGE_PLUGIN;
 
             // 進入確認卡號狀態
             AuthorizingStart();
-        } else {
-            strcpy((char *)pSysConfig->UserId, "");
-        }
     } else {
         strcpy((char *)pSysConfig->UserId, "");
     }
@@ -258,17 +254,42 @@ void SetIsCardScan(bool value)
 {
     isCardScan = value;
 }
-
+void AuthorizeToCharge()
+{
+    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
+    struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
+    SelectGunInfo *ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
+    if(!isAuthorizedComplete())
+        StartSystemTimeoutDet(Timeout_Authorizing);
+    else {
+        //StopSystemTimeoutDet();
+        StartSystemTimeoutDet(Timeout_WaitBalance);
+        if (ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance != FAIL_BALANCE_PRICES) {
+            StopSystemTimeoutDet();
+            // 判斷後台回覆狀態
+            if (canStartCharging()) {
+            // LCM => Authorize complete
+                pSysInfo->SystemPage = _PAGE_PLUGIN;
+                log_info("Wait Gun(%d) plugin",pSysInfo->CurGunSelected);
+                DetectPluginStart();
+                log_info("Gun(%d) Balance: %f",pSysInfo->CurGunSelected,
+                        ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
+            } else {
+                // LCM => Authorize fail
+                pSysInfo->SystemPage = _PAGE_PAY_FAIL;
+                strcpy((char *)pSysConfig->UserId, "");
+            }
+        }
+        ClearAuthorizedFlag();
+    }
+}
 void ScannerCardProcess(void)
 {
-    int i = 0;
     struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
     struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
-    SelectGunInfo *ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
 
-    if (!isDetectPlugin() &&
-            !isCardScan &&
+    if (!isDetectPlugin() && pSysInfo->SystemPage == _PAGE_PLUGIN &&
             pSysWarning->Level != WARN_LV_ER /*&&
             pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE*/) {
         isCardScan = true;
@@ -276,52 +297,12 @@ void ScannerCardProcess(void)
         UserScanFunction();
     }
 
-    if (pSysInfo->PageIndex == _LCM_AUTHORIZING) {
-        if(!isAuthorizedComplete())
-            StartSystemTimeoutDet(Timeout_Authorizing);
-
-        //printf("isAuthorizedComplete = %d, %f", isAuthorizedComplete(), ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
-        // 確認驗證卡號完成沒
-        if (isAuthorizedComplete()
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-                || pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING
-#endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
-           ) {
-                //StopSystemTimeoutDet();
-                StartSystemTimeoutDet(Timeout_WaitBalance);
-                if (ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance != FAIL_BALANCE_PRICES) {
-                    StopSystemTimeoutDet();
-                    // 判斷後台回覆狀態
-                    if (canStartCharging()) {
-                    // LCM => Authorize complete
-                    pSysInfo->SystemPage = _LCM_AUTHORIZ_COMP;
-                    } else {
-                    // LCM => Authorize fail
-                    pSysInfo->SystemPage = _LCM_AUTHORIZ_FAIL;
-                    strcpy((char *)pSysConfig->UserId, "");
-                }
-
-            } ClearAuthorizedFlag();
-        } else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
-            // 白名單驗證
-            for (i = 0; i < 10; i++) {
-                if (strcmp((char *)pSysConfig->LocalWhiteCard[i], "") == EQUAL) {
-                    continue;
-                }
-
-                if (strcmp((char *)pSysConfig->LocalWhiteCard[i], (char *)pSysConfig->UserId) == EQUAL) {
-                    pSysInfo->SystemPage = _LCM_AUTHORIZ_COMP;
-                    ClearAuthorizedFlag();
-                    break;
-                }
-            }
-        }
-    } else if (pSysInfo->PageIndex == _LCM_AUTHORIZ_FAIL) {
+    /*if (pSysInfo->SystemPage == _PAGE_PLUGIN) {
+        AuthorizeToCharge();
+    } else if (pSysInfo->SystemPage == _PAGE_PLUGIN) {
         StartSystemTimeoutDet(Timeout_VerifyFail);
         isCardScan = false;
-    } else if (pSysInfo->PageIndex == _LCM_AUTHORIZ_COMP) {
-        StartSystemTimeoutDet(Timeout_VerifyComp);
-    } else if (pSysInfo->PageIndex == _LCM_WAIT_FOR_PLUG) {
+    } else */if (pSysInfo->SystemPage == _PAGE_PLUGIN) {
         StartSystemTimeoutDet(Timeout_WaitPlug);
     } else {
         isCardScan = false;

+ 5 - 28
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 ||
@@ -147,9 +147,9 @@ void SelfTestRun(void)
                                     ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].version[0] != '\0')
                                     /*&&(ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].SelfTest_Comp != YES)*/
                                ) {
-                             //   log_info("CCS[%d] FW Rev = %s",
-                             //            pDcChargingInfo->type_index,
-                             //            ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].version);
+                                //log_info("CCS[%d] FW Rev = %s",
+                                //         pDcChargingInfo->type_index,
+                                //         ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].version);
                                 ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].SelfTest_Comp = YES;
                             } else {
                                 //log_info("CCS[%d] ccs fw lose...... %s \n",
@@ -169,7 +169,7 @@ void SelfTestRun(void)
                                 pAcChargingInfo->version[0] != '\0')
                                 && (pAcChargingInfo->SelfTest_Comp != YES)
                            ) {
-                            log_info("AC connector[%d] FW Rev = %s", index, pAcChargingInfo->version);
+                            //log_info("AC connector[%d] FW Rev = %s", index, pAcChargingInfo->version);
                             pAcChargingInfo->SelfTest_Comp = YES;
                         } else {
                             evInitFlag = NO;
@@ -190,47 +190,24 @@ void SelfTestRun(void)
         case _STEST_AC_CONTACTOR:
             //ShmPsuData->Work_Step = _TEST_COMPLETE;
             // 因為 30KW 以下沒有 Relay feedback 功能,所以暫時先直接跳過
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
             pSysInfo->SelfTestSeq = _STEST_PSU_DETECT;
             //log_info("Waiting for DO communication");
             break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
-
-            if (pSysInfo->AcContactorStatus == YES) {
-                pSysInfo->SelfTestSeq = _STEST_PSU_DETECT;
-                log_info("AC contactor self test OK");
-            }
-            break;
 
         case _STEST_PSU_DETECT:
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
             pSysInfo->SelfTestSeq = _STEST_PSU_CAP;
             break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
-
-            if (ShmPsuData->Work_Step >= GET_SYS_CAP) {
-                pSysInfo->SelfTestSeq = _STEST_PSU_CAP;
-            }
-            break;
 
         case _STEST_PSU_CAP:
             // 此測試是要確認當前總輸出能力
             // 如果沒有 PSU 模組請 bypass
 
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
             //check the power limit from DO
             pSysInfo->SelfTestSeq = _STEST_COMPLETE;
             pSysInfo->BootingStatus = BOOT_COMPLETE;
             log_info("Successful Self Test");
             break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
 
-            if (ShmPsuData->Work_Step == BOOTING_COMPLETE) {
-                sleep(1);
-                pSysInfo->SelfTestSeq = _STEST_COMPLETE;
-                pSysInfo->BootingStatus = BOOT_COMPLETE;
-            }
-            break;
         }
 
         usleep(100000);

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 105 - 441
EVSE/Projects/DD360Tcci/Apps/CSU/main.c


+ 10 - 8
EVSE/Projects/DD360Tcci/Apps/CSU/main.h

@@ -12,11 +12,7 @@
 #define MAX_BUF                                 (64)
 #define SYSFS_GPIO_DIR                          "/sys/class/gpio"
 #define UPGRADE_FAN                             (0x02)
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
-#define UPGRADE_RB                              (0x09) //0x09 for DD360 dispenser
-#else
-#define UPGRADE_RB                              (0x03) //other module use
-#endif //defined DD360 ||defined DD360Audi || defined DD360ComBox
+#define UPGRADE_RB                              (0x09) //0x09 for DD360Tcci dispenser
 #define UPGRADE_PRI                             (0x04)
 #define UPGRADE_AC                              (0x05)
 #define UPGRADE_LED                             (0x06)
@@ -31,11 +27,12 @@
 
 #define uSEC_VAL                                (1000000)
 #define SELFTEST_TIMEOUT                        (60)//45
+#define RETURN_VIEWPAGE_TIMEOUT                 (120)
 #define AUTHORIZE_TIMEOUT                       (30)//30
 #define BALANCE_TIMEOUT                         (15)//15
-#define AUTHORIZE_COMP_TIMEOUT                  (3)
-#define AUTHORIZE_FAIL_TIMEOUT                  (3)
+#define AUTHORIZE_FAIL_TIMEOUT                  (120)
 #define AUTHORIZE_STOP_TIMEOUT                  (30)
+#define LINKERROR_TIMEOUT						(120)
 #define RETURN_TO_CHARGING_PAGE                 (30)
 #define GUN_PREPARE_TIMEOUT                     (30)
 #define GUN_EV_WAIT_TIMEOUT                     (120)
@@ -43,8 +40,12 @@
 #define GUN_COMP_WAIT_TIMEOUT                   (10)
 #define GUN_PRECHARGING_TIMEOUT                 (60)
 #define EVCCID_LINK_TIMEOUT                     (120)
-
+#define CONN_PLUG_TIMEOUT                       (40)
+#define DETAILVIEW_TIMEOUT                      (30)
+#define TERMINATING_TIMEOUT                     (120)
 #define WHILE_LOOP_TIME                         (10000)
+#define PRECHARGING_TTIMEOUT                    (60)
+#define PLUGOUTGUN_TIMEOUT                      (30)
 
 //#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)
@@ -77,6 +78,7 @@ void AuthorizingStart(void);
 bool IsAuthorizingMode(void);
 bool isAuthorizedComplete(void);
 void ClearAuthorizedFlag(void);
+void ClearDetectPluginFlag(void);
 
 void ChargingAlarmProcess(uint8_t gunIndex);
 void StopChargingProcessByString(uint8_t level);

+ 71 - 23
EVSE/Projects/DD360Tcci/Apps/Config.h

@@ -135,24 +135,41 @@ enum _GUN_TYPE {
     _Type_GB,
     _Type_AC,
 };
-
-enum _LCM_INDEX {
-    _LCM_INIT          = 0x00,
-    _LCM_IDLE          = 0x01,
-    _LCM_AUTHORIZING   = 0x02,
-    _LCM_AUTHORIZ_COMP = 0x03,
-    _LCM_AUTHORIZ_FAIL = 0x04,
-    _LCM_WAIT_FOR_PLUG = 0x05,
-    _LCM_PRE_CHARGE    = 0x06,
-    _LCM_CHARGING      = 0x07,
-    _LCM_COMPLETE      = 0x08,
-    _LCM_FIX           = 0x09,
-    _LCM_SELECT_GUN    = 0x0A,
-    _LCM_EMERGENCY     = 0x0B,
-    _LCM_DISCONNECT    = 0x0C,
-    _LCM_NONE          = 0xFF,
+enum _CCS_GUN_TYPE {
+    _TYPE_CCS_NONE  = 0,
+    _TYPE_CCS1_Natural,
+    _TYPE_CCS1_Liquid,
+    _TYPE_CCS2_Natural,
+    _TYPE_CCS2_Liquid,
 };
 
+enum _PAGE_TCC_INDEX {
+    _PAGE_NONE                   = 0x00,
+    _PAGE_IDLE,
+    _PAGE_AUTHORIZE,
+    _PAGE_PLUGIN,
+    _PAGE_PRECHARGE,
+    _PAGE_CHARGING,
+    _PAGE_COMPLETE,
+    _PAGE_FUNCTION_SELECT,
+    _PAGE_REFUND_SENSEING,
+    _PAGE_REFUNDING,
+    _PAGE_REFUND_COMPLETE,
+    _PAGE_REFUND_NONE,
+    _PAGE_MEMBER_SELECT,
+    _PAGE_MEMBER_QR,
+    _PAGE_DONATE,
+    _PAGE_DONATE_SELECT,
+    _PAGE_PAY_SENSING,
+    _PAGE_PAY_ETICKET_SUCCESS,
+    _PAGE_PAY_MPAY_SUCCESS,
+    _PAGE_PAY_FAIL,
+    _PAGE_MAINTAIN,
+    _PAGE_ERROR,
+
+    __SHOW_CABIENT_VERSION,
+    __SHOW_DISPENSER_VERASION,
+};
 enum _SELF_TEST_SEQ {
     _STEST_VERSION      = 0x00,
     _STEST_AC_CONTACTOR = 0x01,
@@ -268,11 +285,6 @@ enum _CCS_TYPE {
     _CCS_TYPE_CCS2 = 1,
 };
 
-enum _LCM_UPGRADE_RESULT {
-    _LCM_UPGRADE_RESULT_WAIT = 0,
-    _LCM_UPGRADE_RESULT_PASS,
-    _LCM_UPGRADE_RESULT_FAIL,
-};
 //------------------------------------------------------------------------------
 //struct StructMeter {
 //    float curMeterValue;
@@ -338,12 +350,12 @@ typedef union {
     struct {
         uint8_t EmergencyStop: 1;    //Power cabinet emergency stop
         uint8_t DoorOpen: 1;         //Power cabinet emergency door open
-        uint8_t DcInputOVP: 1;      // Power cabient DC OVP
+        uint8_t DcInputOVP: 1;
+        uint8_t DcInputUVP: 1;
         uint8_t SystemL1InputOVP: 1; //Power cabinet system L1 input OVP
         uint8_t SystemL2InputOVP: 1; //Power cabinet System L2 input OVP
         uint8_t SystemL3InputOVP: 1; //Power cabinet System L3 input OVP
         uint8_t PsuFailure: 1;       //Power cabinet PSU Failure Alarm
-        uint8_t Reserved: 1;
     } StatusBit;
 } PowerAlarmState;
 
@@ -368,6 +380,18 @@ typedef struct StPcPsuOutput { //from power cabinet PSU output
     uint16_t Current;
 } PcPsuOutput;
 
+typedef struct Psu_VersionInfo{
+	uint8_t n_PSU;
+	uint8_t DCVersion[32];
+	uint8_t FPCVersion[32];
+}PsuVerInfo;
+
+enum _LCM_UPGRADE_RESULT {
+    _LCM_UPGRADE_RESULT_WAIT = 0,
+    _LCM_UPGRADE_RESULT_PASS,
+    _LCM_UPGRADE_RESULT_FAIL,
+};
+
 typedef struct StDcCommonInfo {
     uint8_t RebootCount;
     uint8_t CcsVersion;
@@ -387,6 +411,30 @@ typedef struct StDcCommonInfo {
     uint8_t _upgrade_lcm_flag;
     uint8_t _upgrade_lcm_result;
     uint8_t Reserved[1];
+    // Power Cabinet Version
+    uint8_t CabinetModelName[32];
+    uint8_t CabinetBoolLoaderVersion[32];
+    uint8_t CabinetKernelVersion[32];
+    uint8_t CabinetRFSystemVersion[32];
+    uint8_t CabinetPrimaryVersion[32];
+    uint8_t CabinetIPAddr[32];
+    uint8_t CabinetRelay0Version[32];
+    uint8_t CabinetRelay1Version[32];
+    uint8_t CabinetFanVersion[32];
+    // PSU Version
+    uint8_t PSU_Number;
+    PsuVerInfo PsuVer[12];
+    // Touch press
+    uint8_t TouchId;
+    // TCC Using
+    uint8_t _ChangeLCMRequest;
+    uint8_t _RefundRequest;
+    uint8_t _RefundCancel;
+    uint8_t _InvoiceRequest;
+    // TCC Payment fail
+    int                 PaymentFailId;
+    unsigned char       PaymentFailString[32];
+
 } DcCommonInfo;
 
 #endif /* CONFIG_H_ */

+ 7 - 7
EVSE/Projects/DD360Tcci/Apps/Define/define.c

@@ -103,8 +103,8 @@ char FaultStatusCode[40][6]=
 "011036", //Rotary switch fault
 "011037", //CCS liquid chiller water level fault
 "011038", //Chiller temperature sensor broken
-"011039", //Reserved
-"011040" //Reserved
+"011039", //Parallel relay welding
+"011040"  //Parallel output relay driving fault
 };
 
 char AlarmStatusCode[160][6]=
@@ -233,11 +233,11 @@ char AlarmStatusCode[160][6]=
 "012321", // System CCS output UCP
 "012322", // System GBT output UCP
 "012323", // System Chiller output OTP
-"012324", // reserved
-"012325", // reserved
-"012326", // reserved
-"012327", // reserved
-"012328",   // reserved
+"012324", // Connector 1 detects abnormal voltage on the output line
+"012325", // Connector 2 detects abnormal voltage on the output line
+"012326", // System task is lost
+"012327", // DC input ovp
+"012328", // DC input uvp
 "012329",   // reserved
 "012330",   // reserved
 "012331",   // reserved

+ 71 - 29
EVSE/Projects/DD360Tcci/Apps/Define/define.h

@@ -63,6 +63,15 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
     #define GENERAL_GUN_QUANTITY    0
     #define PSU_QUANTITY            0
     #define ONE_CONNECTOR_USE       0
+#elif defined NoodoeAX
+    #define MAX_PSU_QUANTITY        62
+    #define CHAdeMO_QUANTITY        1
+    #define CCS_QUANTITY            1
+    #define GB_QUANTITY             0
+    #define AC_QUANTITY             1
+    #define GENERAL_GUN_QUANTITY    0
+    #define PSU_QUANTITY            0
+    #define ONE_CONNECTOR_USE       0
 #elif defined AX80
     #define MAX_PSU_QUANTITY        62
     #define CHAdeMO_QUANTITY        1
@@ -117,7 +126,7 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
     #define GENERAL_GUN_QUANTITY	0
     #define PSU_QUANTITY            2
     #define ONE_CONNECTOR_USE       0
-#elif defined DD360 || defined DD360Audi || defined DD360ComBox || defined DD360UCar
+#elif defined DD360 || defined DD360Audi || defined DD360ComBox || defined DD360UCar || defined DD360Tcci
     #define MAX_PSU_QUANTITY        62
     #define CHAdeMO_QUANTITY        2
     #define CCS_QUANTITY            2
@@ -312,6 +321,8 @@ enum CoreProfile {
      TimeOffsetNextTransition,
      SystemUptimeSec,
      FreeVend,
+     OcppServer,
+     MaintainServer,
      ConfigurationVersion,
 	 _CoreProfile_CNT
 };
@@ -450,7 +461,10 @@ typedef union
         unsigned int AlarmStop:1;                   // 0: no effect,    1: alarm stop
         unsigned int BackendStop:1;                 // 0: no effect,    1: backend stop
         unsigned int ManualStop:1;                  // 0: no effect,    1: manual stop
-        unsigned int res:28;
+        unsigned int HardResetStop:1;               // 0: no effect,    1: hard reset stop
+        unsigned int SoftResetStop:1;               // 0: no effect,    1: soft reset stop
+        unsigned int InvalidIdStop:1;               // 0: no effect,    1: invalid stop when StopTransactionOnInvalidId is true
+        unsigned int res:25;
     }bits;
 }ChargingStop;
 
@@ -658,8 +672,38 @@ struct ChargingInfoData
     unsigned char       Replug_flag;
     unsigned char       isEVCCIDVerify;
     unsigned char       CCSGunType;
+    //Reservation
+    int                 ReservationTrigger;
+    // TCC
+    struct timeval      PreChargeTimer;
+    unsigned char       _SaftyDetect;
+    // TCC Change LCM Page
+    int                 ChangeLcmPage;
+    // TCC Refund
+    unsigned char       RefundDate[32];
+    float               Prepayment;
+    float               ActualCost;
+    float               RefundAmount;
+    // TCC Prepayment
+    unsigned char       CardType;                       // EasyCard or i-pass or icash
+    float               TopupMoney;
+    float               AccountAmount;
+    float               Balance;
+
 };
 
+typedef struct
+{
+    unsigned char       AuthId[32];
+                                                        // 0: Authorize idle, 1: Authorize wait,   2: Authorizing
+    unsigned char       AuthStatus;                     // 3: Authorize done, 4: Authorize end
+    unsigned char       AuthTarget;                     // Authorize Target Connector ID: 1 ~ 4, AutoSelection: 0xFF
+    unsigned char       AuthType;                       // 0: _AuthType_None,   1: _AuthType_RFID, 2: _AuthType_RemoteStart
+    unsigned char       AuthResult;                     // 0: _AuthResult_None, 1: _AuthResult_Valid,   2: _AuthResult_Invalid
+    unsigned char       AuthRequest;                    // 0: no request, 1: authorize request
+    unsigned char       res;
+}AuthorizingInfoData;
+
 typedef union
 {
     unsigned int SettingValue;
@@ -670,7 +714,6 @@ typedef union
         unsigned int DispenserConfigSync:1;             // 0: not synced,   1: synced
         unsigned int MiscNeedAnnouncement:1;            // 0: no need,      1: need send misc command
         unsigned int NeedDispenserVerInfo:1;            // 0: no need,      1: need dispenser to report it's version info
-        unsigned int EnableAutoGunSelection:1;          // 0: disable,      1: enable auto gun selection
         unsigned int AuthorizeRequest:1;                // 0: idle,         1: requesting                           ( dispenser -> cabinet)
         unsigned int ConnectorTimeoutConfigRequest:1;   // 0: no request,   1: connector timeout setting            (    ocpp   -> cabinet -> dispenser)
         unsigned int DefaultPriceConfigRequest:1;       // 0: no request,   1: default price setting                (    ocpp   -> cabinet -> dispenser)
@@ -690,6 +733,7 @@ typedef union
         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:7;
     }bits;
 }DispenserSettingFlag;
@@ -727,11 +771,7 @@ struct DispenserModule
     unsigned char   Connector2FwRev[32];        //Connector2 module firmware version
     struct   LED    LedInfo;                    // LED configuration info
 
-                                                // 0: Authorize idle, 1: Authorize wait,   2: Authorizing
-    unsigned char           AuthStatus;         // 3: Authorize done, 4: Authorize end
-    unsigned char           AuthTarget;         // Authorize Target Connector ID: 1 ~ 4, AutoSelection: 0xFF
-    unsigned char           AuthType;           // 0: _AuthType_None, 1: _AuthType_RFID, 2: _AuthType_RemoteStart
-    unsigned char           AuthResult;         // 0: _AuthResult_None, 1: _AuthResult_Valid,   2: _AuthResult_Invalid
+    AuthorizingInfoData     AuthInfo;
     DispenserSettingFlag    Setting;
     char                    FwFileName[128];
     unsigned char           ConnectionChannel;
@@ -812,7 +852,8 @@ typedef union
         unsigned int  FaultStatusRequest:1;
         unsigned int  Disconnection:1;
         unsigned int  GfdDetection:1;                   // 0: stop,         1: start
-        unsigned int  res:9;
+        unsigned int  GetStartChargingSoc:1;            // 0: no effect,    1: get start soc
+        unsigned int  res:8;
     }bits;
 }ConnectorParameter;
 
@@ -824,8 +865,7 @@ struct ConnectorInfoData
     unsigned char ParentDispensetIndex;                 // Parent Dispenser Index: 0 ~ 3
     ConnectorParameter       Parameter;
 
-    unsigned char            AuthorizingType;
-    unsigned char            AuthorizingResult;         // 0: _AuthResult_None, 1: _AuthResult_Valid,   2: _AuthResult_Invalid
+    AuthorizingInfoData      AuthInfo;
     struct ChargingInfoData  GeneralChargingData;
     struct WARNING_CODE_INFO WarningInfo;
 
@@ -844,8 +884,11 @@ struct ConnectorInfoData
 
     unsigned short          MaxTotalChargingCurrent;        // max total output current, unit: 0.1A
     unsigned short          MaxTotalChargingPower;          // max total output power, unit: 0.1kw
-    unsigned short          MaxOutputEnergy;                //0: no limit,  1 ~ 65535   kWh
-    unsigned short          MaxOutputDuration;              //0: no limit,  1 ~ 65535   minutes
+    unsigned short          MaxOutputEnergy;                // 0: no limit,  1 ~ 65535   kWh
+    unsigned short          MaxOutputDuration;              // 0: no limit,  1 ~ 65535   minutes
+    float                   CapabilityVoltage;              // unit 0.1V
+    float                   CapabilityCurrent;              // unit 0.1A
+    float                   CapabilityPower;                // unit 0.1kW
 
     unsigned int            UserPrice;                      // connector user's user price, unit: 0.01 (dollar / kWh)
     unsigned int            TotalCost;                      // connector user's total cost, unit: 0.01 dollar
@@ -857,14 +900,11 @@ typedef union
     unsigned int SettingValue;
     struct
     {
-        unsigned int StartAuthorize:1;          // 0: idle,    1: authorizing
-        unsigned int AuthorizingCompleted:1;    // 0: not yet, 1: authorizing completed
         unsigned int DispenserDisconnection:1;  // 0: no connection,  1: dispenser connected
-        unsigned int BackendAuthorized:1;       // 0: local authorized, 1: backend authorized
         unsigned int FlashConfigChanged:1;      // 0: no effect, 1: flash config has changed
         unsigned int EnableWriteFlash:1;        // 0: no effect, 1: enable to write flash after timeout
         unsigned int CleanWiringInfo:1;         // 0: no effect, 1: clean wiring info
-        unsigned int res:25;
+        unsigned int res:28;
     }bits;
 }CabinetSettingFlag;
 
@@ -990,7 +1030,7 @@ struct SysInfoData
     CabinetMiscCommand      CabinetMicsStatus;
     struct LocalSharingInfo localSharingInfo;           // Local power sharing info structure
     DC_Meter_Info DcMeterInfo[4];
-    unsigned char           OTPTemp;                    // OTP Temperature 
+    unsigned char           OTPTemp;                    // OTP Temperature
     unsigned char           OTPTempR;                   // OTP Recovery Temperature
 };
 
@@ -1116,8 +1156,8 @@ char FaultStatusCode[40][6]=
 	"011036",	//Rotary switch fault
 	"011037",	//CCS liquid chiller water level fault
 	"011038",	//Chiller temperature sensor broken
-	"011039",	//Reserved
-	"011040"	//Reserved
+	"011039",	//Parallel relay welding
+	"011040"	//Parallel output relay driving fault
 };
 */
 
@@ -1172,7 +1212,8 @@ struct FaultCodeData
 			unsigned char RotarySwitchFault:1;					//bit 3 
 			unsigned char CcsLiquidChillerWaterLevelFault:1;    //bit 4
             unsigned char ChillerTempSensorBroken:1;            //bit 5
-            unsigned char :2;                                   //bit 6 ~ 7 reserved
+            unsigned char ParallelRelayWelding:1;               //bit 6
+            unsigned char ParallelRelayDriving:1;               //bit 7
 		}bits;
 	}FaultEvents;
 };
@@ -1308,7 +1349,7 @@ char AlarmStatusCode[160][6]=
     "012325",   // Connector 2 detects abnormal voltage on the output line
     "012326",   // System task is lost
     "012327",   // DC input ovp
-    "012328",   // reserved
+    "012328",   // DC input uvp
     "012329",   // reserved
     "012330",   // reserved
     "012331",   // reserved
@@ -1495,7 +1536,8 @@ struct AlarmCodeData
             unsigned char SystemTaskLost:1;                         //bit 6
             unsigned char DcInputOVP:1;                             //bit 7
             //AlarmVal[16]
-            unsigned char :8;                                       //reserved bit 0 ~ bit 7
+            unsigned char DcInputUVP:1;                             //bit 0
+            unsigned char :7;                                       //reserved bit 1 ~ bit 7
             //AlarmVal[17]
             unsigned char :8;                                       //reserved bit 0 ~ bit 7
             //AlarmVal[18]
@@ -4387,7 +4429,7 @@ struct OCPP16ConfigurationItem
 {
 	unsigned char 		ItemName[64];
 	unsigned char 		ItemAccessibility;//0:RO, 1:RW
-	unsigned char 		ItemData[500];
+	unsigned char 		ItemData[501];//value should be limited in 500 bytes
 };
 
 struct OCPP16ConfigurationTable
@@ -4567,9 +4609,9 @@ struct StructSignedFirmwareStatusNotification
 
 struct StructSessionTarget
 {
-	unsigned char		targetSoc;			// Unit: %,   		0 is unlimit
-	unsigned short		targetEnergy;		// Unit: KWH		0 is unlimit
-	unsigned short		targetDuration;		// Unit: Minutes	0 is unlimit
+    unsigned char       targetSoc;          // Unit: %,         0 is unlimit
+    unsigned short      targetEnergy;       // Unit: KWH        0 is unlimit
+    unsigned short      targetDuration;     // Unit: Minutes    0 is unlimit
 };
 
 struct OCPP16Data
@@ -4760,7 +4802,7 @@ struct OCPP16Data
     struct StructSecurityEventNotification          SecurityEventNotification;
     struct StructSignCertificate                    SignCertificate;
     struct StructSignedFirmwareStatusNotification   SignedFirmwareStatusNotification;
-    struct StructSessionTarget	                    SessionTarget[CONNECTOR_QUANTITY];
+    struct StructSessionTarget                      SessionTarget[CONNECTOR_QUANTITY];
 };
 
 
@@ -6139,7 +6181,7 @@ struct OCPP20Data
 	struct UpdateFirmware_20					UpdateFirmware;
 	struct ChargingProfileType                  SmartChargingProfile[CONNECTOR_QUANTITY];
 	struct ChargingProfileType                  MaxChargingProfile;
-	struct StructSessionTarget	                SessionTarget[CONNECTOR_QUANTITY];
+	struct StructSessionTarget                  SessionTarget[CONNECTOR_QUANTITY];
 };
 
 

+ 4 - 8
EVSE/Projects/DD360Tcci/Apps/Makefile

@@ -39,7 +39,6 @@ PrimaryLib = $(TOP)/ModulePrimary
 LcmLib = $(TOP)/ModuleLcmCtrl
 DoCommLib = $(TOP)/ModuleDoComm
 EventLogLib = $(TOP)/ModuleEventLog
-SelectGunLib = $(TOP)/SelectGun
 ScriptLib = $(TOP)/Script
 
 
@@ -67,9 +66,7 @@ InfypwrPsuComm_A = $(ModularizationPath)/libInfypwr_PsuCommObj.a
 COMMON_OBJ_FILES = common.o \
 					$(DefineLib)/define.o \
 					$(ShmMemLib)/shmMem.o \
-					$(LogLib)/log.o \
-					$(SelectGunLib)/SelectGun.o \
-
+					$(LogLib)/log.o 
 
 MAIN_OBJ_FILES = $(COMMON_OBJ_FILES) $(DataBaseLib)/DataBase.o \
 					$(CSULib)/main.o  $(CSULib)/Primary.o $(CSULib)/WatchDog.o $(CSULib)/ZipFile.o \
@@ -102,7 +99,7 @@ EVCOMM_SRC_FILES = $(patsubst %.o, %.c, $(EVCOMM_OBJ_FILES))
 	$(CC) $(CFLAGS) -c $<
 
 #Update FW
-UPDATEFW_OBJ_FILES = $(COMMON_OBJ_FILES) $(UpdateFWLib)/Module_UpdateFW.o
+UPDATEFW_OBJ_FILES = $(COMMON_OBJ_FILES) $(UpdateFWLib)/Module_UpdateFW.o 
 UPDATEFW_SRC_FILES = $(patsubst %.o, %.c, $(UPDATEFW_OBJ_FILES))
 %.o: %.c
 	$(CC) $(CFLAGS) -c $<
@@ -128,7 +125,7 @@ EVENTLOG_SRC_FILES = $(patsubst %.o, %.c, $(EVENTLOG_OBJ_FILES))
 
 #LCM Control
 LCM_OBJ_FILES = $(COMMON_OBJ_FILES) $(LcmLib)/Module_LcmControl.o \
-				$(LcmLib)/cbmp.o
+				$(LcmLib)/Lcm_Update.o $(LcmLib)/cbmp.o
 LCM_SRC_FILES = $(patsubst %.o, %.c, $(LCM_OBJ_FILES))
 %.o: %.c
 	$(CC) $(CFLAGS) -c $<
@@ -204,8 +201,7 @@ LcmControlTask:
 	$(CC) $(DEFINE) $(LCM_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) -o Module_LcmControl
 	#$(CC) $(DEFINE) $(CFLAGS) -c -o define.o $(DefineLib)/define.c
 	#$(CC) $(DEFINE) $(CFLAGS) -c -o Module_LcmControl.o $(LcmLib)/Module_LcmControl.c
-	#$(CC) $(DEFINE) $(CFLAGS) -c -o cbmp.o $(LcmLib)/cbmp.c
-	#$(CC) -o Module_LcmControl Module_LcmControl.o define.o cbmp.o
+	#$(CC) -o Module_LcmControl Module_LcmControl.o define.o
 
 PrimaryCommTask:
 	$(CC) $(DEFINE) $(PRIMARY_SRC_FILES) $(CFLAGS) $(TFLAGS) $(INC_FLAGS) -o Module_PrimaryComm

+ 0 - 1
EVSE/Projects/DD360Tcci/Apps/ModuleChkSysTask/Module_ChkSysTask.c

@@ -191,7 +191,6 @@ void CheckSystemTaskAlive()
 {
     unsigned char lostId = CheckSystemTask(ShmSysConfigAndInfo->SysInfo.SystemPage);
     if (lostId != 0) {
-        log_error("Check task(%d) lost",lostId);
         if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemTaskLost == NO) {
            if (lostId == _SYSTEM_TASK_LOST_ITEM_MAIN)
                log_error("System task lost (CSU). ");

+ 1 - 1
EVSE/Projects/DD360Tcci/Apps/ModuleChkSysTask/Module_ChkSysTask.h

@@ -52,7 +52,7 @@
 #define _SYSTEM_TASK_COUNT_INTERNALCOMM     2
 #define _SYSTEM_TASK_COUNT_EVENTLOGGING     1
 #define _SYSTEM_TASK_COUNT_PRIMARYCOMM      1
-#define _SYSTEM_TASK_COUNT_LCM              1
+#define _SYSTEM_TASK_COUNT_LCM              2
 #define _SYSTEM_TASK_COUNT_DOCOMM           1
 #define _SYSTEM_TASK_COUNT_PRODUCEUTILS     1
 #define _SYSTEM_TASK_COUNT_UPDATEFW         1

+ 336 - 34
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.c

@@ -49,7 +49,7 @@ static struct WARNING_CODE_INFO gPreSysWarningInfo = {0};
 
 // Hexdump
 char old_Hexdump[10240];
-
+uint8_t psu_num= 0;
 //------------------------------------------------------------------------------
 static void removeFaultCodeToBuf(uint8_t *Code);
 static void addFaultCodeToBuf(uint8_t *Code);
@@ -673,7 +673,6 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
             }
             log_info("Remote start charging plugNum = %d", plugNum);
 
-#if defined DD360Audi
             if (getSelGunWaitToAuthor(plugNum) == FAIL) {
                 log_error("Remote start gun already charging");
                 break;
@@ -687,7 +686,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                     strcpy((char *)pSysConfig->UserId, "");
                     pSysInfo->WaitForPlugit = NO;
                     sleep(1); //Jerry add
-                    pSysInfo->SystemPage = _LCM_SELECT_GUN;
+                    pSysInfo->SystemPage = _PAGE_AUTHORIZE;
                     GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
                     pSysInfo->SystemTimeoutFlag = Timeout_None;
                 }
@@ -699,18 +698,15 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                     strcpy((char *)pSysConfig->UserId, "");
                     pSysInfo->WaitForPlugit = NO;
                     sleep(1); //Jerry add
-                    pSysInfo->SystemPage = _LCM_SELECT_GUN;
+                    pSysInfo->SystemPage = _PAGE_AUTHORIZE;
                     GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
                     pSysInfo->SystemTimeoutFlag = Timeout_None;
                 }
 
-                pSysInfo->CurGunSelected = (plugNum);
+                //pSysInfo->CurGunSelected = (plugNum);
                 pSysInfo->CurGunSelectedByAc = NO_DEFINE;
             }
-#else
-            pSysInfo->CurGunSelected = (plugNum);
-            pSysInfo->CurGunSelectedByAc = NO_DEFINE;
-#endif //DD360Audi
+
             setConfirmSelGun(pSysInfo->CurGunSelected);
 
             ShmOCPP16Data->CsMsg.bits[plugNum].RemoteStartTransactionReq = YES;
@@ -728,7 +724,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
 
             strcpy((char *)pSysConfig->UserId, "");
             pSysInfo->WaitForPlugit = NO;
-            pSysInfo->SystemPage = _LCM_SELECT_GUN;
+            pSysInfo->SystemPage = _PAGE_COMPLETE;
             GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
             pSysInfo->SystemTimeoutFlag = Timeout_None;
             destroySelectGun(plugNum);
@@ -748,7 +744,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 ClearDetectPluginFlag();
                 strcpy((char *)pSysConfig->UserId, "");
                 pSysInfo->WaitForPlugit = NO;
-                pSysInfo->SystemPage = _LCM_SELECT_GUN;
+                pSysInfo->SystemPage = _PAGE_COMPLETE;
                 GetClockTime(&pSysInfo->SystemTimeoutTimer, NULL);
                 pSysInfo->SystemTimeoutFlag = Timeout_None;
                 destroySelectGun(plugNum);
@@ -768,7 +764,16 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
             log_info("Authorize By EVCCID:%d",pSysConfig->isAuthrizeByEVCCID);
             //clearMiscCommand();
         	break;
-
+        case MISC_CMD_LED_INTENSITY:
+            pSysConfig->LedInfo.Intensity = value;
+            log_info("LED Intensity:%d",pSysConfig->LedInfo.Intensity);
+            break;
+        case MISC_CMD_RESERVATION:
+            pDcChargingInfo->ReservationTrigger = value;
+            break;
+        case MISC_CMD_CHANGELCM_INFO:
+            pDcChargingInfo->ChangeLcmPage = value;
+            break;
         default:
             clearMiscCommand();
             break;
@@ -912,7 +917,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     //uint8_t statusCodeError = 0;
 
     if (dataLen > 0) {
-        Hexdump((uint8_t *)data, dataLen);
+        //Hexdump((uint8_t *)data, dataLen);
 
         remaindLen = dataLen % WARNING_CODE_SIZE;
 
@@ -923,7 +928,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
 
         if (dataLen < WARNING_CODE_SIZE) {
             log_error("fail status code length = %d", dataLen);
-            Hexdump(data, dataLen);
+            //Hexdump(data, dataLen);
             if (pSysWarning->WarningCount > 0) {
                 for (i = 0; i < pSysWarning->WarningCount; i++) {
                     usleep(128);
@@ -993,7 +998,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     } else {
         if (CompareArrayIsZero(data, WARNING_CODE_SIZE) == false) {
             log_error("power cabinet status code data length is zero, but have data");
-            Hexdump((uint8_t *)data, WARNING_CODE_SIZE);
+            //Hexdump((uint8_t *)data, WARNING_CODE_SIZE);
         }
     }
 
@@ -1027,7 +1032,29 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
 
     return PASS;
 }
-
+void GetCabientDcmRevHandle(uint8_t *data)
+{
+	PCDCMVer *pVersion = (PCDCMVer *)&data[0];
+	strcpy(ShmDcCommonData->CabinetModelName , pVersion->CabinetModelName);
+	strcpy(ShmDcCommonData->CabinetBoolLoaderVersion, pVersion->CabinetBoolLoaderVersion);
+	strcpy(ShmDcCommonData->CabinetKernelVersion , pVersion->CabinetKernelVersion);
+	strcpy(ShmDcCommonData->CabinetRFSystemVersion , pVersion->CabinetRFSystemVersion);
+	strcpy(ShmDcCommonData->CabinetPrimaryVersion , pVersion->CabinetPrimaryVersion);
+	strcpy(ShmDcCommonData->CabinetIPAddr , pVersion->CabinetIPAddr);
+}
+void GetCabientOtherRevHandle(uint8_t *data)
+{
+	PCOthVer *pVersion = (PCOthVer *)&data[0];
+	strcpy(ShmDcCommonData->CabinetRelay0Version , pVersion->CabinetRelay0Version);
+	strcpy(ShmDcCommonData->CabinetRelay1Version , pVersion->CabinetRelay1Version);
+	strcpy(ShmDcCommonData->CabinetFanVersion , pVersion->CabinetFanVersion);
+}
+void GetCabientEachPsuRevHandle(uint8_t *data)
+{
+	PCnPsuVer *pVersion = (PCnPsuVer *)&data[0];
+	strcpy(ShmDcCommonData->PsuVer[pVersion->n_PSU].DCVersion, pVersion->DCVersion);
+	strcpy(ShmDcCommonData->PsuVer[pVersion->n_PSU].FPCVersion, pVersion->FPCVersion);
+}
 static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_t reg)
 {
     int ret = PASS;
@@ -1169,7 +1196,21 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
             pDcChargingInfo->GroundFaultStatus = gfd->Status;
         }
         break;
-
+    case REG_GET_CABINET_DCM_VERSION:
+    	GetCabientDcmRevHandle(pCsuResult->Data.Data);
+        break;
+    case REG_GET_CABINET_OTHER_VERSION:
+    	GetCabientOtherRevHandle(pCsuResult->Data.Data);
+        break;
+    case REG_GET_CABINET_PSU_NUMBER:
+        if(ShmDcCommonData->PSU_Number == 0 || ShmDcCommonData->PSU_Number != pCsuResult->Data.Data[0]) {
+            ShmDcCommonData->PSU_Number = pCsuResult->Data.Data[0];
+            log_info("PSU Numbers:%d",ShmDcCommonData->PSU_Number);
+        }
+        break;
+    case REG_GET_CABINET_PSU_VERSION:
+    	GetCabientEachPsuRevHandle(pCsuResult->Data.Data);
+        break;
     default:
         break;
     }
@@ -1206,6 +1247,13 @@ static int composeSocketData(int fd,
 
     //Hexdump((uint8_t *)&csuCmdPkt, sendPktLen);
 
+    // Not Let ask cabinet version trasmit into FAIL Network
+
+    if (reg == REG_GET_CABINET_DCM_VERSION || reg == REG_GET_CABINET_OTHER_VERSION ||
+    		reg == REG_GET_CABINET_PSU_NUMBER || reg == REG_GET_CABINET_PSU_VERSION) {
+    	gDoCommGblData.DisConnCount = 0;
+    }
+
     //send command packet
     if ((size = sendTcpSocket(fd, (uint8_t *)&csuCmdPkt, sendPktLen)) < 0) {
         log_error("TCP socket send packet fail = %d", size);
@@ -1417,6 +1465,7 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
 
     pConnState->ConnectorTemp = pDcChargingInfo->ConnectorTemp;
     pConnState->ChillerTemp = pDcChargingInfo->ChillerTemp;
+    pConnState->PlugIn = pDcChargingInfo->ConnectorPlugIn;
 
     if (pDcChargingInfo->SystemStatus <= S_AUTHORIZING) {
         pConnState->State = CONN_ST_IDLE;    //idle
@@ -1425,6 +1474,7 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
                 sizeof(ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode));
 
         strncpy(&vendorErrorCodeTmp[plugNum][0], "", WARNING_CODE_SIZE);
+
     } else if ((pDcChargingInfo->SystemStatus <= S_PREPARING_FOR_EVSE) ||
                (pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST0) ||
                (pDcChargingInfo->SystemStatus == S_CCS_PRECHARGE_ST1)) {
@@ -1445,9 +1495,12 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
                     (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
                     WARNING_CODE_SIZE);
             vendorErrorCodeTmp[plugNum][6] = '\0';
-            log_info("1 ID = %d, VendorErrorCode = %s",
-                     plugNum,
-                     (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
+            /*
+                log_info("1 ID = %d, VendorErrorCode = %s",
+                         plugNum,
+                         (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
+                _VenderErrorCodeFlag = true;
+            */
         } else {
             if (strncmp(&vendorErrorCodeTmp[plugNum][0],
                         (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
@@ -1544,6 +1597,59 @@ static int readChargingCapability(int fd, uint8_t id)
     return ret;
 }
 
+static int readCabinetDCMVersion(int fd, uint8_t id)
+{
+    int ret = PASS;
+
+    ret = composeSocketData(fd,
+                            id,
+                            OP_READ_DATA,
+                            REG_GET_CABINET_DCM_VERSION,
+                            0,
+                            NULL);
+
+    return ret;
+}
+static int readCabinetOtherVersion(int fd, uint8_t id)
+{
+    int ret = PASS;
+
+    ret = composeSocketData(fd,
+                            id,
+                            OP_READ_DATA,
+							REG_GET_CABINET_OTHER_VERSION,
+                            0,
+                            NULL);
+
+    return ret;
+}
+static int readCabinetPSUNumber(int fd, uint8_t id)
+{
+    int ret = PASS;
+
+    ret = composeSocketData(fd,
+                            id,
+                            OP_READ_DATA,
+							REG_GET_CABINET_PSU_NUMBER,
+                            0,
+                            NULL);
+
+    return ret;
+}
+static int readCabinetEachPSUVersion(int fd, uint8_t id,uint8_t n_psu)
+{
+    int ret = PASS;
+    uint8_t data_buf[0] = {0};
+    data_buf[0] = n_psu;
+    ret = composeSocketData(fd,
+                            id,
+                            OP_READ_DATA,
+							REG_GET_CABINET_PSU_VERSION,
+							sizeof(data_buf),
+							&data_buf[0]);
+
+    return ret;
+}
 static int writeDispenserStatus(int fd, uint8_t gunID)
 {
     uint8_t warningCount = 0;
@@ -1608,7 +1714,62 @@ static int readConnectorID(int fd)
 
     return ret;
 }
+static int writeShowRefundPage(int fd, uint8_t id)
+{
+    int ret = PASS;
+    DispenserRequest* pDispenserRequest = NULL;
+
+    pDispenserRequest->Command = REQ_REFUND_REQUEST;
+    pDispenserRequest->Parameter = ntohl((uint32_t)ShmDcCommonData->_RefundRequest);
+
+    if ((ret = composeSocketData(fd,
+                                 id,
+                                 OP_WRITE_DATA,
+                                 REG_DISPENSER_REQUEST,
+                                 sizeof(DispenserRequest),
+                                 (uint8_t *)pDispenserRequest)) == FAIL) {
+        return ret;
+    }
+    ShmDcCommonData->_RefundRequest = FALSE;
+    return ret;
+}
+static int writeRefundCancelPage(int fd, uint8_t id)
+{
+    int ret = PASS;
+    DispenserRequest* pDispenserRequest = NULL;
+    pDispenserRequest->Command = REQ_REFUND_CANCEL;
+    pDispenserRequest->Parameter = ntohl((uint32_t)ShmDcCommonData->_RefundCancel);
+
+    if ((ret = composeSocketData(fd,
+                                 id,
+                                 OP_WRITE_DATA,
+                                 REG_DISPENSER_REQUEST,
+                                 sizeof(DispenserRequest),
+                                 (uint8_t *)pDispenserRequest)) == FAIL) {
+        return ret;
+    }
+    ShmDcCommonData->_RefundCancel = FALSE;
+    return ret;
+}
+static int writeShowInvociePage(int fd, uint8_t id)
+{
+    int ret = PASS;
+    DispenserRequest* pDispenserRequest = NULL;
+
+    pDispenserRequest->Command = REQ_INVOICE_REQUEST;
+    pDispenserRequest->Parameter = ntohl((uint32_t)ShmDcCommonData->_InvoiceRequest);
 
+    if ((ret = composeSocketData(fd,
+                                 id,
+                                 OP_WRITE_DATA,
+                                 REG_DISPENSER_REQUEST,
+                                 sizeof(DispenserRequest),
+                                 (uint8_t *)pDispenserRequest)) == FAIL) {
+        return ret;
+    }
+    ShmDcCommonData->_InvoiceRequest = FALSE;
+    return ret;
+}
 static int WriteModelName(int fd)
 {
     int ret = PASS;
@@ -1634,7 +1795,45 @@ static int WriteModelName(int fd)
 
     return ret;
 }
+static int readRefundAmount(int fd, uint8_t id)
+{
+    int ret = PASS;
+
+    ret = composeSocketData(fd,
+                            id,
+                            OP_READ_DATA,
+                            REG_GET_REFUND_AMOUNT,
+                            0,
+                            NULL);
+
+    return ret;
+}
+static int readPrepaymentInfo(int fd, uint8_t id)
+{
+    int ret = PASS;
+
+    ret = composeSocketData(fd,
+                            id,
+                            OP_READ_DATA,
+                            REG_GET_PREPAYMOUNT_INFO,
+                            0,
+                            NULL);
+
+    return ret;
+}
+static int readPrepaymentFail(int fd, uint8_t id)
+{
+    int ret = PASS;
 
+    ret = composeSocketData(fd,
+                            id,
+                            OP_READ_DATA,
+                            REG_GET_PREPAYMOUNT_FAIL_INFO,
+                            0,
+                            NULL);
+
+    return ret;
+}
 static void calDisconnectCount(uint8_t *pValue, uint8_t maxCount)
 {
     sleep(3); //wait 1 second
@@ -1708,7 +1907,7 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
 #if defined DD360Audi
     gunID = gDoCommGblData.ConnectorID[pSysInfo->CurGunSelected];
     //gunID = gDoCommGblData.ConnectorID[plugNum];
-    if (pSysConfig->AuthorisationMode) {
+    if (pSysConfig->AutoAuth_Disable) {
         gunID = ID_REGISTER;
         ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance = 0.0;
     }
@@ -1910,7 +2109,21 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         //    }
         //    isContinue = 0;
         //    break;
-
+        case REG_GET_RESERVATION_IDTAG:
+            break;
+        case REG_DISPENSER_REQUEST:
+            break;
+        case REG_GET_REMOTESTART_WITHOUTID:
+            break;
+        case REG_GET_REFUND_AMOUNT:
+            ShmDcCommonData->_ChangeLCMRequest = TRUE;
+            break;
+        case REG_GET_PREPAYMOUNT_INFO:
+            ShmDcCommonData->_ChangeLCMRequest = TRUE;
+            break;
+        case REG_GET_PREPAYMOUNT_FAIL_INFO:
+            ShmDcCommonData->_ChangeLCMRequest = TRUE;
+            break;
         default:
             log_error("error curReg = %x", curReg);
             gDoCommGblData.MiscCmd = 0;
@@ -1935,12 +2148,96 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
 //
 //    return NO;
 //}
-
+void TccProcess(int fd,uint8_t plugNum, uint8_t gunID)
+{
+    struct timeb AuthNowTime = {0};
+    switch (pSysInfo->SystemPage) {
+    case _PAGE_REFUNDING:
+        // To Get Refund Amount result
+        break;
+    case _PAGE_PAY_SENSING:
+        // To Get Invoice result
+        break;
+    case _PAGE_FUNCTION_SELECT:
+        if (ShmDcCommonData->_RefundRequest) {
+            ftime(&AuthNowTime);
+            if (DiffTimeb(gRegTimeUp[plugNum][REG_DISPENSER_REQUEST], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
+                    DiffTimeb(gRegTimeUp[plugNum][REG_DISPENSER_REQUEST], AuthNowTime) < 0
+               ) {
+                writeShowRefundPage(fd, gunID);
+                ftime(&gRegTimeUp[plugNum][REG_DISPENSER_REQUEST]);
+            }
+        }
+        break;
+    case _PAGE_REFUND_SENSEING:
+        if (ShmDcCommonData->_RefundCancel) {
+            ftime(&AuthNowTime);
+            if (DiffTimeb(gRegTimeUp[plugNum][REG_DISPENSER_REQUEST], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
+                    DiffTimeb(gRegTimeUp[plugNum][REG_DISPENSER_REQUEST], AuthNowTime) < 0
+               ) {
+                writeRefundCancelPage(fd, gunID);
+                ftime(&gRegTimeUp[plugNum][REG_DISPENSER_REQUEST]);
+            }
+        }
+        break;
+    case _PAGE_DONATE_SELECT:
+        if (ShmDcCommonData->_InvoiceRequest) {
+            ftime(&AuthNowTime);
+            if (DiffTimeb(gRegTimeUp[plugNum][REG_DISPENSER_REQUEST], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
+                    DiffTimeb(gRegTimeUp[plugNum][REG_DISPENSER_REQUEST], AuthNowTime) < 0
+               ) {
+                writeShowInvociePage(fd, gunID);
+                ftime(&gRegTimeUp[plugNum][REG_DISPENSER_REQUEST]);
+            }
+        }
+        break;
+    }
+}
 static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8_t gunID)
 {
     uint8_t i = 0;
     struct timeb AuthNowTime = {0};
+
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(plugNum);
+    // Get Power Cabinet Version information
+
+    if (pSysConfig->ShowInformation == YES && pSysInfo->SystemPage == _PAGE_AUTHORIZE) {
+    	// Get Power Cabinet DCM Version
+        ftime(&AuthNowTime);
+        if (DiffTimeb(gRegTimeUp[plugNum][REG_GET_CABINET_DCM_VERSION], AuthNowTime) > LOOP_RETRY_TIME ||
+                DiffTimeb(gRegTimeUp[plugNum][REG_GET_CABINET_DCM_VERSION], AuthNowTime) < 0
+           ) {
+            readCabinetDCMVersion(fd, gunID);
+            ftime(&gRegTimeUp[plugNum][REG_GET_CABINET_DCM_VERSION]);
+        }
+        // Get Power Cabinet Relay and Fan Version
+		ftime(&AuthNowTime);
+		if (DiffTimeb(gRegTimeUp[plugNum][REG_GET_CABINET_OTHER_VERSION], AuthNowTime) > LOOP_RETRY_TIME ||
+				DiffTimeb(gRegTimeUp[plugNum][REG_GET_CABINET_OTHER_VERSION], AuthNowTime) < 0
+		   ) {
+			readCabinetOtherVersion(fd, gunID);
+			ftime(&gRegTimeUp[plugNum][REG_GET_CABINET_OTHER_VERSION]);
+		}
+		// Get Power Cabinet PSU Numbers
+		ftime(&AuthNowTime);
+		if (DiffTimeb(gRegTimeUp[plugNum][REG_GET_CABINET_PSU_NUMBER], AuthNowTime) > LOOP_RETRY_TIME ||
+				DiffTimeb(gRegTimeUp[plugNum][REG_GET_CABINET_PSU_NUMBER], AuthNowTime) < 0
+		   ) {
+			readCabinetPSUNumber(fd, gunID);
+			ftime(&gRegTimeUp[plugNum][REG_GET_CABINET_PSU_NUMBER]);
+		}
+		// Get Power Cabinet each PSU Version
+		if (ShmDcCommonData->PSU_Number > 0) {
+			for(i = 0 ; i < ShmDcCommonData->PSU_Number ; i++) {
+				if (DiffTimeb(gRegTimeUp[plugNum][REG_GET_CABINET_PSU_VERSION], AuthNowTime) > LOOP_RETRY_TIME ||
+						DiffTimeb(gRegTimeUp[plugNum][REG_GET_CABINET_PSU_VERSION], AuthNowTime) < 0
+				   ) {
+					readCabinetEachPSUVersion(fd, gunID,i);
+					ftime(&gRegTimeUp[plugNum][REG_GET_CABINET_PSU_VERSION]);
+				}
+			}
+		}
+    }
 
     switch (pDcChargingInfo->SystemStatus) {
     case S_IDLE:
@@ -1949,11 +2246,14 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
     case S_ALARM:
     case S_AUTHORIZING:
         checkAuthorProcess(fd, plugNum);
-
+        if (pDcChargingInfo->SystemStatus == S_IDLE) {
+            TccProcess( fd, plugNum,  gunID);
+        }
         //authorization complete, write wait plug it state
         if (ShmSelectGunInfo->PricesInfo[plugNum].Balance == FAIL_BALANCE_PRICES) {
             break;
         }
+        // For TCC Using
 
         ftime(&AuthNowTime);
         if (DiffTimeb(gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
@@ -2109,17 +2409,19 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
         }
 
         ftime(&AuthNowTime);
-        if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME ||
-                DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
-           ) {
-            if (readChargePermission(fd, gunID) == 0) {
-                log_info("Stop charging by power cabinet's permission = %d, %d",
-                         plugNum,
-                         REG_CHARGING_PERMISSION);
-                pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
-                //printf("%d StopChargeFlag = %d\n", plugNum, pDcChargingInfo->StopChargeFlag);
+        if (pDcChargingInfo->SystemStatus != S_TERMINATING) {
+            if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) > LOOP_RETRY_TIME ||
+                    DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
+               ) {
+                if (readChargePermission(fd, gunID) == 0) {
+                    log_info("Stop charging by power cabinet's permission = %d, %d",
+                             plugNum,
+                             REG_CHARGING_PERMISSION);
+                    pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
+                    //printf("%d StopChargeFlag = %d\n", plugNum, pDcChargingInfo->StopChargeFlag);
+                }
+                ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
             }
-            ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
         }
         writeChargingTarget(fd, plugNum, gunID);
 

+ 44 - 1
EVSE/Projects/DD360Tcci/Apps/ModuleDoComm/DoComm.h

@@ -80,6 +80,16 @@
 #define REG_QRCODE_URL_INFO                     0X10
 #define REG_WAIT_PLUG_IT_STATE                  0x11
 #define REG_Ground_Fault_Detection              0x12
+#define REG_GET_CABINET_DCM_VERSION             0x13
+#define REG_GET_CABINET_OTHER_VERSION           0x14
+#define REG_GET_CABINET_PSU_NUMBER              0x15
+#define REG_GET_CABINET_PSU_VERSION             0x16
+#define REG_GET_RESERVATION_IDTAG               0x17
+#define REG_DISPENSER_REQUEST                   0x18
+#define REG_GET_REMOTESTART_WITHOUTID           0x19
+#define REG_GET_REFUND_AMOUNT                   0x1A
+#define REG_GET_PREPAYMOUNT_INFO                0x1B
+#define REG_GET_PREPAYMOUNT_FAIL_INFO           0x1C
 
 //------------------------------------------------------------------------------
 //--- dispenser result ---
@@ -111,16 +121,22 @@
 #define MISC_CMD_WEB_STOP_CHARGING              (0x000B)
 #define MISC_CMD_AUTH_DISABLE					(0x000C)
 #define MISC_CMD_EVCCID_ENABLE					(0x000D)
+#define MISC_CMD_LED_INTENSITY                  (0x000E)
 
 #define MISC_CMD_HARDWARE_REBOOT                (0x0101)
 #define MISC_CMD_SOFTWARE_RESTART               (0x0102)
 #define MISC_CMD_REMOTE_START_CHARGING          (0x0103)
 #define MISC_CMD_REMOTE_STOP_CHARGING           (0x0104)
 #define MISC_CMD_REMOTE_UNLOCK                  (0x0105)
+#define MISC_CMD_RESERVATION                    (0x0106)
+#define MISC_CMD_CHANGELCM_INFO                 (0x0107)
 
 #define ST_UPDATE_FIRMWARE                      (0x01)
 #define ST_NO_UPDATE_FIRMWARE                   (0x02)
 
+#define REQ_REFUND_REQUEST                      (0x0001)
+#define REQ_REFUND_CANCEL                       (0x0002)
+#define REQ_INVOICE_REQUEST                     (0x0003)
 //------------------------------------------------------------------------------
 #pragma pack(push)
 #pragma pack(1)
@@ -130,7 +146,8 @@ typedef struct StConnectorState {
     uint8_t WarningCode[6];
     uint8_t ConnectorTemp;
     uint8_t ChillerTemp;
-    uint8_t Reserved[3];
+    uint8_t PlugIn;
+    uint8_t Reserved[2];
 } ConnectorState;
 
 typedef struct StConnectorIDTable {
@@ -234,6 +251,32 @@ typedef struct StAccountInfo {
     uint8_t Reserved[3];
 } AccountInfo;
 
+typedef struct stCabinetDCMVersion {
+    uint8_t CabinetModelName[32];
+    uint8_t CabinetBoolLoaderVersion[32];
+    uint8_t CabinetKernelVersion[32];
+    uint8_t CabinetRFSystemVersion[32];
+    uint8_t CabinetPrimaryVersion[32];
+    uint8_t CabinetIPAddr[32];
+}PCDCMVer;
+
+typedef struct stCabinetOtherVersion {
+    uint8_t CabinetRelay0Version[32];
+    uint8_t CabinetRelay1Version[32];
+    uint8_t CabinetFanVersion[32];
+}PCOthVer;
+
+typedef struct stCabinetEachPsuVersion {
+	uint8_t n_PSU;
+	uint8_t DCVersion[32];
+	uint8_t FPCVersion[32];
+}PCnPsuVer;
+
+typedef struct StDispenserRequest {
+    uint16_t Command;
+    uint32_t Parameter;
+} DispenserRequest;
+
 #pragma pack(pop)
 
 #endif /* _DO_COMM_H_ */

+ 25 - 21
EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -337,7 +337,7 @@ void CANReceiver(int fd)
                         log_info("Conn %d, Plugin. ", targetGun);
                         pDcChargingInfo->isEVCCIDVerify = false;
 #ifdef DD360Audi                       
-                        if (pSysConfig->isAuthrizeByEVCCID)
+                        if (pSysConfig->EVCCID_Authorize)
                             pSysInfo->CurGunSelected = targetGun;
 #endif                        
                     } else if (frame.data[0] == UNPLUG) {
@@ -346,6 +346,9 @@ void CANReceiver(int fd)
                     } else {
                         log_info("Conn %d, None Check. (%d) ", targetGun, frame.data[0]);
                     }
+                    if(pDcChargingInfo->RemoteStartFlag == YES) {
+                        pSysInfo->CurGunSelected = targetGun;
+                    }
                 }
 
                 pDcChargingInfo->ConnectorPlugIn = frame.data[0];
@@ -417,7 +420,8 @@ void CANReceiver(int fd)
                         (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
                          pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)
                    ) {
-                    if (pDcChargingInfo->EvBatteryStartSoc <= 0) {
+                    if (pDcChargingInfo->EvBatteryStartSoc <= 0 &&
+                            pDcChargingInfo->SystemStatus >= S_PREPARING_FOR_EVSE) {
                         pDcChargingInfo->EvBatteryStartSoc = frame.data[1];
                     }
 
@@ -644,25 +648,25 @@ void CANReceiver(int fd)
                 break;
             case ACK_EVCCID_REQ:
 
-                        if (frame.can_dlc > 0 && strcmp ( (char *)pDcChargingInfo->EVCCID, "" ) == EQUAL &&
-                            pDcChargingInfo->Type == _Type_CCS_2)
-                        {
-                            {
-                                memset (
-                                        ShmCcsData->V2GMessage_DIN70121 [pDcChargingInfo->type_index].SessionSetupRequest.EVCCID,
-                                        0,
-                                        sizeof(ShmCcsData->V2GMessage_DIN70121 [pDcChargingInfo->type_index].SessionSetupRequest.EVCCID) );
-                                memcpy (
-                                        ShmCcsData->V2GMessage_DIN70121 [pDcChargingInfo->type_index].SessionSetupRequest.EVCCID,
-                                        frame.data, frame.can_dlc );
-                            }
-
-                            sprintf ( (char *) pDcChargingInfo->EVCCID, "%.2x%.2x%.2x%.2x%.2x%.2x", frame.data [0],
-                                    frame.data [1], frame.data [2], frame.data [3], frame.data [4], frame.data [5] );
-
-                            pDcChargingInfo->EVCCID [17] = '\0';
-                            log_info( "************* Gun %d->EVCCID = %s ************* ", targetGun, pDcChargingInfo->EVCCID );
-                        }
+                if (frame.can_dlc > 0 && strcmp ( (char *)pDcChargingInfo->EVCCID, "" ) == EQUAL &&
+                    pDcChargingInfo->Type == _Type_CCS_2)
+                {
+                    {
+                        memset (
+                                ShmCcsData->V2GMessage_DIN70121 [pDcChargingInfo->type_index].SessionSetupRequest.EVCCID,
+                                0,
+                                sizeof(ShmCcsData->V2GMessage_DIN70121 [pDcChargingInfo->type_index].SessionSetupRequest.EVCCID) );
+                        memcpy (
+                                ShmCcsData->V2GMessage_DIN70121 [pDcChargingInfo->type_index].SessionSetupRequest.EVCCID,
+                                frame.data, frame.can_dlc );
+                    }
+
+                    sprintf ( (char *) pDcChargingInfo->EVCCID, "%.2x%.2x%.2x%.2x%.2x%.2x", frame.data [0],
+                            frame.data [1], frame.data [2], frame.data [3], frame.data [4], frame.data [5] );
+
+                    pDcChargingInfo->EVCCID [17] = '\0';
+                    log_info( "Gun %d->EVCCID = %s ", targetGun, pDcChargingInfo->EVCCID );
+                }
                 break;
             default:
                 log_info("EV board = %d, Ack none defined. intCmd = %d  ", targetGun, intCmd);

+ 33 - 32
EVSE/Projects/DD360Tcci/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -302,6 +302,29 @@ static void setCurrentOutput(void)
     }
 }
 
+static void GetMaxVolAndCurMethod(uint8_t index, float *vol, float *cur)
+{
+    struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
+
+    if (maxChargingVol[index] != 0 && maxChargingVol[index] <= *vol) {
+        *vol = maxChargingVol[index];
+    }
+
+    if (maxChargingCur[index] != 0 && maxChargingCur[index] <= *cur) {
+        *cur = maxChargingCur[index];
+    }
+
+    if (((pDcChargingInfo->SystemStatus >= S_PREPARING_FOR_EVSE &&
+            pDcChargingInfo->SystemStatus <= S_CHARGING) ||
+            (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
+             pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) &&
+            pDcChargingInfo->ChargingProfileCurrent >= 0 &&
+            pDcChargingInfo->ChargingProfileCurrent <= *cur
+       ) {
+        *cur = pDcChargingInfo->ChargingProfileCurrent;
+    }
+}
+
 static void SetPresentChargingOutputCap(void)
 {
     float pow1 = 0, cur1 = 0;
@@ -317,18 +340,18 @@ static void SetPresentChargingOutputCap(void)
         chargingData_2 = (struct ChargingInfoData *)GetDcChargingInfoData(1);
     }
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
     float vol = 0;
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
 
     pow1 = chargingData_1->AvailableChargingPower;
     cur1 = chargingData_1->AvailableChargingCurrent;
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
     vol = chargingData_1->MaximumChargingVoltage;
     GetMaxVolAndCurMethod(chargingData_1->Index, &vol, &cur1);
-    GetMaxPowerMethod(chargingData_1->Index, &pow1);
-#endif //!defined DD360 && !defined DD360Audi
+    //GetMaxPowerMethod(chargingData_1->Index, &pow1);
+#endif //!defined DD360Tcci && !defined DD360Audi
 
     //DS60-120 add
     if (pow1 <= 0) {
@@ -349,11 +372,11 @@ static void SetPresentChargingOutputCap(void)
     pow2 = chargingData_2->AvailableChargingPower;
     cur2 = chargingData_2->AvailableChargingCurrent;
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
     vol = chargingData_2->MaximumChargingVoltage;
     GetMaxVolAndCurMethod(chargingData_2->Index, &vol, &cur2);
-    GetMaxPowerMethod(chargingData_2->Index, &pow2);
-#endif //!defined DD360 && !defined DD360Audi
+    //GetMaxPowerMethod(chargingData_2->Index, &pow2);
+#endif //!defined DD360Tcci && !defined DD360Audi
 
     //DS60-120 add
     if (pow2 <= 0) {
@@ -402,29 +425,6 @@ static void SetPresentChargingOutputCap(void)
     SetPresentOutputCapacity(pow1, cur1, pow2, cur2);
 }
 
-static void GetMaxVolAndCurMethod(uint8_t index, float *vol, float *cur)
-{
-    struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
-
-    if (maxChargingVol[index] != 0 && maxChargingVol[index] <= *vol) {
-        *vol = maxChargingVol[index];
-    }
-
-    if (maxChargingCur[index] != 0 && maxChargingCur[index] <= *cur) {
-        *cur = maxChargingCur[index];
-    }
-
-    if (((pDcChargingInfo->SystemStatus >= S_PREPARING_FOR_EVSE &&
-            pDcChargingInfo->SystemStatus <= S_CHARGING) ||
-            (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
-             pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) &&
-            pDcChargingInfo->ChargingProfileCurrent >= 0 &&
-            pDcChargingInfo->ChargingProfileCurrent <= *cur
-       ) {
-        *cur = pDcChargingInfo->ChargingProfileCurrent;
-    }
-}
-
 static uint8_t waitPsuVolwithRealyVol(uint8_t gunIndex)
 {
     PcPsuOutput *pPcPsuOutput = (PcPsuOutput *)&ShmDcCommonData->PcPsuOutput[gunIndex];
@@ -778,11 +778,12 @@ int main(int argc, char *argv[])
 
             switch (pDcChargingInfo->SystemStatus) {
             case S_IDLE:
+            case S_AUTHORIZING:
             case S_RESERVATION:
                 if (pDcChargingInfo->Type == _Type_Chademo) {
 
                     ClearAbnormalStatus_Chademo(gunIndex);
-                    if (pSysInfo->PageIndex == _LCM_WAIT_FOR_PLUG) {
+                    if (pSysInfo->PageIndex == _PAGE_PLUGIN) {
                         if (!chkChademoPermission[gunIndex]) {
                             chkChademoPermission[gunIndex] = true;
                             gettimeofday(&_chk_chademo_permission_timeout[gunIndex], NULL);

+ 3 - 3
EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/AcPlug.c

@@ -363,8 +363,8 @@ void AcPlugTask(int uartFD)
         } else if ((acStatus.CpStatus == AC_SYS_B || pAcChargingInfo->ConnectorPlugIn == AC_SYS_B) &&
                    pAcChargingInfo->IsAvailable &&
                    !pAcChargingInfo->IsErrorOccur &&
-                   (pSysInfo->WaitForPlugit == YES /*||
-                    pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE*/)) {
+                   (pSysInfo->WaitForPlugit == YES ||
+                    pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE)) {
             if (pAcChargingInfo->RemoteStartFlag == YES) {
                 log_info("** AC Remote \n");
                 pAcChargingInfo->RemoteStartFlag = NO;
@@ -409,7 +409,7 @@ void AcPlugTask(int uartFD)
         break;
         case S_PREPARNING: {
             if (isModeChange()) {
-                pSysInfo->SystemPage = _LCM_NONE;
+                pSysInfo->SystemPage = _PAGE_PRECHARGE;
                 pSysInfo->CurGunSelectedByAc = DEFAULT_AC_INDEX;
                 if (pSysInfo->OrderCharging != NO_DEFINE) {
                     pSysInfo->OrderCharging = NO_DEFINE;

+ 2 - 2
EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/LEDlight.c

@@ -266,13 +266,13 @@ static void LEDBoardSelfTest(void)
         return;
     }
 
-#if defined DD360 ||defined DD360Audi
+#if defined DD360Tcci ||defined DD360Audi
     GetFwAndHwVersion_Led();
     sleep(1);
     gettimeofday(&_led_priority_time, NULL);
 
     return;
-#endif //defined DD360 || defined DD360Audi
+#endif //defined DD360Tcci || defined DD360Audi
 
     // 自檢階段
     if (pSysInfo->SelfTestSeq <= _STEST_PSU_CAP) {

+ 30 - 30
EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/Module_InternalCommOrg.c

@@ -601,26 +601,26 @@ void GetPersentOutputVol(void)
 
         switch (targetID) {
         case 0x01:
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox
             _chargingData[index]->FireChargingVoltage = ShmRelayModuleData->Gun1RelayOutputVolt;
             _chargingData[index]->PresentChargingCurrent = ShmRelayModuleData->Gun1FuseOutputVolt / 10;
             _chargingData[index]->PresentChargingVoltage = _chargingData[index]->FireChargingVoltage / 10;
             _chargingData[index]->FuseChargingVoltage = _chargingData[index]->FireChargingVoltage;
             break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
 
             _chargingData[index]->FireChargingVoltage = ShmRelayModuleData->Gun1RelayOutputVolt;
             _chargingData[index]->FuseChargingVoltage = ShmRelayModuleData->Gun1FuseOutputVolt;
             break;
 
         case 0x02:
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox
             _chargingData[index]->FireChargingVoltage = ShmRelayModuleData->Gun2RelayOutputVolt;
             _chargingData[index]->PresentChargingCurrent = ShmRelayModuleData->Gun2FuseOutputVolt / 10;
             _chargingData[index]->PresentChargingVoltage = _chargingData[index]->FireChargingVoltage / 10;
             _chargingData[index]->FuseChargingVoltage = _chargingData[index]->FireChargingVoltage;
             break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
 
             _chargingData[index]->FireChargingVoltage = ShmRelayModuleData->Gun2RelayOutputVolt;
             _chargingData[index]->FuseChargingVoltage = ShmRelayModuleData->Gun2FuseOutputVolt;
@@ -661,9 +661,9 @@ void GetFanSpeed()
 void GetRelayOutputStatus(void)
 {
     if (Query_Relay_Output(Uart5Fd, ADDR_RELAY, &regRelay) == PASS) {
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox
         regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
     }
 }
 
@@ -683,7 +683,7 @@ void CheckK1K2RelayOutput(uint8_t index)
         }
 
         if (_chargingData[index]->Type == _Type_CCS_2) {
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox
             if (regRelay.relay_event.bits.Gun1_N == YES && regRelay.relay_event.bits.CCS_Precharge == YES) {
                 _chargingData[index]->RelayKPK2Status = YES;
             } else {
@@ -695,7 +695,7 @@ void CheckK1K2RelayOutput(uint8_t index)
             } else {
                 _chargingData[index]->RelayKPK2Status = NO;
             }
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
         }
         break;
 
@@ -708,7 +708,7 @@ void CheckK1K2RelayOutput(uint8_t index)
         }
 
         if (_chargingData[index]->Type == _Type_CCS_2) {
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox
             if (regRelay.relay_event.bits.Gun2_N == YES &&
                     regRelay.relay_event.bits.CCS_Precharge == YES) {
                 _chargingData[index]->RelayKPK2Status = YES;
@@ -721,12 +721,12 @@ void CheckK1K2RelayOutput(uint8_t index)
             } else {
                 _chargingData[index]->RelayKPK2Status = NO;
             }
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
         }
         break;
     }
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox
     //DS60-120 add
     if (ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus == YES) {
         if (regRelay.relay_event.bits.Gun1_Parallel_N == NO &&
@@ -741,7 +741,7 @@ void CheckK1K2RelayOutput(uint8_t index)
     }
 #else
     ShmSysConfigAndInfo->SysInfo.BridgeRelayStatus = YES;
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
 }
 
 void GetGfdAdc()
@@ -1008,9 +1008,9 @@ void SetK1K2RelayStatus(uint8_t index)
         break;
 
     case S_CCS_PRECHARGE_ST0:
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox
         break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
 
         if (pDcChargingInfo->Type == _Type_CCS_2 && targetID == 0x02) {
             if (pRegPreChargingState->CcsPrecharge == NO) {
@@ -1022,9 +1022,9 @@ void SetK1K2RelayStatus(uint8_t index)
         break;
 
     case S_CCS_PRECHARGE_ST1:
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox
         break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
 
         if (pDcChargingInfo->Type == _Type_CCS_2 && targetID == 0x02) {
             if (pRegGunPNState->GunP == NO) {
@@ -1087,9 +1087,9 @@ void CheckPhaseLossStatus(uint8_t index)
 
 void SetParalleRelayStatus(void)
 {
-#if defined  DD360 || defined DD360Audi || defined DD360ComBox
+#if defined  DD360Tcci || defined DD360Audi || defined DD360ComBox
     return;
-#endif //!defined  DD360 || !defined DD360Audi || !defined DD360ComBox
+#endif //!defined  DD360Tcci || !defined DD360Audi || !defined DD360ComBox
 
     // 之後雙槍單模機種,橋接都會上
     if (gunCount >= 2) {
@@ -1532,19 +1532,19 @@ bool IsNoneMatchRelayStatus()
     bool result = false;
 
     if (
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox
         (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) ||
         (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) ||
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
         (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) ||
         (regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) ||
         (regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) ||
         (regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N)
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox
         ||
         (regRelay.relay_event.bits.Gun1_Parallel_P != outputRelay.relay_event.bits.Gun1_Parallel_P) ||
         (regRelay.relay_event.bits.Gun1_Parallel_N != outputRelay.relay_event.bits.Gun1_Parallel_N)
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
     ) {
         /*if (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) {
             log_info("AC Contact Relay none match. \n");
@@ -1588,9 +1588,9 @@ void MatchRelayStatus()
 {
     // 因為 AC Contactor 沒有 Feedback,所以暫時先這樣處理
     //regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox
     ShmSysConfigAndInfo->SysInfo.AcContactorStatus  = regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
 
     regRelay.relay_event.bits.CCS_Precharge = outputRelay.relay_event.bits.CCS_Precharge;
     regRelay.relay_event.bits.Gun1_P = outputRelay.relay_event.bits.Gun1_P;
@@ -2293,7 +2293,7 @@ int main(void)
 #if !defined DD360ComBox
         // 自檢階段處理,自檢階段如果讀不到版號則代表該系統沒有掛燈板
         if (ShmLedModuleData->SelfTest_Comp == NO) {
-#if defined DD360 ||defined DD360Audi
+#if defined DD360Tcci ||defined DD360Audi
             GetFwAndHwVersion_Led();
             sleep(1);
             gettimeofday(&_led_priority_time, NULL);
@@ -2309,7 +2309,7 @@ int main(void)
                     ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LedboardStestFail = YES;
                 }
             }
-#endif //defined DD360 || defined DD360Audi
+#endif //defined DD360Tcci || defined DD360Audi
         }
 #endif //!defined DD360ComBox
 
@@ -2320,14 +2320,14 @@ int main(void)
             // 輸出電壓
             GetPersentOutputVol();
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox
             // 三相輸入電壓
             GetPresentInputVol();
             // 讀取當前 AC relay 狀態
             regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
 
             GetRelayOutputStatus();
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
 
             for (i = 0; i < gunCount; i++) {
                 // Cable check (Set)
@@ -2339,13 +2339,13 @@ int main(void)
                 // 依據當前各槍的狀態選擇 搭上/放開 Relay
                 SetK1K2RelayStatus(i);
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox
                 if (ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy == YES) {
                     CheckPhaseLossStatus(i);
                 }
 
                 CheckAcInputOvpStatus(i);
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
 
                 if (_chargingData[i]->SystemStatus == S_IDLE) {
                     _chargingData[i]->RelayWeldingCheck = NO;

+ 50 - 42
EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/RelayBoard.c

@@ -37,6 +37,7 @@ static Led_Color cur_led_color = {COLOR_MIN_LV};
 static Led_Color led_color;
 static struct timeval _led_priority_time;
 
+bool _show_GFD_Warming[2] = {TRUE};
 //static bool _isRelayWelding[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 //static struct timeval _checkRelayWeldingTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
@@ -142,24 +143,24 @@ static bool IsNoneMatchRelayStatus(void)
     bool result = false;
 
     if (
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
         (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) ||
         (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) ||
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
         (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) ||
         (regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) ||
         (regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) ||
         (regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N)
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
         ||
         (regRelay.relay_event.bits.Gun1_Parallel_P != outputRelay.relay_event.bits.Gun1_Parallel_P) ||
         (regRelay.relay_event.bits.Gun1_Parallel_N != outputRelay.relay_event.bits.Gun1_Parallel_N)
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
     ) {
         result = true;
     }
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
     if (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) {
         log_info("AC Contact Relay none match. ");
     }
@@ -197,7 +198,7 @@ static bool IsNoneMatchRelayStatus(void)
         StopCheckRelayInfo(RELAY_SMR2_N_STATUS);
     }
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
     if (regRelay.relay_event.bits.Gun1_Parallel_P != outputRelay.relay_event.bits.Gun1_Parallel_P) {
         //log_info("Parallel:D+ Relay none match. ");
         StartCheckRelayInfo(RELAY_PARA_P_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_P);
@@ -218,9 +219,9 @@ static bool IsNoneMatchRelayStatus(void)
 
 static void SetParalleRelayStatus(void)
 {
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox || defined DD360UCar
     return;
-#endif //!defined  DD360 || !defined DD360Audi || !defined DD360ComBox
+#endif //!defined  DD360Tcci || !defined DD360Audi || !defined DD360ComBox
 
     struct ChargingInfoData *pDcChargingInfo0 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
     struct ChargingInfoData *pDcChargingInfo1 = (struct ChargingInfoData *)GetDcChargingInfoData(1);
@@ -323,12 +324,13 @@ static void GetGfdAdc(void)
                 } else if (pDcChargingInfo->GroundFaultStatus == GFD_PASS ||
                            pDcChargingInfo->GroundFaultStatus == GFD_WARNING
                           ) {
-                    if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING) {
+                    if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING && _show_GFD_Warming[gunIndex]) {
                         log_info("GFD Warning. index = %d, Result = %d, R = %d, Vol = %d ",
                                  gunIndex,
                                  pDcChargingInfo->GroundFaultStatus,
                                  gfd_adc.Resister_conn1,
                                  gfd_adc.voltage_conn1);
+                        _show_GFD_Warming[gunIndex] = FALSE;
                     }
                 }
             } else if (targetID == 0x02) {
@@ -345,12 +347,13 @@ static void GetGfdAdc(void)
                 } else if (pDcChargingInfo->GroundFaultStatus == GFD_PASS ||
                            pDcChargingInfo->GroundFaultStatus == GFD_WARNING
                           ) {
-                    if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING) {
+                    if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING && _show_GFD_Warming[gunIndex]) {
                         log_info("GFD Warning. index = %d, Result = %d, R = %d, Vol = %d ",
                                  gunIndex,
                                  pDcChargingInfo->GroundFaultStatus,
                                  gfd_adc.Resister_conn1,
                                  gfd_adc.voltage_conn1);
+                        _show_GFD_Warming[gunIndex] = FALSE;
                     }
                 }
             }
@@ -599,9 +602,9 @@ void SetK1K2RelayStatus(uint8_t index)
         break;
 
     case S_CCS_PRECHARGE_ST0:
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox || defined DD360UCar
         break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
 
         //if (pDcChargingInfo->Type == _Type_CCS_2 && targetID == 0x02) {
         //    if (pRegPreChargingState->CcsPrecharge == NO) {
@@ -617,9 +620,9 @@ void SetK1K2RelayStatus(uint8_t index)
         break;
 
     case S_CCS_PRECHARGE_ST1:
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox || defined DD360UCar
         break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
 
         //if (pDcChargingInfo->Type == _Type_CCS_2 && targetID == 0x02) {
         //    if (pRegGunPNState->GunP == NO) {
@@ -653,7 +656,7 @@ void CheckK1K2RelayOutput(uint8_t index)
         }
 
         if (pDcChargingInfo->Type == _Type_CCS_2) {
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
             if (regRelay.relay_event.bits.Gun1_N == YES && regRelay.relay_event.bits.CCS_Precharge == YES) {
                 pDcChargingInfo->RelayKPK2Status = YES;
             } else {
@@ -665,7 +668,7 @@ void CheckK1K2RelayOutput(uint8_t index)
             } else {
                 pDcChargingInfo->RelayKPK2Status = NO;
             }
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
         }
         break;
 
@@ -678,7 +681,7 @@ void CheckK1K2RelayOutput(uint8_t index)
         }
 
         if (pDcChargingInfo->Type == _Type_CCS_2) {
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
             if (regRelay.relay_event.bits.Gun2_N == YES &&
                     regRelay.relay_event.bits.CCS_Precharge == YES) {
                 pDcChargingInfo->RelayKPK2Status = YES;
@@ -691,12 +694,12 @@ void CheckK1K2RelayOutput(uint8_t index)
             } else {
                 pDcChargingInfo->RelayKPK2Status = NO;
             }
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
         }
         break;
     }
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
     //DS60-120 add
     if (pSysInfo->BridgeRelayStatus == YES) {
         if (regRelay.relay_event.bits.Gun1_Parallel_N == NO &&
@@ -711,7 +714,7 @@ void CheckK1K2RelayOutput(uint8_t index)
     }
 #else
     pSysInfo->BridgeRelayStatus = YES;
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
 }
 
 void SetGfdConfig(uint8_t index, uint8_t resister)
@@ -798,9 +801,9 @@ void CableCheckDetected(uint8_t index)
 void GetRelayOutputStatus(void)
 {
     if (Query_Relay_Output(Uart5Fd, ADDR_RELAY, &regRelay) == PASS) {
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
         regRelay.relay_event.bits.AC_Contactor = pSysInfo->AcContactorStatus;
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
     }
 }
 
@@ -1050,26 +1053,26 @@ void GetPersentOutputVol(void)
 
         switch (targetID) {
         case 0x01:
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox || defined DD360UCar
             pDcChargingInfo->FireChargingVoltage = ShmRelayModuleData->Gun1RelayOutputVolt;
             pDcChargingInfo->PresentChargingCurrent = ((float)ShmRelayModuleData->Gun1FuseOutputVolt) / 10;
             pDcChargingInfo->PresentChargingVoltage = ((float)pDcChargingInfo->FireChargingVoltage) / 10;
             pDcChargingInfo->FuseChargingVoltage = pDcChargingInfo->FireChargingVoltage;
             break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
 
             pDcChargingInfo->FireChargingVoltage = ShmRelayModuleData->Gun1RelayOutputVolt;
             pDcChargingInfo->FuseChargingVoltage = ShmRelayModuleData->Gun1FuseOutputVolt;
             break;
 
         case 0x02:
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox
             pDcChargingInfo->FireChargingVoltage = ShmRelayModuleData->Gun2RelayOutputVolt;
             pDcChargingInfo->PresentChargingCurrent = ((float)ShmRelayModuleData->Gun2FuseOutputVolt) / 10;
             pDcChargingInfo->PresentChargingVoltage = ((float)pDcChargingInfo->FireChargingVoltage) / 10;
             pDcChargingInfo->FuseChargingVoltage = pDcChargingInfo->FireChargingVoltage;
             break;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
 
             pDcChargingInfo->FireChargingVoltage = ShmRelayModuleData->Gun2RelayOutputVolt;
             pDcChargingInfo->FuseChargingVoltage = ShmRelayModuleData->Gun2FuseOutputVolt;
@@ -1460,7 +1463,6 @@ static void SetLedColor(void)
     static uint8_t _checkLedChanged = 3;
     struct ChargingInfoData *chargingData_1 = NULL;
     struct ChargingInfoData *chargingData_2 = NULL;
-    uint8_t _colorBuf = COLOR_MAX_LV * LED_INTENSITY_BRIGHTEST;
 
     if (pSysConfig->TotalConnectorCount == 1) {
         chargingData_1 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
@@ -1469,11 +1471,14 @@ static void SetLedColor(void)
         chargingData_1 = (struct ChargingInfoData *)GetDcChargingInfoData(0);
         chargingData_2 = (struct ChargingInfoData *)GetDcChargingInfoData(1);
     }
+    uint8_t _colorBuf = COLOR_MAX_LV * LED_INTENSITY_BRIGHTEST;
 
     if (pSysConfig->LedInfo.Intensity == _LED_INTENSITY_DARKEST) {
         _colorBuf = COLOR_MAX_LV * LED_INTENSITY_DARKEST;
     } else if (pSysConfig->LedInfo.Intensity == _LED_INTENSITY_MEDIUM) {
         _colorBuf = COLOR_MAX_LV * LED_INTENSITY_MEDIUM;
+    } else if (pSysConfig->LedInfo.Intensity == LED_INTENSITY_BRIGHTEST) {
+        _colorBuf = COLOR_MAX_LV * LED_INTENSITY_BRIGHTEST;
     }
 
     //printf("chargingData_1->SystemStatus=%d\n",chargingData_1->SystemStatus);
@@ -1534,8 +1539,7 @@ static void SetLedColor(void)
         } else {
             if (chargingData_1->SystemStatus == S_BOOTING ||
                     chargingData_1->SystemStatus == S_IDLE ||
-                    chargingData_1->SystemStatus == S_RESERVATION ||
-                    chargingData_1->SystemStatus == S_MAINTAIN) {
+                    chargingData_1->SystemStatus == S_RESERVATION) {
 
                 if (chargingData_1->IsAvailable == NO) { //For Audi
                     led_color.Connect_1_Green = COLOR_MIN_LV;
@@ -1559,7 +1563,9 @@ static void SetLedColor(void)
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Blue = _colorBuf;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
-            }else if ( chargingData_1->SystemStatus == S_UPDATE ) {
+            }else if ( chargingData_1->SystemStatus == S_UPDATE ||
+                    chargingData_1->SystemStatus == S_MAINTAIN ||
+                    chargingData_1->SystemStatus == S_ALARM ) {
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Blue = COLOR_MIN_LV;
                 led_color.Connect_1_Red = _colorBuf;
@@ -1569,8 +1575,7 @@ static void SetLedColor(void)
             // --------------------------------------------------------------------------
             if (chargingData_2->SystemStatus == S_BOOTING ||
                     chargingData_2->SystemStatus == S_IDLE ||
-                    chargingData_2->SystemStatus == S_RESERVATION ||
-                    chargingData_2->SystemStatus == S_MAINTAIN) {
+                    chargingData_2->SystemStatus == S_RESERVATION ) {
                 if (chargingData_2->IsAvailable == NO) {
                     led_color.Connect_2_Green = COLOR_MIN_LV;
                     led_color.Connect_2_Blue = COLOR_MIN_LV;
@@ -1593,7 +1598,9 @@ static void SetLedColor(void)
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
-            }else if ( chargingData_2->SystemStatus == S_UPDATE ) {
+            }else if ( chargingData_2->SystemStatus == S_UPDATE ||
+                    chargingData_2->SystemStatus == S_MAINTAIN ||
+                    chargingData_2->SystemStatus == S_ALARM) {
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Blue = COLOR_MIN_LV;
                 led_color.Connect_2_Red = _colorBuf;
@@ -1624,13 +1631,13 @@ static void LEDBoardSelfTest(void)
         return;
     }
 
-#if defined DD360 ||defined DD360Audi
+#if defined DD360Tcci ||defined DD360Audi || defined DD360UCar
     GetFwAndHwVersion_Led();
     sleep(1);
     gettimeofday(&_led_priority_time, NULL);
 
     return;
-#endif //defined DD360 || defined DD360Audi
+#endif //defined DD360Tcci || defined DD360Audi
 
     // 自檢階段
     if (pSysInfo->SelfTestSeq <= _STEST_PSU_CAP) {
@@ -1653,7 +1660,7 @@ static void LEDBoardProcess(void)
     if (ShmLedModuleData->SelfTest_Comp == NO) {
         return;
     }
-
+    pSysConfig->LedInfo.Intensity = LED_INTENSITY_BRIGHTEST;
     if (GetTimeoutValue(_led_priority_time) / 1000 >= 1000) {
 
         //if (pSysConfig->TotalConnectorCount == 1) {
@@ -1740,10 +1747,10 @@ void RelayBoardTask(int uartFD)
                 // 輸出電壓
                 GetPersentOutputVol();
 
-    #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+    #if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
                 // 三相輸入電壓
                 GetPresentInputVol();
-    #endif //!defined DD360 && !defined DD360Audi
+    #endif //!defined DD360Tcci && !defined DD360Audi
 
                 // 讀取當前 AC relay 狀態
                 regRelay.relay_event.bits.AC_Contactor = pSysInfo->AcContactorStatus;
@@ -1764,13 +1771,13 @@ void RelayBoardTask(int uartFD)
                     // 依據當前各槍的狀態選擇 搭上/放開 Relay
                     SetK1K2RelayStatus(i);
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
                     if (pSysConfig->PhaseLossPolicy == YES) {
                         CheckPhaseLossStatus(i);
                     }
 
                     CheckAcInputOvpStatus(i);
-#endif //!defined DD360 && !defined DD360Audi
+#endif //!defined DD360Tcci && !defined DD360Audi
 
                     if (pDcChargingInfo->SystemStatus == S_IDLE ||
                             pDcChargingInfo->SystemStatus == S_RESERVATION ||
@@ -1778,6 +1785,7 @@ void RelayBoardTask(int uartFD)
                         //pDcChargingInfo->RelayWeldingCheck = NO;
                         //_isRelayWelding[i] = NO;
                         _isOvpChkTimeFlag[i] = NO;
+                        _show_GFD_Warming[i] = TRUE;
                         //ResetDetAlarmStatus(i); //DS60-120 add
                     }
 
@@ -1787,8 +1795,8 @@ void RelayBoardTask(int uartFD)
                             (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
                              pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1) ||
                             pSysInfo->WaitForPlugit == YES ||
-                            (pSysInfo->PageIndex >= _LCM_AUTHORIZING &&
-                             pSysInfo->PageIndex <= _LCM_WAIT_FOR_PLUG)
+                            (pSysInfo->PageIndex >=  _PAGE_AUTHORIZE &&
+                             pSysInfo->PageIndex <= _PAGE_PLUGIN)
                        ) {
                         pDcChargingInfo->IsReadyToCharging = YES;
                         isCharging = true;

+ 2 - 2
EVSE/Projects/DD360Tcci/Apps/ModuleInternalComm/internalComm.h

@@ -15,11 +15,11 @@
 //address
 #define ADDR_AUX                                (0x01)
 #define ADDR_FAN                                (0x02)
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox || defined DD360UCar
 #define ADDR_RELAY                              (0x09)
 #else
 #define ADDR_RELAY                              (0x03)
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
 #define ADDR_AC_PLUG                            (0x05)
 #define ADDR_LED                                (0x06)
 #define ADDR_BROADCAST                          (0xFF)

+ 415 - 0
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Lcm_Update.c

@@ -0,0 +1,415 @@
+/*
+ * Lcm_Update.c
+ *
+ *  Created on: 2022年1月3日
+ *      Author: 8513
+ */
+#include <stdio.h>      /*標準輸入輸出定義*/
+#include <stdlib.h>     /*標準函數庫定義*/
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/timeb.h>
+#include <dirent.h>
+#include "cbmp.h"
+
+#include "Module_LcmControl.h"
+#include "../Log/log.h"
+#include "../ShareMemory/shmMem.h"
+#include "../Define/define.h"
+#include "../Config.h"
+#include "../SelectGun/SelectGun.h"
+#include "../CSU/main.h"
+
+DcCommonInfo *ShmDcCommonData = NULL;
+int _port;
+void displayMessageDgus(uint8_t *data, uint16_t len, uint8_t isRX)
+{
+    uint8_t output[8192];
+
+    memset(output, 0x00, ARRAY_SIZE(output));
+    sprintf((char*)output, "%s", (isRX?"RX: ":"TX: "));
+    for(uint16_t idx = 0;idx<len;idx++)
+    {
+        sprintf((char*)output, "%s%02x ", output, data[idx]);
+    }
+
+    #ifdef isDebugPrint
+    log_info("%s\n", output);
+    #endif
+}
+int transceiverDgus(int32_t fd, uint8_t *tx, uint16_t tx_len, uint8_t *rx, uint16_t rx_len)
+{
+    int result = FAIL;
+    int len;
+
+    tcflush(fd,TCIOFLUSH);
+
+    #ifdef isDebugPrint
+    displayMessageDgus(tx, tx_len, NO);
+    #endif
+
+    usleep(10000);
+
+    if(write(fd, tx, tx_len) >= ARRAY_SIZE(tx))
+    {
+        if(tx[3] == CMD_REG_WRITE_DATA)
+        {
+            len = read(fd, rx, rx_len);
+            if(len > 0)
+            {
+                if((rx[0] == CMD_HEADER_1) && (rx[1] == CMD_HEADER_2))
+                {
+                    if((rx[3] == CMD_REG_WRITE_DATA) && (rx[4] == 0x4f) && (rx[5] == 0x4b))
+                    {
+                        displayMessageDgus(rx, len, YES);
+                        result = PASS;
+                    }
+                }
+            }
+        }
+        else if(tx[3] == CMD_REG_READ_DATA)
+        {
+            len = read(fd, rx, rx_len);
+            if(len > 0)
+            {
+                if((rx[0] == CMD_HEADER_1) && (rx[1] == CMD_HEADER_2))
+                {
+                    if(rx[3] == CMD_REG_READ_DATA)
+                    {
+
+                        displayMessageDgus(rx, len, YES);
+
+                        result = PASS;
+                    }
+                    else
+                    {}
+                }
+                else
+                {}
+            }
+            else
+            {}
+        }
+        else
+        {}
+    }
+    else
+    {}
+
+    return result;
+}
+
+int8_t lcdRegisterWrite(int32_t fd, uint8_t regType, uint16_t address, uint8_t *data, uint16_t dataLen)
+{
+    int8_t result = FAIL;
+    uint8_t tx[(regType == REG_TYPE_CONTROL? 8 : 6) + dataLen];
+    uint8_t rx[6];
+
+    memset(tx, 0x00, sizeof(tx));
+    memset(rx, 0x00, sizeof(rx));
+
+    tx[0] = CMD_HEADER_1;
+    tx[1] = CMD_HEADER_2;
+    tx[2] = (regType == REG_TYPE_CONTROL? 7 : (3 + dataLen));
+    tx[3] = CMD_REG_WRITE_DATA;
+    tx[4] = (address >> 8) & 0xff;
+    tx[5] = (address >> 0) & 0xff;
+
+    if(regType == REG_TYPE_CONTROL)
+    {
+        if(address == REG_ADDRESS_SET_PAGE_ID)
+        {
+            tx[6] = 0x5A;
+            tx[7] = 0x01;
+
+            memcpy(&tx[8], data, dataLen);
+        }
+    }
+    else
+    {
+        memcpy(&tx[6], data, dataLen);
+    }
+
+    if(fd > 0)
+    {
+        if(transceiverDgus(fd, tx, ARRAY_SIZE(tx), rx, ARRAY_SIZE(rx)) == PASS)
+        {
+            result = PASS;
+        }
+        else
+        {}
+    }
+    else
+    {}
+
+    return result;
+}
+//=======================================
+// LCD upgrade
+//=======================================
+int downloadBMP(uint8_t picIdx, char *filename)
+{
+    int result = PASS;
+    BMP *bmp;
+    struct stat fileSt;
+    uint32_t pageSize = 0xf0;
+    uint32_t pixelSize;
+    uint32_t transferedByte=0;
+    uint16_t bufferRamAddr = 0x8000;
+    uint32_t dataLen = 0;
+    uint32_t startAddr=0;
+
+    // Reset LCD
+    ResetLCM();
+
+    // Get image file size
+    stat(filename, &fileSt);
+    bmp = bopen(filename);
+    uint8_t buf[bmp->width*bmp->height*2];
+
+    log_info("Target address: %d\n", picIdx);
+    log_info("Image filename: %s\n", filename);
+    log_info("Image width: %d height: %d\n", bmp->width, bmp->height);
+    log_info("Image data size: %d\n", ARRAY_SIZE(buf));
+
+    // Get bmp pixel data and convert to 16 bit color
+    for(uint16_t idxY=0 ; idxY<bmp->height ; idxY++)
+    {
+        for(uint16_t idxX=0 ; idxX<bmp->width ; idxX++)
+        {
+            uint8_t r, g, b;
+            get_pixel_rgb(bmp, idxX, (bmp->height-idxY-1), &r, &g, &b);
+            buf[(2*((idxY*bmp->width) + idxX)) + 0] = ((((r>>3)<<11) | ((g>>2)<<5) | (b>>3)) >> 8) & 0xff;
+            buf[(2*((idxY*bmp->width) + idxX)) + 1] = ((((r>>3)<<11) | ((g>>2)<<5) | (b>>3)) >> 0) & 0xff;
+        }
+    }
+    bclose(bmp);
+
+    // Transfer pixel to screen page
+    pixelSize = ARRAY_SIZE(buf);
+    for(uint16_t idxSrcData=0;idxSrcData<(((pixelSize%pageSize)==0)?(pixelSize/pageSize):(pixelSize/pageSize)+1);idxSrcData++)
+    {
+        //log_info("Buffer start data address: 0x%08X\n", (idxSrcData*pageSize));
+        //log_info("  Image start ram address: 0x%08X\n", ((idxSrcData*pageSize) >> 1));
+        uint8_t display_cmd[] ={0x5a, (bufferRamAddr>>8)&0xff, (bufferRamAddr>>0)&0xff, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+        if((idxSrcData+1) != (((pixelSize%pageSize)==0)?(pixelSize/pageSize):(pixelSize/pageSize)+1))
+        {
+            // Data transfer
+            while(lcdRegisterWrite(_port, REG_TYPE_RAM, (bufferRamAddr+(dataLen>>1)), &buf[(idxSrcData*pageSize)], pageSize) != PASS)
+            {
+                log_info("Transfer data to ram 0x%04X fail.\n", transferedByte);
+            }
+            transferedByte += pageSize;
+            dataLen += pageSize;
+        }
+        else
+        {
+            // Last data transfer
+            while(lcdRegisterWrite(_port, REG_TYPE_RAM, (bufferRamAddr+(dataLen>>1)), &buf[(idxSrcData*pageSize)], (pixelSize-(idxSrcData*pageSize))) != PASS)
+            {
+                log_info("Transfer data to ram 0x%04X fail.\n", transferedByte);
+            }
+            transferedByte += (pixelSize-(idxSrcData*pageSize));
+            dataLen += (pixelSize-(idxSrcData*pageSize));
+        }
+
+        // Move data from ram to flash
+        if((dataLen >= (pageSize*10)) || (idxSrcData == (((pixelSize%pageSize)==0)?(pixelSize/pageSize):(pixelSize/pageSize)+1)-1))
+        {
+            display_cmd[3] = ((dataLen>>1) >> 8) & 0xff;                            // Data length high byte
+            display_cmd[4] = ((dataLen>>1) >> 0) & 0xff;                            // Data length low byte
+            display_cmd[5] = (((startAddr)>>1) >> 16) & 0xff;               // Screen on ram address 1st byte
+            display_cmd[6] = (((startAddr)>>1) >> 8) & 0xff;                // Screen on ram address 2nd byte
+            display_cmd[7] = (((startAddr)>>1) >> 0) & 0xff;                // Screen on ram address 3th byte
+
+            while(lcdRegisterWrite(_port, REG_TYPE_RAM, 0xa2, display_cmd, ARRAY_SIZE(display_cmd)) != PASS)
+            {
+                log_info("Write data to display buffer 0x%04X fail.\n", transferedByte);
+            }
+            startAddr += dataLen;
+            dataLen = 0;
+        }
+    }
+
+    // Save image to target address
+    uint8_t save_cmd[] ={0x5a, 0x02, ((picIdx>>8)&0xff), (picIdx&0xff)};
+    while(lcdRegisterWrite(_port, REG_TYPE_RAM, 0x84, save_cmd, ARRAY_SIZE(save_cmd)) != PASS)
+    {
+        log_info("Save image fail.\n");
+    }
+    log_info("Save image success.\n");
+    sleep(1);
+
+    return result;
+}
+
+int downloadBIN(uint8_t targetAddr, char *filename)
+{
+    int result = PASS;
+    int fd;
+    struct stat fileSt;
+    uint32_t pageSize = 128;
+    uint32_t blocklSize = 32768;
+    uint32_t transferedByte=0;
+    uint16_t bufferRamAddr = 0x8000;
+
+    // Reset LCD
+    ResetLCM();
+
+    // Get image file size
+    stat(filename, &fileSt);
+    if(S_ISDIR(fileSt.st_mode))
+    {
+        return FAIL;
+    }
+    uint8_t buf[(fileSt.st_size%32768==0?(fileSt.st_size/32768)*32768:(fileSt.st_size/32768)+1)*32768];
+
+    log_info("Target address: %d\n", targetAddr);
+    log_info("Bin filename: %s\n", filename);
+    log_info("Bin data size: %ld\n", fileSt.st_size);
+
+    fd = open(filename, O_RDWR);
+    if (fd < 0)
+    {
+        log_info("Bin can not be open.\n");
+        result = FAIL;
+    }
+    else
+    {
+        // Read data from bin file
+        memset(buf, 0x00, ARRAY_SIZE(buf));
+        read(fd, buf, ARRAY_SIZE(buf));
+        close(fd);
+
+        for(uint8_t idxBinSrc=0;idxBinSrc<(fileSt.st_size%32768==0?fileSt.st_size/32768:(fileSt.st_size/32768)+1);idxBinSrc++)
+        {
+            // Transfer data to ram
+            for(uint16_t idxSrcData=0;idxSrcData<(((blocklSize%pageSize)==0)?(blocklSize/pageSize):(blocklSize/pageSize)+1);idxSrcData++)
+            {
+                //log_info("Buffer start data address: 0x%08X\n", (idxBinSrc*blocklSize)+(idxSrcData*pageSize));
+                //log_info("  Image start ram address: 0x%08X\n", ((idxSrcData*pageSize) >> 1));
+                if((idxSrcData+1) != (((blocklSize%pageSize)==0)?(blocklSize/pageSize):(blocklSize/pageSize)+1))
+                {
+                    // Data transfer
+                    while(lcdRegisterWrite(_port, REG_TYPE_RAM, bufferRamAddr+((idxSrcData*pageSize)>>1), &buf[(idxBinSrc*blocklSize)+(idxSrcData*pageSize)], pageSize) != PASS)
+                    {
+                        log_info("Transfer data to ram 0x%04X fail.\n", transferedByte);
+                    }
+                    transferedByte += pageSize;
+                }
+                else
+                {
+                    // Last data transfer
+                    while(lcdRegisterWrite(_port, REG_TYPE_RAM, bufferRamAddr+((idxSrcData*pageSize)>>1), &buf[(idxBinSrc*blocklSize)+(idxSrcData*pageSize)], (blocklSize-(idxSrcData*pageSize)))!= PASS)
+                    {
+                        log_info("Transfer data to ram 0x%04X fail.\n", transferedByte);
+                    }
+                    transferedByte += (blocklSize-(idxSrcData*pageSize));
+                }
+            }
+
+            // Move data from ram to flash
+            uint8_t save_cmd[] ={0x5a, 0x02, ((((targetAddr*8)+idxBinSrc)>>8)&0xff), ((((targetAddr*8)+idxBinSrc)>>0)&0xff), ((bufferRamAddr>>8)&0xff), ((bufferRamAddr>>0)&0xff), 0x00, 0x01, 0x00, 0x00, 0x00, 0x00};
+            while(lcdRegisterWrite(_port, REG_TYPE_RAM, 0xaa, save_cmd, ARRAY_SIZE(save_cmd)) != PASS)
+            {
+                log_info("Save bin file to 0x%04X fail.\n", ((targetAddr*8)+idxBinSrc));
+            }
+            //log_info("Save bin file on 0x%04X success.\n", ((targetAddr*8)+idxBinSrc));
+            sleep(1);
+        }
+    }
+
+    return result;
+}
+uint8_t lcdUpgrade(char *forlder)
+{
+    int result = _LCM_UPGRADE_RESULT_PASS;
+    DIR *dir;
+    struct dirent *file;
+    struct stat fileSt;
+
+    log_info("forlder = %s \n", forlder);
+    if ((dir = opendir (forlder)) != NULL)
+    {
+        /* print all the files and directories within directory */
+        while ((file = readdir (dir)) != NULL)
+        {
+            //log_error("file->d_name = %s \n", file->d_name);
+            if((strlen(file->d_name) > 2) && (file->d_type == DT_REG))
+            {
+                int targetAddr;
+                stat(file->d_name, &fileSt);
+
+                if(sscanf(file->d_name, "%d", &targetAddr) == 1)
+                {
+                    char targetFile[384];
+
+                    sprintf(targetFile, "/mnt/lcd/DWIN_SET/%s", file->d_name);
+                    log_info("targetFile = %s \n", targetFile);
+                    if(strstr(file->d_name, ".bmp") != NULL)
+                    {
+                        downloadBMP(targetAddr, targetFile);
+                    }
+                    else
+                    {
+                        downloadBIN(targetAddr, targetFile);
+                    }
+                }
+                else
+                {
+                    log_error("%s can not parse target address.\n", file->d_name);
+                }
+            }
+            else
+            {
+                if(strlen(file->d_name) >= 3)
+                {
+                    log_error("File name error.\n");
+                    result = _LCM_UPGRADE_RESULT_FAIL;
+                }
+                else
+                {
+                    log_error("Searching file.\n");
+                }
+            }
+            sleep(1);
+        }
+        closedir (dir);
+    }
+    else
+    {
+        log_error("%s does not valid.\n", forlder);
+        result = _LCM_UPGRADE_RESULT_FAIL;
+    }
+
+    return result;
+}
+void ResetLCM()
+{
+    uint8_t cmd_reset [] = { 0x55, 0xaa, 0x5a, 0xa5 };
+    while (lcdRegisterWrite ( _port, REG_TYPE_RAM, 0x04, cmd_reset, ARRAY_SIZE( cmd_reset ) ) != PASS)
+    {
+        log_error( "LCD reset fail.\n" );
+    }
+    sleep ( 1 );
+}
+void UpdateLcmFunction(DcCommonInfo *ShmDcCommonData,int _lcmport)
+{
+    _port = _lcmport;
+    if(ShmDcCommonData->_upgrade_lcm_flag)
+    {
+        log_info("Update LCM Start");
+        // 固定路徑 /mnt/lcd/DWIN_SET
+        ShmDcCommonData->_upgrade_lcm_result = lcdUpgrade("/mnt/lcd/DWIN_SET");
+        ResetLCM();
+        ShmDcCommonData->_upgrade_lcm_flag = NO;
+    }
+}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 331 - 602
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c


+ 0 - 2393
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c.Ph

@@ -1,2393 +0,0 @@
-#include <stdio.h>      /*標準輸入輸出定義*/
-#include <stdlib.h>     /*標準函數庫定義*/
-#include <stdint.h>
-#include <string.h>
-#include <unistd.h>
-#include <termios.h>
-#include <fcntl.h>
-#include <time.h>
-
-#include <sys/ioctl.h>
-#include <sys/timeb.h>
-
-#include "Module_LcmControl.h"
-#include "../Log/log.h"
-#include "../ShareMemory/shmMem.h"
-#include "../Define/define.h"
-#include "../Config.h"
-#include "../SelectGun/SelectGun.h"
-
-//------------------------------------------------------------------------------
-//struct SysConfigAndInfo         *ShmSysConfigAndInfo;
-//struct StatusCodeData           *ShmStatusCodeData;
-static struct SysConfigData *pSysConfig = NULL;
-static struct SysInfoData *pSysInfo = NULL;
-static struct WARNING_CODE_INFO *pSysWarning = NULL;
-
-static struct FanModuleData *ShmFanModuleData;
-static struct PrimaryMcuData *ShmPrimaryMcuData;
-static SelectGunInfo *ShmSelectGunInfo = NULL;
-static struct ChargingInfoData *pDcChargingInfo = NULL;
-static struct ChargingInfoData *pAcChargingInfo = NULL;
-
-bool needReloadQr = true;
-
-bool _isShow = false; //DS60-120 add
-uint8_t _showInformIndex = 0; //DS60-120 add
-
-int _port;
-//char* pPortName         = "/dev/ttyO2";
-char *pPortName           = "/dev/ttyS3";
-char *moduleName          = "DMT80480T070_09WT";
-uint8_t _totalCount;
-uint8_t acgunCount;
-//struct ChargingInfoData *_chargingInfoData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-//struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
-
-uint8_t ac_ani_battery_level    = _BATTERY_LEVEL_FOR_MAP_LV5;
-uint8_t isDiffStatus            = false;
-uint8_t isChangeBattMap         = false;
-// 當前選擇的槍號
-#if defined DD360Audi
-short _currentPage              = _LCM_SELECT_GUN;
-short _oldPage                  = _LCM_SELECT_GUN;
-#else
-short _currentPage              = _LCM_NONE;
-short _oldPage                  = _LCM_NONE;
-#endif //defined DD360Audi
-uint8_t _gunIndex               = 0;
-bool _wifi_conn_status          = false;
-bool _battery_display_ani       = false;
-uint8_t _curPage_index          = 0;
-bool _page_reload               = false;
-
-// LCM - HW
-uint8_t _everyPageRollChange    = 0;
-short __conn_status             = 0x0030;
-short __ethernet_status         = 0x0032;
-short __3G4G_status             = 0x0036;
-short __3G4G_status1            = 0x0037;
-short __3G4G_move_status        = 0x0038;
-short __wifi_status             = 0x003C;
-
-short __sel_gun_btn             = 0x0040;
-short __ret_home_btn            = 0x0042;
-short __stop_method_btn         = 0x0044;
-
-short __qr_code                 = 0x0250;
-short __main_rfid               = 0x0052;
-short __main_qr                 = 0x0054;
-short __main_app                = 0x0056;
-
-short __plug_in_arrow           = 0x0060;
-
-short __conn_line               = 0x0066;
-
-short __gun_type_index          = 0x0070;
-short __cmp_gun_type_index      = 0x0080; ////For Audi
-short __batt_map_empty          = 0x0090; ////For Audi
-short __qr_code_pre             = 0x0280;
-
-short __side_top                = 0x0090;
-short __side_down               = 0x0092;
-short __side_mid                = 0x0094;
-
-short __conn_line_chag          = 0x0096;
-short __batt_map                = 0x0100;
-short __soc_value_charging      = 0x0102;
-short __remain_time_map         = 0x0106;
-short __power_map               = 0x0108;
-short __energy_map              = 0x010A;
-short __remain_time_tx          = 0x0110;
-
-short __trp_remain_time_map     = 0x0116;
-short __trp_power_map           = 0x0118;
-short __trp_energy_map          = 0x011A;
-
-short __output_eng_tx           = 0x0120;
-short __total_out_eng_tx        = 0x0130;
-short __conn_line_comp          = 0x0140;
-short __charging_fee_map        = 0x0146;
-short __charging_fee_tx         = 0x0150;
-
-short __money_by_rate           = 0x0200;
-short __money_rate              = 0x0220;
-short __money_rate_map          = 0x0230;
-
-//DS60-120 add
-short __csu_ver_string          = 0x0300;
-short __csu_ver_value           = 0x0310;
-short __fan_speed_string        = 0x0390;
-short __fan_speed_value         = 0x0400;
-
-short __dc1_ver_string          = 0x0320;
-short __dc1_ver_value           = 0x0330;
-short __dc2_ver_string          = 0x0340;
-short __dc2_ver_value           = 0x0350;
-short __eth0_ip_string          = 0x0360;
-short __eth0_ip_value           = 0x0370;
-short __sn_string               = 0x0410;
-short __sn_value                = 0x0420;
-
-//For Audi, for select gun
-short __left_gun_map            = 0x0260;
-short __right_gun_map           = 0x0262;
-short __add_chk_btn             = 0x0264;
-//short __station_id            = 0x0270;
-short __balance                 = 0x0270;
-short __remain_balance          = 0x0280;
-short __custStationIdL1         = 0x0450;
-//short __custStationIdL2       = 0x0470;
-short _emergency_map            = 0x011C;
-
-// ICON ID
-uint8_t _disappear              = 0;
-uint8_t _disconnect             = 1;
-uint8_t _connect                = 2;
-uint8_t _warning                = 3;
-uint8_t _arrow_dark             = 4;
-uint8_t _arrow_light            = 5;
-uint8_t _3G4G_disconnect        = 6;
-uint8_t __3G4G_connect          = 7;
-uint8_t _wifi_disconnect        = 8;
-uint8_t _wifi_connect           = 9;
-uint8_t _logo                   = 10;
-uint8_t _conn_map1              = 11;
-uint8_t _conn_map2              = 12;
-uint8_t _sel_gun_btn            = 13;
-uint8_t _back_home_btn          = 14;
-uint8_t _stop_charging_btn      = 15;
-uint8_t _stop_charging_btn_scan = 16;
-uint8_t _chademo_dark           = 17;
-uint8_t _ccs_dark               = 18;
-uint8_t _gbt_dark               = 19;
-uint8_t _actype_dark            = 20;
-uint8_t _chademo_light          = 21;
-uint8_t _ccs_light              = 22;
-uint8_t _gbt_light              = 23;
-uint8_t _actype_light           = 24;
-uint8_t _main_none_rfid         = 25;
-uint8_t _main_rfid              = 26;
-uint8_t _main_none_app          = 27;
-uint8_t _main_app               = 28;
-uint8_t _main_none_qr           = 29;
-uint8_t _main_qr                = 30;
-uint8_t _charging_map1          = 31;
-uint8_t _charging_map2          = 32;
-uint8_t _battery_empty          = 33;
-uint8_t _battery_cap_20         = 34;
-uint8_t _battery_cap_40         = 35;
-uint8_t _battery_cap_60         = 36;
-uint8_t _battery_cap_80         = 37;
-uint8_t _battery_cap_100        = 38;
-uint8_t _battery_map            = 39;
-uint8_t _power_map              = 40;
-uint8_t _time_map               = 41;
-uint8_t _complete_map           = 42;
-uint8_t _battery_soc_20         = 43;
-uint8_t _battery_soc_40         = 44;
-uint8_t _battery_soc_60         = 45;
-uint8_t _battery_soc_80         = 46;
-uint8_t _battery_soc_100        = 47;
-uint8_t _battery_eng_map        = 48;
-uint8_t _money_map              = 49;
-uint8_t _elapse_time_map        = 50;
-uint8_t _charging_money         = 51;
-//uint8_t _side_none_rfid       = 52;
-//uint8_t _side_rfid            = 53;
-//uint8_t _side_none_app        = 54;
-//uint8_t _side_app             = 55;
-//uint8_t _side_none_qr         = 56;
-//uint8_t _side_qr              = 57;
-uint8_t _eth_disconnect         = 52; //58;
-uint8_t _eth_connect            = 53; //59;
-
-uint8_t _chademo_dark_cmp       = 54;
-uint8_t _ccs_dark_cmp           = 55;
-uint8_t _gbt_dark_cmp           = 56;
-uint8_t _actype_dark_cmp        = 57;
-uint8_t _chademo_light_cmp      = 58;
-uint8_t _ccs_light_cmp          = 59;
-uint8_t _gbt_light_cmp          = 60;
-uint8_t _actype_light_cmp       = 61;
-
-uint8_t _logo_cmp               = 62;
-uint8_t _battery_eng_trp_map    = 63;
-uint8_t _money_trp_map          = 64;
-uint8_t _elapse_time_trp_map    = 65;
-
-////For Audi
-uint8_t _left_gun_disable_map   = 66;
-uint8_t _left_gun_enable_map    = 67;
-uint8_t _right_gun_disable_map  = 68;
-uint8_t _right_gun_enable_map   = 69;
-uint8_t _select_gun_btn         = 70;
-uint8_t _emergency_disable_map  = 72;
-// For replug
-struct timespec showReplugStrTimer;
-struct timespec showFullTargetTimer;
-short __show_StatusString_value_1 = 0x0460;
-short __show_StatusString_value_2 = 0x0462;
-uint8_t _showfulltarget_1       = 73;
-uint8_t _showfulltarget_2       = 74;
-uint8_t _showReplugStr_1        = 75;
-uint8_t _showReplugStr_2        = 76;
-// Select Gun for Audi
-short __show_selectgun_value    = 0x0464;
-uint8_t _showselectgun_left     = 77;
-uint8_t _showselectgun_right    = 78;
-// Wait for gun plugin Audi
-short __show_waitgunplug_value    = 0x0468;
-uint8_t _showwaitgunplug_left     = 80;
-uint8_t _showwaitgunplug_right    = 81;
-
-//#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)
-
-//=================================
-// Common routine
-//=================================
-/*int StoreLogMsg(const char *fmt, ...)
-{
-    char Buf[4096 + 256];
-    char buffer[4096];
-    va_list args;
-    struct timeb  SeqEndTime;
-    struct tm *tm;
-
-    va_start(args, fmt);
-    int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-    va_end(args);
-
-    memset(Buf, 0, sizeof(Buf));
-    ftime(&SeqEndTime);
-    SeqEndTime.time = time(NULL);
-    tm = localtime(&SeqEndTime.time);
-
-    if (pSysConfig->SwitchDebugFlag == YES) {
-        sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
-                tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
-        printf("%s ", Buf);
-    } else {
-        sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-                tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
-                buffer,
-                tm->tm_year + 1900, tm->tm_mon + 1);
-        system(Buf);
-    }
-
-    return rc;
-}
-
-char *getTimeString(void)
-{
-    char *result = malloc(21);
-    time_t timep;
-    struct tm *p;
-    time(&timep);
-    p = gmtime(&timep);
-
-    sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900 + p->tm_year), (1 + p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
-
-    return result;
-}
-*/
-
-#if 0
-//==========================================
-// Init all share memory
-//==========================================
-int InitShareMemory()
-{
-    int result = PASS;
-    int MeterSMId;
-
-    //creat ShmSysConfigAndInfo
-    if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0) {
-#ifdef SystemLogMessage
-        log_error("shmget ShmSysConfigAndInfo NG");
-#endif
-        result = FAIL;
-    } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-#ifdef SystemLogMessage
-        log_error("shmat ShmSysConfigAndInfo NG");
-#endif
-        result = FAIL;
-    } else
-    {}
-
-    //creat ShmStatusCodeData
-    if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0) {
-#ifdef SystemLogMessage
-        log_error("shmget ShmStatusCodeData NG");
-#endif
-        result = FAIL;
-    } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-#ifdef SystemLogMessage
-        log_error("shmat ShmStatusCodeData NG");
-#endif
-        result = FAIL;
-    } else
-    {}
-
-    //creat Audi customization info
-    if ((MeterSMId = shmget(ShmSelectGunInfoKey, sizeof(SelectGunInfo), IPC_CREAT | 0777)) < 0) {
-        log_error("[main]CreatShareMemory:shmget select gun info NG ");
-        return 0;
-    } else if ((ShmSelectGunInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        log_error("[main]CreatShareMemory:shmat shmget select gun info ");
-        return 0;
-    }
-
-    //creat ShmStatusCodeData
-    if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0) {
-#ifdef SystemLogMessage
-        log_error("shmget ShmPrimaryMcuData NG");
-#endif
-        result = FAIL;
-    } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-#ifdef ShmPrimaryMcuData
-        log_error("shmat ShmPrimaryMcuData NG");
-#endif
-        result = FAIL;
-    }
-
-    return result;
-}
-#endif //0
-
-//==========================================
-// Open and Close RS232 and R/W
-//==========================================
-int CreateCommunicationLcmPort()
-{
-    int fd;
-    struct termios tios;
-
-    fd = open(pPortName, O_RDWR);
-    if (fd <= 0) {
-#ifdef SystemLogMessage
-        log_error("open /dev/ttyS3 NG ");
-#endif
-        return -1;
-    }
-    ioctl(fd, TCGETS, &tios);
-    tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
-    tios.c_lflag = 0;
-    tios.c_iflag = 0;
-    tios.c_oflag = 0;
-    tios.c_cc[VMIN] = 0;
-    tios.c_cc[VTIME] = (uint8_t) 5;
-    tios.c_lflag = 0;
-    tcflush(fd, TCIFLUSH);
-    ioctl(fd, TCSETS, &tios);
-
-    return fd;
-}
-
-void CloseCommunicationLcmPort()
-{
-    close(_port);
-}
-
-void WriteCmdToLcm(uint8_t *cmd, uint8_t cmdLen)
-{
-    int len = write(_port, cmd, cmdLen);
-    if (len >= sizeof(cmd)) {
-        //log_info("Write cmd to LCM successfully. ");
-    }
-}
-
-void ReadMsgFromLcm(uint8_t *msg, uint8_t readLen)
-{
-    read(_port, msg, readLen);
-
-    if (*msg == CMD_TITLE_1 && *(msg + 1) == CMD_TITLE_2) {
-        if (*(msg + 3) == CMD_WRITE) {
-            switch (*(msg + 4)) {
-            case CMD_REGISTER: {
-                // 頁面
-                strcpy((char *)pSysInfo->LcmHwRev, moduleName);
-            }
-            break;
-            }
-        } else if (*(msg + 3) == CMD_MULTI_READ) {
-//          switch ((unsigned short) (*(msg + 4) << 8) + (unsigned short) *(msg + 5))
-//          {
-//              case BUTTON_GUN_INDEX:
-//              {
-//                  // 當前選的槍號
-//                  _curGunIndex = (*(msg + 8));
-//              }
-//              break;
-//          }
-        }
-    }
-}
-
-//================================================
-// Function
-//================================================
-void ChangeToOtherPage(short newPage)
-{
-    uint8_t cmd[7];
-    memset(cmd, 0x00, sizeof(cmd));
-
-    cmd[0] = CMD_TITLE_1;
-    cmd[1] = CMD_TITLE_2;
-    cmd[2] = 0x02 + sizeof(newPage);
-    cmd[3] = CMD_READ;
-    cmd[4] = CMD_REGISTER;
-    cmd[5] = newPage >> 8;
-    cmd[6] = newPage & 0x00FF;
-
-    WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
-    usleep(100000);
-}
-
-void ChangeBackLight(bool islight)
-{
-    uint8_t value = 0x01;
-
-    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;
-
-    WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
-    usleep(100000);
-}
-
-void GetCurrentPage()
-{
-    uint8_t cmd[6];
-    memset(cmd, 0x00, sizeof(cmd));
-    uint8_t msg[8];
-    memset(msg, 0x00, sizeof(msg));
-
-    cmd[0] = CMD_TITLE_1;
-    cmd[1] = CMD_TITLE_2;
-    cmd[2] = 0x03;              // 底下總長度
-    cmd[3] = CMD_WRITE;
-    cmd[4] = CMD_REGISTER;
-    cmd[5] = 0x02;
-
-    WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
-    usleep(100000);
-    ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
-}
-
-void DisplayValueToLcm(short address, uint8_t *data, uint8_t len)
-{
-    uint8_t cmd[256];
-    memset(cmd, 0x00, sizeof(cmd));
-
-    cmd[0] = CMD_TITLE_1;
-    cmd[1] = CMD_TITLE_2;
-    cmd[2] = 0x03 + len;
-    cmd[3] = CMD_MULTI_WRITE;
-    cmd[4] = address >> 8;
-    cmd[5] = address & 0x00FF;
-
-    for (uint8_t count = 0; count < len; count++) {
-        cmd[6 + count] = *(data + count);
-    }
-
-    WriteCmdToLcm(cmd, cmd[2] + 3);
-}
-
-void ChangeDisplay2Value(short address, short value)
-{
-    uint8_t data[2];
-    data[0] = value >> 8;
-    data[1] = value & 0x00FF;
-
-    DisplayValueToLcm(address, data, sizeof(data));
-}
-
-void GetBtnStatus(short address, uint8_t len)
-{
-    uint8_t cmd[8];
-    memset(cmd, 0x00, sizeof(cmd));
-    uint8_t msg[8];
-    memset(msg, 0x00, sizeof(msg));
-
-    cmd[0] = CMD_TITLE_1;
-    cmd[1] = CMD_TITLE_2;
-    cmd[2] = 0x03 + len;
-    cmd[3] = CMD_MULTI_READ;
-    cmd[4] = address >> 8;
-    cmd[5] = address & 0x00FF;
-    cmd[6] = 0x00 + len;
-
-    WriteCmdToLcm(cmd, cmd[2] + 3);
-    usleep(100000);
-    ReadMsgFromLcm(msg, (len * 2) + sizeof(msg));
-}
-
-//================================================
-// Warning process
-//================================================
-void string2ByteArray(uint8_t *input, uint8_t *output)
-{
-    int loop;
-    int i;
-
-    loop = 0;
-    i = 0;
-
-    while (input[loop] != '\0') {
-        output[i++] = input[loop++];
-    }
-    output[loop] = '\0';
-}
-
-void ChangeWarningFunc()
-{
-    uint8_t cmd[7] = {0};
-    uint8_t i = 0;
-    //uint8_t j = 0;
-    //log_info("ChangeWarningFunc ");
-    // 最多一次五筆
-    //log_info("LCM PageIndex = %d ", pSysWarning->PageIndex);
-    //log_info("WarningCount = %d ", pSysWarning->WarningCount);
-//#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
-    for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
-        memset(cmd, 0x00, sizeof(cmd));
-        if ((i) >= 5) {
-            break;
-        }
-
-        //error code
-        string2ByteArray(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], cmd);
-        DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
-        //警告標示
-        memset(cmd, 0x00, sizeof(cmd));
-
-        cmd[0] = 0x00;
-        cmd[1] = 0x01;
-        DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
-    }
-
-    memset(cmd, 0x00, sizeof(cmd));
-    for (; i < 5; i++) {
-        DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
-        DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
-    }
-
-    /*#else
-        for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
-            memset(cmd, 0x00, sizeof(cmd));
-            if ((i - j) >= 5) {
-                break;
-            }
-            if (
-                (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "033900", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "033901", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "033902", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043627", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043628", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043622", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043623", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043624", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043625", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "043626", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "042241", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], "042242", 6) == 0)
-            ) {
-                j++;
-                continue;
-            }
-            //error code
-            string2ByteArray(&pSysWarning->WarningCode[i + pSysWarning->PageIndex * 5][0], cmd);
-            DisplayValueToLcm(0x0010 + ((i - j) * 6), cmd, sizeof(cmd));
-            //警告標示
-            memset(cmd, 0x00, sizeof(cmd));
-
-            cmd[0] = 0x00;
-            cmd[1] = 0x01;
-            DisplayValueToLcm(0x0002 + ((i - j) * 2), cmd, 2);
-        }
-
-        memset(cmd, 0x00, sizeof(cmd));
-        i = i - j;
-        for (; (i) < 5; i++) {
-            DisplayValueToLcm(0x0010 + ((i) * 6), cmd, sizeof(cmd));
-            DisplayValueToLcm(0x0002 + ((i) * 2), cmd, 2);
-        }
-
-    #endif //!defined DD360 && !defined DD360Audi
-    */
-}
-
-//================================================
-// QR Code process
-//================================================
-void ChangeQrCode_Idle(char *input)
-{
-#if defined DD360Audi
-    int len = strlen(input) + 3;
-    int loop = 0;
-    int i = 0, j = 0, k = 0, l = 0;
-    uint8_t qrUrl[128] = {0};
-    uint16_t urlLen = 0;
-    uint8_t cmd[len];
-    uint8_t tmpBuf[15] = {0};
-    //uint8_t tmpLen = sizeof(tmpBuf) - 1;
-
-    strncpy((char *)cmd, " ", len);
-
-    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", tmpBuf);
-            } else if (i >= 21 && i <= 23) {
-                tmpBuf[k++] = input[l];
-            }
-        }
-    }
-    tmpBuf[k] = '\0';
-    //printf("tmpBuf = %s", tmpBuf);
-    j += sprintf((char *)&cmd[i], ":%d", pSysInfo->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", qrUrl);
-    DisplayValueToLcm(__qr_code, qrUrl, urlLen);
-
-    j = 0;
-    j += sprintf((char *)&tmpBuf[k], "0%d", pSysInfo->CurGunSelected); ////For Audi
-    tmpBuf[k + j] = '\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));
-        tmpBuf[tmpLen] = '\0';
-        DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
-
-        memset(tmpBuf, 0, sizeof(tmpBuf));
-        strncpy((char *)tmpBuf, (char *)&cmd[tmpLen], sizeof(tmpBuf));
-        tmpBuf[tmpLen] = '\0';
-        DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
-    } else {
-        DisplayValueToLcm(__custStationIdL1, cmd, len);
-
-        strncpy((char *)tmpBuf, " ", sizeof(tmpBuf));
-        tmpBuf[tmpLen] = '\0';
-        DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
-    }*/
-
-#else
-    int len = strlen(input);
-    uint8_t cmd[len];
-
-    int loop = 0;
-    int i = 0;
-
-    while (input[loop] != '\0') {
-        cmd[i++] = input[loop++];
-    }
-
-    DisplayValueToLcm(__qr_code, cmd, len + 1);
-#endif //defined DD360Audi
-}
-
-void ChangeQrCode_Charge(char *input)
-{
-#if defined DD360Audi
-    int len = strlen(input) + 3;
-    int loop = 0;
-    int i = 0, j = 0, k = 0, l = 0;
-    uint8_t qrUrl[128] = {0};
-    uint16_t urlLen = 0;
-    uint8_t cmd[len];
-    uint8_t tmpBuf[15] = {0};
-    //uint8_t tmpLen = sizeof(tmpBuf) - 1;
-
-    strncpy((char *)cmd, " ", len);
-
-    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", tmpBuf);
-            } else if (i >= 21 && i <= 23) {
-                tmpBuf[k++] = input[l];
-            }
-        }
-    }
-    tmpBuf[k] = '\0';
-    //printf("tmpBuf = %s", tmpBuf);
-    j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
-    cmd[len - 1] = '\0';
-    urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
-    qrUrl[urlLen] = '\0';
-    DisplayValueToLcm(__qr_code, qrUrl, urlLen);
-
-    j = 0;
-    j += sprintf((char *)&tmpBuf[k], "0%d", pSysInfo->CurGunSelected); ////For Audi
-    tmpBuf[k + j] = '\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));
-        tmpBuf[tmpLen] = '\0';
-        DisplayValueToLcm(__custStationIdL1, tmpBuf, sizeof(tmpBuf));
-
-        memset(tmpBuf, 0, sizeof(tmpBuf));
-        strncpy((char *)tmpBuf, (char *)&cmd[tmpLen], sizeof(tmpBuf));
-        tmpBuf[tmpLen] = '\0';
-        DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
-    } else {
-        DisplayValueToLcm(__custStationIdL1, cmd, len);
-
-        strncpy((char *)tmpBuf, " ", sizeof(tmpBuf));
-        tmpBuf[tmpLen] = '\0';
-        DisplayValueToLcm(__custStationIdL2, tmpBuf, sizeof(tmpBuf));
-    }*/
-
-#else
-    int len = strlen(input);
-    uint8_t cmd[len];
-
-    int loop = 0;
-    int i = 0;
-
-    while (input[loop] != '\0') {
-        cmd[i++] = input[loop++];
-    }
-
-    DisplayValueToLcm(__qr_code_pre, cmd, len + 1);
-#endif //defined DD360Audi
-}
-
-//================================================
-// Change current page
-//================================================
-void ChangeCurPage()
-{
-    //log_info("cur = %d, new = %d ", _currentPage, pSysInfo->PageIndex);
-    if (_currentPage != pSysInfo->PageIndex) {
-        _currentPage = pSysInfo->PageIndex;
-        ChangeToOtherPage(_currentPage);
-        _everyPageRollChange = 0;
-    }
-}
-
-//================================================
-// Main process
-//================================================
-uint8_t demoCount = 0;
-void DemoFunction()
-{
-    if (demoCount == 0) {
-        pSysWarning->WarningCount = 6;
-        memcpy(&pSysWarning->WarningCode[0][0], "000001", 7);
-        memcpy(&pSysWarning->WarningCode[1][0], "000002", 7);
-        memcpy(&pSysWarning->WarningCode[2][0], "000003", 7);
-        memcpy(&pSysWarning->WarningCode[3][0], "000004", 7);
-        memcpy(&pSysWarning->WarningCode[4][0], "000005", 7);
-        memcpy(&pSysWarning->WarningCode[5][0], "000006", 7);
-    } else {
-        if (demoCount == 20) {
-            pSysInfo->PageIndex = _LCM_IDLE;
-        } else if (demoCount == 80) {
-            pSysInfo->PageIndex = _LCM_AUTHORIZING;
-        } else if (demoCount == 100) {
-            pSysInfo->PageIndex = _LCM_AUTHORIZ_COMP;
-        } else if (demoCount == 120) {
-            pSysInfo->PageIndex = _LCM_AUTHORIZ_FAIL;
-        } else if (demoCount == 140) {
-            pSysInfo->PageIndex = _LCM_PRE_CHARGE;
-        } else if (demoCount == 180) {
-            pSysInfo->PageIndex = _LCM_CHARGING;
-        }
-    }
-
-    if (demoCount < 180) {
-        demoCount++;
-    }
-}
-
-//================================================
-// Main process
-//================================================
-bool FindChargingInfoData(uint8_t target, struct ChargingInfoData **_chargingData)
-{
-    for (uint8_t index = 0; index < CHAdeMO_QUANTITY; index++) {
-        if (pSysInfo->ChademoChargingData[index].Index == target) {
-            _chargingData[target] = &pSysInfo->ChademoChargingData[index];
-            return true;
-        }
-    }
-
-    for (uint8_t index = 0; index < CCS_QUANTITY; index++) {
-        if (pSysInfo->CcsChargingData[index].Index == target) {
-            _chargingData[target] = &pSysInfo->CcsChargingData[index];
-            return true;
-        }
-    }
-
-    for (uint8_t index = 0; index < GB_QUANTITY; index++) {
-        if (pSysInfo->GbChargingData[index].Index == target) {
-            _chargingData[target] = &pSysInfo->GbChargingData[index];
-            return true;
-        }
-    }
-
-    return false;
-}
-
-bool FindAcChargingInfoData(uint8_t target, struct ChargingInfoData **acChargingData)
-{
-    if (target < AC_QUANTITY) {
-        acChargingData[target] = &pSysInfo->AcChargingData[target];
-        return true;
-    }
-
-    return false;
-}
-int GetTimeoutValue(struct timespec *startTime)
-{
-    struct timespec endTime;
-    clock_gettime(CLOCK_MONOTONIC_COARSE, &endTime);
-    return endTime.tv_sec - startTime->tv_sec;
-}
-void GetTimespecFunc(struct timespec *time)
-{
-    clock_gettime(CLOCK_MONOTONIC_COARSE, time);
-}
-
-void RunReplugStringFunction(bool isRun)
-{
-    if (isRun) {
-        int time = GetTimeoutValue(&showReplugStrTimer);
-        if (time >=1 && time <2) {
-            ChangeDisplay2Value(__show_StatusString_value_1, _showReplugStr_1);
-            ChangeDisplay2Value(__show_StatusString_value_2, _showReplugStr_2);
-        } else if (time < 1) {
-            ChangeDisplay2Value(__show_StatusString_value_1, _disappear);
-            ChangeDisplay2Value(__show_StatusString_value_2, _disappear);
-        } else
-            GetTimespecFunc(&showReplugStrTimer);
-
-    } else {
-        ChangeDisplay2Value(__show_StatusString_value_1, _disappear);
-        ChangeDisplay2Value(__show_StatusString_value_2, _disappear);
-    }
-}
-void RunFullTargetFunction(bool isRun)
-{
-    if (isRun) {
-        int time = GetTimeoutValue(&showFullTargetTimer);
-        if (time >=1 && time <2) {
-            ChangeDisplay2Value(__show_StatusString_value_1, _showfulltarget_1 );
-            ChangeDisplay2Value(__show_StatusString_value_2, _showfulltarget_2);
-        } else if (time < 1) {
-            ChangeDisplay2Value(__show_StatusString_value_1, _disappear);
-            ChangeDisplay2Value(__show_StatusString_value_2, _disappear);
-
-        } else
-            GetTimespecFunc(&showFullTargetTimer);
-
-    } else {
-        ChangeDisplay2Value(__show_StatusString_value_1, _disappear);
-        ChangeDisplay2Value(__show_StatusString_value_2, _disappear);
-    }
-}
-
-/**
- * [ChangeBalanceValue :print balance information]
- * @Author
- * @DateTime 2020-11-26
- */
-static void ChangeBalanceValue(uint16_t addr, uint8_t index) ////For Audi
-{
-    uint8_t cmd[10] = {0};
-    uint8_t value[10] = {0};
-    uint8_t len = 0;
-    float balance = ShmSelectGunInfo->PricesInfo[index].Balance;
-
-    if ((balance) == (FAIL_BALANCE_PRICES)) {
-        balance = 0.00;
-    }
-
-    len += sprintf((char *) value, "%.2f", balance);
-    if (len < 6) {
-        sprintf((char *)&value[len], "%s",
-                (uint8_t *)GetCurrency(pSysConfig->BillingData.Currency));
-    }
-
-    value[sizeof(value) - 1] = '\0';
-
-    string2ByteArray(value, cmd);
-    DisplayValueToLcm(addr, cmd, sizeof(cmd));
-}
-
-void ChangeAcBattMapAndValue(short page)
-{
-    pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
-
-    if (page == _LCM_CHARGING) {
-        if (isDiffStatus != _battery_display_ani) {
-            isChangeBattMap = false;
-            isDiffStatus = _battery_display_ani;
-        }
-
-        if (pAcChargingInfo->IsCharging && !isChangeBattMap) {
-            isChangeBattMap = true;
-            if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV5) {
-                ChangeDisplay2Value(__batt_map, _battery_empty);
-                ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_EMP;
-            } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_EMP) {
-                ChangeDisplay2Value(__batt_map, _battery_cap_20);
-                ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV1;
-            } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV1) {
-                ChangeDisplay2Value(__batt_map, _battery_cap_40);
-                ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV2;
-            } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV2) {
-                ChangeDisplay2Value(__batt_map, _battery_cap_60);
-                ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV3;
-            } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV3) {
-                ChangeDisplay2Value(__batt_map, _battery_cap_80);
-                ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV4;
-            } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV4) {
-                ChangeDisplay2Value(__batt_map, _battery_cap_100);
-                ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV5;
-            }
-        }
-    } else if (page == _LCM_COMPLETE) {
-        if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV5) {
-            ChangeDisplay2Value(__batt_map, _battery_soc_20);
-        } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_EMP) {
-            ChangeDisplay2Value(__batt_map, _battery_soc_20);
-        } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV1) {
-            ChangeDisplay2Value(__batt_map, _battery_soc_40);
-        } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV2) {
-            ChangeDisplay2Value(__batt_map, _battery_soc_60);
-        } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV3) {
-            ChangeDisplay2Value(__batt_map, _battery_soc_80);
-        } else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV4) {
-            ChangeDisplay2Value(__batt_map, _battery_soc_100);
-        }
-    }
-
-    ChangeDisplay2Value(__soc_value_charging, _disappear);
-}
-
-void ChangeBattMapAndValue(short page, int soc)
-{
-//  srand(time(NULL));
-//  int min = 10;
-//  int max = 90;
-//  soc = rand() % (max - min + 1) + min;
-
-    if (page == _LCM_PRE_CHARGE) {
-        ChangeDisplay2Value(__batt_map_empty, _battery_empty);
-    } else if (page == _LCM_CHARGING) {
-        if (soc < 20) {
-            if (_battery_display_ani) {
-                ChangeDisplay2Value(__batt_map, _battery_empty);
-            } else {
-                ChangeDisplay2Value(__batt_map, _battery_cap_20);
-            }
-        } else if (soc >= 20 && soc < 40) {
-            if (_battery_display_ani) {
-                ChangeDisplay2Value(__batt_map, _battery_cap_20);
-            } else {
-                ChangeDisplay2Value(__batt_map, _battery_cap_40);
-            }
-        } else if (soc >= 40 && soc < 60) {
-            if (_battery_display_ani) {
-                ChangeDisplay2Value(__batt_map, _battery_cap_40);
-            } else {
-                ChangeDisplay2Value(__batt_map, _battery_cap_60);
-            }
-        } else if (soc >= 60 && soc < 80) {
-            if (_battery_display_ani) {
-                ChangeDisplay2Value(__batt_map, _battery_cap_60);
-            } else {
-                ChangeDisplay2Value(__batt_map, _battery_cap_80);
-            }
-        } else if (soc >= 80 && soc <= 100) {
-            if (_battery_display_ani) {
-                ChangeDisplay2Value(__batt_map, _battery_cap_80); //DS60-120 add
-            } else {
-                ChangeDisplay2Value(__batt_map, _battery_cap_100);
-            }
-        }
-    } else if (page == _LCM_COMPLETE) {
-        if (soc < 20) {
-            ChangeDisplay2Value(__batt_map, _battery_soc_20);
-        } else if (soc >= 20 && soc < 40) {
-            ChangeDisplay2Value(__batt_map, _battery_soc_40);
-        } else if (soc >= 40 && soc < 60) {
-            ChangeDisplay2Value(__batt_map, _battery_soc_60);
-        } else if (soc >= 60 && soc < 80) {
-            ChangeDisplay2Value(__batt_map, _battery_soc_80);
-        } else if (soc >= 80 && soc <= 100) {
-            ChangeDisplay2Value(__batt_map, _battery_soc_100);
-        }
-    }
-
-    uint8_t cmd[5];
-    uint8_t value[5];
-
-    memset(cmd, 0x00, sizeof(cmd));
-    memset(value, 0x00, sizeof(value));
-    sprintf((char *)value, "%d%%", soc);
-    string2ByteArray(value, cmd);
-    DisplayValueToLcm(__soc_value_charging, cmd, sizeof(cmd));
-}
-
-void ChangeRemainTime(int sec)
-{
-    int h, m, s;
-    uint8_t cmd[10];
-    uint8_t value[10];
-
-    memset(cmd, 0x00, sizeof(cmd));
-
-//  srand(time(NULL));
-//  int min = 0;
-//  int max = 65536;
-//  sec = rand() % (max - min + 1) + min;
-
-    h = (sec / 3600);
-    m = (sec - (3600 * h)) / 60;
-    s = (sec - (3600 * h) - (m * 60));
-    sprintf((char *)value, "%02d:%02d:%02d", h, m, s);
-    string2ByteArray(value, cmd);
-    DisplayValueToLcm(__remain_time_tx, cmd, sizeof(cmd));
-}
-
-void ChangeChargingEnergyValue(float energy)
-{
-    uint8_t cmd[10];
-    uint8_t value[10];
-
-    memset(cmd, 0x00, sizeof(cmd));
-    if (energy >= 0.05) {
-        energy -= 0.05;
-    }
-    sprintf((char *) value, "%.1f kWh", energy);
-    string2ByteArray(value, cmd);
-    DisplayValueToLcm(__total_out_eng_tx, cmd, sizeof(cmd));
-}
-
-void ChangeChargingPowerValue(float pow)
-{
-    uint8_t cmd[10];
-    uint8_t value[10];
-
-    memset(cmd, 0x00, sizeof(cmd));
-
-//  float min = 0.0;
-//  float max = 50;
-//  pow = (max - min) * rand() / (RAND_MAX + 1.0) + min;
-    sprintf((char *) value, "%.1f kW", pow);
-    string2ByteArray(value, cmd);
-    DisplayValueToLcm(__output_eng_tx, cmd, sizeof(cmd));
-}
-
-void ChangeChargingFeeValue(float fee)
-{
-    uint8_t cmd[10];
-    uint8_t value[10];
-
-    memset(cmd, 0x00, sizeof(cmd));
-
-    sprintf((char *) value, "%.2f", fee);
-    string2ByteArray(value, cmd);
-    DisplayValueToLcm(__charging_fee_tx, cmd, sizeof(cmd));
-}
-
-void DisplayMoneyRate(float money)
-{
-    uint8_t cmd[8];
-    uint8_t value[8];
-
-    memset(cmd, 0x00, sizeof(cmd));
-
-    sprintf((char *) value, "%.2f", money);
-    string2ByteArray(value, cmd);
-    DisplayValueToLcm(__money_by_rate, cmd, sizeof(cmd));
-}
-
-void DisplayMoneyCur(uint8_t *cur)
-{
-    uint8_t cmd[10] = {0};
-    uint8_t buf[10] = {0};
-    uint8_t len = 0;
-
-    *(cur + 3) = '\0';
-    memset(cmd, 0x00, sizeof(cmd));
-    len = sprintf((char *) buf, "%s/kWh", cur);
-    buf[len] = '\0';
-    string2ByteArray(buf, cmd);
-    DisplayValueToLcm(__money_rate, cmd, sizeof(cmd));
-}
-
-void RefreshPageAnimation(uint8_t value)
-{
-    switch (_currentPage) {
-    case _LCM_IDLE: {
-
-    }
-    break;
-    case _LCM_WAIT_FOR_PLUG: {
-        if (_everyPageRollChange == 0) {
-            ChangeDisplay2Value(__plug_in_arrow, _arrow_dark);
-        } else if (_everyPageRollChange == 15) {
-            ChangeDisplay2Value(__plug_in_arrow, _arrow_light);
-        }
-
-        _everyPageRollChange > 30 ? _everyPageRollChange = 0 : _everyPageRollChange++;
-    }
-    break;
-    case _LCM_PRE_CHARGE:
-    case _LCM_CHARGING:
-    case _LCM_COMPLETE: {
-        if (_currentPage == _LCM_PRE_CHARGE) {
-            if (_everyPageRollChange == 0 || _everyPageRollChange == 22) {
-                ChangeDisplay2Value(__conn_line, _conn_map1);
-            } else if (_everyPageRollChange == 11 || _everyPageRollChange == 33) {
-                ChangeDisplay2Value(__conn_line, _conn_map2);
-            }
-        } else if (_currentPage == _LCM_CHARGING) {
-            if (_everyPageRollChange == 0 || _everyPageRollChange == 22) {
-                ChangeDisplay2Value(__conn_line_chag, _charging_map1);
-            } else if (_everyPageRollChange == 11 || _everyPageRollChange == 33) {
-                ChangeDisplay2Value(__conn_line_chag, _charging_map2);
-            }
-        } else if (_currentPage == _LCM_COMPLETE) {
-            if (_everyPageRollChange == 0) {
-                ChangeDisplay2Value(__conn_line_comp, _complete_map);
-            }
-        }
-
-        _everyPageRollChange >= 45 ? _everyPageRollChange = 0 : _everyPageRollChange++;
-    }
-    break;
-    }
-}
-
-void RefreshConnStatus()
-{
-    // Wifi priority is higher than Ethernet
-#if defined DD360 ||defined DD360Audi || defined DD360ComBox
-    uint8_t i = 0;
-    uint8_t ethstatus = 0;
-
-    for (i = 0; i < pSysWarning->WarningCount; i++) {
-        if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
-            ethstatus = 1;
-            //if (ShmSelectGunInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
-            //    ShmSelectGunInfo->EthDevStatus.Ethernet = DEV_ST_ENABLE_NO_USE;
-            //}
-            break;
-        }
-    }
-
-    if (ShmSelectGunInfo->EthDevStatus.Backend == DEV_ST_DISABLE) {
-        ChangeDisplay2Value(__conn_status, _disappear);
-    } else if (ShmSelectGunInfo->EthDevStatus.Backend == DEV_ST_ENABLE_USE) {
-        ChangeDisplay2Value(__conn_status, _connect);
-    } else if (ShmSelectGunInfo->EthDevStatus.Backend == DEV_ST_ENABLE_NO_USE) {
-        ChangeDisplay2Value(__conn_status, _disconnect);
-    }
-
-    if (ethstatus == 1) {
-        if (ShmSelectGunInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
-            ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
-        }
-    } else {
-        if (ShmSelectGunInfo->EthDevStatus.Ethernet != DEV_ST_DISABLE) {
-            ChangeDisplay2Value(__ethernet_status, _eth_connect);
-        }
-        //if (ShmSelectGunInfo->EthDevStatus.Ethernet == DEV_ST_DISABLE) {
-        //} else if (ShmSelectGunInfo->EthDevStatus.Ethernet == DEV_ST_ENABLE_USE) {
-        //    ChangeDisplay2Value(__ethernet_status, _eth_connect);
-        //} else if (ShmSelectGunInfo->EthDevStatus.Ethernet == DEV_ST_ENABLE_NO_USE) {
-        //    ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
-        //}
-    }
-
-    if (ShmSelectGunInfo->EthDevStatus.Wifi == DEV_ST_DISABLE) {
-        ChangeDisplay2Value(__wifi_status, _disappear);
-
-        ChangeDisplay2Value(__3G4G_status, _disappear);
-        if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_DISABLE) {
-            ChangeDisplay2Value(__3G4G_move_status, _disappear);
-        } else if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_ENABLE_USE) {
-            ChangeDisplay2Value(__3G4G_move_status, __3G4G_connect);
-        } else if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_ENABLE_NO_USE) {
-            ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect);
-        }
-    } else if (ShmSelectGunInfo->EthDevStatus.Wifi == DEV_ST_ENABLE_USE) {
-        ChangeDisplay2Value(__3G4G_move_status, _disappear);
-        ChangeDisplay2Value(__wifi_status, _wifi_connect);
-    } else if (ShmSelectGunInfo->EthDevStatus.Wifi == DEV_ST_ENABLE_NO_USE) {
-        ChangeDisplay2Value(__3G4G_move_status, _disappear);
-        ChangeDisplay2Value(__wifi_status, _wifi_disconnect);
-    }
-
-    if (ShmSelectGunInfo->EthDevStatus.Wifi != DEV_ST_DISABLE) {
-        if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_DISABLE) {
-            ChangeDisplay2Value(__3G4G_status, _disappear);
-        } else if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_ENABLE_USE) {
-            ChangeDisplay2Value(__3G4G_status, __3G4G_connect);
-        } else if (ShmSelectGunInfo->EthDevStatus.FourG == DEV_ST_ENABLE_NO_USE) {
-            ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect);
-        }
-    }
-
-    //uint8_t flag[4] = {0};
-
-    /*for (i = 0; i < pSysWarning->WarningCount; i++) {
-        //printf("status code = %s", &pSysWarning->WarningCode[i][0]);
-        if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
-            flag[0] = 1;
-            continue;
-        }
-
-        if (memcmp(&pSysWarning->WarningCode[i][0], "043625", 6) == 0) {
-            //disconnected from AP through WiFi
-            flag[1] = 1;
-            continue;
-        }
-
-        if (memcmp(&pSysWarning->WarningCode[i][0], "043627", 6) == 0) { //wifi disabled
-            flag[1] = 2;
-            continue;
-        }
-
-        if ((memcmp(&pSysWarning->WarningCode[i][0], "033900", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i][0], "033901", 6) == 0) ||
-                (memcmp(&pSysWarning->WarningCode[i][0], "033902", 6) == 0)) {
-            flag[2] = 1;
-            continue;
-        }
-
-        if (memcmp(&pSysWarning->WarningCode[i][0], "043626", 6) == 0) {
-            //disconnected from APN through 3G/4G
-            flag[3] = 1;
-            continue;
-        }
-
-        if (memcmp(&pSysWarning->WarningCode[i][0], "043628", 6) == 0) { //4g disabled
-            flag[3] = 2;
-            continue;
-        }
-    }
-
-
-    if (flag[0] == 1) {
-        ChangeDisplay2Value(__ethernet_status, _eth_disconnect);
-    } else {
-        ChangeDisplay2Value(__ethernet_status, _eth_connect);
-    }
-
-    //ChangeDisplay2Value(__wifi_status, _disappear);
-    //ChangeDisplay2Value(__conn_status, _disappear);
-    //ChangeDisplay2Value(__3G4G_status, _disappear);
-
-    if (flag[1] == 1) {
-        ChangeDisplay2Value(__3G4G_move_status, _disappear);
-        ChangeDisplay2Value(__wifi_status, _wifi_disconnect);
-    } else if (flag[1] == 2) {
-        ChangeDisplay2Value(__wifi_status, _disappear);
-    } else {
-        ChangeDisplay2Value(__3G4G_move_status, _disappear);
-        ChangeDisplay2Value(__wifi_status, _wifi_connect);
-    }
-
-    if (flag[2] == 1) {
-        ChangeDisplay2Value(__conn_status, _disconnect);
-    } else {
-        ChangeDisplay2Value(__conn_status, _connect);
-    }
-
-    if (flag[1] == 2) {
-        ChangeDisplay2Value(__3G4G_status, _disappear);
-        if (flag[3] == 1) {
-            ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect);
-        } else if (flag[3] == 2) {
-            ChangeDisplay2Value(__3G4G_move_status, _disappear);
-        } else {
-            ChangeDisplay2Value(__3G4G_move_status, __3G4G_connect);
-        }
-    } else {
-        if (flag[3] == 1) {
-            ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect);
-        } else if (flag[3] == 2) {
-            ChangeDisplay2Value(__3G4G_status, _disappear);
-        } else {
-            ChangeDisplay2Value(__3G4G_status, __3G4G_connect);
-        }
-    }
-    */
-#else
-// eth
-    if (pSysInfo->ethInternetConn == YES) {
-        ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
-    } else {
-        ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
-    }
-
-    // Wifi
-    if ((pSysConfig->ModelName[10] == 'W' ||
-            pSysConfig->ModelName[10] == 'D') &&
-            pSysConfig->AthInterface.WifiMode != _SYS_WIFI_MODE_DISABLE) {
-        if (pSysConfig->AthInterface.WifiNetworkConn == YES ||
-                pSysConfig->AthInterface.WifiMode == _SYS_WIFI_MODE_AP) {
-            ChangeDisplay2Value(__wifi_status, _wifi_connect);
-        } else {
-            ChangeDisplay2Value(__wifi_status, _wifi_disconnect);
-        }
-    } else {
-        ChangeDisplay2Value(__wifi_status, _disappear);
-    }
-
-    if ((pSysConfig->ModelName[10] == 'T' ||
-            pSysConfig->ModelName[10] == 'D') &&
-            pSysConfig->TelecomInterface.TelcomEnabled != NO) {
-        if (pSysConfig->AthInterface.WifiMode == _SYS_WIFI_MODE_DISABLE) {
-            ChangeDisplay2Value(__3G4G_status, _disappear);
-            // 3G/4G
-            if (pSysConfig->TelecomInterface.TelcomNetworkConn == YES)
-            { ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect); }
-            else
-            { ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect); }
-        } else {
-            ChangeDisplay2Value(__3G4G_move_status, _disappear);
-            // 3G/4G
-            if (pSysConfig->TelecomInterface.TelcomNetworkConn == YES)
-            { ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect); }
-
-            else
-            { ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect); }
-        }
-    } else {
-        ChangeDisplay2Value(__3G4G_status, _disappear);
-
-        ChangeDisplay2Value(__3G4G_move_status, _disappear);
-    }
-
-    // 連線到後台
-    if (pSysInfo->OcppConnStatus == YES) {
-        ChangeDisplay2Value(__conn_status, _connect);
-    } else {
-        ChangeDisplay2Value(__conn_status, _disconnect);
-    }
-
-    /*if (pSysConfig->AthInterface.WifiNetworkConn == YES ||
-            pSysConfig->AthInterface.WifiMode == _SYS_WIFI_MODE_AP) {
-        _wifi_conn_status = true;
-        ChangeDisplay2Value(__wifi_status, _wifi_connect);
-        ChangeDisplay2Value(__ethernet_status, _disappear);
-    } else {
-        _wifi_conn_status = false;
-        ChangeDisplay2Value(__wifi_status, _disappear);
-    }
-
-    if (!_wifi_conn_status) {
-        if (pSysConfig->TelecomInterface.TelcomNetworkConn == YES ||
-                pSysInfo->InternetConn == YES) {
-            ChangeDisplay2Value(__ethernet_status, _ethernet_connect);
-        } else {
-            ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect);
-        }
-    }
-
-    // 連線到後台
-    if (pSysInfo->OcppConnStatus == YES) {
-        ChangeDisplay2Value(__conn_status, _connect);
-    } else {
-        ChangeDisplay2Value(__conn_status, _disconnect);
-    }
-    */
-#endif //defined DD360 || defined DD360Audi
-}
-
-uint8_t FirstPageChanged()
-{
-    uint8_t result = NO;
-
-    if (_currentPage != _oldPage) {
-        result = YES;
-        _oldPage = _currentPage;
-    }
-
-    return result;
-}
-
-bool IsPageReloadChk()
-{
-    bool result = false;
-
-    if (pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
-        if (_curPage_index != pSysInfo->CurGunSelected) {
-            _curPage_index = pSysInfo->CurGunSelected;
-            result = true;
-        }
-    } else {
-        if (_curPage_index != pSysInfo->CurGunSelectedByAc) {
-            _curPage_index = pSysInfo->CurGunSelectedByAc;
-            result = true;
-        }
-    }
-
-    return result;
-}
-
-void ClearDisplayInfo()
-{
-    ChangeDisplay2Value(__csu_ver_string, _disappear);
-    ChangeDisplay2Value(__csu_ver_value, _disappear);
-
-    ChangeDisplay2Value(__eth0_ip_string, _disappear);
-    ChangeDisplay2Value(__eth0_ip_value, _disappear);
-
-    ChangeDisplay2Value(__sn_string, _disappear);
-    ChangeDisplay2Value(__sn_value, _disappear);
-
-    ChangeDisplay2Value(__dc1_ver_string, _disappear);
-    ChangeDisplay2Value(__dc1_ver_value, _disappear);
-
-    ChangeDisplay2Value(__dc2_ver_string, _disappear);
-    ChangeDisplay2Value(__dc2_ver_value, _disappear);
-
-    ChangeDisplay2Value(__fan_speed_string, _disappear);
-    ChangeDisplay2Value(__fan_speed_value, _disappear);
-}
-
-void DisplayInfoCsuVer(bool isShow, uint8_t *modelName)
-{
-    if (isShow) {
-        uint8_t value[10];
-
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *)value, "CSU Ver >");
-        DisplayValueToLcm(__csu_ver_string, value, sizeof(value));
-        memset(value, 0x00, sizeof(value));
-        strncpy((char *)value, (char *)modelName, 5);
-        DisplayValueToLcm(__csu_ver_value, value, sizeof(value));
-    } else {
-        ChangeDisplay2Value(__csu_ver_string, _disappear);
-        ChangeDisplay2Value(__csu_ver_value, _disappear);
-    }
-}
-
-void ShowWifiMode(bool isShow, uint8_t mode)
-{
-    if (isShow) {
-        uint8_t value[20];
-
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, "Wifi Mo. >");
-        DisplayValueToLcm(__csu_ver_string, value, sizeof(value));
-        memset(value, 0x00, sizeof(value));
-        if (mode == 0) {
-            sprintf((char *)value, "disable");
-        } else if (mode == 1) {
-            sprintf((char *)value, "station");
-        } else if (mode == 2) {
-            sprintf((char *)value, "AP");
-        }
-
-        DisplayValueToLcm(__csu_ver_value, value, sizeof(value));
-    } else {
-        ChangeDisplay2Value(__csu_ver_string, _disappear);
-        ChangeDisplay2Value(__csu_ver_value, _disappear);
-    }
-}
-
-void DisplayInfoEthIp(bool isShow, uint8_t *ip)
-{
-    if (isShow) {
-        uint8_t value[20];
-
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, "Eth IP >");
-        DisplayValueToLcm(__eth0_ip_string, value, sizeof(value));
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, (char *) ip);
-        DisplayValueToLcm(__eth0_ip_value, value, sizeof(value));
-    } else {
-        ChangeDisplay2Value(__eth0_ip_string, _disappear);
-        ChangeDisplay2Value(__eth0_ip_value, _disappear);
-    }
-}
-
-void Show4GRssi(bool isShow, int dbValue)
-{
-    if (isShow) {
-        uint8_t value[20];
-
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, "RSSI >");
-        DisplayValueToLcm(__eth0_ip_string, value, sizeof(value));
-        memset(value, 0x00, sizeof(value));
-        sprintf((char *)value, "%d dBm", dbValue);
-        DisplayValueToLcm(__eth0_ip_value, value, sizeof(value));
-    } else {
-        ChangeDisplay2Value(__eth0_ip_string, _disappear);
-        ChangeDisplay2Value(__eth0_ip_value, _disappear);
-    }
-}
-
-void DisplayInfoSN(bool isShow, uint8_t *sn)
-{
-    if (isShow) {
-        uint8_t value[30];
-
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, "SN >");
-        DisplayValueToLcm(__sn_string, value, sizeof(value));
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, (char *) sn);
-        DisplayValueToLcm(__sn_value, value, sizeof(value));
-    } else {
-        ChangeDisplay2Value(__sn_string, _disappear);
-        ChangeDisplay2Value(__sn_value, _disappear);
-    }
-}
-
-void ShowWifiRssi(bool isShow, int dbValue)
-{
-    if (isShow) {
-        uint8_t value[20];
-
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, "RSSI >");
-        DisplayValueToLcm(__sn_string, value, sizeof(value));
-        memset(value, 0x00, sizeof(value));
-        sprintf((char *)value, "%d dBm", dbValue);
-        DisplayValueToLcm(__sn_value, value, sizeof(value));
-    } else {
-        ChangeDisplay2Value(__sn_string, _disappear);
-        ChangeDisplay2Value(__sn_value, _disappear);
-    }
-}
-
-void DisplayInfoGun1Ver(bool isShow, uint8_t *version)
-{
-    if (isShow) {
-        uint8_t value[10];
-
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, "Ct1 Ver >");
-        DisplayValueToLcm(__dc1_ver_string, value, sizeof(value));
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, (char *) version);
-        DisplayValueToLcm(__dc1_ver_value, value, sizeof(value));
-    } else {
-        ChangeDisplay2Value(__dc1_ver_string, _disappear);
-        ChangeDisplay2Value(__dc1_ver_value, _disappear);
-    }
-}
-
-void Show4GMode(bool isShow, uint8_t mode)
-{
-    if (isShow) {
-        uint8_t value[20];
-
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, "3/4G Mo. >");
-        DisplayValueToLcm(__dc1_ver_string, value, sizeof(value));
-        memset(value, 0x00, sizeof(value));
-        if (mode == 0) {
-            sprintf((char *)value, "disable");
-        } else if (mode == 1) {
-            sprintf((char *)value, "enable");
-        }
-
-        DisplayValueToLcm(__dc1_ver_value, value, sizeof(value));
-    } else {
-        ChangeDisplay2Value(__dc1_ver_string, _disappear);
-        ChangeDisplay2Value(__dc1_ver_value, _disappear);
-    }
-}
-
-void DisplayInfoGun2Ver(bool isShow, uint8_t *version)
-{
-    if (isShow) {
-        uint8_t value[10];
-
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, "Ct2 Ver >");
-        DisplayValueToLcm(__dc2_ver_string, value, sizeof(value));
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, (char *) version);
-        DisplayValueToLcm(__dc2_ver_value, value, sizeof(value));
-    } else {
-        ChangeDisplay2Value(__dc2_ver_string, _disappear);
-        ChangeDisplay2Value(__dc2_ver_value, _disappear);
-    }
-}
-
-void Show4GIP(bool isShow, uint8_t *ip)
-{
-    if (isShow) {
-        uint8_t value[20];
-
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, "3/4G IP >");
-        DisplayValueToLcm(__dc2_ver_string, value, sizeof(value));
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, (char *) ip);
-        DisplayValueToLcm(__dc2_ver_value, value, sizeof(value));
-    } else {
-        ChangeDisplay2Value(__dc2_ver_string, _disappear);
-        ChangeDisplay2Value(__dc2_ver_value, _disappear);
-    }
-}
-
-void DisplayInfoSpeed(bool isShow, unsigned int fan)
-{
-    if (isShow) {
-        uint8_t value[10];
-
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, "Fan Spd >");
-        DisplayValueToLcm(__fan_speed_string, value, sizeof(value));
-        memset(value, 0x00, sizeof(value));
-        sprintf((char *)value, "%d", fan);
-        DisplayValueToLcm(__fan_speed_value, value, sizeof(value));
-    } else {
-        ChangeDisplay2Value(__fan_speed_string, _disappear);
-        ChangeDisplay2Value(__fan_speed_value, _disappear);
-    }
-}
-
-void ShowWifiIP(bool isShow, uint8_t *ip)
-{
-    if (isShow) {
-        uint8_t value[20];
-
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, "Wifi IP >");
-        DisplayValueToLcm(__fan_speed_string, value, sizeof(value));
-        memset(value, 0x00, sizeof(value));
-        strcpy((char *) value, (char *) ip);
-        DisplayValueToLcm(__fan_speed_value, value, sizeof(value));
-    } else {
-        ChangeDisplay2Value(__fan_speed_string, _disappear);
-        ChangeDisplay2Value(__fan_speed_value, _disappear);
-    }
-}
-
-void InformationShow()
-{
-    if (pSysConfig->ShowInformation == YES) {
-        bool show = _isShow = true;
-        if (_showInformIndex == 0) {
-            DisplayInfoCsuVer(show, pSysInfo->CsuRootFsFwRev);
-            DisplayInfoSpeed(show, pSysInfo->SystemFanRotaSpeed);
-            DisplayInfoSN(show, pSysConfig->SerialNumber);
-
-            DisplayInfoEthIp(show, pSysConfig->Eth0Interface.EthIpAddress);
-            DisplayInfoGun1Ver(show, pSysInfo->Connector1FwRev);
-            if (_totalCount > 1) {
-                DisplayInfoGun2Ver(show, pSysInfo->Connector2FwRev);
-            } else {
-                DisplayInfoGun2Ver(false, pSysInfo->Connector2FwRev);
-            }
-        } else if (_showInformIndex == 1) {
-            ShowWifiMode(show, pSysConfig->AthInterface.WifiMode);
-            ShowWifiIP(show, pSysConfig->AthInterface.WifiIpAddress);
-            ShowWifiRssi(show, pSysConfig->AthInterface.WifiRssi);
-
-            Show4GMode(show, pSysConfig->TelecomInterface.TelcomEnabled);
-            Show4GIP(show, pSysConfig->TelecomInterface.TelcomIpAddress);
-            Show4GRssi(show, pSysConfig->TelecomInterface.TelcomRssi);
-        }
-    } else {
-        ClearDisplayInfo();
-
-        if (_isShow) {
-            _isShow = false;
-            _showInformIndex++;
-            if (_showInformIndex >= 2) {
-                _showInformIndex = 0;
-            }
-        }
-    }
-}
-
-void ProcessPageInfo()
-{
-    _page_reload = IsPageReloadChk();
-    pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
-    struct InfoCodeData *pInfoCode = (struct InfoCodeData *)GetShmInfoCodeData();
-    struct AlarmCodeData *pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
-    uint8_t i;
-
-    // 隨插即充 - 可省略該按鈕 //DS60-120 add
-    if (pSysConfig->AuthorisationMode == AUTH_MODE_ENABLE) {
-        ChangeDisplay2Value(__ret_home_btn, _back_home_btn);
-        if (_totalCount >= 2 && pSysInfo->IsAlternatvieConf == NO) {
-            ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
-        } else {
-            ChangeDisplay2Value(__sel_gun_btn, _disappear);
-        }
-    }
-
-    switch (_currentPage) {
-#if defined DD360Audi
-    case _LCM_SELECT_GUN: ////For Audi
-        if (pSysInfo->CurGunSelected == 0) {
-            ChangeDisplay2Value(__left_gun_map, _left_gun_enable_map);
-            ChangeDisplay2Value(__right_gun_map, _right_gun_disable_map);
-        } else if (pSysInfo->CurGunSelected == 1) {
-            ChangeDisplay2Value(__left_gun_map, _left_gun_disable_map);
-            ChangeDisplay2Value(__right_gun_map, _right_gun_enable_map);
-        }
-        ChangeDisplay2Value(__add_chk_btn, _select_gun_btn);
-        break;
-#endif //defined DD360Audi
-
-    case _LCM_IDLE: {
-        if (pSysConfig->isRFID) {
-            ChangeDisplay2Value(__main_rfid, _main_rfid);
-        } else {
-            ChangeDisplay2Value(__main_rfid, _main_none_rfid);
-        }
-
-        if (pSysConfig->isQRCode) {
-            ChangeDisplay2Value(__main_qr, _main_qr);
-        } else {
-            ChangeDisplay2Value(__qr_code, _disappear);
-            ChangeDisplay2Value(__main_qr, _main_none_qr);
-            needReloadQr = true;
-        }
-
-        if (pSysConfig->isAPP) {
-            ChangeDisplay2Value(__main_app, _main_app);
-        } else {
-            ChangeDisplay2Value(__main_app, _main_none_app);
-        }
-#if defined DD360Audi
-        if(pSysInfo->CurGunSelected == LEFT_GUN_NUM )
-            ChangeDisplay2Value(__show_selectgun_value, _showselectgun_left);
-        else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM )
-            ChangeDisplay2Value(__show_selectgun_value, _showselectgun_right);
-#endif
-        //if (FirstPageChanged() == YES || needReloadQr || _page_reload) {
-        if (pSysConfig->isQRCode) {
-            needReloadQr = false;
-            if (pSysConfig->QRCodeMadeMode == NO) {
-                //uint8_t len = strlen((char *)pSysConfig->SystemId);
-                ChangeQrCode_Idle((char *)pSysConfig->SystemId);
-            } else {
-                //uint8_t len = strlen((char *)pSysConfig->QRCodeContent);
-                ChangeQrCode_Idle((char *)pSysConfig->QRCodeContent);
-            }
-            //ChangeQrCode_Idle((char *)pSysConfig->SystemId);
-        }
-        //}
-
-        //DS60-120 add
-        bool isCharging = false;
-        for (uint8_t i = 0; i < _totalCount; i++) {
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
-
-            if (pDcChargingInfo->SystemStatus == S_IDLE) {
-                continue;
-            }
-
-            isCharging = true;
-            break;
-        }
-        if (isCharging && pSysInfo->IsAlternatvieConf == NO) {
-            ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
-        } else {
-            ChangeDisplay2Value(__sel_gun_btn, _disappear);
-        }
-    }
-    break;
-    case _LCM_AUTHORIZING:
-    case _LCM_AUTHORIZ_COMP:
-    case _LCM_AUTHORIZ_FAIL: {
-        //case _LCM_WAIT_FOR_PLUG: {
-        FirstPageChanged();
-#if defined DD360Audi
-        if (_currentPage == _LCM_AUTHORIZ_COMP) { ////For Audi
-            ChangeBalanceValue(__balance, pSysInfo->CurGunSelected);
-        }
-#endif //defined DD360Audi
-    }
-    break;
-    case _LCM_WAIT_FOR_PLUG: {
- #if defined DD360Audi
-        if(pSysInfo->CurGunSelected == LEFT_GUN_NUM )
-            ChangeDisplay2Value(__show_waitgunplug_value, _showwaitgunplug_left);
-        else if (pSysInfo->CurGunSelected == RIGHT_GUN_NUM )
-            ChangeDisplay2Value(__show_waitgunplug_value, _showwaitgunplug_right);
-#endif
-        FirstPageChanged();
-        if (pSysConfig->AuthorisationMode == AUTH_MODE_DISABLE) {
-            // 新增隨插即充功能預設在等待插槍頁面在開啟
-            ChangeDisplay2Value(__ret_home_btn, _disappear);
-            bool isCharging = false;
-            for (uint8_t i = 0; i < _totalCount; i++) {
-                pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
-
-                if (pDcChargingInfo->SystemStatus == S_IDLE) {
-                    continue;
-                }
-
-                isCharging = true;
-                break;
-            }
-
-            if (isCharging && pSysInfo->IsAlternatvieConf == NO) {
-                ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
-            } else {
-                ChangeDisplay2Value(__sel_gun_btn, _disappear);
-            }
-        } else {
-            ChangeDisplay2Value(__sel_gun_btn, _disappear);
-        }
-    }
-    break;
-    case _LCM_PRE_CHARGE:
-    case _LCM_CHARGING:
-    case _LCM_COMPLETE: {
-        bool isShowAc = false;
-        uint8_t gunTargetIndex = 0;
-
-        if (acgunCount > 0) {
-            gunTargetIndex = 2;
-            if (pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
-                isShowAc = true;
-                //ChangeDisplay2Value(__gun_type_index + (2 * 2), _actype_light); //DS60-120 remove
-                if (_currentPage == _LCM_COMPLETE) {
-                    ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _actype_light_cmp);
-                } else {
-                    ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _actype_light);
-                }
-
-                if (_currentPage == _LCM_CHARGING) {
-                    ChangeAcBattMapAndValue(_LCM_CHARGING);
-                    if (pAcChargingInfo->PresentChargedDuration >= 0 &&
-                            pAcChargingInfo->PresentChargedDuration <= TIME_MAX_SEC) {
-                        ChangeRemainTime(pAcChargingInfo->PresentChargedDuration);
-                    } else {
-                        ChangeRemainTime(0);
-                    }
-
-                    if (pAcChargingInfo->PresentChargingPower >= 0.1 &&
-                            pAcChargingInfo->PresentChargingPower <= POWER_MAX_KW) {
-                        ChangeChargingPowerValue(pAcChargingInfo->PresentChargingPower);
-                    } else {
-                        ChangeChargingPowerValue(0);
-                    }
-
-                    if (pAcChargingInfo->PresentChargedEnergy >= 0.1 &&
-                            pAcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
-                        ChangeChargingEnergyValue(pAcChargingInfo->PresentChargedEnergy);
-                    } else {
-                        ChangeChargingEnergyValue(0);
-                    }
-
-                    if (strcmp((char *)pAcChargingInfo->StartUserId, "") == 0 ||
-                            pSysConfig->StopChargingByButton == YES) {
-                        ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
-                    } else {
-                        ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
-                    }
-                } else if (_currentPage == _LCM_COMPLETE) {
-                    ChangeAcBattMapAndValue(_LCM_COMPLETE);
-                    if (pAcChargingInfo->PresentChargedDuration >= 0 &&
-                            pAcChargingInfo->PresentChargedDuration <= TIME_MAX_SEC) {
-                        ChangeRemainTime(pAcChargingInfo->PresentChargedDuration);
-                    } else {
-                        ChangeRemainTime(0);
-                    }
-
-                    if (pAcChargingInfo->PresentChargingPower >= 0.1 &&
-                            pAcChargingInfo->PresentChargingPower <= POWER_MAX_KW) {
-                        ChangeChargingPowerValue(pAcChargingInfo->PresentChargingPower);
-                    } else {
-                        ChangeChargingPowerValue(0);
-                    }
-
-                    if (pAcChargingInfo->PresentChargedEnergy >= 0.1 &&
-                            pAcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
-                        ChangeChargingEnergyValue(pAcChargingInfo->PresentChargedEnergy);
-
-                        if (pSysConfig->BillingData.isBilling &&
-                                pAcChargingInfo->ChargingFee >= 0) {
-                            ChangeChargingFeeValue(pAcChargingInfo->ChargingFee);
-                        }
-                    } else {
-                        ChangeChargingEnergyValue(0);
-                        if (pSysConfig->BillingData.isBilling) {
-                            ChangeChargingFeeValue(0);
-                        }
-                    }
-
-                    if (!pSysConfig->BillingData.isBilling) {
-                        ChangeDisplay2Value(__charging_fee_map, _disappear);
-                        ChangeDisplay2Value(__charging_fee_tx, _disappear);
-                    } else {
-                        ChangeDisplay2Value(__charging_fee_map, _money_map);
-                    }
-                }
-            } else {
-                //ChangeDisplay2Value(__gun_type_index + (2 * 2), _actype_dark); //DS60-120 remove
-                if (_currentPage == _LCM_COMPLETE) {
-                    ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _actype_dark_cmp);
-                } else {
-                    ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _actype_dark);
-                }
-            }
-        } else {
-            //ChangeDisplay2Value(__gun_type_index + (2 * 2), _disappear); //DS60-120 remove
-            if (_totalCount > 1) {
-                gunTargetIndex = 2;
-                ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _disappear);
-                ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _disappear);
-            }
-        }
-
-        gunTargetIndex = 0; //DS60-120 add
-        for (uint8_t i = 0; i < _totalCount; i++) {
-            if (_totalCount == 1 && acgunCount <= 0) { //DS60-120 add
-                gunTargetIndex = 2;
-            } else {
-                gunTargetIndex = i;
-            }
-
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
-
-            switch (pDcChargingInfo->Type) {
-            case _Type_Chademo: {
-                if (pSysInfo->CurGunSelected == i && !isShowAc) {
-                    if (_currentPage == _LCM_COMPLETE) {
-                        ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _chademo_light_cmp);
-                    } else {
-                        ChangeDisplay2Value(__gun_type_index + (i * 2), _chademo_light);
-                    }
-                } else {
-                    if (_currentPage == _LCM_COMPLETE) {
-                        ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _chademo_dark_cmp);
-                    } else {
-                        ChangeDisplay2Value(__gun_type_index + (i * 2), _chademo_dark);
-                    }
-                }
-            }
-            break;
-            case _Type_GB: {
-                if (pSysInfo->CurGunSelected == i && !isShowAc) {
-                    if (_currentPage == _LCM_COMPLETE) {
-                        ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _gbt_light_cmp);
-                    } else {
-                        ChangeDisplay2Value(__gun_type_index + (i * 2), _gbt_light);
-                    }
-                } else {
-                    if (_currentPage == _LCM_COMPLETE) {
-                        ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _gbt_dark_cmp);
-                    } else {
-                        ChangeDisplay2Value(__gun_type_index + (i * 2), _gbt_dark);
-                    }
-                }
-            }
-            break;
-            case _Type_CCS_2: {
-                if (pSysInfo->CurGunSelected == i && !isShowAc) {
-                    if (_currentPage == _LCM_COMPLETE) {
-                        ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _ccs_light_cmp);
-                    } else {
-                        ChangeDisplay2Value(__gun_type_index + (i * 2), _ccs_light);
-                    }
-                } else {
-                    if (_currentPage == _LCM_COMPLETE) {
-                        ChangeDisplay2Value(__cmp_gun_type_index + (i * 2), _ccs_dark_cmp);
-                    } else {
-                        ChangeDisplay2Value(__gun_type_index + (i * 2), _ccs_dark);
-                    }
-                }
-            }
-            break;
-            }
-
-            if (_currentPage == _LCM_PRE_CHARGE && !isShowAc) {
-                if (pSysInfo->CurGunSelected == i) {
-                    ChangeBattMapAndValue(_currentPage, pDcChargingInfo->EvBatterySoc);
-                }
-            } else if (_currentPage == _LCM_CHARGING && !isShowAc) {
-                if (pSysInfo->CurGunSelected == i) {
-                    ChangeBattMapAndValue(_LCM_CHARGING, pDcChargingInfo->EvBatterySoc);
-                    if (pDcChargingInfo->PresentChargedDuration >= 0 &&
-                            pDcChargingInfo->PresentChargedDuration <= TIME_MAX_SEC) {
-                        ChangeRemainTime(pDcChargingInfo->PresentChargedDuration);
-                    } else {
-                        ChangeRemainTime(0);
-                    }
-
-                    if (pDcChargingInfo->PresentChargingPower >= 0 &&
-                            pDcChargingInfo->PresentChargingPower <= POWER_MAX_KW) {
-                        ChangeChargingPowerValue(pDcChargingInfo->PresentChargingPower);
-                    } else {
-                        ChangeChargingPowerValue(0);
-                    }
-
-                    if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
-                            pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
-                        ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);
-                    } else {
-                        ChangeChargingEnergyValue(0);
-                    }
-
-                    if (strcmp((char *)pDcChargingInfo->StartUserId, "") == 0 ||
-                            pSysConfig->StopChargingByButton == YES) {
-                        ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
-                    } else {
-                        ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
-                    }
-                }
-            } else if (_currentPage == _LCM_COMPLETE && !isShowAc) {
-                if (pSysInfo->CurGunSelected == i) {
-                    ChangeBattMapAndValue(_LCM_COMPLETE, pDcChargingInfo->EvBatterySoc);
-                    if (pDcChargingInfo->PresentChargedDuration >= 0 &&
-                            pDcChargingInfo->PresentChargedDuration <= TIME_MAX_SEC) {
-                        ChangeRemainTime(pDcChargingInfo->PresentChargedDuration);
-                    } else {
-                        ChangeRemainTime(0);
-                    }
-
-                    if (pDcChargingInfo->PresentChargingPower >= 0 &&
-                            pDcChargingInfo->PresentChargingPower <= POWER_MAX_KW) {
-                        ChangeChargingPowerValue(pDcChargingInfo->PresentChargingPower);
-                    } else {
-                        ChangeChargingPowerValue(0);
-                    }
-#if 1
-                    if (pDcChargingInfo->PresentChargedEnergy >= 0.1 &&
-                            pDcChargingInfo->PresentChargedEnergy <= ENERGY_MAX_KWH) {
-                        ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);
-
-                        if (pSysConfig->BillingData.isBilling &&
-                                pDcChargingInfo->ChargingFee >= 0) {
-                            ChangeChargingFeeValue(pDcChargingInfo->ChargingFee);
-                            ChangeBalanceValue(__remain_balance, i);
-                        }
-                    } else {
-                        ChangeChargingEnergyValue(0);
-                        if (pSysConfig->BillingData.isBilling) {
-                            ChangeChargingFeeValue(0);
-                            ChangeBalanceValue(__remain_balance, i);
-                        }
-                    }
-#else
-                    ChangeChargingEnergyValue(pDcChargingInfo->PresentChargedEnergy);
-
-                    if (pSysConfig->BillingData.isBilling &&
-                            pDcChargingInfo->ChargingFee >= 0) {
-                        ChangeChargingFeeValue(pDcChargingInfo->ChargingFee);
-                        ChangeBalanceValue(__remain_balance, i);
-                    }
-#endif // 0
-                    if (!pSysConfig->BillingData.isBilling) {
-                        ChangeDisplay2Value(__charging_fee_map, _disappear);
-                        ChangeDisplay2Value(__charging_fee_tx, _disappear);
-                    } else {
-                        ChangeDisplay2Value(__charging_fee_map, _money_map);
-                    }
-#ifdef DD360Audi
-                    // Warming Occur in prepare or precharing state, turn into complete mode
-                    if (pInfoCode->InfoEvents.bits.Stop_by_EV_with_unknow_reason) {
-                        RunFullTargetFunction(true);
-                    } else {
-                        RunFullTargetFunction(false);
-                        if (pDcChargingInfo->Replug_flag) {
-                            RunReplugStringFunction(true);
-                        } else {
-                            RunReplugStringFunction(false);
-                        }
-                    }
-#endif					
-                }
-            }
-        }
-
-        // gun btn and QR code
-        if (_totalCount + acgunCount >= 2 && _currentPage) {
-            uint8_t index = 0;
-            for (index = 0; index < _totalCount; index++) {
-                if (pSysInfo->CurGunSelected != index) {
-                    break;
-                }
-            }
-
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
-
-            if (pDcChargingInfo->SystemStatus == S_IDLE ||
-                    pDcChargingInfo->SystemStatus == S_RESERVATION ||
-                    pDcChargingInfo->SystemStatus == S_BOOTING) {
-                if (FirstPageChanged() == YES || needReloadQr || _page_reload) {
-                    if (pSysConfig->isQRCode) {
-                        needReloadQr = false;
-                        //ChangeQrCode_Charge((char *)pSysConfig->SystemId); //DS60-120 remove
-                        if (pSysConfig->QRCodeMadeMode == NO) {
-                            //uint8_t len = strlen((char *)pSysConfig->SystemId);
-                            ChangeQrCode_Charge((char *)pSysConfig->SystemId);
-                        } else {
-                            //uint8_t len = strlen((char *)pSysConfig->QRCodeContent);
-                            ChangeQrCode_Charge((char *)pSysConfig->QRCodeContent);
-                        }
-                    }
-                }
-            }
-        }
-    }
-    break;
-    case _LCM_FIX:
-#if defined DD360Audi
-        // For Emergency Button
-        if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == 1) {
-            ChangeToOtherPage(_LCM_EMERGENCY);
-            break;
-        }
-        // For Network Disconnect
-        for (i = 0; i < pSysWarning->WarningCount; i++) {
-            if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0 || 
-                memcmp(&pSysWarning->WarningCode[i][0], "042304", 6) == 0) {
-                ChangeToOtherPage(_LCM_DISCONNECT);
-            break;
-            }
-        }
-#endif
-
-        break;
-    }
-}
-
-void ChangeDisplayMoneyInfo()
-{
-    uint8_t curGun = pSysInfo->CurGunSelected;
-
-    if (pSysConfig->BillingData.isBilling) {
-        struct timeb csuTime;
-        struct tm *tmCSU;
-
-        ftime(&csuTime);
-        tmCSU = localtime(&csuTime.time);
-
-        ChangeDisplay2Value(__money_rate_map, _charging_money);
-#if defined DD360Audi
-        if (ShmSelectGunInfo->PricesInfo[curGun].UserPrices != 0.00) { //Jerry add
-            DisplayMoneyRate(ShmSelectGunInfo->PricesInfo[curGun].UserPrices);
-        } else {
-#endif //defined DD360Audi
-            if (tmCSU->tm_hour <= 23) {
-                pSysConfig->BillingData.Cur_fee = pSysConfig->BillingData.Fee[tmCSU->tm_hour];
-                DisplayMoneyRate(pSysConfig->BillingData.Cur_fee);
-            }
-
-            if (pSysConfig->BillingData.Currency <= 53) {
-                DisplayMoneyCur((uint8_t *)GetCurrency(pSysConfig->BillingData.Currency));
-            }
-#if defined DD360Audi
-        }
-#endif //defined DD360Audi
-    } else {
-        ChangeDisplay2Value(__money_rate_map, _disappear);
-        ChangeDisplay2Value(__money_by_rate, _disappear);
-        ChangeDisplay2Value(__money_rate, _disappear);
-    }
-}
-
-/*void Initialization()
-{
-    bool isPass = false;
-    uint8_t count = 5;
-    while (!isPass && count > 0) {
-        isPass = true;
-        for (uint8_t _index = 0; _index < _totalCount; _index++) {
-            if (!FindChargingInfoData(_index, &_chargingInfoData[0])) {
-                log_error("LcmComm (main) : FindChargingInfoData false ");
-                isPass = false;
-                count--;
-                break;
-            }
-        }
-
-        sleep(1);
-    }
-
-    isPass = false;
-
-    if (acgunCount > 0) {
-        while (!isPass) {
-            isPass = true;
-            for (uint8_t _index = 0; _index < acgunCount; _index++) {
-                if (!FindAcChargingInfoData(_index, &ac_chargingInfo[0])) {
-                    log_error("LcmComm : FindAcChargingInfoData false ");
-                    isPass = false;
-                    break;
-                }
-            }
-
-            sleep(1);
-        }
-    }
-
-    if (count == 0) {
-        log_info("LCM Initialization Gun Fail.............");
-    }
-}
-*/
-
-//DS60-120 add
-void DefaultIconStatus()
-{
-    for (uint8_t i = 0; i < 3; i++) {
-        ChangeDisplay2Value(__gun_type_index + (i * 2), _disappear);
-    }
-
-    if (pSysInfo->IsAlternatvieConf == YES || _totalCount == 1) {
-        ChangeDisplay2Value(__sel_gun_btn, _disappear);
-    } else {
-        ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
-    }
-}
-
-int main(void)
-{
-
-    //if (InitShareMemory() == FAIL) {
-    //    log_error("InitShareMemory NG");
-    //
-    //    if (ShmStatusCodeData != NULL) {
-    //        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
-    //    }
-    //    sleep(5);
-    //    return 0;
-    //}
-
-    if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error");
-        return FAIL;
-    }
-
-    MappingGunChargingInfo("LCM Control Task");
-
-    pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-    pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
-    ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();;
-    ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
-    ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
-    struct StatusCodeData *ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();;
- 
-
-    _port = CreateCommunicationLcmPort();
-    uint8_t changeWarningPriority = 0;
-    uint8_t curWarningCount = 255;
-    ChangeBackLight(true);
-    _totalCount = pSysConfig->TotalConnectorCount;
-    acgunCount = pSysConfig->AcConnectorCount;
-    //Initialization();
-
-    //printf("_LCM_COMPLETE ");
-    //ChangeToOtherPage(_LCM_COMPLETE);
-    //return 0;
-
-    for (uint8_t i = 0; i < 3; i++) {
-        ChangeDisplay2Value(__gun_type_index + (i * 2), _disappear);
-    }
-
-    DefaultIconStatus(); //DS60-120 add
-
-    while (_port != -1) {
-        if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
-            GetCurrentPage();
-            sleep(1);
-#ifndef DD360ComBox
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
-#endif
-
-        } else {
-            //DemoFunction();
-#ifndef DD360ComBox
-            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false;
-#endif
-
-            // Warning 處理
-            if (curWarningCount != pSysWarning->WarningCount) {
-                changeWarningPriority = 0;
-                pSysWarning->PageIndex = 0;
-                curWarningCount = pSysWarning->WarningCount;
-                ChangeWarningFunc();
-            } else if (pSysWarning->WarningCount > 5 && changeWarningPriority == 0) {
-                // 當有兩頁 Warning 則每隔三秒改變一次
-                if (pSysWarning->PageIndex == 0) {
-                    pSysWarning->PageIndex = 1;
-                } else {
-                    pSysWarning->PageIndex = 0;
-                }
-
-                ChangeWarningFunc();
-            }
-            // 頁面資訊處理
-            ProcessPageInfo();
-
-            // 網路 - wifi - 連線訊號處理
-            RefreshConnStatus();
-
-            // 換頁處理
-            GetCurrentPage(); //DS60-120 add
-            ChangeCurPage();
-
-            RefreshPageAnimation(_everyPageRollChange);
-
-#if defined DD360Audi
-            ChangeDisplayMoneyInfo();
-#else
-            if (changeWarningPriority == 0) { ////For Audi
-                ChangeDisplayMoneyInfo();
-                InformationShow();
-            }
-#endif //defined DD360Audi
-
-            changeWarningPriority >= 15 ? (_battery_display_ani = true) : (_battery_display_ani = false);
-            changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
-            usleep(100000);
-        }
-    }
-
-#ifndef DD360ComBox
-    ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
-#endif
-    log_info("Close LCM Uart Port");
-    CloseCommunicationLcmPort();
-
-    return FAIL;
-}

+ 0 - 2339
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.c.test

@@ -1,2339 +0,0 @@
-#include "Module_LcmControl.h"
-#include "../Log/log.h"
-//#include "cbmp.h"
-
-#define CMD_HEADER_1						0x5A
-#define CMD_HEADER_2						0xA5
-#define CMD_REG_WRITE						0x80
-#define CMD_REG_READ						0x81
-#define CMD_REG_WRITE_DATA					0x82
-#define CMD_REG_READ_DATA					0x83
-
-#define REG_ADDRESS_READ_VERSION			0x0F
-#define REG_ADDRESS_READ_RTC				0x10
-#define REG_ADDRESS_READ_PAGE_ID			0x14
-#define REG_ADDRESS_READ_BRIGHTNESS       	0x31
-#define REG_ADDRESS_WRITE_BRIGHTNESS		0X82
-#define REG_ADDRESS_SET_PAGE_ID				0x84
-#define REG_ADDRESS_SET_RTC					0x9C
-
-bool needReloadQr = true;
-
-bool _isShow = false;
-byte _showInformIndex = 0;
-
-byte _btn_pressed = 0xF0;
-
-void PRINTF_FUNC(char *string, ...);
-
-//int StoreLogMsg(const char *fmt, ...);
-//#define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-//#define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-//#define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-
-char* getTimeString(void);
-struct SysInfoData *pSysInfo = NULL;
-static struct SysConfigData *pSysConfig = NULL;
-//=================================
-// Common routine
-//=================================
-#if 0
-int StoreLogMsg(const char *fmt, ...)
-{
-	char Buf[4096+256];
-	char buffer[4096];
-	va_list args;
-	struct timeb  SeqEndTime;
-	struct tm *tm;
-
-	va_start(args, fmt);
-	int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-	va_end(args);
-
-	memset(Buf,0,sizeof(Buf));
-	ftime(&SeqEndTime);
-	SeqEndTime.time = time(NULL);
-	tm=localtime(&SeqEndTime.time);
-
-	if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
-	{
-		sprintf(Buf,"%02d:%02d:%02d:%03d - %s",
-			tm->tm_hour,tm->tm_min,tm->tm_sec,SeqEndTime.millitm, buffer);
-		printf("%s \n", Buf);
-	}
-	else
-	{
-		sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog_%s",
-			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,SeqEndTime.millitm,
-			buffer,
-			tm->tm_year+1900,tm->tm_mon+1,
-			ShmSysConfigAndInfo->SysConfig.SerialNumber);
-		system(Buf);
-	}
-
-	return rc;
-}
-#endif
-char* getTimeString(void)
-{
-	char *result=malloc(21);
-	time_t timep;
-	struct tm *p;
-	time(&timep);
-	p=gmtime(&timep);
-
-	sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
-
-	return result;
-}
-
-void PRINTF_FUNC(char *string, ...)
-{
-	va_list args;
-	char buffer[4096];
-	va_start(args, string);
-	vsnprintf(buffer, sizeof(buffer), string, args);
-	va_end(args);
-
-	log_info("%s ", buffer);
-}
-
-//==========================================
-// Init all share memory
-//==========================================
-int InitShareMemory()
-{
-	int result = PASS;
-	int MeterSMId;
-
-	//creat ShmSysConfigAndInfo
-	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0)
-    {
-		#ifdef SystemLogMessage
-		log_error("shmget ShmSysConfigAndInfo NG\n");
-		#endif
-		result = FAIL;
-	}
-    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	log_error("shmat ShmSysConfigAndInfo NG\n");
-		#endif
-    	result = FAIL;
-   	}
-
-   	//creat ShmStatusCodeData
-   	if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0)
-    {
-		#ifdef SystemLogMessage
-   		log_error("shmget ShmStatusCodeData NG\n");
-		#endif
-   		result = FAIL;
-	}
-    else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	log_error("shmat ShmStatusCodeData NG\n");
-		#endif
-    	result = FAIL;
-   	}
-/*
- 	if ((MeterSMId = shmget(ShmCommonKey, sizeof(struct DcCommonInformation), IPC_CREAT | 0777)) < 0)
-    {
-    	#ifdef SystemLogMessage
-    	log_error("shmget ShmCommonKey NG \n");
-    	#endif
-    	return 0;
-    }
-    else if ((ShmDcCommonData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	log_error("shmat ShmCommonKey NG \n");
-    	#endif
-    	return 0;
-    }
-*/
-    return result;
-}
-
-//==========================================
-// Open and Close RS232 and R/W
-//==========================================
-int CreateCommunicationLcmPort()
-{
-	int fd;
-	struct termios tios;
-
-	fd = open(pPortName, O_RDWR);
-	if (fd <= 0) {
-		#ifdef SystemLogMessage
-		log_error("open /dev/ttyS3 NG \n");
-		#endif
-		return -1;
-	}
-	ioctl(fd, TCGETS, &tios);
-	tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
-	tios.c_lflag = 0;
-	tios.c_iflag = 0;
-	tios.c_oflag = 0;
-	tios.c_cc[VMIN] = 0;
-	tios.c_cc[VTIME] = (unsigned char) 5;
-	tios.c_lflag = 0;
-	tcflush(fd, TCIFLUSH);
-	ioctl(fd, TCSETS, &tios);
-
-	return fd;
-}
-
-void CloseCommunicationLcmPort()
-{
-	close(Uart1Fd);
-}
-
-void WriteCmdToLcm(byte *cmd, byte cmdLen)
-{
-	int len = write(Uart1Fd, cmd, cmdLen);
-	if(len >= sizeof(cmd))
-	{
-		//PRINTF_FUNC("Write cmd to LCM successfully. \n");
-	}
-}
-
-void ReadMsgFromLcm(byte *msg, byte readLen)
-{
-	read(Uart1Fd, msg, readLen);
-
-//	5a : CMD_TITLE_1
-//	a5 : CMD_TITLE_2
-//	5
-//	81 : CMD_WRITE
-//	3  : CMD_REGISTER
-//	2  : Data length
-//	0  : High byte
-//	1  : Low byte
-
-//	printf("-------------------------------------------- \n");
-//	printf("msg = %x \n", *msg);			// A5
-//	printf("msg = %x \n", *(msg + 1));		// 5A
-//	printf("msg = %x \n", *(msg + 2));		// Len : [3] ~ [6] + Data Len
-//	printf("msg = %x \n", *(msg + 3));		// cmd : 0x83
-//	printf("msg = %x \n", *(msg + 4));		// addr : H
-//	printf("msg = %x \n", *(msg + 5));		// addr : L
-//	printf("msg = %x \n", *(msg + 6));		// Data Len
-//
-//	printf("msg = %x \n", *(msg + 7));
-//	printf("msg = %x \n", *(msg + 8));
-//	printf("msg = %x \n", *(msg + 9));
-//	printf("msg = %x \n", *(msg + 10));
-//	printf("msg = %x \n", *(msg + 11));
-//	printf("msg = %x \n", *(msg + 12));
-//	printf("msg = %x \n", *(msg + 13));
-//	printf("msg = %x \n", *(msg + 14));
-
-	if(*msg == CMD_TITLE_1 && *(msg + 1) == CMD_TITLE_2)
-	{
-		if(*(msg + 3) == CMD_WRITE)
-		{
-			switch (*(msg + 4))
-			{
-				case CMD_REGISTER:
-				{
-					// 頁面
-					if(strcmp((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, "") != EQUAL)
-						strcpy((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, moduleName);
-
-					_currentPage = *(msg + 7);
-//					if (_currentPage != 1 && _currentPage != 5 && _currentPage != 6 && _currentPage != 7 && _currentPage != 8)
-//						printf("_currentPage = %d \n", _currentPage);
-				}
-				break;
-			}
-		}
-		else if (*(msg + 3) == CMD_MULTI_READ)
-		{
-			short key = ((short)(*(msg + 4) << 8) + *(msg + 5));
-			if (key == __lcm_version)
-			{
-				if(strcmp((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, "") != EQUAL)
-						strcpy((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, moduleName);
-
-				//pSysInfo->LcmFwRev = atoi((char *)(msg + 7));
-				printf("msg = %d \n", atoi((char *)(msg + 7)));
-//				printf("msg = %x \n", *(msg + 7));
-//				printf("msg = %x \n", *(msg + 8));
-//				printf("msg = %x \n", *(msg + 9));
-			}
-			else if (key == 0x0014)
-			{
-				//printf("page = %d \n", *(msg + 8));
-				_currentPage = *(msg + 8);
-			}
-			else if (key == 0x0600)
-			{
-				if (_btn_pressed != *(msg + 8))
-				{
-					if (_btn_pressed == 0x0A)
-						printf("NotPressed \n");
-					else
-						printf("Pressed \n");
-
-					_btn_pressed = *(msg + 8);
-				}
-
-				//printf("msg = %x \n", *(msg + 7));
-			}
-
-//			switch ((unsigned short) (*(msg + 4) << 8) + (unsigned short) *(msg + 5))
-//			{
-//				case BUTTON_GUN_INDEX:
-//				{
-//					// 當前選的槍號
-//					_curGunIndex = (*(msg + 8));
-//				}
-//				break;
-//			}
-		}
-	}
-}
-
-//================================================
-// Function
-//================================================
-//void ChangeToOtherPage(short newPage)
-//{
-//	byte cmd[7];
-//	memset(cmd, 0x00, sizeof(cmd));
-//
-//	cmd[0] = CMD_TITLE_1;
-//	cmd[1] = CMD_TITLE_2;
-//	cmd[2] = 0x02 + sizeof(newPage);
-//	cmd[3] = CMD_READ;
-//	cmd[4] = CMD_REGISTER;
-//	cmd[5] = newPage >> 8;
-//	cmd[6] = newPage & 0x00FF;
-//
-//	WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
-//	usleep(100000);
-//}
-
-void ChangeToOtherPage(short newPage)
-{
-	byte cmd[10];
-	memset(cmd, 0x00, sizeof(cmd));
-	byte msg[9];
-	memset(msg, 0x00, sizeof(msg));
-
-	cmd[0] = CMD_TITLE_1;
-	cmd[1] = CMD_TITLE_2;
-	cmd[2] = 0x07;
-	cmd[3] = 0x82;
-	cmd[4] = 0x00;
-	cmd[5] = 0x84;
-	cmd[6] = 0x5A;
-	cmd[7] = 0x01;
-	cmd[8] = newPage >> 8;
-	cmd[9] = newPage & 0x00FF;
-
-	WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
-	usleep(10000);
-	ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
-}
-
-void ChangeBackLight(bool islight)
-{
-	byte value = 0x01;
-	byte msg[9];
-	memset(msg, 0x00, sizeof(msg));
-
-	// 0x00 ~ 0x40
-	if (islight)
-	{
-		value = 0x20;
-	}
-	byte 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;
-
-	WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
-	usleep(10000);
-	ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
-}
-
-//void GetCurrentPage()
-//{
-//	byte cmd[6];
-//	memset(cmd, 0x00, sizeof(cmd));
-//	byte msg[8];
-//	memset(msg, 0x00, sizeof(msg));
-//
-//	cmd[0] = CMD_TITLE_1;
-//	cmd[1] = CMD_TITLE_2;
-//	cmd[2] = 0x03;				// 底下總長度
-//	cmd[3] = CMD_WRITE;
-//	cmd[4] = CMD_REGISTER;
-//	cmd[5] = 0x02;
-//
-//	WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
-//	usleep(10000);
-//	ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
-//}
-
-void GetCurrentPage()
-{
-	byte cmd[7];
-	memset(cmd, 0x00, sizeof(cmd));
-	byte msg[9];
-	memset(msg, 0x00, sizeof(msg));
-
-	cmd[0] = CMD_TITLE_1;
-	cmd[1] = CMD_TITLE_2;
-	cmd[2] = 0x04;				// 底下總長度
-	cmd[3] = 0x83;
-	cmd[4] = 0x00;
-	cmd[5] = 0x14;
-	cmd[6] = 0x01;
-
-	WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
-	usleep(10000);
-	ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
-}
-
-
-void DisplayValueToLcm(short address, byte *data, byte len)
-{
-	byte cmd[256];
-	memset(cmd, 0x00, sizeof(cmd));
-	byte msg[9];
-	memset(msg, 0x00, sizeof(msg));
-
-	cmd[0] = CMD_TITLE_1;
-	cmd[1] = CMD_TITLE_2;
-	cmd[2] = 0x03 + len;
-	cmd[3] = CMD_MULTI_WRITE;
-	cmd[4] = address >> 8;
-	cmd[5] = address & 0x00FF;
-
-	for(byte count = 0; count < len; count++)
-	{
-		cmd[6 + count] = *(data + count);
-	}
-
-	WriteCmdToLcm(cmd, cmd[2] + 3);
-	usleep(10000);
-	ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
-}
-
-void ChangeDisplay2Value(short address, short value)
-{
-	byte data[2];
-	data[0] = value >> 8;
-	data[1] = value & 0x00FF;
-
-	DisplayValueToLcm(address, data, sizeof(data));
-}
-
-void GetDeviceInfoStatus(short address, byte len)
-{
-	byte cmd[8];
-	memset(cmd, 0x00, sizeof(cmd));
-	byte msg[11];
-	memset(msg, 0x00, sizeof(msg));
-
-	cmd[0] = CMD_TITLE_1;
-	cmd[1] = CMD_TITLE_2;
-	cmd[2] = 0x04;
-	cmd[3] = CMD_MULTI_READ;
-	cmd[4] = (address >> 8) & 0xff;
-	cmd[5] = (address >> 0) & 0xff;
-	cmd[6] = len;
-
-	WriteCmdToLcm(cmd, ARRAY_SIZE(cmd));
-	usleep(10000);
-	ReadMsgFromLcm(msg, ARRAY_SIZE(msg));
-}
-
-//================================================
-// Warning process
-//================================================
-void string2ByteArray(unsigned char *input, byte *output)
-{
-    int loop;
-    int i;
-
-    loop = 0;
-    i = 0;
-
-    while(input[loop] != '\0')
-    {
-        output[i++] = input[loop++];
-    }
-    output[loop] = '\0';
-}
-
-void ChangeWarningFunc()
-{
-	byte cmd[7];
-	byte i = 0;
-	//PRINTF_FUNC("ChangeWarningFunc \n");
-	// 最多一次五筆
-	//PRINTF_FUNC("LCM PageIndex = %d \n", ShmSysConfigAndInfo->SysWarningInfo.PageIndex);
-	//PRINTF_FUNC("WarningCount = %d \n", ShmSysConfigAndInfo->SysWarningInfo.WarningCount);
-	for(i = 0; (i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5) < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++)
-	{
-		memset(cmd, 0x00, sizeof(cmd));
-		if(i >= 5)
-		{
-			break;
-		}
-		//error code
-		string2ByteArray(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], cmd);
-		DisplayValueToLcm(0x1010 + (i * 6), cmd, sizeof(cmd));
-		//警告標示
-		memset(cmd, 0x00, sizeof(cmd));
-
-		cmd[0] = 0x00;
-		cmd[1] = 0x01;
-		DisplayValueToLcm(0x1002 + (i * 2), cmd, 2);
-	}
-
-	memset(cmd, 0x00, sizeof(cmd));
-	for(; i < 5; i++)
-	{
-		DisplayValueToLcm(0x1010 + (i * 6), cmd, sizeof(cmd));
-		DisplayValueToLcm(0x1002 + (i * 2), cmd, 2);
-	}
-}
-
-//================================================
-// QR Code process
-//================================================
-void ChangeQrCode_Idle(char *input, byte len)
-{
-	byte cmd[len];
-	int loop = 0;
-
-	input[len] = '\0';
-	cmd[len] = '\0';
-	while(input[loop] != '\0')
-	{
-		cmd[loop] = input[loop];
-		loop++;
-	}
-
-	//printf("cmd = %s, len = %d \n", cmd, len + 1);
-	DisplayValueToLcm(__qr_code, cmd, len + 1);
-}
-
-void ChangeQrCode_Charge(char *input, byte len)
-{
-	byte cmd[len];
-	int loop = 0;
-
-	input[len] = '\0';
-	cmd[len] = '\0';
-	while(input[loop] != '\0')
-	{
-		cmd[loop] = input[loop];
-		loop++;
-	}
-
-	//printf("2 - cmd = %s, len = %d \n", cmd, len + 1);
-	DisplayValueToLcm(__qr_code_pre, cmd, len + 1);
-}
-
-//================================================
-// Change current page
-//================================================
-void ChangeCurPage()
-{
-	//PRINTF_FUNC("cur = %d, new = %d \n", _currentPage, ShmSysConfigAndInfo->SysInfo.PageIndex);
-	if (_currentPage != ShmSysConfigAndInfo->SysInfo.PageIndex)
-	{
-		//_currentPage = ShmSysConfigAndInfo->SysInfo.PageIndex;
-		ChangeToOtherPage(ShmSysConfigAndInfo->SysInfo.PageIndex);
-		_everyPageRollChange = 0;
-	}
-}
-
-//================================================
-// Main process
-//================================================
-byte demoCount = 0;
-void DemoFunction()
-{
-	if (demoCount == 0)
-	{
-		ShmSysConfigAndInfo->SysWarningInfo.WarningCount = 6;
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[0][0], "000001", 7);
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[1][0], "000002", 7);
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[2][0], "000003", 7);
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[3][0], "000004", 7);
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[4][0], "000005", 7);
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[5][0], "000006", 7);
-	}
-	else
-	{
-		if (demoCount == 20) {
-			ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_IDLE;
-		} else if (demoCount == 80) {
-			ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_AUTHORIZING;
-		} else if (demoCount == 100) {
-			ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_AUTHORIZ_COMP;
-		} else if (demoCount == 120) {
-			ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_AUTHORIZ_FAIL;
-		} else if (demoCount == 140) {
-			ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_PRE_CHARGE;
-		} else if (demoCount == 180) {
-			ShmSysConfigAndInfo->SysInfo.PageIndex = _LCM_CHARGING;
-		}
-	}
-
-	if (demoCount < 180)
-		demoCount++;
-}
-
-//================================================
-// Main process
-//================================================
-bool FindChargingInfoData(byte target, struct ChargingInfoData **_chargingData)
-{
-	for (byte index = 0; index < CHAdeMO_QUANTITY; index++)
-	{
-		if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == target)
-		{
-			_chargingData[target] = &ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index];
-			return true;
-		}
-	}
-
-	for (byte index = 0; index < CCS_QUANTITY; index++)
-	{
-		if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == target)
-		{
-			_chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[index];
-			return true;
-		}
-	}
-
-	for (byte index = 0; index < GB_QUANTITY; index++)
-	{
-		if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == target)
-		{
-			_chargingData[target] = &ShmSysConfigAndInfo->SysInfo.GbChargingData[index];
-			return true;
-		}
-	}
-
-	return false;
-}
-
-bool FindAcChargingInfoData(byte target, struct ChargingInfoData **acChargingData)
-{
-	if (target < AC_QUANTITY)
-	{
-		acChargingData[target] = &ShmSysConfigAndInfo->SysInfo.AcChargingData[target];
-		return true;
-	}
-
-	return false;
-}
-
-void ChangeAcBattMapAndValue(short page)
-{
-	if (page == _LCM_CHARGING)
-	{
-		if (isDiffStatus != _battery_display_ani)
-		{
-			isChangeBattMap = false;
-			isDiffStatus = _battery_display_ani;
-		}
-
-		if (ac_chargingInfo[0]->IsCharging && !isChangeBattMap)
-		{
-			isChangeBattMap = true;
-			if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV5)
-			{
-				ChangeDisplay2Value(__batt_map, _battery_empty);
-				ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_EMP;
-			}
-			else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_EMP)
-			{
-				ChangeDisplay2Value(__batt_map, _battery_cap_20);
-				ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV1;
-			}
-			else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV1)
-			{
-				ChangeDisplay2Value(__batt_map, _battery_cap_40);
-				ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV2;
-			}
-			else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV2)
-			{
-				ChangeDisplay2Value(__batt_map, _battery_cap_60);
-				ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV3;
-			}
-			else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV3)
-			{
-				ChangeDisplay2Value(__batt_map, _battery_cap_80);
-				ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV4;
-			}
-			else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV4)
-			{
-				ChangeDisplay2Value(__batt_map, _battery_cap_100);
-				ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV5;
-			}
-		}
-	}
-	else if (page == _LCM_COMPLETE)
-	{
-		if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV5)
-			ChangeDisplay2Value(__batt_map, _battery_soc_20);
-		else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_EMP)
-			ChangeDisplay2Value(__batt_map, _battery_soc_20);
-		else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV1)
-			ChangeDisplay2Value(__batt_map, _battery_soc_40);
-		else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV2)
-			ChangeDisplay2Value(__batt_map, _battery_soc_60);
-		else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV3)
-			ChangeDisplay2Value(__batt_map, _battery_soc_80);
-		else if (ac_ani_battery_level == _BATTERY_LEVEL_FOR_MAP_LV4)
-			ChangeDisplay2Value(__batt_map, _battery_soc_100);
-	}
-
-	ChangeDisplay2Value(__soc_value_charging, _disappear);
-}
-
-void ChangeBattMapAndValue(short page, int soc)
-{
-//	srand(time(NULL));
-//	int min = 10;
-//	int max = 90;
-//	soc = rand() % (max - min + 1) + min;
-
-	if (page == _LCM_PRE_CHARGE)
-	{
-		ChangeDisplay2Value(__batt_map_empty, _battery_empty);
-	}
-	else if (page == _LCM_CHARGING)
-	{
-		if (soc < 20)
-		{
-			if (_battery_display_ani)
-				ChangeDisplay2Value(__batt_map, _battery_empty);
-			else
-				ChangeDisplay2Value(__batt_map, _battery_cap_20);
-		}
-		else if (soc >= 20 && soc < 40)
-		{
-			if (_battery_display_ani)
-				ChangeDisplay2Value(__batt_map, _battery_cap_20);
-			else
-				ChangeDisplay2Value(__batt_map, _battery_cap_40);
-		}
-		else if (soc >= 40 && soc < 60)
-		{
-			if (_battery_display_ani)
-				ChangeDisplay2Value(__batt_map, _battery_cap_40);
-			else
-				ChangeDisplay2Value(__batt_map, _battery_cap_60);
-		}
-		else if (soc >= 60 && soc < 80)
-		{
-			if (_battery_display_ani)
-				ChangeDisplay2Value(__batt_map, _battery_cap_60);
-			else
-				ChangeDisplay2Value(__batt_map, _battery_cap_80);
-		}
-		else if (soc >= 80 && soc < 100)
-		{
-			if (_battery_display_ani)
-				ChangeDisplay2Value(__batt_map, _battery_cap_80);
-			else
-				ChangeDisplay2Value(__batt_map, _battery_cap_100);
-		}
-		else if (soc == 100)
-			ChangeDisplay2Value(__batt_map, _battery_cap_100);
-	}
-	else if (page == _LCM_COMPLETE)
-	{
-		if (soc < 20)
-			ChangeDisplay2Value(__batt_map, _battery_soc_20);
-		else if (soc >= 20 && soc < 40)
-			ChangeDisplay2Value(__batt_map, _battery_soc_40);
-		else if (soc >= 40 && soc < 60)
-			ChangeDisplay2Value(__batt_map, _battery_soc_60);
-		else if (soc >= 60 && soc < 80)
-			ChangeDisplay2Value(__batt_map, _battery_soc_80);
-		else if (soc >= 80 && soc <= 100)
-			ChangeDisplay2Value(__batt_map, _battery_soc_100);
-	}
-
-	byte cmd[5];
-	byte value[5];
-
-	memset(cmd, 0x00, sizeof(cmd));
-	memset(value, 0x00, sizeof(value));
-	sprintf((char *)value, "%d%%", soc);
-	string2ByteArray(value, cmd);
-	DisplayValueToLcm(__soc_value_charging, cmd, sizeof(cmd));
-}
-
-void ChangeRemainTime(int sec)
-{
-	int h, m, s;
-	byte cmd[10];
-	byte value[10];
-
-	memset(cmd, 0x00, sizeof(cmd));
-
-//	srand(time(NULL));
-//	int min = 0;
-//	int max = 65536;
-//	sec = rand() % (max - min + 1) + min;
-
-	h = (sec / 3600);
-	m = (sec - (3600 * h)) / 60;
-	s = (sec - (3600 * h) - (m * 60));
-	sprintf((char *)value, "%02d:%02d:%02d", h, m, s);
-	string2ByteArray(value, cmd);
-	DisplayValueToLcm(__remain_time_tx, cmd, sizeof(cmd));
-}
-
-void ChangeChargingEnergyValue(float energy)
-{
-	byte cmd[10];
-	byte value[10];
-
-	memset(cmd, 0x00, sizeof(cmd));
-	if (energy >= 0.05)
-		energy -= 0.05;
-	sprintf((char *) value, "%.1f kWh", energy);
-	string2ByteArray(value, cmd);
-	DisplayValueToLcm(__total_out_eng_tx, cmd, sizeof(cmd));
-}
-
-void ChangeChargingPowerValue(float pow)
-{
-	byte cmd[10];
-	byte value[10];
-
-	memset(cmd, 0x00, sizeof(cmd));
-
-//	float min = 0.0;
-//	float max = 50;
-//	pow = (max - min) * rand() / (RAND_MAX + 1.0) + min;
-	sprintf((char *) value, "%.1f kW", pow);
-	string2ByteArray(value, cmd);
-	DisplayValueToLcm(__output_eng_tx, cmd, sizeof(cmd));
-}
-
-void ChangeChargingFeeValue(float fee)
-{
-	byte cmd[10];
-	byte value[10];
-
-	memset(cmd, 0x00, sizeof(cmd));
-
-	sprintf((char *) value, "%.2f", fee);
-	string2ByteArray(value, cmd);
-	DisplayValueToLcm(__charging_fee_tx, cmd, sizeof(cmd));
-}
-
-void DisplayMoneyRate(float money)
-{
-	byte cmd[8];
-	byte value[8];
-
-	memset(cmd, 0x00, sizeof(cmd));
-
-	sprintf((char *) value, "%.2f", money);
-	string2ByteArray(value, cmd);
-	DisplayValueToLcm(__money_by_rate, cmd, sizeof(cmd));
-}
-
-void DisplayMoneyCur(byte *cur)
-{
-	byte cmd[8];
-	byte buf[8];
-
-	memset(cmd, 0x00, sizeof(cmd));
-	memcpy((char *) buf, cur, 3);
-	memcpy((char *) buf + 3, "/kWh", 4);
-	buf[7] = '\0';
-	string2ByteArray(buf, cmd);
-	DisplayValueToLcm(__money_rate, cmd, sizeof(cmd));
-}
-
-void RefreshPageAnimation(byte value)
-{
-	switch(_currentPage)
-	{
-		case _LCM_IDLE:
-		{
-
-		}
-			break;
-		case _LCM_WAIT_FOR_PLUG:
-		{
-			if(_everyPageRollChange == 0)
-				ChangeDisplay2Value(__plug_in_arrow, _arrow_dark);
-			else if(_everyPageRollChange == 15)
-				ChangeDisplay2Value(__plug_in_arrow, _arrow_light);
-
-			_everyPageRollChange > 30 ? _everyPageRollChange = 0 : _everyPageRollChange++;
-		}
-			break;
-		case _LCM_PRE_CHARGE:
-		case _LCM_CHARGING:
-		case _LCM_COMPLETE:
-		{
-			if (_currentPage == _LCM_PRE_CHARGE)
-			{
-				if (_everyPageRollChange == 0 || _everyPageRollChange == 22)
-					ChangeDisplay2Value(__conn_line, _conn_map1);
-				else if (_everyPageRollChange == 11 || _everyPageRollChange == 33)
-					ChangeDisplay2Value(__conn_line, _conn_map2);
-			}
-			else if (_currentPage == _LCM_CHARGING)
-			{
-				if (_everyPageRollChange == 0 || _everyPageRollChange == 22)
-					ChangeDisplay2Value(__conn_line_chag, _charging_map1);
-				else if (_everyPageRollChange == 11 || _everyPageRollChange == 33)
-					ChangeDisplay2Value(__conn_line_chag, _charging_map2);
-			}
-			else if (_currentPage == _LCM_COMPLETE)
-			{
-				if (_everyPageRollChange == 0)
-					ChangeDisplay2Value(__conn_line_comp, _complete_map);
-			}
-
-			_everyPageRollChange >= 45 ? _everyPageRollChange = 0 : _everyPageRollChange++;
-		}
-			break;
-	}
-}
-
-void RefreshConnStatus()
-{
-	// eth
-	if (ShmSysConfigAndInfo->SysInfo.ethInternetConn == YES)
-	{ ChangeDisplay2Value(__ethernet_status, _ethernet_connect); }
-	else
-	{ ChangeDisplay2Value(__ethernet_status, _ethernet_disconnect); }
-
-	// Wifi
-	if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'W' || ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D') &&
-			ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode != _SYS_WIFI_MODE_DISABLE)
-	{
-		if (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn == YES ||
-				ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == _SYS_WIFI_MODE_AP)
-		{ ChangeDisplay2Value(__wifi_status, _wifi_connect); }
-		else
-		{ ChangeDisplay2Value(__wifi_status, _wifi_disconnect); }
-	}
-	else
-	{
-		ShmSysConfigAndInfo->SysConfig.AthInterface.WifiRssi = 0;
-		ChangeDisplay2Value(__wifi_status, _disappear);
-	}
-
-	if((ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'T' || ShmSysConfigAndInfo->SysConfig.ModelName[10] == 'D') &&
-			ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled != NO)
-	{
-		if (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == _SYS_WIFI_MODE_DISABLE)
-		{
-			ChangeDisplay2Value(__3G4G_status, _disappear);
-			// 3G/4G
-			if (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn == YES)
-			{ ChangeDisplay2Value(__3G4G_move_status, _3G4G_connect); }
-			else
-			{ ChangeDisplay2Value(__3G4G_move_status, _3G4G_disconnect); }
-		}
-		else
-		{
-			ChangeDisplay2Value(__3G4G_move_status, _disappear);
-			// 3G/4G
-			if (ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn == YES)
-			{ ChangeDisplay2Value(__3G4G_status, _3G4G_connect); }
-			else
-			{ ChangeDisplay2Value(__3G4G_status, _3G4G_disconnect); }
-		}
-	}
-	else
-	{
-		ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi = 0;
-		ChangeDisplay2Value(__3G4G_status, _disappear);
-		ChangeDisplay2Value(__3G4G_move_status, _disappear);
-	}
-
-	// 連線到後台
-	if (ShmSysConfigAndInfo->SysInfo.OcppConnStatus == YES)
-		ChangeDisplay2Value(__conn_status, _connect);
-	else
-		ChangeDisplay2Value(__conn_status, _disconnect);
-}
-
-byte FirstPageChanged()
-{
-	byte result = NO;
-
-	if (_currentPage != _oldPage)
-	{
-		result = YES;
-		_oldPage = _currentPage;
-	}
-
-	return result;
-}
-
-bool IsPageReloadChk()
-{
-	bool result = false;
-
-	if (ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == NO_DEFINE)
-	{
-		if (_curPage_index != ShmSysConfigAndInfo->SysInfo.CurGunSelected)
-		{
-			_curPage_index = ShmSysConfigAndInfo->SysInfo.CurGunSelected;
-			result = true;
-		}
-	}
-	else
-	{
-		if (_curPage_index != ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc)
-		{
-			_curPage_index = ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc;
-			result = true;
-		}
-	}
-
-	return result;
-}
-
-bool IsConfigReloadChk()
-{
-	bool result = false;
-
-	if (ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode == NO)
-	{
-		if (strcmp((char *)QRCodeBuf, (char *)ShmSysConfigAndInfo->SysConfig.SystemId) != EQUAL)
-			result = true;
-	}
-	else
-	{
-		if (strcmp((char *)QRCodeBuf, (char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent) != EQUAL)
-			result = true;
-	}
-
-	return result;
-}
-
-void SaveQrcodeToBuf(byte *qrcode)
-{
-	strncpy((char *)QRCodeBuf, (char *)qrcode, sizeof(QRCodeBuf));
-}
-
-void ClearDisplayInfo()
-{
-	ChangeDisplay2Value(__csu_ver_string, _disappear);
-	ChangeDisplay2Value(__csu_ver_value, _disappear);
-
-	ChangeDisplay2Value(__eth0_ip_string, _disappear);
-	ChangeDisplay2Value(__eth0_ip_value, _disappear);
-
-	ChangeDisplay2Value(__sn_string, _disappear);
-	ChangeDisplay2Value(__sn_value, _disappear);
-
-	ChangeDisplay2Value(__dc1_ver_string, _disappear);
-	ChangeDisplay2Value(__dc1_ver_value, _disappear);
-
-	ChangeDisplay2Value(__dc2_ver_string, _disappear);
-	ChangeDisplay2Value(__dc2_ver_value, _disappear);
-
-	ChangeDisplay2Value(__fan_speed_string, _disappear);
-	ChangeDisplay2Value(__fan_speed_value, _disappear);
-}
-
-void DisplayInfoCsuVer(bool isShow, unsigned char *modelName)
-{
-	if (isShow)
-	{
-		byte value[10];
-
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *)value, "CSU Ver >");
-		DisplayValueToLcm(__csu_ver_string, value, sizeof(value));
-		memset(value, 0x00, sizeof(value));
-		strncpy((char *)value, (char *)modelName, 5);
-		DisplayValueToLcm(__csu_ver_value, value, sizeof(value));
-	}
-	else
-	{
-		ChangeDisplay2Value(__csu_ver_string, _disappear);
-		ChangeDisplay2Value(__csu_ver_value, _disappear);
-	}
-}
-
-void ShowWifiMode(bool isShow, unsigned char mode)
-{
-	if (isShow)
-	{
-		byte value[20];
-
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, "Wifi Mo. >");
-		DisplayValueToLcm(__csu_ver_string, value, sizeof(value));
-		memset(value, 0x00, sizeof(value));
-		if (mode == 0)
-			sprintf((char *)value, "disable");
-		else if (mode == 1)
-			sprintf((char *)value, "station");
-		else if (mode == 2)
-			sprintf((char *)value, "AP");
-
-		DisplayValueToLcm(__csu_ver_value, value, sizeof(value));
-	}
-	else
-	{
-		ChangeDisplay2Value(__csu_ver_string, _disappear);
-		ChangeDisplay2Value(__csu_ver_value, _disappear);
-	}
-}
-
-void DisplayInfoEthIp(bool isShow, unsigned char *ip)
-{
-	if (isShow)
-	{
-		byte value[20];
-
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, "Eth IP >");
-		DisplayValueToLcm(__eth0_ip_string, value, sizeof(value));
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, (char *) ip);
-		DisplayValueToLcm(__eth0_ip_value, value, sizeof(value));
-	}
-	else
-	{
-		ChangeDisplay2Value(__eth0_ip_string, _disappear);
-		ChangeDisplay2Value(__eth0_ip_value, _disappear);
-	}
-}
-
-void Show4GRssi(bool isShow, int dbValue)
-{
-	if (isShow)
-	{
-		byte value[20];
-
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, "RSSI >");
-		DisplayValueToLcm(__dc2_ver_string, value, sizeof(value));
-		memset(value, 0x00, sizeof(value));
-		sprintf((char *)value, "%d dBm", dbValue);
-		DisplayValueToLcm(__dc2_ver_value, value, sizeof(value));
-	}
-	else
-	{
-		ChangeDisplay2Value(__dc2_ver_string, _disappear);
-		ChangeDisplay2Value(__dc2_ver_value, _disappear);
-	}
-}
-
-void DisplayInfoSN(bool isShow, unsigned char *sn)
-{
-	if (isShow)
-	{
-		byte value[30];
-
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, "SN >");
-		DisplayValueToLcm(__sn_string, value, sizeof(value));
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, (char *) sn);
-		DisplayValueToLcm(__sn_value, value, sizeof(value));
-	}
-	else
-	{
-		ChangeDisplay2Value(__sn_string, _disappear);
-		ChangeDisplay2Value(__sn_value, _disappear);
-	}
-}
-
-void ShowWifiRssi(bool isShow, int dbValue)
-{
-	if (isShow)
-	{
-		byte value[20];
-
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, "RSSI >");
-		DisplayValueToLcm(__fan_speed_string, value, sizeof(value));
-		memset(value, 0x00, sizeof(value));
-		sprintf((char *)value, "%d dBm", dbValue);
-		DisplayValueToLcm(__fan_speed_value, value, sizeof(value));
-	}
-	else
-	{
-		ChangeDisplay2Value(__fan_speed_string, _disappear);
-		ChangeDisplay2Value(__fan_speed_value, _disappear);
-	}
-}
-
-void DisplayInfoGun1Ver(bool isShow, unsigned char *version)
-{
-	if (isShow)
-	{
-		byte value[10];
-
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, "Ct1 Ver >");
-		DisplayValueToLcm(__dc1_ver_string, value, sizeof(value));
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, (char *) version);
-		DisplayValueToLcm(__dc1_ver_value, value, sizeof(value));
-	}
-	else
-	{
-		ChangeDisplay2Value(__dc1_ver_string, _disappear);
-		ChangeDisplay2Value(__dc1_ver_value, _disappear);
-	}
-}
-
-void Show4GMode(bool isShow, unsigned char mode)
-{
-	if (isShow)
-	{
-		byte value[20];
-
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, "3/4G Mo. >");
-		DisplayValueToLcm(__dc1_ver_string, value, sizeof(value));
-		memset(value, 0x00, sizeof(value));
-		if (mode == 0)
-			sprintf((char *)value, "disable");
-		else if (mode == 1)
-			sprintf((char *)value, "enable");
-
-		DisplayValueToLcm(__dc1_ver_value, value, sizeof(value));
-	}
-	else
-	{
-		ChangeDisplay2Value(__dc1_ver_string, _disappear);
-		ChangeDisplay2Value(__dc1_ver_value, _disappear);
-	}
-}
-
-void DisplayInfoGun2Ver(bool isShow, unsigned char *version)
-{
-	if (isShow)
-	{
-		byte value[10];
-
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, "Ct2 Ver >");
-		DisplayValueToLcm(__dc2_ver_string, value, sizeof(value));
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, (char *) version);
-		DisplayValueToLcm(__dc2_ver_value, value, sizeof(value));
-	}
-	else
-	{
-		ChangeDisplay2Value(__dc2_ver_string, _disappear);
-		ChangeDisplay2Value(__dc2_ver_value, _disappear);
-	}
-}
-
-void Show4GIP(bool isShow, unsigned char *ip)
-{
-	if (isShow)
-	{
-		byte value[20];
-
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, "3/4G IP ");
-		DisplayValueToLcm(__eth0_ip_string, value, sizeof(value));
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, (char *) ip);
-		DisplayValueToLcm(__eth0_ip_value, value, sizeof(value));
-	}
-	else
-	{
-		ChangeDisplay2Value(__eth0_ip_string, _disappear);
-		ChangeDisplay2Value(__eth0_ip_value, _disappear);
-	}
-}
-
-void DisplayInfoSpeed(bool isShow, unsigned int fan)
-{
-	if (isShow)
-	{
-		byte value[10];
-
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, "Fan Spd >");
-		DisplayValueToLcm(__fan_speed_string, value, sizeof(value));
-		memset(value, 0x00, sizeof(value));
-		sprintf((char *)value, "%d", fan);
-		DisplayValueToLcm(__fan_speed_value, value, sizeof(value));
-	}
-	else
-	{
-		ChangeDisplay2Value(__fan_speed_string, _disappear);
-		ChangeDisplay2Value(__fan_speed_value, _disappear);
-	}
-}
-
-void ShowWifiIP(bool isShow, unsigned char *ip)
-{
-	if (isShow)
-	{
-		byte value[20];
-
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, "Wifi IP ");
-		DisplayValueToLcm(__sn_string, value, sizeof(value));
-		memset(value, 0x00, sizeof(value));
-		strcpy((char *) value, (char *) ip);
-		DisplayValueToLcm(__sn_value, value, sizeof(value));
-	}
-	else
-	{
-		ChangeDisplay2Value(__sn_string, _disappear);
-		ChangeDisplay2Value(__sn_value, _disappear);
-	}
-}
-
-void InformationShow()
-{
-	if(ShmSysConfigAndInfo->SysConfig.ShowInformation == YES)
-	{
-		bool show = _isShow = true;
-		if (_showInformIndex == 0)
-		{
-			DisplayInfoCsuVer(show, ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
-			DisplayInfoSpeed(show, ShmSysConfigAndInfo->SysInfo.SystemFanRotaSpeed);
-			DisplayInfoSN(show, ShmSysConfigAndInfo->SysConfig.SerialNumber);
-
-			DisplayInfoEthIp(show, ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress);
-			DisplayInfoGun1Ver(show, ShmSysConfigAndInfo->SysInfo.Connector1FwRev);
-			if (_totalCount > 1)
-				DisplayInfoGun2Ver(show, ShmSysConfigAndInfo->SysInfo.Connector2FwRev);
-			else
-			{
-				DisplayInfoGun2Ver(false, ShmSysConfigAndInfo->SysInfo.Connector2FwRev);
-			}
-		}
-		else if (_showInformIndex == 1)
-		{
-			ShowWifiMode(show, ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode);
-			ShowWifiRssi(show, ShmSysConfigAndInfo->SysConfig.AthInterface.WifiRssi);
-			ShowWifiIP(show, ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress);
-
-			Show4GMode(show, ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomEnabled);
-			Show4GRssi(show, ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi);
-			Show4GIP(show, ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress);
-		}
-	}
-	else
-	{
-		ClearDisplayInfo();
-
-		if (_isShow)
-		{
-			_isShow = false;
-			_showInformIndex++;
-			if (_showInformIndex >= 2)
-				_showInformIndex = 0;
-		}
-	}
-}
-
-void ProcessPageInfo()
-{
-	_page_reload = IsPageReloadChk();
-
-	if (!_page_reload)
-		_page_reload = IsConfigReloadChk();
-
-	// 隨插即充 - 可省略該按鈕
-//	if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_ENABLE)
-//	{
-//		ChangeDisplay2Value(__ret_home_btn, _back_home_btn);
-//		if (_totalCount >= 2 && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
-//			ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
-//		else
-//			ChangeDisplay2Value(__sel_gun_btn, _disappear);
-//	}
-	switch(_currentPage)
-	{
-		case _LCM_IDLE:
-		{
-			if (ShmSysConfigAndInfo->SysConfig.isRFID)
-				ChangeDisplay2Value(__main_rfid, _main_rfid);
-			else
-				ChangeDisplay2Value(__main_rfid, _main_none_rfid);
-
-			if (ShmSysConfigAndInfo->SysConfig.isQRCode)
-				ChangeDisplay2Value(__main_qr, _main_qr);
-			else
-			{
-				ChangeDisplay2Value(__qr_code, _disappear);
-				ChangeDisplay2Value(__main_qr, _main_none_qr);
-				needReloadQr = true;
-			}
-
-			if (ShmSysConfigAndInfo->SysConfig.isAPP)
-				ChangeDisplay2Value(__main_app, _main_app);
-			else
-				ChangeDisplay2Value(__main_app, _main_none_app);
-
-			if (FirstPageChanged() == YES || needReloadQr || _page_reload)
-			{
-				if (ShmSysConfigAndInfo->SysConfig.isQRCode)
-				{
-					needReloadQr = false;
-					if (ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode == NO)
-					{
-						byte len = strlen((char *)ShmSysConfigAndInfo->SysConfig.SystemId);
-						SaveQrcodeToBuf(ShmSysConfigAndInfo->SysConfig.SystemId);
-						ChangeQrCode_Idle((char *)ShmSysConfigAndInfo->SysConfig.SystemId, len);
-					}
-					else
-					{
-						byte len = strlen((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent);
-						SaveQrcodeToBuf(ShmSysConfigAndInfo->SysConfig.QRCodeContent);
-						ChangeQrCode_Idle((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent, len);
-					}
-				}
-			}
-
-			bool isCharging = false;
-			for(byte i = 0; i < _totalCount; i++)
-			{
-				if (_chargingInfoData[i]->SystemStatus == SYS_MODE_IDLE)
-					continue;
-
-				isCharging = true;
-				break;
-			}
-
-			if (isCharging && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
-			{
-				ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
-			}
-			else
-			{
-				ChangeDisplay2Value(__sel_gun_btn, _disappear);
-			}
-		}
-			break;
-		case _LCM_AUTHORIZING:
-		case _LCM_AUTHORIZ_COMP:
-		case _LCM_AUTHORIZ_FAIL:
-		{
-			FirstPageChanged();
-		}
-			break;
-		case _LCM_WAIT_FOR_PLUG:
-		{
-			FirstPageChanged();
-			bool isCharging = false;
-			for(byte i = 0; i < _totalCount; i++)
-			{
-				if (_chargingInfoData[i]->SystemStatus == SYS_MODE_IDLE ||
-						_chargingInfoData[i]->SystemStatus == SYS_MODE_MAINTAIN ||
-						_chargingInfoData[i]->SystemStatus == SYS_MODE_RESERVATION)
-					continue;
-
-				isCharging = true;
-				break;
-			}
-
-			if (ShmSysConfigAndInfo->SysConfig.AuthorisationMode == AUTH_MODE_DISABLE)
-			{
-				// 新增隨插即充功能預設在等待插槍頁面在開啟
-				ChangeDisplay2Value(__ret_home_btn, _disappear);
-			}
-			else
-				ChangeDisplay2Value(__ret_home_btn, _back_home_btn);
-
-			if (isCharging && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
-			{
-				ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
-			}
-			else
-			{
-				ChangeDisplay2Value(__sel_gun_btn, _disappear);
-			}
-		}
-			break;
-		case _LCM_PRE_CHARGE:
-		case _LCM_CHARGING:
-		case _LCM_COMPLETE:
-		{
-			bool isShowAc = false;
-			byte gunTargetIndex = 0;
-
-			ChangeDisplay2Value(__ret_home_btn, _back_home_btn);
-
-			if (acgunCount > 0)
-			{
-				gunTargetIndex = 2;
-				if (ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc != NO_DEFINE)
-				{
-					isShowAc = true;
-					if (_currentPage == _LCM_COMPLETE)
-						ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _actype_light_cmp);
-					else
-						ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _actype_light);
-
-					if (_currentPage == _LCM_CHARGING)
-					{
-						ChangeAcBattMapAndValue(_LCM_CHARGING);
-						if (ac_chargingInfo[0]->PresentChargedDuration >= 0 &&
-								ac_chargingInfo[0]->PresentChargedDuration <= TIME_MAX_SEC)
-							ChangeRemainTime(ac_chargingInfo[0]->PresentChargedDuration);
-						else
-							ChangeRemainTime(0);
-
-						if (ac_chargingInfo[0]->PresentChargingPower >= 0.1 &&
-								ac_chargingInfo[0]->PresentChargingPower <= POWER_MAX_KW)
-							ChangeChargingPowerValue(ac_chargingInfo[0]->PresentChargingPower);
-						else
-							ChangeChargingPowerValue(0);
-
-						if (ac_chargingInfo[0]->PresentChargedEnergy >= 0.1 &&
-								ac_chargingInfo[0]->PresentChargedEnergy <= ENERGY_MAX_KWH)
-							ChangeChargingEnergyValue(ac_chargingInfo[0]->PresentChargedEnergy);
-						else
-							ChangeChargingEnergyValue(0);
-
-						if (strcmp((char *)ac_chargingInfo[0]->StartUserId, "") == 0 ||
-								ShmSysConfigAndInfo->SysConfig.StopChargingByButton == YES)
-							ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
-						else
-							ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
-					}
-					else if (_currentPage == _LCM_COMPLETE)
-					{
-						ChangeAcBattMapAndValue(_LCM_COMPLETE);
-						if (ac_chargingInfo[0]->PresentChargedDuration >= 0 &&
-								ac_chargingInfo[0]->PresentChargedDuration <= TIME_MAX_SEC)
-							ChangeRemainTime(ac_chargingInfo[0]->PresentChargedDuration);
-						else
-							ChangeRemainTime(0);
-
-						if (ac_chargingInfo[0]->PresentChargingPower >= 0.1 &&
-								ac_chargingInfo[0]->PresentChargingPower <= POWER_MAX_KW)
-							ChangeChargingPowerValue(ac_chargingInfo[0]->PresentChargingPower);
-						else
-							ChangeChargingPowerValue(0);
-
-						if ((ac_chargingInfo[0]->PresentChargedEnergy >= 0.1 &&
-								ac_chargingInfo[0]->PresentChargedEnergy <= ENERGY_MAX_KWH) ||
-								(strcmp((char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL, "") != EQUAL &&
-										strcmp((char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId, "") != EQUAL))
-						{
-							ChangeChargingEnergyValue(ac_chargingInfo[0]->PresentChargedEnergy);
-
-							if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling &&
-									ac_chargingInfo[0]->ChargingFee >= 0)
-							{
-								ChangeChargingFeeValue(ac_chargingInfo[0]->ChargingFee);
-							}
-						}
-						else
-						{
-							ChangeChargingEnergyValue(0);
-							if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
-								ChangeChargingFeeValue(0);
-						}
-
-						if(!ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
-						{
-							ChangeDisplay2Value(__charging_fee_map, _disappear);
-							ChangeDisplay2Value(__charging_fee_tx, _disappear);
-						}
-						else
-						{
-							ChangeDisplay2Value(__charging_fee_map, _money_map);
-						}
-					}
-				}
-				else
-				{
-					if (_currentPage == _LCM_COMPLETE)
-						ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _actype_dark_cmp);
-					else
-						ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _actype_dark);
-				}
-			}
-			else
-			{
-				if (_totalCount > 1)
-				{
-					gunTargetIndex = 2;
-					ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _disappear);
-					ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _disappear);
-				}
-			}
-
-			gunTargetIndex = 0;
-			for(byte i = 0; i < _totalCount; i++)
-			{
-				if (_totalCount == 1 && acgunCount <= 0)
-					gunTargetIndex = 2;
-				else
-					gunTargetIndex = i;
-
-				switch(_chargingInfoData[i]->Type)
-				{
-					case _Type_Chademo:
-					{
-						if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i && !isShowAc)
-						{
-							if (_currentPage == _LCM_COMPLETE)
-								ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _chademo_light_cmp);
-							else
-								ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _chademo_light);
-						}
-						else
-						{
-							if (_currentPage == _LCM_COMPLETE)
-								ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _chademo_dark_cmp);
-							else
-								ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _chademo_dark);
-						}
-					}
-						break;
-					case _Type_GB:
-					{
-						if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i && !isShowAc)
-						{
-							if (_currentPage == _LCM_COMPLETE)
-								ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _gbt_light_cmp);
-							else
-								ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _gbt_light);
-						}
-						else
-						{
-							if (_currentPage == _LCM_COMPLETE)
-								ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _gbt_dark_cmp);
-							else
-								ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _gbt_dark);
-						}
-					}
-						break;
-					case _Type_CCS_2:
-					{
-						if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i && !isShowAc)
-						{
-							if (_currentPage == _LCM_COMPLETE)
-								ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _ccs_light_cmp);
-							else
-								ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _ccs_light);
-						}
-						else
-						{
-							if (_currentPage == _LCM_COMPLETE)
-								ChangeDisplay2Value(__cmp_gun_type_index + (gunTargetIndex * 2), _ccs_dark_cmp);
-							else
-								ChangeDisplay2Value(__gun_type_index + (gunTargetIndex * 2), _ccs_dark);
-						}
-					}
-						break;
-				}
-
-				if (_currentPage == _LCM_PRE_CHARGE && !isShowAc)
-				{
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
-					{
-						ChangeBattMapAndValue(_currentPage, _chargingInfoData[i]->EvBatterySoc);
-					}
-				}
-				else if (_currentPage == _LCM_CHARGING && !isShowAc)
-				{
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
-					{
-						ChangeBattMapAndValue(_currentPage, _chargingInfoData[i]->EvBatterySoc);
-						if (_chargingInfoData[i]->PresentChargedDuration >= 0 &&
-								_chargingInfoData[i]->PresentChargedDuration <= TIME_MAX_SEC)
-							ChangeRemainTime(_chargingInfoData[i]->PresentChargedDuration);
-						else
-							ChangeRemainTime(0);
-
-						if (_chargingInfoData[i]->PresentChargingPower >= 0 &&
-								_chargingInfoData[i]->PresentChargingPower <= POWER_MAX_KW)
-							ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
-						else
-							ChangeChargingPowerValue(0);
-
-						if (_chargingInfoData[i]->PresentChargedEnergy >= 0.1 &&
-								_chargingInfoData[i]->PresentChargedEnergy <= ENERGY_MAX_KWH)
-							ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
-						else
-							ChangeChargingEnergyValue(0);
-                            /*
-						if (strcmp((char *)_chargingInfoData[i]->StartUserId, "") == 0 ||
-								ShmSysConfigAndInfo->SysConfig.StopChargingByButton == YES ||
-								_chargingInfoData[i]->isRemoteStart ||
-								ShmDcCommonData->_authWithCcidFlag [i] == _CCID_AUTHCOMP)
-							ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn);
-						else
-							ChangeDisplay2Value(__stop_method_btn, _stop_charging_btn_scan);
-                            */
-					}
-				}
-				else if (_currentPage == _LCM_COMPLETE && !isShowAc)
-				{
-					if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == i)
-					{
-						ChangeBattMapAndValue(_currentPage, _chargingInfoData[i]->EvBatterySoc);
-						if (_chargingInfoData[i]->PresentChargedDuration >= 0 &&
-								_chargingInfoData[i]->PresentChargedDuration <= TIME_MAX_SEC)
-							ChangeRemainTime(_chargingInfoData[i]->PresentChargedDuration);
-						else
-							ChangeRemainTime(0);
-
-						if (_chargingInfoData[i]->PresentChargingPower >= 0 &&
-								_chargingInfoData[i]->PresentChargingPower <= POWER_MAX_KW)
-							ChangeChargingPowerValue(_chargingInfoData[i]->PresentChargingPower);
-						else
-							ChangeChargingPowerValue(0);
-
-						if ((_chargingInfoData[i]->PresentChargedEnergy >= 0.1 &&
-								_chargingInfoData[i]->PresentChargedEnergy <= ENERGY_MAX_KWH) ||
-								(strcmp((char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL, "") != EQUAL &&
-									strcmp((char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId, "") != EQUAL))
-						{
-							ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
-
-							if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling &&
-								_chargingInfoData[i]->ChargingFee >= 0)
-							{
-								ChangeChargingFeeValue(_chargingInfoData[i]->ChargingFee);
-							}
-						}
-						else
-						{
-							ChangeChargingEnergyValue(0);
-							if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
-								ChangeChargingFeeValue(0);
-						}
-
-						if(!ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
-						{
-							ChangeDisplay2Value(__charging_fee_map, _disappear);
-							ChangeDisplay2Value(__charging_fee_tx, _disappear);
-						}
-						else
-						{
-							ChangeDisplay2Value(__charging_fee_map, _money_map);
-						}
-					}
-				}
-			}
-
-			if (_totalCount > 1 &&
-					ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
-			{
-				ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
-			}
-			else
-			{
-				ChangeDisplay2Value(__sel_gun_btn, _disappear);
-			}
-
-			// gun btn and QR code
-			if (_totalCount + acgunCount >= 2 && _currentPage)
-			{
-				byte index = 0;
-				for(index = 0; index < _totalCount; index++)
-				{
-					if(ShmSysConfigAndInfo->SysInfo.CurGunSelected != index)
-					{
-						break;
-					}
-				}
-
-				if (_chargingInfoData[index]->SystemStatus == SYS_MODE_IDLE ||
-						_chargingInfoData[index]->SystemStatus == SYS_MODE_RESERVATION ||
-						_chargingInfoData[index]->SystemStatus == SYS_MODE_BOOTING)
-				{
-					if (FirstPageChanged() == YES || needReloadQr || _page_reload)
-					{
-						if (ShmSysConfigAndInfo->SysConfig.isQRCode)
-						{
-							needReloadQr = false;
-							if (ShmSysConfigAndInfo->SysConfig.QRCodeMadeMode == NO)
-							{
-								byte len = strlen((char *)ShmSysConfigAndInfo->SysConfig.SystemId);
-								ChangeQrCode_Charge((char *)ShmSysConfigAndInfo->SysConfig.SystemId, len);
-							}
-							else
-							{
-								byte len = strlen((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent);
-								ChangeQrCode_Charge((char *)ShmSysConfigAndInfo->SysConfig.QRCodeContent, len);
-							}
-						}
-					}
-				}
-			}
-		}
-			break;
-	}
-}
-
-void ChangeDisplayMoneyInfoWithoutBackend()
-{
-	struct timeb csuTime;
-	struct tm *tmCSU;
-
-	ftime(&csuTime);
-	tmCSU = localtime(&csuTime.time);
-
-	ChangeDisplay2Value(__money_rate_map, _charging_money);
-
-	if (tmCSU->tm_hour <= 23)
-	{
-		//ShmDcCommonData->_hour_index = tmCSU->tm_hour;
-		ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee = ShmSysConfigAndInfo->SysConfig.BillingData.Fee[tmCSU->tm_hour];
-		DisplayMoneyRate(ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee);
-	}
-
-	if (ShmSysConfigAndInfo->SysConfig.BillingData.Currency <= 53)
-	{
-        DisplayMoneyCur((uint8_t *)GetCurrency(pSysConfig->BillingData.Currency));
-	}
-}
-
-void ChangeDisplayMoneyInfo()
-{
-    uint8_t curGun = pSysInfo->CurGunSelected;
-
-    if (pSysConfig->BillingData.isBilling) {
-        struct timeb csuTime;
-        struct tm *tmCSU;
-
-        ftime(&csuTime);
-        tmCSU = localtime(&csuTime.time);
-
-        ChangeDisplay2Value(__money_rate_map, _charging_money);
-#if defined DD360Audi
-        if (ShmSelectGunInfo->PricesInfo[curGun].UserPrices != 0.00) { //Jerry add
-            DisplayMoneyRate(ShmSelectGunInfo->PricesInfo[curGun].UserPrices);
-        } else {
-#endif //defined DD360Audi
-            if (tmCSU->tm_hour <= 23) {
-                pSysConfig->BillingData.Cur_fee = pSysConfig->BillingData.Fee[tmCSU->tm_hour];
-                DisplayMoneyRate(pSysConfig->BillingData.Cur_fee);
-            }
-
-            if (pSysConfig->BillingData.Currency <= 53) {
-                DisplayMoneyCur((uint8_t *)GetCurrency(pSysConfig->BillingData.Currency));
-            }
-#if defined DD360Audi
-        }
-#endif //defined DD360Audi
-    } else {
-        ChangeDisplay2Value(__money_rate_map, _disappear);
-        ChangeDisplay2Value(__money_by_rate, _disappear);
-        ChangeDisplay2Value(__money_rate, _disappear);
-    }
-#if 0
-	struct timeb csuTime;
-	struct tm *tmCSU;
-
-	ftime(&csuTime);
-	tmCSU = localtime(&csuTime.time);
-
-	ChangeDisplay2Value(__money_rate_map, _charging_money);
-	//ShmDcCommonData->_hour_index = tmCSU->tm_hour;
-	if (ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc == DEFAULT_AC_INDEX)
-	{
-		if (ac_chargingInfo[0]->SystemStatus == SYS_MODE_IDLE ||
-				ac_chargingInfo[0]->SystemStatus == SYS_MODE_MAINTAIN ||
-				ac_chargingInfo[0]->SystemStatus == SYS_MODE_RESERVATION)
-		{
-			ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee = (float)ShmDcCommonData->balanceInfo.defaultPrice / 100;
-		}
-		else
-		{
-			if (ShmSysConfigAndInfo->SysConfig.TotalConnectorCount > 0)
-			{
-				if (ShmDcCommonData->balanceInfo.connectorBalanceInfo[1].UserPrice == 0)
-					ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee = (float)ShmDcCommonData->balanceInfo.defaultPrice / 100;
-				else
-				{
-					ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee =
-							(float)ShmDcCommonData->balanceInfo.connectorBalanceInfo[1].UserPrice / 100;
-				}
-
-				if (ShmDcCommonData->balanceInfo.connectorBalanceInfo[1].AccountBalance > 0)
-					ac_chargingInfo[0]->ChargingFee = (float)ShmDcCommonData->balanceInfo.connectorBalanceInfo[1].AccountBalance / 100;
-				else
-					ac_chargingInfo[0]->ChargingFee = 0;
-			}
-			else
-			{
-				if (ShmDcCommonData->balanceInfo.connectorBalanceInfo[0].UserPrice == 0)
-					ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee = (float)ShmDcCommonData->balanceInfo.defaultPrice / 100;
-				else
-					ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee = ShmDcCommonData->balanceInfo.connectorBalanceInfo[0].UserPrice;
-
-				if (ShmDcCommonData->balanceInfo.connectorBalanceInfo[0].AccountBalance > 0)
-					ac_chargingInfo[0]->ChargingFee = (float)ShmDcCommonData->balanceInfo.connectorBalanceInfo[0].AccountBalance / 100;
-				else
-					ac_chargingInfo[0]->ChargingFee = 0;
-			}
-		}
-		DisplayMoneyRate(ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee);
-	}
-	else
-	{
-		if (_chargingInfoData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus == SYS_MODE_IDLE ||
-				_chargingInfoData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus == SYS_MODE_MAINTAIN ||
-				_chargingInfoData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus == SYS_MODE_RESERVATION)
-		{
-			ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee = (float)ShmDcCommonData->balanceInfo.defaultPrice / 100;
-		}
-		else
-		{
-			byte acGunIndex = 0;
-
-			if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == 1)
-				acGunIndex = ShmSysConfigAndInfo->SysConfig.AcConnectorCount;
-
-			if (ShmDcCommonData->balanceInfo.connectorBalanceInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected + acGunIndex].UserPrice == 0)
-			{
-				ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee = (float)ShmDcCommonData->balanceInfo.defaultPrice / 100;
-			}
-			else
-			{
-				ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee =
-					(float)ShmDcCommonData->balanceInfo.connectorBalanceInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected + acGunIndex].UserPrice / 100;
-			}
-
-			if (ShmDcCommonData->balanceInfo.connectorBalanceInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected + acGunIndex].AccountBalance > 0)
-			{
-				_chargingInfoData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->ChargingFee =
-						(float)ShmDcCommonData->balanceInfo.connectorBalanceInfo[ShmSysConfigAndInfo->SysInfo.CurGunSelected + acGunIndex].AccountBalance / 100;
-			}
-			else
-			{
-				_chargingInfoData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->ChargingFee = 0;
-			}
-		}
-		DisplayMoneyRate(ShmSysConfigAndInfo->SysConfig.BillingData.Cur_fee);
-	}
-
-	if (ShmSysConfigAndInfo->SysConfig.BillingData.Currency <= 53)
-	{
-        DisplayMoneyCur((uint8_t *)GetCurrency(pSysConfig->BillingData.Currency));
-	}
-#endif
-}
-
-void Initialization()
-{
-	bool isPass = false;
-	byte count = 5;
-	while(!isPass && count > 0)
-	{
-		isPass = true;
-		for (byte _index = 0; _index < _totalCount; _index++)
-		{
-			if (!FindChargingInfoData(_index, &_chargingInfoData[0]))
-			{
-				log_error("LcmComm (main) : FindChargingInfoData false \n");
-				isPass = false;
-				count--;
-				break;
-			}
-		}
-
-		sleep(1);
-	}
-
-	isPass = false;
-
-	if (acgunCount > 0)
-	{
-		while(!isPass)
-		{
-			isPass = true;
-			for (byte _index = 0; _index < acgunCount; _index++)
-			{
-				if (!FindAcChargingInfoData(_index, &ac_chargingInfo[0]))
-				{
-					log_error("LcmComm : FindAcChargingInfoData false \n");
-					isPass = false;
-					break;
-				}
-			}
-
-			sleep(1);
-		}
-	}
-
-	if (count == 0)
-		PRINTF_FUNC("LCM Initialization Gun Fail.............\n");
-}
-
-void DefaultIconStatus()
-{
-	for(byte i = 0; i < 3; i++)
-		ChangeDisplay2Value(__gun_type_index + (i * 2), _disappear);
-
-	if (ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == YES || _totalCount == 1)
-		ChangeDisplay2Value(__sel_gun_btn, _disappear);
-	else
-		ChangeDisplay2Value(__sel_gun_btn, _sel_gun_btn);
-/*
-	if (ShmDcCommonData->ShowLogoFlag)
-	{
-		ChangeDisplay2Value(__logo, _logo);
-		ChangeDisplay2Value(__logo_cmp, _logo_cmp);
-	}
-	else
-	{
-		ChangeDisplay2Value(__logo, _disappear);
-		ChangeDisplay2Value(__logo_cmp, _disappear);
-	}
-*/
-	char _buf[3] = {0};
-	memcpy(_buf, &ShmSysConfigAndInfo->SysConfig.ModelName[12], 2);
-
-	// N0 : 拓連
-    /*
-	if (ShmDcCommonData->ShowLogoFlag &&
-			strcmp(_buf, "N0") != EQUAL)
-	{
-		ChangeDisplay2Value(__phihong_string, _phihong_string_map);
-	}
-	else
-	{
-		ChangeDisplay2Value(__phihong_string, _disappear);
-	}
-    */
-}
-
-//=======================================
-// Download image
-//=======================================
-//char lcdRegisterWrite(byte command, short address, byte *data, byte len)
-//{
-//	byte cmd[256];
-//	memset(cmd, 0x00, sizeof(cmd));
-//	char result = FAIL;
-//
-//	cmd[0] = CMD_TITLE_1;
-//	cmd[1] = CMD_TITLE_2;
-//	cmd[2] = 0x03 + len;
-//	cmd[3] = command;
-//	cmd[4] = address >> 8;
-//	cmd[5] = address & 0x00FF;
-//
-//	for(byte count = 0; count < len; count++)
-//	{
-//		cmd[6 + count] = *(data + count);
-//	}
-//
-//	//WriteCmdToLcm(cmd, cmd[2] + 3);
-//	int slen = write(Uart1Fd, cmd, cmd[2] + 3);
-//	printf("%d \n", slen);
-//	if(slen >= cmd[2] + 3)
-//	{
-//		printf("Pass. \n");
-//		result = PASS;
-//	}
-//	else
-//	{
-//		result = FAIL;
-//		printf("Fail. \n");
-//	}
-//
-//	return result;
-//}
-
-void displayMessageDgus(uint8_t *data, uint16_t len, uint8_t isRX)
-{
-	uint8_t output[8192];
-
-	memset(output, 0x00, ARRAY_SIZE(output));
-	sprintf((char*)output, "%s", (isRX?"RX: ":"TX: "));
-	for(uint16_t idx = 0;idx<len;idx++)
-	{
-		sprintf((char*)output, "%s%02x ", output, data[idx]);
-	}
-
-	#ifdef isDebugPrint
-	log_info("%s\n", output);
-	#endif
-}
-
-int transceiverDgus(int32_t fd, uint8_t *tx, uint16_t tx_len, uint8_t *rx, uint16_t rx_len)
-{
-	int result = FAIL;
-	int len;
-
-	tcflush(fd,TCIOFLUSH);
-
-	#ifdef isDebugPrint
-	displayMessageDgus(tx, tx_len, NO);
-	#endif
-
-	usleep(10000);
-
-	if(write(fd, tx, tx_len) >= ARRAY_SIZE(tx))
-	{
-		if(tx[3] == CMD_REG_WRITE_DATA)
-		{
-			len = read(fd, rx, rx_len);
-			if(len > 0)
-			{
-				if((rx[0] == CMD_HEADER_1) && (rx[1] == CMD_HEADER_2))
-				{
-					if((rx[3] == CMD_REG_WRITE_DATA) && (rx[4] == 0x4f) && (rx[5] == 0x4b))
-					{
-						displayMessageDgus(rx, len, YES);
-						result = PASS;
-					}
-				}
-			}
-		}
-		else if(tx[3] == CMD_REG_READ_DATA)
-		{
-			len = read(fd, rx, rx_len);
-			if(len > 0)
-			{
-				if((rx[0] == CMD_HEADER_1) && (rx[1] == CMD_HEADER_2))
-				{
-					if(rx[3] == CMD_REG_READ_DATA)
-					{
-
-						displayMessageDgus(rx, len, YES);
-
-						result = PASS;
-					}
-					else
-					{}
-				}
-				else
-				{}
-			}
-			else
-			{}
-		}
-		else
-		{}
-	}
-	else
-	{}
-
-	return result;
-}
-
-int8_t lcdRegisterWrite(int32_t fd, uint8_t regType, uint16_t address, uint8_t *data, uint16_t dataLen)
-{
-	int8_t result = FAIL;
-	uint8_t tx[(regType == REG_TYPE_CONTROL? 8 : 6) + dataLen];
-	uint8_t rx[6];
-
-	memset(tx, 0x00, sizeof(tx));
-	memset(rx, 0x00, sizeof(rx));
-
-	tx[0] = CMD_HEADER_1;
-	tx[1] = CMD_HEADER_2;
-	tx[2] = (regType == REG_TYPE_CONTROL? 7 : (3 + dataLen));
-	tx[3] = CMD_REG_WRITE_DATA;
-	tx[4] = (address >> 8) & 0xff;
-	tx[5] = (address >> 0) & 0xff;
-
-	if(regType == REG_TYPE_CONTROL)
-	{
-		if(address == REG_ADDRESS_SET_PAGE_ID)
-		{
-			tx[6] = 0x5A;
-			tx[7] = 0x01;
-
-			memcpy(&tx[8], data, dataLen);
-		}
-	}
-	else
-	{
-		memcpy(&tx[6], data, dataLen);
-	}
-
-	if(fd > 0)
-	{
-		if(transceiverDgus(fd, tx, ARRAY_SIZE(tx), rx, ARRAY_SIZE(rx)) == PASS)
-		{
-			result = PASS;
-		}
-		else
-		{}
-	}
-	else
-	{}
-
-	return result;
-}
-
-int main(void)
-{
-    /*
-	if(InitShareMemory() == FAIL)
-	{
-		#ifdef SystemLogMessage
-		log_error("InitShareMemory NG\n");
-		#endif
-		if (ShmStatusCodeData != NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory =	1;
-		}
-		sleep(5);
-		return 0;
-	}*/
-    log_info("!!!!!!!!!!!!!!!!!!! LCM !!!!!!!!!!!!!!!!!!!!!!!!!!!!");
-    if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error");
-        return FAIL;
-    }
-
-    MappingGunChargingInfo("LCM Control Task");
-
-
-	Uart1Fd = CreateCommunicationLcmPort();
-	byte changeWarningPriority = 0;
-	byte curWarningCount = 255;
-	ChangeBackLight(true);
-	_totalCount = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
-	acgunCount = ShmSysConfigAndInfo->SysConfig.AcConnectorCount;
-    pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-    pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-	//Initialization();
-
-	//GetDeviceInfoStatus(0x104A, 3);
-	//ChangeToOtherPage(_LCM_AUTHORIZING);
-	//ChangeDisplay2Value(0x1052, _main_rfid);
-	//byte len = strlen((char *)ShmSysConfigAndInfo->SysConfig.SystemId);
-	//ChangeQrCode_Idle((char *)ShmSysConfigAndInfo->SysConfig.SystemId, len);
-	ChangeToOtherPage(_LCM_INIT);
-	//GetCurrentPage();
-	//return -1;
-
-	DefaultIconStatus();
-
-//	for(;;)
-//	{
-//		GetDeviceInfoStatus(__lcm_version, 3);
-//		sleep(1);
-//	}
-//
-//	return -1;
-
-//	int xxx = 3;
-//	while(xxx > 0 && Uart1Fd != -1)
-//	{
-//		if (xxx == 1)
-//		{
-//			printf("---------------------------- \n");
-//			downloadBMP(1, "/tmp/1_idle.bmp");
-//			printf("---------------------------- end \n");
-//			return -1;
-//		}
-//		sleep(1);
-//		xxx--;
-//	}
-//	return -1;
-
-	byte _verShowCount = 5;
-
-	while(Uart1Fd != -1)
-	{
-		if (strcmp((char *)ShmSysConfigAndInfo->SysInfo.LcmHwRev, moduleName) != 0x00)
-		{
-			GetDeviceInfoStatus(__lcm_version, 3);
-			GetCurrentPage();
-			sleep(1);
-			if (_verShowCount > 0)
-			{
-				//PRINTF_FUNC("LCM Version = V.%03d \n", ShmDcCommonData->LcmFwVersion);
-				_verShowCount--;
-			}
-            log_info("LCM Version Count:%d",_verShowCount);
-		}
-		else
-		{
-			//DemoFunction();
-
-			// Warning 處理
-			if(curWarningCount != ShmSysConfigAndInfo->SysWarningInfo.WarningCount)
-			{
-				changeWarningPriority = 0;
-				ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
-				curWarningCount = ShmSysConfigAndInfo->SysWarningInfo.WarningCount;
-				ChangeWarningFunc();
-			}
-			else if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 5 && changeWarningPriority == 0)
-			{
-				// 當有兩頁 Warning 則每隔三秒改變一次
-				if(ShmSysConfigAndInfo->SysWarningInfo.PageIndex == 0)
-					ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 1;
-				else
-					ShmSysConfigAndInfo->SysWarningInfo.PageIndex = 0;
-
-				ChangeWarningFunc();
-			}
-			// 頁面資訊處理
-			ProcessPageInfo();
-
-			// 網路 - wifi - 連線訊號處理
-			RefreshConnStatus();
-			// 換頁處理
-			GetCurrentPage();
-			ChangeCurPage();
-
-			RefreshPageAnimation(_everyPageRollChange);
-
-			if (changeWarningPriority == 0)
-			{
-				if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling)
-				{
-					if(strcmp((char *)ShmSysConfigAndInfo->SysConfig.OcppServerURL, "") != EQUAL &&
-							strcmp((char *)ShmSysConfigAndInfo->SysConfig.ChargeBoxId, "") != EQUAL)
-					{
-						ChangeDisplayMoneyInfo();
-					}
-					else
-						ChangeDisplayMoneyInfoWithoutBackend();
-				}
-				else
-				{
-					ChangeDisplay2Value(__money_rate_map, _disappear);
-					ChangeDisplay2Value(__money_by_rate, _disappear);
-					ChangeDisplay2Value(__money_rate, _disappear);
-				}
-
-				InformationShow();
-			}
-
-			// 掃按鈕
-			//GetDeviceInfoStatus(0x0600, 1);
-
-			changeWarningPriority >= 15 ? (_battery_display_ani = true) : (_battery_display_ani = false);
-			changeWarningPriority >= 30 ? changeWarningPriority = 0 : changeWarningPriority++;
-			usleep(100000);
-		}
-	}
-
-	CloseCommunicationLcmPort();
-	return FAIL;
-}

+ 306 - 30
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h

@@ -1,5 +1,8 @@
 #ifndef MODULE_LCM_CTRL_H_
 #define MODULE_LCM_CTRL_H_
+#include <stdint.h>
+#include <stdbool.h>
+#include "../Define/define.h"
 
 //------------------------------------------------------------------------------
 #define DEFAULT_AC_INDEX                        (2)
@@ -18,39 +21,312 @@
 #define CMD_BACKLIGHT                           (0x01)
 #define CMD_REGISTER                            (0x03)
 
-#define CMD_HEADER_1						0x5A
-#define CMD_HEADER_2						0xA5
-#define CMD_REG_WRITE						0x80
-#define CMD_REG_READ						0x81
-#define CMD_REG_WRITE_DATA					0x82
-#define CMD_REG_READ_DATA					0x83
-
-#define REG_ADDRESS_READ_VERSION			0x0F
-#define REG_ADDRESS_READ_RTC				0x10
-#define REG_ADDRESS_READ_PAGE_ID			0x14
-#define REG_ADDRESS_READ_BRIGHTNESS       	0x31
-#define REG_ADDRESS_WRITE_BRIGHTNESS		0X82
-#define REG_ADDRESS_SET_PAGE_ID				0x84
-#define REG_ADDRESS_SET_RTC					0x9C
-
-//=======================================
-// Register Control type
-//=======================================
-#define REG_TYPE_CONTROL					0x00
-#define REG_TYPE_RAM						0x01
-#define REG_TYPE_SPECIAL_CONTROL			0x02
+#define CMD_HEADER_1                        0x5A
+#define CMD_HEADER_2                        0xA5
+#define CMD_REG_WRITE                       0x80
+#define CMD_REG_READ                        0x81
+#define CMD_REG_WRITE_DATA                  0x82
+#define CMD_REG_READ_DATA                   0x83
 
+#define REG_ADDRESS_READ_VERSION            0x0F
+#define REG_ADDRESS_READ_RTC                0x10
+#define REG_ADDRESS_READ_PAGE_ID            0x14
+#define REG_ADDRESS_READ_BRIGHTNESS         0x31
+#define REG_ADDRESS_WRITE_BRIGHTNESS        0X82
+#define REG_ADDRESS_SET_PAGE_ID             0x84
+#define REG_ADDRESS_SET_RTC                 0x9C
+#define REG_TYPE_CONTROL                    0x00
+#define REG_TYPE_RAM                        0x01
+#define REG_TYPE_SPECIAL_CONTROL            0x02
+
+#define _CHANGE_REMOTESTART     0x01
+#define _CHANGE_REFUNDING       0x02
+#define _CHANGE_REFUNDAMOUNT    0x03
+#define _CHANGE_NOREFUND        0x04
+#define _CHANGE_PREPAYMENTINFO  0x05
+#define _CHANGE_PAYMENT_OK      0x06
+#define _CHANGE_PAYMENT_FAIL    0x07
+
+#define _LeftGun_btn_flag       0x3000
+#define _RightGun_btn_flag      0x3002
 //#define NOODOE_QR_CODE_URL                    "https://ev-alpha-test.noodoe.com/station?id=" ////For Audi
-#define NOODOE_QR_CODE_URL                      "https://ev.noodoe.com/station?id=" ////For Audi
 
-//------------------------------------------------------------------------------
-enum _BATTERY_LEVEL_FOR_MAP {
-    _BATTERY_LEVEL_FOR_MAP_EMP = 0x00,
-    _BATTERY_LEVEL_FOR_MAP_LV1 = 0x01,
-    _BATTERY_LEVEL_FOR_MAP_LV2 = 0x02,
-    _BATTERY_LEVEL_FOR_MAP_LV3 = 0x03,
-    _BATTERY_LEVEL_FOR_MAP_LV4 = 0x04,
-    _BATTERY_LEVEL_FOR_MAP_LV5 = 0x05,
+#define _LeftGun_Title          0x1000
+#define _RightGun_Title         0x1002
+#define _LeftGun_Status         0x1004
+#define _LeftGun_Type           0x1006
+#define _RightGun_Status        0x1008
+#define _RightGun_Type          0x100A
+#define _CellPhone_Mode         0x100C
+#define _Screen_Mode            0x100E
+#define _PlugIn_String          0x1010
+#define _Communication_Status   0x1012
+#define _SaftyDetect_Status     0x1014
+#define _PreCharge_Status       0x1016
+#define _Text_Voltage           0x1018
+#define _Text_Current           0x101A
+#define _Text_Power             0x101C
+#define _Text_Rate              0x101E
+#define _Text_Time              0x1020
+#define _Battery_Progress_0     0x1022
+#define _Symbol_V               0x1024
+#define _Symbol_A               0x1026
+#define _Symbol_KW              0x1028
+#define _Symbol_Rate            0x102A
+#define _Symbol_Percent         0x102C
+#define _Text_ChargeRate        0x102E
+#define _Text_ChargePay         0x1030
+#define _Battery_Progress_1     0x1032
+#define _Text_ChargeComplete    0x1034
+#define _Symbol_Dollar          0x1074
+#define _QR_CODE_               0x1082
+#define _PreChargeTimer         0x2000
+#define _String_Voltage_        0x2010
+#define _String_Current_        0x2020
+#define _String_Power_          0x2030
+#define _String_Rate_           0x2040
+#define _String_ChargeTime_     0x2050
+#define _String_BatterySoc_     0x2060
+#define _String_Cost_           0x2070
+#define _String_SensingTime_    0x2080
+#define _String_RefunTime_      0x2090
+#define _String_SensingResultTime_ 0x20A0
+
+// Touch
+#define _Button_LeftGun_Select  0x3000
+#define _Button_RightGun_Select 0x3002
+#define _Button_Screen_Mode     0x3004
+#define _Button_Charge          0x3006
+#define _Button_Refund          0x3008
+#define _Button_Return          0x300A
+#define _Button_Member          0x300C
+#define _Button_Member_None     0x300E
+#define _Button_Return_Home     0x3010
+#define _Button_Donate          0x3012
+#define _Button_Donate_Select0  0x3014
+#define _Button_Donate_Select1  0x3016
+#define _Button_Donate_Select2  0x3018
+#define _Button_Donate_Select3  0x301A
+#define _Button_Donate_Confirm  0x301C
+#define _Button_Authorize       0x301E
+
+// ICON Map Address
+enum _LCM_TCC_INDEX {
+    _LCM_NONE                   = 0x00,
+    _LCM_INIT,
+    _LCM_AUTHORIZE_LEFT,
+    _LCM_PLUGIN_LEFT,
+    _LCM_PRECHARGE_LEFT,
+    _LCM_CHARGING_LEFT,
+    _LCM_COMPLETE_LEFT,
+    _LCM_FUNCTION_SELECT_LEFT,
+    _LCM_REFUND_SENSEING_LEFT,
+    _LCM_REFUNDING_LEFT,
+    _LCM_REFUND_COMPLETE_LEFT,
+    _LCM_REFUND_NONE_LEFT,
+    _LCM_MEMBER_SELECT_LEFT,
+    _LCM_MEMBER_QR_LFET,
+    _LCM_DONATE_LEFT,
+    _LCM_DONATE_SELECT_LEFT,
+    _LCM_PAY_SENSING_LEFT,
+    _LCM_PAY_ETICKET_SUCCESS_LEFT,
+    _LCM_PAY_MPAY_SUCCESS_LEFT,
+    _LCM_PAY_FAIL_LEFT,
+    _LCM_AUTHORIZE_RIGHT         = 32,
+    _LCM_PLUGIN_RIGHT,
+    _LCM_PRECHARGE_RIGHT,
+    _LCM_CHARGING_RIGHT,
+    _LCM_COMPLETE_RIGHT,
+    _LCM_FUNCTION_SELECT_RIGHT,
+    _LCM_REFUND_SENSEING_RIGHT,
+    _LCM_REFUNDING_RIGHT,
+    _LCM_REFUND_COMPLETE_RIGHT,
+    _LCM_REFUND_NONE_RIGHT,
+    _LCM_MEMBER_SELECT_RIGHT,
+    _LCM_MEMBER_QR_RIGHT,
+    _LCM_DONATE_RIGHT,
+    _LCM_DONATE_SELECT_RIGHT,
+    _LCM_PAY_SENSING_RIGHT,
+    _LCM_PAY_ETICKET_SUCCESS_RIGHT,
+    _LCM_PAY_MPAY_SUCCESS_RIGHT,
+    _LCM_PAY_FAIL_RIGHT,
+};
+
+enum _ICON_LIST_ {
+    _ICON_Empty = 0,
+    _ICON_LeftGunShow = 1,
+    _ICON_RightGunShow,
+    _ICON_LeftGun_off,
+    _ICON_LeftGun_on,
+    _ICON_LeftGun_off_CCS1,
+    _ICON_LeftGun_off_CCS2,
+    _ICON_LeftGun_off_CHAdeMo,
+    _ICON_LeftGun_on_CCCS1,
+    _ICON_LeftGun_on_CCS2,
+    _ICON_LeftGun_on_CHAdeMo,
+    _ICON_RightGun_off,
+    _ICON_RightGun_on,
+    _ICON_RightGun_off_CCS1,
+    _ICON_RightGun_off_CCS2,
+    _ICON_RightGun_off_CHAdeMo,
+    _ICON_RightGun_on_CCS1,
+    _ICON_RightGun_on_CCS2,
+    _ICON_RightGun_on_CHAdeMo,
+    _ICON_cellphone_mode,
+    _ICON_screen_mode,
+    _ICON_Plugin,
+    _ICON_Communication_off,
+    _ICON_Communication_on,
+    _ICON_SaftyDetect_off,
+    _ICON_SaftyDetect_on,
+    _ICON_PrepareCharge_off,
+    _ICON_PrepareCharge_on,
+    _ICON_text_Voltage,
+    _ICON_text_Current,
+    _ICON_text_Power,
+    _ICON_text_Rate,
+    _ICON_text_time,
+    _ICON_battery_0,
+    _ICON_battery_1,
+    _ICON_battery_2,
+    _ICON_battery_3,
+    _ICON_battery_4,
+    _ICON_symbol_V,
+    _ICON_symbol_A,
+    _ICON_symbol_KW,
+    _ICON_symbol_rate,
+    _ICON_symbol_percent,
+    _ICON_text_ChargereRate,
+    _ICON_text_ChargePay,
+    _ICON_text_battery_0,
+    _ICON_text_battery_1,
+    _ICON_text_battery_2,
+    _ICON_text_battery_3,
+    _ICON_text_battery_4,
+    _ICON_text_ChargeComplete,
+    _ICON_return_button,
+    _ICON_charge,
+    _ICON_refund,
+    _ICON_Scanning,
+    _ICON_Refunding,
+    _ICON_text_ChargeDate,
+    _ICON_text_HoldMoney,
+    _ICON_text_ChargeMoney,
+    _ICON_text_ReturnMoney,
+    _ICON_text_bar,
+    _ICON_text_RefundNone,
+    _ICON_member,
+    _ICON_non_member,
+    _ICON_scan_QR_code,
+    _ICON_text_UsingPhone,
+    _ICON_Button_return_to_main,
+    _ICON_Button_Donate,
+    _ICON_Text_DonateBill,
+    _ICON_Button_Confirm,
+    _ICON_NHOA_TCCSupport,
+    _ICON_text_Eticket,
+    _ICON_text_CreditCard,
+    _ICON_text_MPay,
+    _ICON_BarL,
+    _ICON_BarR,
+    _ICON_text_Scaing,
+    _ICON_text_DeducationSuccess,
+    _ICON_text_Store,
+    _ICON_ext_CardMoney,
+    _ICON_text_PayMoney,
+    _ICON_text_CardRefund,
+    _ICON_text_dollor,
+    _ICON_text_SensingSuccess,
+    _ICON_text_Sensing_Fail_Farm,
 };
 
+
+/* Show Version */
+
+#define _Version_Cabient_Name_Text          0x0500
+#define _Version_Cabient_BootLoader_Text    0x0510
+#define _Version_Cabient_Kernel_Text        0x0520
+#define _Version_Cabient_CSU_Text           0x0530
+#define _Version_Cabient_Priamry_Text       0x0540
+#define _Version_Cabient_Relay0_Text        0x0550
+#define _Version_Cabient_Relay1_Text        0x0560
+#define _Version_Cabient_Fan_Text           0x0570
+#define _Version_Cabient_IPAddr_Text        0x0580
+#define _Version_Cabient_PSU1_Text          0x0590
+#define _Version_Cabient_PSU2_Text          0x05A0
+#define _Version_Cabient_PSU3_Text          0x05B0
+#define _Version_Cabient_PSU4_Text          0x05C0
+#define _Version_Cabient_PSU5_Text          0x05D0
+#define _Version_Cabient_PSU6_Text          0x05E0
+#define _Version_Cabient_PSU7_Text          0x05F0
+#define _Version_Cabient_PSU8_Text          0x0600
+#define _Version_Cabient_PSU9_Text          0x0610
+#define _Version_Cabient_PSU10_Text         0x0620
+#define _Version_Cabient_PSU11_Text         0x0630
+#define _Version_Cabient_PSU12_Text         0x0640
+
+#define _Version_Cabient_Primary_Text       0x0920
+#define _Version_Cabient_Secondary_Text     0x0930
+
+#define _Version_Cabient_Model_value        0x0650
+#define _Version_Cabient_BootLoader_value   0x0660
+#define _Version_Cabient_Kernel_value       0x0670
+#define _Version_Cabient_CSU_value          0x0680
+#define _Version_Cabient_Priamry_value      0x0690
+#define _Version_Cabient_Relay0_value       0x06A0
+#define _Version_Cabient_Relay1_value       0x06B0
+#define _Version_Cabient_Fan_value          0x06C0
+#define _Version_Cabient_IPAddr_value       0x06D0
+#define _Version_Cabient_PSU_Prim1_value    0x06E0
+#define _Version_Cabient_PSU_Prim2_value    0x06F0
+#define _Version_Cabient_PSU_Prim3_value    0x0700
+#define _Version_Cabient_PSU_Prim4_value    0x0710
+#define _Version_Cabient_PSU_Prim5_value    0x0720
+#define _Version_Cabient_PSU_Prim6_value    0x0730
+#define _Version_Cabient_PSU_Sec1_value     0x0740
+#define _Version_Cabient_PSU_Sec2_value     0x0750
+#define _Version_Cabient_PSU_Sec3_value     0x0760
+#define _Version_Cabient_PSU_Sec4_value     0x0770
+#define _Version_Cabient_PSU_Sec5_value     0x0780
+#define _Version_Cabient_PSU_Sec6_value     0x0790
+
+#define _Version_Cabient_PSU_Prim7_value    0x09E0
+#define _Version_Cabient_PSU_Prim8_value    0x09F0
+#define _Version_Cabient_PSU_Prim9_value    0x1000
+#define _Version_Cabient_PSU_Prim10_value   0x1010
+#define _Version_Cabient_PSU_Prim11_value   0x1020
+#define _Version_Cabient_PSU_Prim12_value   0x1030
+#define _Version_Cabient_PSU_Sec7_value     0x1040
+#define _Version_Cabient_PSU_Sec8_value     0x1050
+#define _Version_Cabient_PSU_Sec9_value     0x1060
+#define _Version_Cabient_PSU_Sec10_value    0x1070
+#define _Version_Cabient_PSU_Sec11_value    0x1080
+#define _Version_Cabient_PSU_Sec12_value    0x1090
+
+#define _Version_Dispenser_Name_Text        0x07A0
+#define _Version_Dispenser_BootLoader_Text  0x07B0
+#define _Version_Dispenser_Kernel_Text      0x07C0
+#define _Version_Dispenser_CSU_Text         0x07D0
+#define _Version_Dispenser_Relay_Text       0x07E0
+#define _Version_Dispenser_Fan_Text         0x07F0
+#define _Version_Dispenser_Priamry_Text     0x0800
+#define _Version_Dispenser_LCM_Text         0x0810
+#define _Version_Dispenser_LED_Text         0x0820
+#define _Version_Dispenser_Connector0_Text  0x0830
+#define _Version_Dispenser_Connector1_Text  0x0840
+#define _Version_Dispenser_IPAddr_Text      0x0850
+
+#define _Version_Dispenser_Model_value      0x0860
+#define _Version_Dispenser_BootLoader_value 0x0870
+#define _Version_Dispenser_Kernel_value     0x0880
+#define _Version_Dispenser_CSU_value        0x0890
+#define _Version_Dispenser_Relay_value      0x08A0
+#define _Version_Dispenser_Fan_value        0x08B0
+#define _Version_Dispenser_Priamry_value    0x08C0
+#define _Version_Dispenser_LCM_value        0x08D0
+#define _Version_Dispenser_LED_value        0x08E0
+#define _Version_Dispenser_Connector0_value 0x08F0
+#define _Version_Dispenser_Connector1_value 0x0900
+#define _Version_Dispenser_IPAddr_value     0x0910
+
 #endif //MODULE_LCM_CTRL_H_

+ 0 - 34
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h.Ph

@@ -1,34 +0,0 @@
-#ifndef MODULE_LCM_CTRL_H_
-#define MODULE_LCM_CTRL_H_
-
-//------------------------------------------------------------------------------
-#define DEFAULT_AC_INDEX                        (2)
-
-#define TIME_MAX_SEC                            (2592000) // 一個月,秒數
-#define POWER_MAX_KW                            (5000)
-#define ENERGY_MAX_KWH                          (5000)
-
-#define CMD_TITLE_1                             (0x5A)
-#define CMD_TITLE_2                             (0xA5)
-#define CMD_READ                                (0x80)
-#define CMD_WRITE                               (0x81)
-#define CMD_MULTI_WRITE                         (0x82)
-#define CMD_MULTI_READ                          (0x83)
-
-#define CMD_BACKLIGHT                           (0x01)
-#define CMD_REGISTER                            (0x03)
-
-//#define NOODOE_QR_CODE_URL                    "https://ev-alpha-test.noodoe.com/station?id=" ////For Audi
-#define NOODOE_QR_CODE_URL                      "https://ev.noodoe.com/station?id=" ////For Audi
-
-//------------------------------------------------------------------------------
-enum _BATTERY_LEVEL_FOR_MAP {
-    _BATTERY_LEVEL_FOR_MAP_EMP = 0x00,
-    _BATTERY_LEVEL_FOR_MAP_LV1 = 0x01,
-    _BATTERY_LEVEL_FOR_MAP_LV2 = 0x02,
-    _BATTERY_LEVEL_FOR_MAP_LV3 = 0x03,
-    _BATTERY_LEVEL_FOR_MAP_LV4 = 0x04,
-    _BATTERY_LEVEL_FOR_MAP_LV5 = 0x05,
-};
-
-#endif //MODULE_LCM_CTRL_H_

+ 0 - 234
EVSE/Projects/DD360Tcci/Apps/ModuleLcmCtrl/Module_LcmControl.h.test

@@ -1,234 +0,0 @@
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
-#include    <sys/types.h>
-#include    <sys/stat.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/wireless.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
-
-#include 	<unistd.h>
-#include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include 	<stdbool.h>
-#include	"../Define/define.h"
-#include    "../Config.h"
-#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
-#define PASS				1
-#define FAIL				-1
-#define YES					1
-#define NO					0
-#define EQUAL				0
-
-typedef unsigned char 			byte;
-
-struct SysConfigAndInfo			*ShmSysConfigAndInfo;
-struct StatusCodeData 			*ShmStatusCodeData;
-struct FanModuleData			*ShmFanModuleData;
-struct DcCommonInformation		*ShmDcCommonData;
-
-#define NO_DEFINE			255
-#define DEFAULT_AC_INDEX	2
-
-#define TIME_MAX_SEC		2592000 // 一個月,秒數
-#define POWER_MAX_KW		5000
-#define ENERGY_MAX_KWH		5000
-
-#define CMD_TITLE_1				0x5A
-#define CMD_TITLE_2				0xA5
-#define CMD_READ				0x80
-#define CMD_WRITE				0x81
-#define CMD_MULTI_WRITE			0x82
-#define CMD_MULTI_READ			0x83
-
-#define CMD_BACKLIGHT			0x01
-#define CMD_REGISTER			0x03
-
-//=======================================
-// Register Control type
-//=======================================
-#define REG_TYPE_CONTROL					0x00
-#define REG_TYPE_RAM						0x01
-#define REG_TYPE_SPECIAL_CONTROL			0x02
-
-enum _BATTERY_LEVEL_FOR_MAP
-{
-	_BATTERY_LEVEL_FOR_MAP_EMP = 0x00,
-	_BATTERY_LEVEL_FOR_MAP_LV1 = 0x01,
-	_BATTERY_LEVEL_FOR_MAP_LV2 = 0x02,
-	_BATTERY_LEVEL_FOR_MAP_LV3 = 0x03,
-	_BATTERY_LEVEL_FOR_MAP_LV4 = 0x04,
-	_BATTERY_LEVEL_FOR_MAP_LV5 = 0x05,
-};
-
-int Uart1Fd;
-//char* pPortName = "/dev/ttyO2";
-char* pPortName = "/dev/ttyS3";
-char* moduleName = "DMT80480T070_09WT";
-byte _totalCount;
-byte acgunCount;
-struct ChargingInfoData *_chargingInfoData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
-
-byte ac_ani_battery_level = _BATTERY_LEVEL_FOR_MAP_LV5;
-byte isDiffStatus = false;
-byte isChangeBattMap = false;
-// 當前選擇的槍號
-short _currentPage = _LCM_NONE;
-short _oldPage = _LCM_NONE;
-byte _gunIndex = 0;
-bool _battery_display_ani = false;
-byte _curPage_index = 0;
-bool _page_reload = false;
-byte QRCodeBuf[128];
-
-// LCM - HW
-byte _everyPageRollChange = 0;
-short __logo = 0x1000;
-short __conn_status = 0x1030;
-short __ethernet_status = 0x1032;
-short __3G4G_status = 0x1036;
-short __3G4G_move_status = 0x1038;
-short __wifi_status = 0x103C;
-
-short __sel_gun_btn = 0x1040;
-short __ret_home_btn = 0x1042;
-short __stop_method_btn = 0x1044;
-short __phihong_string = 0x1046;
-
-short __lcm_version = 0x104A;
-
-short __qr_code = 0x1250;
-short __main_rfid = 0x1052;
-short __main_qr = 0x1054;
-short __main_app = 0x1056;
-
-short __plug_in_arrow = 0x1060;
-
-short __conn_line = 0x1066;
-
-short __gun_type_index = 0x1070;
-short __cmp_gun_type_index = 0x1080;
-short __qr_code_pre = 0x1280;
-
-short __batt_map_empty = 0x1090;
-
-short __conn_line_chag = 0x1096;
-short __batt_map = 0x1100;
-short __soc_value_charging = 0x1102;
-short __remain_time_map = 0x1106;
-short __power_map = 0x1108;
-short __energy_map = 0x110A;
-short __remain_time_tx = 0x1110;
-
-short __trp_remain_time_map = 0x1116;
-short __trp_power_map = 0x1118;
-short __trp_energy_map = 0x111A;
-
-short __output_eng_tx = 0x1120;
-short __total_out_eng_tx = 0x1130;
-short __conn_line_comp = 0x1140;
-short __charging_fee_map = 0x1146;
-short __logo_cmp = 0x114A;
-short __charging_fee_tx = 0x1150;
-
-short __money_by_rate = 0x1200;
-short __money_rate = 0x1220;
-short __money_rate_map = 0x1230;
-
-short __csu_ver_string = 0x1300;
-short __csu_ver_value = 0x1310;
-short __fan_speed_string = 0x1390;
-short __fan_speed_value = 0x1400;
-
-short __dc1_ver_string = 0x1320;
-short __dc1_ver_value = 0x1330;
-short __dc2_ver_string = 0x1340;
-short __dc2_ver_value = 0x1350;
-short __eth0_ip_string = 0x1360;
-short __eth0_ip_value = 0x1370;
-short __sn_string = 0x1410;
-short __sn_value = 0x1420;
-
-// ICON ID
-byte _disappear = 0;
-byte _disconnect = 1;
-byte _connect = 2;
-byte _warning = 3;
-byte _arrow_dark = 4;
-byte _arrow_light = 5;
-byte _3G4G_disconnect = 6;
-byte _3G4G_connect = 7;
-byte _wifi_disconnect = 8;
-byte _wifi_connect = 9;
-byte _logo = 10;
-byte _conn_map1 = 11;
-byte _conn_map2 = 12;
-byte _sel_gun_btn = 13;
-byte _back_home_btn = 14;
-byte _stop_charging_btn = 15;
-byte _stop_charging_btn_scan = 16;
-byte _chademo_dark = 17;
-byte _ccs_dark = 18;
-byte _gbt_dark = 19;
-byte _actype_dark = 20;
-byte _chademo_light = 21;
-byte _ccs_light = 22;
-byte _gbt_light = 23;
-byte _actype_light = 24;
-byte _main_none_rfid = 25;
-byte _main_rfid = 26;
-byte _main_none_app = 27;
-byte _main_app = 28;
-byte _main_none_qr = 29;
-byte _main_qr = 30;
-byte _charging_map1 = 31;
-byte _charging_map2 = 32;
-byte _battery_empty = 33;
-byte _battery_cap_20 = 34;
-byte _battery_cap_40 = 35;
-byte _battery_cap_60 = 36;
-byte _battery_cap_80 = 37;
-byte _battery_cap_100 = 38;
-byte _battery_map = 39;
-byte _power_map = 40;
-byte _time_map = 41;
-byte _complete_map = 42;
-byte _battery_soc_20 = 43;
-byte _battery_soc_40 = 44;
-byte _battery_soc_60 = 45;
-byte _battery_soc_80 = 46;
-byte _battery_soc_100 = 47;
-byte _battery_eng_map = 48;
-byte _money_map = 49;
-byte _elapse_time_map = 50;
-byte _charging_money = 51;
-byte _ethernet_disconnect = 52;
-byte _ethernet_connect = 53;
-byte _chademo_dark_cmp = 54;
-byte _ccs_dark_cmp = 55;
-byte _gbt_dark_cmp = 56;
-byte _actype_dark_cmp = 57;
-byte _chademo_light_cmp = 58;
-byte _ccs_light_cmp = 59;
-byte _gbt_light_cmp = 60;
-byte _actype_light_cmp = 61;
-byte _logo_cmp = 62;
-byte _battery_eng_trp_map = 63;
-byte _money_trp_map = 64;
-byte _elapse_time_trp_map = 65;
-byte _phihong_string_map = 66;

+ 18 - 217
EVSE/Projects/DD360Tcci/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -53,108 +53,6 @@ uint8_t Door_count = 0;
 uint8_t EmgBtn_flag = 0;
 uint8_t Door_flag = 0;
 
-//struct ChargingInfoData *ChargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
-
-//------------------------------------------------------------------------------
-/*int StoreLogMsg(const char *fmt, ...)
-{
-    char Buf[4096 + 256];
-    char buffer[4096];
-    va_list args;
-    struct timeb  SeqEndTime;
-    struct tm *tm;
-
-    va_start(args, fmt);
-    int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-    va_end(args);
-
-    memset(Buf, 0, sizeof(Buf));
-    ftime(&SeqEndTime);
-    SeqEndTime.time = time(NULL);
-    tm = localtime(&SeqEndTime.time);
-
-    if (pSysConfig->SwitchDebugFlag == YES) {
-        sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
-                tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
-        printf("%s ", Buf);
-    } else {
-        sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-                tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
-                buffer,
-                tm->tm_year + 1900, tm->tm_mon + 1);
-        system(Buf);
-    }
-
-    return rc;
-}
-*/
-
-#if 0 //non use
-int DiffTimeb(struct timeb ST, struct timeb ET)
-{
-    //return milli-second
-    unsigned int StartTime, StopTime;
-
-    StartTime = (unsigned int)ST.time;
-    StopTime = (unsigned int)ET.time;
-    return (StopTime - StartTime) * 1000 + ET.millitm - ST.millitm;
-}
-
-//=================================
-// Common routine
-//=================================
-char *getTimeString(void)
-{
-    char *result = malloc(21);
-    time_t timep;
-    struct tm *p;
-    time(&timep);
-    p = gmtime(&timep);
-
-    sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]",
-            (1900 + p->tm_year),
-            (1 + p->tm_mon),
-            p->tm_mday,
-            p->tm_hour,
-            p->tm_hour,
-            p->tm_sec);
-
-    return result;
-}
-#endif //0
-
-//==========================================
-// Init all share memory
-//==========================================
-/*int InitShareMemory()
-{
-    int result = PASS;
-    int MeterSMId;
-
-    //creat ShmSysConfigAndInfo
-    if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0) {
-        result = FAIL;
-    } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        result = FAIL;
-    }
-
-    //creat ShmStatusCodeData
-    if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0) {
-        result = FAIL;
-    } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        result = FAIL;
-    }
-
-    //creat ShmStatusCodeData
-    if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0) {
-        result = FAIL;
-    } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        result = FAIL;
-    }
-
-    return result;
-}
-*/
 
 //================================================
 // Function
@@ -185,9 +83,7 @@ void GetInputGpioStatus(int fd)
     }
 
     ShmPrimaryMcuData->InputDet.bits.SpdDetec = gpio_in.SPD;
-#ifdef DD360ComBox
-    EmgBtn_flag = 0;
-#else
+
     if (gpio_in.Emergency_Btn && (EmgBtn_flag != gpio_in.Emergency_Btn))
     {
             EmgBtn_count++;
@@ -202,7 +98,7 @@ void GetInputGpioStatus(int fd)
             EmgBtn_count = 0;
         }
     }
-#endif
+
     ShmPrimaryMcuData->InputDet.bits.EmergencyButton = EmgBtn_flag;
 
     dispenserSwTmp |= (ShmPrimaryMcuData->InputDet.bits.Key0);
@@ -223,7 +119,7 @@ void GetInputGpioStatus(int fd)
     ShmPrimaryMcuData->InputDet.bits.Button1 = gpio_in.Button[0];
     ShmPrimaryMcuData->InputDet.bits.Button2 = gpio_in.Button[1];
 
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+
     if ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
             (strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
             (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0) ||
@@ -236,16 +132,13 @@ void GetInputGpioStatus(int fd)
         pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault = gpio_in.AC_MainBreaker;
     }
 
-#if defined DD360ComBox
-    Door_flag = 0;
-#else
     if (Door_flag == gpio_in.Door_Open) {
         Door_count++;
         if (Door_count == 3 ) {
             Door_count = 0;
             Door_flag = gpio_in.Door_Open;
         }
-    } else { 
+    } else {
         Door_flag = gpio_in.Door_Open;
         Door_count = 0;
     }
@@ -265,12 +158,10 @@ void GetInputGpioStatus(int fd)
         }
     }
     */
-#endif 
-#if defined DD360ComBox
-    ShmPrimaryMcuData->InputDet.bits.DoorOpen = Door_flag;
-#else
+
+
     ShmPrimaryMcuData->InputDet.bits.DoorOpen = ~Door_flag;
-#endif
+
 
 /*
     log_info("Emergency Button Count = %d , Emergency flag = %d",
@@ -285,56 +176,8 @@ void GetInputGpioStatus(int fd)
     ShmPrimaryMcuData->InputDet.bits.Key3 = ~gpio_in.Key[3] & 0x01;
 
     return;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
-
-    static uint8_t _curDeviceStatus[3] = {0};
-    static uint8_t _reCheckCount[3] = {0};
-
-    //DS60-120 add
-    if (_curDeviceStatus[_PRIMARY_CHECK_TAG_AC_CONTACT] != gpio_in.AC_Connector) {
-        if (_reCheckCount[_PRIMARY_CHECK_TAG_AC_CONTACT] >= 3) {
-            _curDeviceStatus[_PRIMARY_CHECK_TAG_AC_CONTACT] = gpio_in.AC_Connector;
-            pSysInfo->AcContactorStatus =
-                ShmPrimaryMcuData->InputDet.bits.AcContactorDetec =
-                    gpio_in.AC_Connector;
-        } else {
-            _reCheckCount[_PRIMARY_CHECK_TAG_AC_CONTACT]++;
-        }
-    } else {
-        _reCheckCount[_PRIMARY_CHECK_TAG_AC_CONTACT] = 0;
-    }
 
-    if (_curDeviceStatus[_PRIMARY_CHECK_TAG_MAIN_BREAKER] != gpio_in.AC_MainBreaker) {
-        if (_reCheckCount[_PRIMARY_CHECK_TAG_MAIN_BREAKER] >= 3) {
-            _curDeviceStatus[_PRIMARY_CHECK_TAG_MAIN_BREAKER] = gpio_in.AC_MainBreaker;
-            ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec = gpio_in.AC_MainBreaker;
-        } else {
-            _reCheckCount[_PRIMARY_CHECK_TAG_MAIN_BREAKER]++;
-        }
-    } else {
-        _reCheckCount[_PRIMARY_CHECK_TAG_MAIN_BREAKER] = 0;
-    }
-    //pSysInfo->AcContactorStatus = ShmPrimaryMcuData->InputDet.bits.AcContactorDetec = gpio_in.AC_Connector;
-    //ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec = gpio_in.AC_MainBreaker;
-
-    ShmPrimaryMcuData->InputDet.bits.Key0 = gpio_in.Key[0] & 0x01;
-    ShmPrimaryMcuData->InputDet.bits.Key1 = gpio_in.Key[1] & 0x01;
-    ShmPrimaryMcuData->InputDet.bits.Key2 = gpio_in.Key[2] & 0x01;
-    ShmPrimaryMcuData->InputDet.bits.Key3 = gpio_in.Key[3] & 0x01;
-    ShmPrimaryMcuData->InputDet.bits.DoorOpen = gpio_in.Door_Open;
-
-    /*printf(" gpio_in.Key[0]~ gpio_in.Key[3]=%d, %d, %d, %d",
-    ShmPrimaryMcuData->InputDet.bits.Key0 , ShmPrimaryMcuData->InputDet.bits.Key1,
-    ShmPrimaryMcuData->InputDet.bits.Key2,ShmPrimaryMcuData->InputDet.bits.Key3);
-    printf("pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning=%d", pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning);
-    printf("pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault=%d", pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault);
-    */
-    //log_info("left = %d ", ShmPrimaryMcuData->InputDet.bits.Button1);
-    //log_info("right = %d ", ShmPrimaryMcuData->InputDet.bits.Button2);
-    //log_info("pSysInfo->AcContactorStatus = %d ", pSysInfo->AcContactorStatus);
-    if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == YES) {
-        log_error("AC Mainbreaker occur. ");
-    }
+
 }
 
 static void checkChillerStatus(Gpio_out *gpio)
@@ -365,7 +208,7 @@ static void checkChillerStatus(Gpio_out *gpio)
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
         pChillerInfo = (ChillerInfo *)&fChillerInfo[gunIndex];
 
-        if((pDcChargingInfo->SystemStatus > S_IDLE && pDcChargingInfo->SystemStatus < S_TERMINATING) ||
+        if((pDcChargingInfo->SystemStatus > S_AUTHORIZING && pDcChargingInfo->SystemStatus < S_TERMINATING) ||
             (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 && pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1))
         {
             pChillerInfo->ChillerSwitch = YES;
@@ -386,7 +229,7 @@ static void checkChillerStatus(Gpio_out *gpio)
                 pChillerInfo->ChillerSwitch = NO;
             }
         }
-#if 0
+/*
         if ((pDcChargingInfo->PresentChargingCurrent) >= 150) { //當前電壓於150A,打開水冷機
             pChillerInfo->ChillerSwitch = YES;
             pChillerInfo->ChillerOnTime = time((time_t *)NULL);
@@ -406,7 +249,7 @@ static void checkChillerStatus(Gpio_out *gpio)
                 pChillerInfo->ChillerSwitch = NO;
             }
         }
-#endif
+*/
     }
 
     uint8_t _chillerNeedOn = NO;
@@ -522,9 +365,7 @@ int InitComPort()
 
     fd = open(priPortName, O_RDWR);
     if (fd <= 0) {
-#ifdef SystemLogMessage
         log_error("open 407 Communication port NG ");
-#endif
         return -1;
     }
     ioctl (fd, TCGETS, &tios);
@@ -549,48 +390,6 @@ unsigned long GetTimeoutValue(struct timeval _sour_time)
     return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
 }
 
-//int FindChargingInfoData(uint8_t target, struct ChargingInfoData **chargingData)
-//{
-//    for (uint8_t index = 0; index < CHAdeMO_QUANTITY; index++) {
-//        if (pSysInfo->ChademoChargingData[index].Index == target) {
-//            chargingData[target] = &pSysInfo->ChademoChargingData[index];
-//            return 1;
-//        }
-//    }
-//
-//    for (uint8_t index = 0; index < CCS_QUANTITY; index++) {
-//        if (pSysInfo->CcsChargingData[index].Index == target) {
-//            chargingData[target] = &pSysInfo->CcsChargingData[index];
-//            return 1;
-//        }
-//    }
-//
-//    for (uint8_t index = 0; index < GB_QUANTITY; index++) {
-//        if (pSysInfo->GbChargingData[index].Index == target) {
-//            chargingData[target] = &pSysInfo->GbChargingData[index];
-//            return 1;
-//        }
-//    }
-//
-//    return 0;
-//}
-
-//void Initialization() //DS60-120 add
-//{
-//    bool isPass = false;
-//    while (!isPass) {
-//        isPass = true;
-//        for (uint8_t _index = 0; _index < gun_count; _index++) {
-//            if (!FindChargingInfoData(_index, &ChargingData[0])) {
-//                log_error("EvComm (main) : FindChargingInfoData false ");
-//                isPass = false;
-//                break;
-//            }
-//        }
-//        sleep(1);
-//    }
-//}
-
 static bool IsPrimaryProcessNeedPause(void)
 {
     bool _pause = false;
@@ -664,6 +463,12 @@ int main(void)
     for (;;) {
         // 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
         // 模組更新 FW 後,需重新做
+        if(IsPrimaryProcessNeedPause() == true)
+        {
+            sleep(1);
+            continue;
+        }
+
         if (ShmPrimaryMcuData->SelfTest_Comp != PASS) {
             //log_info("(407) Get Fw and Hw Ver. ");
             GetFwAndHwVersion(Uart1Fd);
@@ -674,11 +479,7 @@ int main(void)
 
             GetInputGpioStatus(Uart1Fd);
         }
-        if(IsPrimaryProcessNeedPause() == true)
-        {
-            sleep(1);
-            continue;
-        }
+
 
         usleep(50000);
     }

+ 16 - 12
EVSE/Projects/DD360Tcci/Apps/ModuleUpdateFW/Module_UpdateFW.c

@@ -22,11 +22,11 @@ static struct ChargingInfoData *pDcChargingInfo = NULL;
 DcCommonInfo *ShmDcCommonData = NULL; 
 #define MODELNAME_FAIL                          (0)
 #define UPGRADE_FAN                             (0x02)
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
-#define UPGRADE_RB                              (0x09) //0x09 for DD360 dispenser
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox
+#define UPGRADE_RB                              (0x09) //0x09 for DD360Tcci dispenser
 #else
 #define UPGRADE_RB                              (0x03) //other module use
-#endif //defined DD360 ||defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci ||defined DD360Audi || defined DD360ComBox
 #define UPGRADE_PRI                             (0x04)
 #define UPGRADE_AC                              (0x05)
 #define UPGRADE_LED                             (0x06)
@@ -39,7 +39,7 @@ static char *_485PortName = "/dev/ttyS5";
 
 void KillAllTask(void)
 {
-    pSysInfo->PageIndex = _LCM_FIX;
+    pSysInfo->PageIndex = _PAGE_MAINTAIN;
 
     system("killall Module_EventLogging");
     system("killall Module_PrimaryComm");
@@ -47,10 +47,10 @@ void KillAllTask(void)
     system("killall Module_LcmControl");
     system("killall Module_InternalComm");
 
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox
     system("killall Module_DoComm");
     return ;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
 
     system("killall Module_PsuComm");
     system("killall OcppBackend &");
@@ -60,7 +60,7 @@ void KillAllTask(void)
 
 void KillTask(void)
 {
-    pSysInfo->PageIndex = _LCM_FIX;
+    pSysInfo->PageIndex = _PAGE_MAINTAIN;
 
     system("killall Module_EventLogging");
     system("killall Module_PrimaryComm");
@@ -68,9 +68,9 @@ void KillTask(void)
     system("killall Module_LcmControl");
     system("killall Module_InternalComm");
     //system("killall Module_DoComm");
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox
     return ;
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
 
     system("killall Module_PsuComm");
     system("killall OcppBackend &");
@@ -248,6 +248,7 @@ static int CheckUpdateProcess(void)
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     d = opendir("/mnt/");
     if (d) {
+        log_info("Open /mnt success");
         while ((dir = readdir(d)) != NULL) {
             if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0) {
                 continue;
@@ -271,6 +272,7 @@ static int CheckUpdateProcess(void)
             ImageLen = read(fd, ptr, MaxLen);
             for (uint8_t i = 0; i < 16; i++) {
                 if (pSysConfig->ModelName[i] != ptr[i]) {
+                    log_info("model name check fail. ");
                     return FAIL;
                 }
             }
@@ -449,6 +451,8 @@ static int CheckUpdateProcess(void)
                             retSucc++;
                         } else
                             retFail++;
+                    } else {
+                        log_info("CreateBufferForLcmFile fail");
                     }
                     break;
                 }
@@ -473,7 +477,7 @@ void CheckFwUpdateFunction(void)
     if (pSysInfo->FirmwareUpdate == YES) {
         log_info("ftp : update start. ");
         TryCloseWatchdog();
-        pSysInfo->SystemPage = _LCM_FIX;
+        pSysInfo->SystemPage = _PAGE_MAINTAIN;
         for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
             setChargerMode(gun_index, MODE_UPDATE);
         }
@@ -495,7 +499,7 @@ void CheckFwUpdateFunction(void)
 
         pSysInfo->FirmwareUpdate = NO;
         sleep(5);
-        system("reboot -f");
+        //system("reboot -f");
     } else if (ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq == YES) {
         ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = NO;
 
@@ -562,7 +566,7 @@ int main(int argc, char *argv[])
     ShmDcCommonData->_upgrade_lcm_result = _LCM_UPGRADE_RESULT_WAIT;
 
     while (1) {
-        if (IsConnectorWholeIdle() || (pSysInfo->PageIndex == _LCM_FIX) )
+        //if (IsConnectorWholeIdle() || (pSysInfo->PageIndex == _PAGE_MAINTAIN) )
             CheckFwUpdateFunction();
         sleep(3);
     } //while

+ 1427 - 1468
EVSE/Projects/DD360Tcci/Apps/ReadCmdline.c

@@ -1,1468 +1,1427 @@
-/*
- * Main.c
- *
- *  Created on: 2019年8月6日
- *      Author: 7564
- */
-
-
-#include <sys/time.h>
-#include <sys/timeb.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/shm.h>
-#include <sys/mman.h>
-#include <linux/wireless.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-
-#include <unistd.h>
-#include <stdarg.h>
-#include <stdio.h>      /*標準輸入輸出定義*/
-#include <stdlib.h>     /*標準函數庫定義*/
-#include <stdint.h>
-#include <unistd.h>     /*Unix 標準函數定義*/
-#include <fcntl.h>      /*檔控制定義*/
-#include <termios.h>    /*PPSIX 終端控制定義*/
-#include <errno.h>      /*錯誤號定義*/
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <ctype.h>
-#include <ifaddrs.h>
-#include <math.h>
-#include <stdbool.h>
-
-#include "./ShareMemory/shmMem.h"
-#include "./Define/define.h"
-#include "./SelectGun/SelectGun.h"
-#include "Config.h"
-
-//------------------------------------------------------------------------------
-#define CMD_KEY_WAIT                                (1)
-#define CMD_KEY_DONT_WAIT                           (0)
-
-#define DEFAULT_AC_INDEX                            (2)
-
-#define AUTORUN_STEP1_TIME_START                    (140)             // Minutes
-#define AUTORUN_STEP1_TIME_END                      (150)
-#define AUTORUN_STEP2_TIME_START                    (210)
-#define AUTORUN_STEP2_TIME_END                      (410)
-#define AUTORUN_END_TIME                            (480)
-#define AUTORUN_CYCLE_COUNT                         (30)
-
-#define TTY_PATH                                    "/dev/tty"
-#define STTY_US                                     "stty raw -echo -F "
-#define STTY_DEF                                    "stty -raw echo -F "
-
-//------------------------------------------------------------------------------
-uint8_t _curAutoRunCount = 0;
-uint8_t _usingAutoRun = 0;
-struct timeval _autoTime;
-
-static struct SysConfigData *pSysConfig = NULL;
-static struct SysInfoData *pSysInfo = NULL;
-static struct WARNING_CODE_INFO *pSysWarning = NULL;
-
-static struct AlarmCodeData *pAlarmCode = NULL;
-
-static struct PrimaryMcuData *ShmPrimaryMcuData = NULL;
-static struct CHAdeMOData *ShmCHAdeMOData = NULL;
-static struct CcsData *ShmCcsData = NULL;
-static struct GBTData *ShmGBTData = NULL;
-static struct FanModuleData *ShmFanModuleData = NULL;
-static struct RelayModuleData *ShmRelayModuleData = NULL;
-static struct LedModuleData *ShmLedModuleData = NULL;
-static struct PsuData *ShmPsuData = NULL;
-static struct OCPP16Data *ShmOCPP16Data = NULL;
-static SelectGunInfo *ShmSelectGunInfo = NULL;
-static DcCommonInfo *ShmDcCommonData = NULL;
-
-static struct ChargingInfoData *pDcChargingInfo = NULL;
-static struct ChargingInfoData *pAcChargingInfo = NULL;
-
-static char newString[8][16] = {0};
-
-//------------------------------------------------------------------------------
-static int DiffTimeb(struct timeb ST, struct timeb ET)
-{
-    //return milli-second
-    unsigned int StartTime, StopTime;
-
-    StartTime = (unsigned int)ST.time;
-    StopTime = (unsigned int)ET.time;
-
-    return (StopTime - StartTime) * 1000 + ET.millitm - ST.millitm;
-}
-
-static void get_char(char *word)
-{
-    fd_set rfds;
-    struct timeval tv;
-
-    FD_ZERO(&rfds);
-    FD_SET(0, &rfds);
-    tv.tv_sec = 0;
-    tv.tv_usec = 10; //wait input timout time
-
-    //if input
-    if (select(1, &rfds, NULL, NULL, &tv) > 0) {
-        fgets(word, 128, stdin);
-    }
-}
-
-static uint8_t helpCmd(void)
-{
-    if (strcmp(newString[0], "?") == 0 ||
-            strcmp(newString[0], "help") == 0 ||
-            strcmp(newString[0], "h") == 0) {
-        return YES;
-    }
-
-    return NO;
-}
-
-static uint8_t exitCmd(void)
-{
-    if (strcmp(newString[0], "c") == EQUAL ||
-            strcmp(newString[0], "C") == EQUAL ||
-            strncmp(&newString[0][0], "exit", 4) == EQUAL
-       ) {
-        return YES;
-    }
-
-    return NO;
-}
-
-static uint8_t readCmdKey(uint8_t state)
-{
-    char word[128] = {0};
-    int i = 0, j = 0, ctr = 0;
-
-    memset(word, 0, sizeof(word));
-    if (state == CMD_KEY_WAIT) {
-        fgets(word, sizeof(word), stdin);
-    } else if (state == CMD_KEY_DONT_WAIT) {
-        get_char(word);
-
-        if (strlen(word) == 0) {
-            //usleep(50000);
-            return NO;
-        }
-    }
-
-    memset(newString, 0, sizeof(newString));
-
-    strcpy(newString[1], "-1");
-    strcpy(newString[2], "-1");
-    for (i = 0; i <= (strlen(word)); i++) {
-        if (word[i] == ' ' ||
-                word[i] == '\0' ||
-                word[i] == '\r' ||
-                word[i] == '\n' ||
-                word[i] == 10) {
-            newString[ctr][j] = '\0';
-            ctr++;
-            j = 0;
-        } else {
-            newString[ctr][j] = word[i];
-            j++;
-        }
-    }
-
-    return YES;
-}
-
-unsigned long GetTimeoutValue(struct timeval _sour_time)
-{
-    struct timeval _end_time;
-    gettimeofday(&_end_time, NULL);
-
-    return (_end_time.tv_sec - _sour_time.tv_sec);
-}
-
-void RunStatusProc(char *v1, char *v2)
-{
-    printf("OrderCharging = %d \n", pSysInfo->OrderCharging);
-    printf("WaitForPlugit = %d \n", pSysInfo->WaitForPlugit);
-    if (strcmp(v1, "ac") == 0) {
-        pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
-        //if (!FindAcChargingInfoData(0, &ac_chargingInfo[0])) {
-        //    printf("FindChargingInfoData (AC) false \n");
-        //}
-        printf("AC Status = %d \n", pAcChargingInfo->ConnectorPlugIn);
-        return;
-    }
-
-    int _index = atoi(v1);
-
-    if (_index <= 1) {
-        //if (!FindChargingInfoData(_index, &_chargingData[0])) {
-        //    printf ("FindChargingInfoData error\n");
-        //    return;
-        //}
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
-
-        if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0) {
-            // get
-            printf ("index = %x, status = %x (%d)\n",
-                    _index,
-                    pDcChargingInfo->SystemStatus,
-                    pDcChargingInfo->IsAvailable);
-            printf ("SystemTimeoutFlag = %d, PageIndex = %d\n",
-                    pSysInfo->SystemTimeoutFlag, pSysInfo->PageIndex);
-        } else {
-            // set
-            pDcChargingInfo->SystemStatus = atoi(v2);
-        }
-    } else {
-        //if (!FindAcChargingInfoData(0, &ac_chargingInfo[0])) {
-        //    printf("FindChargingInfoData (AC) false \n");
-        //}
-        pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
-
-        if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0) {
-            // get
-            printf ("AC Type, status = %x (%d)\n",
-                    pAcChargingInfo->SystemStatus,
-                    pAcChargingInfo->IsAvailable);
-        } else {
-            // set
-            pAcChargingInfo->SystemStatus = atoi(v2);
-        }
-    }
-}
-
-void RunCardProc(char *v1, char *v2)
-{
-    if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0) {
-        if (pSysInfo->WaitForPlugit) {
-            pSysInfo->WaitForPlugit = 0x00;
-            printf ("SysInfo.WaitForPlugit = %x \n", pSysInfo->WaitForPlugit);
-        } else {
-            pSysInfo->WaitForPlugit = 0x01;
-            printf ("SysInfo.WaitForPlugit = %x \n", pSysInfo->WaitForPlugit);
-        }
-    } else {
-        strcpy((char *)pSysConfig->UserId, "");
-        memcpy((char *)pSysConfig->UserId, v1, strlen(v1));
-        pSysConfig->UserId[strlen(v1)] = '\0';
-        printf("StartUserId = %s \n", pSysConfig->UserId);
-    }
-}
-
-void RunGunPlugitProc(char *v1, char *v2)
-{
-    if (strcmp(v1, "ac") == 0) {
-        //if (!FindAcChargingInfoData(0, &ac_chargingInfo[0])) {
-        //    printf("FindChargingInfoData (AC) false \n");
-        //}
-        pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
-
-        if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0) {
-            // get
-            printf("ConnectorPlugIn = %d \n", pAcChargingInfo->ConnectorPlugIn);
-        } else {
-            // set
-            pAcChargingInfo->ConnectorPlugIn = atoi(v2);
-        }
-        return;
-    }
-
-    int _index = atoi(v1);
-    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
-    //    printf("FindChargingInfoData error\n");
-    //    return;
-    //}
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
-
-    if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0) {
-        // get
-        printf("index = %x, plug it = %x\n",
-               _index,
-               pDcChargingInfo->ConnectorPlugIn);
-    } else {
-        // set
-        pDcChargingInfo->ConnectorPlugIn = atoi(v2);
-    }
-}
-
-void GetGunLockStatusProc(char *v1, char *v2)
-{
-    int _index = atoi(v1);
-    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
-    //    printf("FindChargingInfoData error\n");
-    //    return;
-    //}
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
-
-    if (strcmp(v2, "-1") != 0 && strcmp(v2, "") != 0) {
-        pDcChargingInfo->GunLocked = atoi(v2);
-    }
-
-    printf("Gun Locked Status = %d \n", pDcChargingInfo->GunLocked);
-}
-
-void SetSystemIDProc()
-{
-    char *systemId = "Alston_Test";
-    memcpy(&pSysConfig->SystemId, systemId, strlen(systemId));
-}
-
-void RunSelfProc()
-{
-    printf("self test status = %x\n", pSysInfo->SelfTestSeq);
-}
-
-void GetFwVerProc(void)
-{
-    int _index = 0;
-    int isContinue = 1;
-    char *usageMsg = "Usage:\n"
-                     "      model\n"
-                     "      407\n"
-                     "      conn index, ex: conn 0 | 1\n"
-                     "      relay\n"
-                     "      fan\n"
-                     "      dc\n"
-                     "      led\n"
-                     "      ac\n"
-                     "      exit | c | C\n"
-                     "      help | ? | h\n";
-
-    while (isContinue) {
-        if (readCmdKey(CMD_KEY_WAIT) == NO) {
-            continue;
-        }
-
-        if (strcmp(newString[0], "407") == 0) {
-            printf("407 FW Version = %s\n", ShmPrimaryMcuData->version);
-        } else if (strcmp(newString[0], "model") == 0) {
-            printf("ModelName = %s\r\n", pSysConfig->ModelName);
-        } else if (strcmp(newString[0], "conn") == 0) {
-            if (strcmp(newString[1], "-1") == 0  ||
-                    strcmp(newString[1], "") == 0 ||
-                    atoi(newString[1]) >= pSysConfig->TotalConnectorCount
-               ) {
-                printf("index over flow\r\n");
-                continue;
-            }
-
-            _index = atoi(newString[1]);
-
-            if (_index == 0) {
-                printf("Gun 0 FW Version = %s \n", pSysInfo->Connector1FwRev);
-            } else if (_index == 1) {
-                printf("Gun 1 FW Version = %s \n", pSysInfo->Connector2FwRev);
-            }
-        } else if (strcmp(newString[0], "relay") == 0) {
-            printf("RB Version = %s \n", pSysInfo->RelayModuleFwRev);
-        } else if (strcmp(newString[0], "fan") == 0) {
-            printf("FAN Version = %s \n", pSysInfo->FanModuleFwRev);
-        } else if (strcmp(newString[0], "dc") == 0) {
-            printf("DC Main Version = %s \n", pSysInfo->CsuRootFsFwRev);
-        } else if (strcmp(newString[0], "led") == 0) {
-            printf("LED Version = %s \n", pSysInfo->LedModuleFwRev);
-        } else if (strcmp(newString[0], "ac") == 0) {
-            pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
-
-            printf("AC Version = %s \n", pAcChargingInfo->version);
-        } else if (exitCmd() == YES) {
-            return;
-        } else if (helpCmd() == YES) {
-            printf ("%s\n", usageMsg);
-        }
-
-    }//while
-}
-
-void CreateOneError(char *v1)
-{
-    int value = atoi(v1);
-
-    pAlarmCode->AlarmEvents.bits.SystemL1InputOVP = value;
-    pSysConfig->BillingData.isBilling = value;
-}
-
-void GetAuthorizeFlag(char *v1)
-{
-    if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0) {
-        printf("AuthorizeFlag = %d \n", pSysInfo->AuthorizeFlag);
-    } else {
-        pSysInfo->AuthorizeFlag = atoi(v1);
-    }
-}
-
-void GetRelayStatus(char *v1)
-{
-    int _index = atoi(v1);
-    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
-    //    printf("FindChargingInfoData error\n");
-    //    return;
-    //}
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
-
-    printf("RelayK1K2Status = %d \n", pDcChargingInfo->RelayK1K2Status);
-    printf("RelayKPK2Status = %d \n", pDcChargingInfo->RelayKPK2Status);
-}
-
-void FwUpdateFlagProc()
-{
-    pSysInfo->FirmwareUpdate = 0x01;
-}
-
-void CheckAcStatus(char *v1)
-{
-    if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0) {
-        printf("AC Status = %d \n", pSysInfo->AcContactorStatus);
-    }
-}
-
-void SetCableChkStatus(char *v1, char *v2)
-{
-    int _index = atoi(v1);
-    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
-    //    printf ("FindChargingInfoData error\n");
-    //    return;
-    //}
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
-
-    pDcChargingInfo->GroundFaultStatus = atoi(v2);
-}
-
-void SetChargingInfoCCID(char *v1, char *v2)
-{
-    int _index = atoi(v1);
-    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
-    //    printf ("FindChargingInfoData error\n");
-    //    return;
-    //}
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
-
-    memcpy(pDcChargingInfo->EVCCID, v2, 8);
-    pDcChargingInfo->EVCCID[8] = '\0';
-}
-
-void SetPowerValue(char *v1, char *v2)
-{
-    int _index = atoi(v1);
-    float _Current = atof(v2);
-
-    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
-    //    printf ("FindChargingInfoData error\n");
-    //    return;
-    //}
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
-
-    // 盲沖的時候才允許使用~
-    if (pDcChargingInfo->Type != 9) {
-        return;
-    }
-
-    pDcChargingInfo->EvBatterytargetCurrent = _Current;
-}
-
-void GetSystemInfo()
-{
-    printf ("ModelName = %s \n", pSysConfig->ModelName);
-    printf ("SerialNumber = %s \n", pSysConfig->SerialNumber);
-    printf ("InternetConn = %d \n", pSysInfo->InternetConn);
-
-    printf ("MaxChargingPower = %d, MaxChargingCurrent = %d \n",
-            pSysConfig->MaxChargingPower,
-            pSysConfig->MaxChargingCurrent);
-}
-
-void ChangeGunNum()
-{
-    if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount) {
-        pSysInfo->CurGunSelected += 1;
-        pSysInfo->CurGunSelectedByAc = NO_DEFINE;
-    } else if (pSysConfig->AcConnectorCount > 0 &&
-               pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
-        pSysInfo->CurGunSelectedByAc = DEFAULT_AC_INDEX;
-    } else {
-        pSysInfo->CurGunSelected = 0;
-        pSysInfo->CurGunSelectedByAc = NO_DEFINE;
-    }
-}
-
-void GetGunSelectedNum(char *v1)
-{
-    if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0) {
-        if (AC_QUANTITY > 0 &&
-                pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
-            printf("connector select changed = AC \n");
-        } else {
-            printf("connector selected = %d \n", pSysInfo->CurGunSelected);
-        }
-    } else {
-        int _index = atoi(v1);
-        if (_index <= 1) {
-            pSysInfo->CurGunSelected = _index;
-            pSysInfo->CurGunSelectedByAc = NO_DEFINE;
-            printf("connector select changed = %d \n", _index);
-        } else if (AC_QUANTITY > 0) {
-            pSysInfo->CurGunSelectedByAc = DEFAULT_AC_INDEX;
-            printf("connector select changed = AC \n");
-        }
-    }
-}
-
-void SetFanSpeed(char *v1)
-{
-    int speed = atoi(v1);
-
-    ShmFanModuleData->TestFanSpeed = speed;
-}
-
-void GetFanSpeed()
-{
-    printf("ShmFanModuleData->PresentFan1Speed = %d \n", ShmFanModuleData->PresentFan1Speed);
-    printf("ShmFanModuleData->PresentFan2Speed = %d \n", ShmFanModuleData->PresentFan2Speed);
-    printf("ShmFanModuleData->PresentFan3Speed = %d \n", ShmFanModuleData->PresentFan3Speed);
-    printf("ShmFanModuleData->PresentFan4Speed = %d \n", ShmFanModuleData->PresentFan4Speed);
-}
-
-void SetDebugMode(char *v1)
-{
-    int mode = atoi(v1);
-
-    pSysConfig->SwitchDebugFlag = mode;
-}
-
-void SetGFDMode(char *v1)
-{
-    int mode = atoi(v1);
-
-    pSysConfig->AlwaysGfdFlag = mode;
-}
-
-void GetPsuTemp()
-{
-    for (uint8_t index = 0; index < ShmPsuData->GroupCount; index++) {
-        for (uint8_t count = 0; count < ShmPsuData->PsuGroup[index].GroupPresentPsuQuantity; count++) {
-            printf("PSU Temp = %d \n", ShmPsuData->PsuGroup[index].PsuModule[count].ExletTemp);
-        }
-    }
-}
-
-void GetAcInputVol()
-{
-    printf("L1N_L12 = %f, L2N_L23 = %f, L3N_L31 = %f \n",
-           pSysInfo->InputVoltageR,
-           pSysInfo->InputVoltageS,
-           pSysInfo->InputVoltageT);
-}
-
-void GetPsuInformation(char *v1, char *v2, char *v3)
-{
-    printf("**********************AC Contact needed*************************\n");
-    if (strcmp(v1, "count") == 0) {
-        for (int i = 0; i < 4; i++) {
-            printf("Group Index = %d, Module Count = %d \n",
-                   i,
-                   ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity);
-        }
-    } else if (strcmp(v1, "ver") == 0) {
-        for (int i = 0; i < ShmPsuData->SystemPresentPsuQuantity; i++) {
-            printf("Psu Index = %d, PriVersion = %s, SecVersion = %s \n",
-                   i, ShmPsuData->PsuVersion[i].FwPrimaryVersion,
-                   ShmPsuData->PsuVersion[i].FwSecondVersion);
-        }
-
-        for (int i = 0; i < ShmPsuData->GroupCount; i++) {
-            for (int j = 0; j < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; j++) {
-                printf("Group Index = %d, Psu Index = %d, Version = %s \n",
-                       i,
-                       j,
-                       ShmPsuData->PsuGroup[i].PsuModule[j].FwVersion);
-            }
-        }
-    } else if (strcmp(v1, "cap") == 0) {
-        for (int i = 0; i < ShmPsuData->GroupCount; i++) {
-            printf("Group Index = %d, MaxCur = %d, Power = %d \n",
-                   i,
-                   ShmPsuData->PsuGroup[i].GroupAvailableCurrent,
-                   ShmPsuData->PsuGroup[i].GroupAvailablePower);
-        }
-    } else if (strcmp(v1, "input") == 0) {
-        for (int i = 0; i < ShmPsuData->GroupCount; i++) {
-            for (uint8_t count = 0; count < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; count++) {
-                printf("gp = %d, Index = %d, volR = %d, volS = %d, volT = %d \n",
-                       i,
-                       count,
-                       ShmPsuData->PsuGroup[i].PsuModule[count].InputVoltageL1,
-                       ShmPsuData->PsuGroup[i].PsuModule[count].InputVoltageL2,
-                       ShmPsuData->PsuGroup[i].PsuModule[count].InputVoltageL3);
-            }
-        }
-    } else if (strcmp(v1, "output") == 0) {
-        for (int i = 0; i < ShmPsuData->GroupCount; i++) {
-            printf("Group Index = %d, OutputV = %d, OutputC = %d \n",
-                   i,
-                   ShmPsuData->PsuGroup[i].GroupPresentOutputVoltage,
-                   ShmPsuData->PsuGroup[i].GroupPresentOutputCurrent);
-        }
-
-        for (int i = 0; i < pSysConfig->TotalConnectorCount; i++) {
-            //if (!FindChargingInfoData(i, &_chargingData[0])) {
-            //    printf ("FindChargingInfoData error\n");
-            //    continue;
-            //}
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
-
-            printf("Form RB : Group Index = %d, OutputV = %f \n",
-                   i,
-                   pDcChargingInfo->FireChargingVoltage);
-        }
-    } else if (strcmp(v1, "test") == 0) {
-        int mode = atoi(v2);
-
-        if (mode >= _TEST_MODE && mode <= _TEST_MODE) {
-            ShmPsuData->Work_Step = mode;
-        }
-    } else if (strcmp(v1, "out") == 0) {
-        float vol = atof(v2);
-        float cur = atof(v3);
-
-        if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE) {
-            //if (!FindChargingInfoData(0, &_chargingData[0])) {
-            //    printf ("FindChargingInfoData error\n");
-            //    return;
-            //}
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(0);
-
-            pDcChargingInfo->EvBatterytargetVoltage = vol;
-            pDcChargingInfo->EvBatterytargetCurrent = cur;
-        }
-    }
-    printf("*************************************************\n");
-}
-
-void GetConnectorCapInfo(char *v1)
-{
-    int _GunIndex = atoi(v1);
-
-    //if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
-    //    printf ("FindChargingInfoData error\n");
-    //    return;
-    //}
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
-
-    printf ("Charger Max Current = %d, Max Power = %d \n",
-            pSysConfig->MaxChargingCurrent * 10,
-            pSysConfig->MaxChargingPower * 10);
-
-    printf ("Index = %d, MaxPow = %f, MaxVol = %f, MaxCur = %f\n",
-            _GunIndex,
-            pDcChargingInfo->RealMaxPower,
-            pDcChargingInfo->RealMaxVoltage,
-            pDcChargingInfo->RealMaxCurrent);
-}
-
-static void setConfirmSelGun(uint8_t selGun)
-{
-    if (selGun == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_RELEASE) {
-        ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
-        //printf("confirmSelGun left\r\n");
-    } else if (selGun == RIGHT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_RELEASE) {
-        ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
-        //printf("confirmSelGun right\r\n");
-    }
-}
-
-void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
-{
-    int _GunIndex;
-    uint8_t gunIndex = 0;
-    uint8_t stopChg = 0;
-    uint8_t curGun = 0;
-    int isContinue = 1;
-    float _Voltage;
-    float _Current;
-    uint8_t PreviousSystemStatus[2] = {0xff};
-    char *usageMsg = "Usage:\n"
-                     "       strchg <index> <voltage> <current>    ex: strchg 0 150 2\n"
-                     "       chg    <voltage> <current>            ex: chg 500 100\n"
-                     "       c      <index>                        ex: c 0\n"
-                     "       help | ? | h\n"
-                     "\r\n";
-
-    if (strcmp(v1, "auto") == EQUAL) {
-        _usingAutoRun = 0x01;
-        _GunIndex = 0;
-        _Voltage = 500;
-        _Current = (pSysConfig->MaxChargingPower * 1000) / _Voltage;
-    } else {
-        _usingAutoRun = 0x00;
-        _GunIndex = atoi(v1);
-        _Voltage = atof(v2);
-        _Current = atof(v3);
-    }
-
-    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
-
-    printf("Power = %d, ReqVoltage = %f, ReqCurrent = %f\n",
-           pSysConfig->MaxChargingPower,
-           _Voltage,
-           _Current);
-
-    if (_Voltage > 1000 || _Voltage < 50) {
-        printf ("Input Voltage over range\n");
-        return;
-    }
-
-    //kill ev task
-    system("killall Module_EvComm");
-
-    pSysInfo->CurGunSelected = _GunIndex;
-
-    while (isContinue) {
-
-        curGun = pSysInfo->CurGunSelected;
-        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(curGun);
-
-        //fix gun 1
-        switch (pDcChargingInfo->SystemStatus) {
-        case S_IDLE:
-            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
-                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
-#if defined DD360Audi
-                setConfirmSelGun(curGun);
-#endif //defined DD360Audi
-
-                strcpy((char *)pSysConfig->UserId, "AutoStartCharging");
-                pDcChargingInfo->ConnectorPlugIn = 1;
-                printf ("[UnconditionalCharge - S_IDLE]\n");
-                pDcChargingInfo->Type = 9;
-
-            }
-            if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf == 1) {
-                pSysInfo->StartToChargingFlag = 0x01;
-                pDcChargingInfo->SystemStatus = S_PREPARNING;
-            }
-            break;
-
-        case S_PREPARNING:
-            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
-                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
-
-                printf ("[UnconditionalCharge - S_PREPARNIN]\n");
-
-                //等待 AC Relay 搭上且找到模組 (main 在此 statue 其它 task 會去做完)
-                printf ("wait find module\n");
-
-            }
-            //main 會在此階段判斷以下資料跳到下一個 state
-            //用來得知 AC 是否有搭上 (搭上模組的資訊才會出來) 因為每次  AC_Contactor
-            //ShmPsuData->SystemPresentPsuQuantity;
-            //ShmPsuData->PsuGroup[gun_index].GroupPresentPsuQuantity;
-            //ShmPsuData->PsuGroup[gun_index].GroupAvailablePower;
-            //_chargingData[gun_index]->AvailableChargingPower;
-
-            //等待 AC Relay 搭上且找到模組 (main 在此 statue 其它 task 會去做完)
-            //sleep(10);
-
-            //清除 main timeout 機制
-            pDcChargingInfo->TimeoutFlag = 0;
-            //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
-            pDcChargingInfo->Type = 9;
-            break;
-
-        case S_PREPARING_FOR_EV:
-            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
-                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
-
-                printf ("[UnconditionalCharge - S_PREPARING_FOR_EV]\n");
-                printf ("ReqVoltage = %f, ReqCurrent = %f \n", _Voltage * 10, _Current * 10);
-
-            }
-            //清除 main timeout 機制
-            pDcChargingInfo->TimeoutFlag = 0;
-            //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
-            pDcChargingInfo->Type = 9;
-
-            //充電電壓電流
-            pDcChargingInfo->EvBatterySoc             = 50;
-            pDcChargingInfo->EvBatterytargetVoltage   = 500;
-            pDcChargingInfo->EvBatterytargetCurrent   = 2;
-            pDcChargingInfo->AvailableChargingCurrent = 1000;
-
-            //****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
-            //確定模組己升壓完成
-            //if(pDcChargingInfo->PresentChargingVoltage <=  (3000+500) &&
-            //  pDcChargingInfo->PresentChargingVoltage >=  (3000-500) )
-            {
-                printf ("Precharge Done = %f \n",
-                        pDcChargingInfo->PresentChargingVoltage);
-                //EV done
-                pDcChargingInfo->SystemStatus = S_PREPARING_FOR_EVSE;
-            }
-            break;
-
-        case S_PREPARING_FOR_EVSE:
-            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
-                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
-
-                printf ("[UnconditionalCharge - S_PREPARING_FOR_EVSE]\n");
-
-            }
-            //printf ("tar vol = %d \n", _Voltage);
-            //printf ("tar cur = %d \n", _Current);
-
-            //清除 main timeout 機制
-            pDcChargingInfo->TimeoutFlag = 0;
-            //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
-            pDcChargingInfo->Type = 9;
-
-            //充電電壓電流
-            pDcChargingInfo->EvBatterySoc = 50;
-            pDcChargingInfo->EvBatterytargetVoltage = 500;
-            pDcChargingInfo->EvBatterytargetCurrent = 2;
-            pDcChargingInfo->AvailableChargingCurrent = 1000;
-
-            //printf ("tar vol_ = %d \n", pDcChargingInfo->EvBatterytargetVoltage);
-            // printf ("tar cur_ = %d \n", pDcChargingInfo->EvBatterytargetCurrent);
-
-            //****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
-            //確定模組己升壓完成
-            if (pDcChargingInfo->GroundFaultStatus == 0x01 ||
-                    pDcChargingInfo->GroundFaultStatus == 0x03) {
-                printf ("First Ground Fault State (%d)\n",
-                        pDcChargingInfo->GroundFaultStatus);
-                printf ("Wait K1K2 = %f \n", pDcChargingInfo->PresentChargingVoltage);
-                sleep(5);
-                //EV done
-                pDcChargingInfo->SystemStatus = S_CHARGING;
-            } else if (pDcChargingInfo->GroundFaultStatus > 0x02) {
-                printf ("First Ground Fault check Fail (%d)\n",
-                        pDcChargingInfo->GroundFaultStatus);
-                pDcChargingInfo->SystemStatus = S_TERMINATING;
-            }
-            break;
-
-        case S_CHARGING:
-            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
-                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
-
-                if (_usingAutoRun == 0x00) {
-                    //充電電壓電流
-                    pDcChargingInfo->EvBatterytargetVoltage = _Voltage;
-                    pDcChargingInfo->EvBatterytargetCurrent = _Current;
-                } else {
-                    _curAutoRunCount = 0;
-                    gettimeofday(&_autoTime, NULL);
-                }
-
-                pDcChargingInfo->EvBatterySoc = 50;
-                pDcChargingInfo->AvailableChargingCurrent = 1000;
-
-                printf ("[UnconditionalCharge - S_CHARGING]\n");
-            }
-
-            if (_usingAutoRun == 0x01) {
-                if (((GetTimeoutValue(_autoTime)) >= AUTORUN_STEP1_TIME_START * 60 &&
-                        (GetTimeoutValue(_autoTime)) <= AUTORUN_STEP1_TIME_END * 60) ||
-                        ((GetTimeoutValue(_autoTime)) >= AUTORUN_STEP2_TIME_START * 60 &&
-                         (GetTimeoutValue(_autoTime)) <= AUTORUN_STEP2_TIME_END * 60)
-                   ) {
-                    pDcChargingInfo->EvBatterytargetVoltage = _Voltage;
-                    pDcChargingInfo->EvBatterytargetCurrent = _Current;
-                } else if ((GetTimeoutValue(_autoTime)) >= AUTORUN_END_TIME * 60) {
-                    _curAutoRunCount++;
-                    if (_curAutoRunCount >= AUTORUN_CYCLE_COUNT) {
-                        pDcChargingInfo->SystemStatus = S_TERMINATING;
-                    } else {
-                        gettimeofday(&_autoTime, NULL);
-                    }
-                } else {
-                    pDcChargingInfo->EvBatterytargetVoltage = 0;
-                    pDcChargingInfo->EvBatterytargetCurrent = 0;
-                }
-            }
-
-//              printf("out : vol = %f, cur = %f \n",
-//                      pDcChargingInfo->EvBatterytargetVoltage,
-//                      pDcChargingInfo->EvBatterytargetCurrent);
-            //ev task do this
-            pDcChargingInfo->PresentChargingPower =
-                ((float)((pDcChargingInfo->PresentChargingVoltage) *
-                         (pDcChargingInfo->PresentChargingCurrent)) / 1000);
-
-            if (pDcChargingInfo->GroundFaultStatus == 0x02) {
-                printf ("Charging Ground Fault check Fail (%d)\n",
-                        pDcChargingInfo->GroundFaultStatus);
-                pDcChargingInfo->SystemStatus = S_TERMINATING;
-            }
-            break;
-
-        case S_TERMINATING:
-            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
-                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
-
-                printf ("[UnconditionalCharge - S_TERMINATING]\n");
-                //無阻塞偵測 keybaord 結束
-                system(STTY_DEF TTY_PATH);
-            }
-
-            pDcChargingInfo->SystemStatus = S_COMPLETE;
-            break;
-
-        case S_COMPLETE:
-            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
-                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
-
-                printf ("[UnconditionalCharge - S_COMPLETE]\n");
-            }
-
-            PreviousSystemStatus[curGun] = 0xFF;
-            stopChg = 0;
-            for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
-                if (PreviousSystemStatus[gunIndex] == 0xFF) {
-                    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(curGun);
-                    pDcChargingInfo->SystemStatus = S_IDLE;
-                } else {
-                    pSysInfo->CurGunSelected = gunIndex;
-                }
-
-                pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
-                if (pDcChargingInfo->SystemStatus == S_IDLE) {
-                    stopChg++;
-                }
-            }
-
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(curGun);
-            pDcChargingInfo->PresentChargingPower = 0;
-
-            if (stopChg == pSysConfig->TotalConnectorCount) {
-                system("/root/Module_EvComm &");
-                sleep(3);
-
-                for (_GunIndex = 0; _GunIndex < pSysConfig->TotalConnectorCount; _GunIndex++) {
-                    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
-
-                    pDcChargingInfo->SystemStatus = S_IDLE;
-                }
-                return;
-            }
-            break;
-        }
-
-        if (readCmdKey(CMD_KEY_DONT_WAIT) == NO) {
-            continue;
-        }
-
-        if (strcmp(newString[0], "strchg") == 0) {
-            if (strcmp(newString[1], "-1") == 0 ||
-                    strcmp(newString[1], "") == 0 ||
-                    strcmp(newString[2], "-1") == 0 ||
-                    strcmp(newString[2], "") == 0
-               ) {
-                printf ("Input cmd fail ------  strchg [vol 150-1000] [cru 2-100]\n");
-                continue;
-            }
-
-            if (atoi(newString[1]) == pSysInfo->CurGunSelected) {
-                continue;
-            }
-
-            _GunIndex = atoi((char *)newString[1]);
-            _Voltage = atof((char *)newString[2]);
-            _Current = atof((char *)newString[3]);
-
-            printf ("Power = %d, ReqVoltage = %f, ReqCurrent = %f\n",
-                    pSysConfig->MaxChargingPower,
-                    _Voltage,
-                    _Current);
-
-            if (_Voltage > 1000 || _Voltage < 50) {
-                _Voltage = 200;
-                printf ("Input Voltage over range\n");
-                continue;
-            }
-
-            pSysInfo->CurGunSelected = _GunIndex;
-            strcpy((char *)pSysConfig->UserId, "");
-        } else if (strcmp(newString[0], "chg") == 0) {
-            if (strcmp(newString[1], "-1") == 0) {
-                continue;
-            }
-
-            if (strcmp(newString[2], "-1") == 0 ||
-                    strcmp(newString[2], "") == 0) {
-                continue;
-            }
-
-            if (strcmp(newString[3], "-1") == 0 ||
-                    strcmp(newString[3], "") == 0) {
-                continue;
-            }
-
-            _GunIndex = atoi((char *)newString[1]);
-            float _vol = atof(newString[2]);
-            float _cur = atof(newString[3]);
-
-            if (_cur <= 0 || _cur <= 0) {
-                continue;
-            }
-
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
-
-            printf("reset vol = %f, cur = %f \n", _vol, _cur);
-            pDcChargingInfo->EvBatterytargetVoltage = _vol;
-            pDcChargingInfo->EvBatterytargetCurrent = _cur;
-        } else if (strcmp(newString[0], "c") == 0) {
-            if (strcmp(newString[1], "-1") == 0 ||
-                    strcmp(newString[1], "") == 0) {
-                printf("argc 1 is error parameter\r\n");
-                continue;
-            }
-
-            if (atoi((char *)newString[1]) != -1) {
-                pSysInfo->CurGunSelected = atoi((char *)newString[1]);
-            }
-            printf("stop \n\r");
-
-            pSysInfo->StartToChargingFlag = 0x00;
-
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData( pSysInfo->CurGunSelected);
-
-            pDcChargingInfo->SystemStatus = S_TERMINATING;
-        } else if (helpCmd() == YES) {
-            printf("%s\n", usageMsg);
-        }
-
-        usleep(100000);
-    }
-}
-
-int printTimeMsg(const char *fmt, ...)
-{
-    char Buf[4096 + 256] = {0};
-    char buffer[4096] = {0};
-    int rc = -1;
-    va_list args;
-    struct timeb  SeqEndTime;
-    struct tm *tm;
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-
-    va_start(args, fmt);
-    rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
-    va_end(args);
-
-    ftime(&SeqEndTime);
-    SeqEndTime.time = time(NULL);
-    tm = localtime(&SeqEndTime.time);
-
-    sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
-            tm->tm_hour,
-            tm->tm_min,
-            tm->tm_sec,
-            SeqEndTime.millitm,
-            buffer);
-    printf("%s", Buf);
-
-    return rc;
-}
-
-static void resdGunAndChillerTemp(void)
-{
-    int isContinue = 1;
-    uint8_t i = 0;
-    uint32_t sleepTime = 500000;
-    uint32_t loopTime = 1000;
-    struct timeb showTime;
-    struct timeb nowTime;
-
-    char *usageMsg = "Usage:\n"
-                     "       t <index>: loop time, ex: t 1\n"
-                     "       exit | c | C: exit test\n"
-                     "       h | help | ?: show usage message\n"
-                     "\r\n";
-
-    ftime(&showTime);
-
-    while (isContinue) {
-        ftime(&nowTime);
-
-        if (DiffTimeb(showTime, nowTime) > loopTime ||
-                DiffTimeb(showTime, nowTime) < 0) {
-            for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
-
-                pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
-
-                printTimeMsg("get gun %d temp = %3d, chiller = %3d, ConnTemp = %3d, %3d,SysTemp = %3d, %3d, %3d, %3d\r\n",
-                             i,
-                             pDcChargingInfo->ConnectorTemp,
-                             pDcChargingInfo->ChillerTemp,
-                             ShmDcCommonData->ConnectorTemp[i][0],
-                             ShmDcCommonData->ConnectorTemp[i][1],
-                             ShmDcCommonData->SystemTemp[0],
-                             ShmDcCommonData->SystemTemp[1],
-                             ShmDcCommonData->SystemTemp[2],
-                             ShmDcCommonData->SystemTemp[3]);
-            }//for
-            ftime(&showTime);
-        }
-
-        if (readCmdKey(CMD_KEY_DONT_WAIT) == NO) {
-            usleep(sleepTime);
-            continue;
-        }
-
-        if (strcmp(newString[0], "t") == 0) {
-            if (strcmp(newString[1], "-1") == 0 ||
-                    strcmp(newString[1], "") == 0 ||
-                    atoi((char *)newString[1]) > 255
-               ) {
-                printf("argc 1 is error parameter\r\n");
-                continue;
-            }
-
-            loopTime = ((atoi((char *)newString[1])) * 1000);
-            printf("loopTime = %d\r\n", loopTime);
-            ftime(&showTime);
-            continue;
-        } else if (exitCmd() == YES) {
-            return;
-        } else if (helpCmd() == YES) {
-            printf ("%s\n", usageMsg);
-        }
-
-        usleep(sleepTime);
-    }//while
-}
-static void writeOTPTemp(void)
-{
-    uint8_t _GunIndex = 0;
-    int isContinue = 1;
-    uint32_t sleepTime = 500000;
-    char *usageMsg = "Usage:\n"
-                     "       OTP  <temp_recovery>  <temp>, ex: OTP 140 150\n"
-                     "       exit | c | C\n"
-                     "       help | ? | h\n"
-                     "\r\n";
-
-    while (isContinue) {
-        if (readCmdKey(CMD_KEY_WAIT) == NO) {
-            sleep(sleepTime);
-            continue;
-        }
-
-        if (helpCmd() == YES) {
-            printf ("%s\n", usageMsg);
-            continue;
-        } else if (exitCmd() == YES) {
-            sleep(1);
-            return;
-        } 
-        if (strcmp(newString[0], "OTP") != 0) {
-            printf("argc 1 is error parameter\r\n");
-            continue;
-        }
-
-        if (atoi(newString[1]) > 255 ||
-                atoi(newString[1]) == -1) {
-            printf("Recovey temperature value overflow\r\n");
-            continue;
-        }
-
-        if (atoi(newString[2]) > 255 ||
-                atoi(newString[2]) == -1) {
-            printf("Recovey temperature value overflow\r\n");
-            continue;
-        }
-
-        pSysInfo->OTPTempR = atoi(newString[1]);
-        pSysInfo->OTPTemp = atoi(newString[2]);
-
-        printf("OTP Recovery Temp set:%d\n",pSysInfo->OTPTempR);
-        printf("OTP Temp set:%d\n",pSysInfo->OTPTemp);
-        usleep(sleepTime);
-    }//while
-}
-
-static void writeGunAndChillerTemp(void)
-{
-    uint8_t _GunIndex = 0;
-    int isContinue = 1;
-    uint32_t sleepTime = 500000;
-    char *usageMsg = "Usage:\n"
-                     "       conn    <index> <temp>, ex: conn 0 150\n"
-                     "       chiller <index> <temp>, ex: chiller 0 150\n"
-                     "       tempR\n"
-                     "       exit | c | C\n"
-                     "       help | ? | h\n"
-                     "\r\n";
-
-    ShmDcCommonData->TestTemperature = YES;
-
-    while (isContinue) {
-        if (readCmdKey(CMD_KEY_WAIT) == NO) {
-            sleep(sleepTime);
-            continue;
-        }
-
-        if (helpCmd() == YES) {
-            printf ("%s\n", usageMsg);
-            continue;
-        } else if (exitCmd() == YES) {
-            ShmDcCommonData->TestTemperature = NO;
-            sleep(1);
-            return;
-        } else if (strcmp(newString[0], "tempR") == 0) {
-            resdGunAndChillerTemp();
-        }
-
-        if ((strcmp(newString[0], "chiller") != 0) &&
-                (strcmp(newString[1], "-1") == 0 ||
-                 strcmp(newString[1], "") == 0)
-           ) {
-            printf("argc 1 is error parameter\r\n");
-            continue;
-        }
-
-        if (atoi(newString[2]) > 255 ||
-                atoi(newString[2]) == -1) {
-            printf("temperature value overflow\r\n");
-            continue;
-        }
-
-        _GunIndex = atoi((char *)newString[1]);
-
-        if (_GunIndex >= pSysConfig->TotalConnectorCount) {
-            printf("gun index over total connector\r\n");
-            continue;
-        }
-
-        if (strcmp(newString[0], "chiller") == 0) {//修改水冷機溫度值
-            if (_GunIndex >= 1) {
-                _GunIndex = 0; //只會有一個水冷機
-            }
-
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
-            pDcChargingInfo->ChillerTemp = atoi(newString[2]);
-            printf("set %d chiller temperature = %d\r\n",
-                   _GunIndex,
-                   pDcChargingInfo->ChillerTemp);
-        } else if (strcmp(newString[0], "conn") == 0) {//修改槍頭溫度值
-            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
-
-            pDcChargingInfo->ConnectorTemp = atoi(newString[2]);
-            printf("set %d connector temp = %d\r\n",
-                   _GunIndex,
-                   pDcChargingInfo->ConnectorTemp);
-        }
-
-        usleep(sleepTime);
-    }//while
-}
-
-int main(void)
-{
-    uint8_t _GunIndex = 0;
-    int isContinue = 1;
-    char *usageMsg = "Usage:\n"
-                     "       state <index>                     : get gun state\n"
-                     "       card                              : scanning card (x)\n"
-                     "       gun <index>                       : get gun plugit state\n"
-                     "       lock <index>                      : get gun locked state\n"
-                     "       sysid                             : test system ID\n"
-                     "       self                              : self test state (x)\n"
-                     "       version | v | -v                  : version of board (407 or relay or other)\n"
-                     "       update                            : update firmware\n"
-                     "       ac                                : get ac relay state (x) \n"
-                     "       cable <index> <state>             : set ground fault state\n"
-                     "       pow <index> <power>               : set power value\n"
-                     "       model                             : get system information\n"
-                     "       temp                              : get PSU temperature\n"
-                     "       fan <speed>                       : set fan board speed\n"
-                     "       strchg <auto>                     : auto test charging\n"
-                     "       strchg <index> <voltage <current> : select gun test charging\n"
-                     "       tempW                             : write connector header and Chiller temperature\r\n"
-                     "       tempR                             : print connector header and chiller temperature\r\n"
-                     "       OTP                               : Write OTP temperature\r\n"
-                     "\r\n";
-
-    if (CreateAllCsuShareMemory() == FAIL) {
-        printf("create share memory error\r\n");
-        return FAIL;
-    }
-
-    MappingGunChargingInfo("ReadCmdline Task");
-
-    pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-    pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
-
-    pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
-
-    ShmCHAdeMOData = (struct CHAdeMOData *)GetShmCHAdeMOData();
-    ShmGBTData = (struct GBTData *)GetShmGBTData();
-    ShmCcsData = (struct CcsData *)GetShmCcsData();
-
-    ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
-    ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();
-    ShmRelayModuleData = (struct RelayModuleData *)GetShmRelayModuleData();
-    ShmLedModuleData = (struct LedModuleData *)GetShmLedModuleData();
-    ShmPsuData = (struct PsuData *)GetShmPsuData();
-    ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
-    ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
-    ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
-
-//    for (_GunIndex = 0; _GunIndex < pSysConfig->TotalConnectorCount; _GunIndex++) {
-//        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
-
-//        pDcChargingInfo->SystemStatus = S_IDLE;
-//    }
-
-    while (isContinue) {
-        if (readCmdKey(CMD_KEY_WAIT) == NO) {
-            continue;
-        }
-
-        if (strcmp(newString[0], "state") == 0) {
-            if (strcmp(newString[1], "-1") == 0 ||
-                    strcmp(newString[1], "") == 0) {
-                continue;
-            }
-
-            // 槍狀態
-            RunStatusProc(newString[1], newString[2]);
-        } else if (strcmp(newString[0], "card") == 0) {
-            // 刷卡狀態
-            RunCardProc(newString[1], newString[2]);
-        } else if (strcmp(newString[0], "gun") == 0) {
-            if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
-                continue;
-            }
-
-            // 插槍狀態
-            RunGunPlugitProc(newString[1], newString[2]);
-        } else if (strcmp(newString[0], "lock") == 0) {
-            if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
-                continue;
-            }
-
-            // 插槍狀態
-            GetGunLockStatusProc(newString[1], newString[2]);
-        } else if (strcmp(newString[0], "sysid") == 0) {
-            // 測試 sys id
-            SetSystemIDProc();
-        } else if (strcmp(newString[0], "self") == 0) {
-            // CSU 自我檢測狀態
-            RunSelfProc(newString[1]);
-        } else if (strcmp(newString[0], "version") == 0 ||
-                   strcmp(newString[0], "v") == 0 ||
-                   strcmp(newString[0], "-v") == 0) {
-            //if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
-            //    continue;
-            //}
-            // 取 FW 版號
-            GetFwVerProc();
-        } else if (strcmp(newString[0], "update") == 0) {
-            // 更新
-            FwUpdateFlagProc(newString[1]);
-        } else if (strcmp(newString[0], "ac") == 0) {
-            // AC contactor 狀態
-            CheckAcStatus(newString[1]);
-        } else if (strcmp(newString[0], "cable") == 0) {
-            if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
-                continue;
-            }
-
-            // cable check pass
-            SetCableChkStatus(newString[1], newString[2]);
-        } else if (strcmp(newString[0], "pow") == 0) {
-            if (strcmp(newString[1], "-1") == 0 ||
-                    strcmp(newString[1], "") == 0) {
-                continue;
-            }
-            // cable check pass
-            SetPowerValue(newString[1], newString[2]);
-        } else if (strcmp(newString[0], "model") == 0) {
-            GetSystemInfo();
-        } else if (strcmp(newString[0], "select") == 0) {
-            // 取得 / 設定 當前選的槍號
-            GetGunSelectedNum(newString[1]);
-        } else if (strcmp(newString[0], "change") == 0) {
-            // 模擬按鈕改變選槍
-            ChangeGunNum();
-        } else if (strcmp(newString[0], "fan") == 0) {
-            // 設定風扇速度
-            SetFanSpeed(newString[1]);
-        } else if (strcmp(newString[0], "speed") == 0) {
-            // 取得風扇速度
-            GetFanSpeed();
-        } else if (strcmp(newString[0], "debug") == 0) {
-            // 設定 debug mode
-            SetDebugMode(newString[1]);
-        } else if (strcmp(newString[0], "gfd") == 0) {
-            // 設定盲沖使用 GFD 功能
-            SetGFDMode(newString[1]);
-        } else if (strcmp(newString[0], "temp") == 0) {
-            // 取得 PSU 溫度
-            GetPsuTemp();
-        } else if (strcmp(newString[0], "acin") == 0) {
-            // 取得三向輸入電壓
-            GetAcInputVol();
-        } else if (strcmp(newString[0], "psu") == 0) {
-            //如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
-            if (strcmp(newString[1], "-1") == 0 ||
-                    strcmp(newString[1], "") == 0) {
-                printf ("PSU : Param fail..Please retry again......\n");
-                continue;
-            }
-            // 取得 PSU 資訊
-            GetPsuInformation(newString[1], newString[2], newString[3]);
-        } else if (strcmp(newString[0], "cap") == 0) {
-            GetConnectorCapInfo(newString[1]);
-        } else if (strcmp(newString[0], "error") == 0) {
-            CreateOneError(newString[1]);
-        } else if (strcmp(newString[0], "auth") == 0) {
-            GetAuthorizeFlag(newString[1]);
-        } else if (strcmp(newString[0], "relay") == 0) {
-            GetRelayStatus(newString[1]);
-        } else if (strcmp(newString[0], "ccid") == 0) {
-            if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
-                    strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0) {
-                printf ("Input ccid fail.\n");
-                continue;
-            }
-            SetChargingInfoCCID(newString[1], newString[2]);
-        } else if (strcmp(newString[0], "strchg") == 0) {
-            //如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
-            if (strcmp(newString[1], "auto") == 0) {
-                newString[2][0] = 0;
-                newString[3][0] = 0;
-            } else if (strcmp(newString[1], "-1") == 0 ||
-                       strcmp(newString[1], "") == 0   ||
-                       strcmp(newString[2], "-1") == 0 ||
-                       strcmp(newString[2], "") == 0) {
-                printf ("Input cmd fail ------  strchg [vol 150-1000] [cru 2-100]\n");
-                continue;
-            }
-
-            // 槍狀態
-            RunUnconditionalChargeIndex1(newString[1], newString[2], newString[3]);
-        } else if (strcmp(newString[0], "tempW") == 0) { //測試槍頭和水冷機溫度
-            writeGunAndChillerTemp();
-        } else if (strcmp(newString[0], "tempR") == 0) { //讀取槍頭和水冷機溫度
-            resdGunAndChillerTemp();
-        } else if (strcmp(newString[0], "OTP") == 0) { //測試槍頭和水冷機溫度
-            writeOTPTemp();
-        } else {
-            printf("%s\n", usageMsg);
-        }
-
-        sleep(1);
-    }//while
-
-    return 0;
-}
+/*
+ * Main.c
+ *
+ *  Created on: 2019年8月6日
+ *      Author: 7564
+ */
+
+
+#include <sys/time.h>
+#include <sys/timeb.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/shm.h>
+#include <sys/mman.h>
+#include <linux/wireless.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#include <unistd.h>
+#include <stdarg.h>
+#include <stdio.h>      /*標準輸入輸出定義*/
+#include <stdlib.h>     /*標準函數庫定義*/
+#include <stdint.h>
+#include <unistd.h>     /*Unix 標準函數定義*/
+#include <fcntl.h>      /*檔控制定義*/
+#include <termios.h>    /*PPSIX 終端控制定義*/
+#include <errno.h>      /*錯誤號定義*/
+#include <errno.h>
+#include <string.h>
+#include <time.h>
+#include <ctype.h>
+#include <ifaddrs.h>
+#include <math.h>
+#include <stdbool.h>
+
+#include "./ShareMemory/shmMem.h"
+#include "./Define/define.h"
+#include "./SelectGun/SelectGun.h"
+#include "Config.h"
+#include "./CSU/main.h"
+
+//------------------------------------------------------------------------------
+#define CMD_KEY_WAIT                                (1)
+#define CMD_KEY_DONT_WAIT                           (0)
+
+#define DEFAULT_AC_INDEX                            (2)
+
+#define AUTORUN_STEP1_TIME_START                    (140)             // Minutes
+#define AUTORUN_STEP1_TIME_END                      (150)
+#define AUTORUN_STEP2_TIME_START                    (210)
+#define AUTORUN_STEP2_TIME_END                      (410)
+#define AUTORUN_END_TIME                            (480)
+#define AUTORUN_CYCLE_COUNT                         (30)
+
+#define TTY_PATH                                    "/dev/tty"
+#define STTY_US                                     "stty raw -echo -F "
+#define STTY_DEF                                    "stty -raw echo -F "
+
+//------------------------------------------------------------------------------
+uint8_t _curAutoRunCount = 0;
+uint8_t _usingAutoRun = 0;
+struct timeval _autoTime;
+
+static struct SysConfigData *pSysConfig = NULL;
+static struct SysInfoData *pSysInfo = NULL;
+static struct WARNING_CODE_INFO *pSysWarning = NULL;
+
+static struct AlarmCodeData *pAlarmCode = NULL;
+
+static struct PrimaryMcuData *ShmPrimaryMcuData = NULL;
+static struct CHAdeMOData *ShmCHAdeMOData = NULL;
+static struct CcsData *ShmCcsData = NULL;
+static struct GBTData *ShmGBTData = NULL;
+static struct FanModuleData *ShmFanModuleData = NULL;
+static struct RelayModuleData *ShmRelayModuleData = NULL;
+static struct LedModuleData *ShmLedModuleData = NULL;
+static struct PsuData *ShmPsuData = NULL;
+static struct OCPP16Data *ShmOCPP16Data = NULL;
+static SelectGunInfo *ShmSelectGunInfo = NULL;
+static DcCommonInfo *ShmDcCommonData = NULL;
+
+static struct ChargingInfoData *pDcChargingInfo = NULL;
+static struct ChargingInfoData *pAcChargingInfo = NULL;
+
+static char newString[8][16] = {0};
+
+//------------------------------------------------------------------------------
+static int DiffTimeb(struct timeb ST, struct timeb ET)
+{
+    //return milli-second
+    unsigned int StartTime, StopTime;
+
+    StartTime = (unsigned int)ST.time;
+    StopTime = (unsigned int)ET.time;
+
+    return (StopTime - StartTime) * 1000 + ET.millitm - ST.millitm;
+}
+
+static void get_char(char *word)
+{
+    fd_set rfds;
+    struct timeval tv;
+
+    FD_ZERO(&rfds);
+    FD_SET(0, &rfds);
+    tv.tv_sec = 0;
+    tv.tv_usec = 10; //wait input timout time
+
+    //if input
+    if (select(1, &rfds, NULL, NULL, &tv) > 0) {
+        fgets(word, 128, stdin);
+    }
+}
+
+static uint8_t helpCmd(void)
+{
+    if (strcmp(newString[0], "?") == 0 ||
+            strcmp(newString[0], "help") == 0 ||
+            strcmp(newString[0], "h") == 0) {
+        return YES;
+    }
+
+    return NO;
+}
+
+static uint8_t exitCmd(void)
+{
+    if (strcmp(newString[0], "c") == EQUAL ||
+            strcmp(newString[0], "C") == EQUAL ||
+            strncmp(&newString[0][0], "exit", 4) == EQUAL
+       ) {
+        return YES;
+    }
+
+    return NO;
+}
+
+static uint8_t readCmdKey(uint8_t state)
+{
+    char word[128] = {0};
+    int i = 0, j = 0, ctr = 0;
+
+    memset(word, 0, sizeof(word));
+    if (state == CMD_KEY_WAIT) {
+        fgets(word, sizeof(word), stdin);
+    } else if (state == CMD_KEY_DONT_WAIT) {
+        get_char(word);
+
+        if (strlen(word) == 0) {
+            //usleep(50000);
+            return NO;
+        }
+    }
+
+    memset(newString, 0, sizeof(newString));
+
+    strcpy(newString[1], "-1");
+    strcpy(newString[2], "-1");
+    for (i = 0; i <= (strlen(word)); i++) {
+        if (word[i] == ' ' ||
+                word[i] == '\0' ||
+                word[i] == '\r' ||
+                word[i] == '\n' ||
+                word[i] == 10) {
+            newString[ctr][j] = '\0';
+            ctr++;
+            j = 0;
+        } else {
+            newString[ctr][j] = word[i];
+            j++;
+        }
+    }
+
+    return YES;
+}
+
+unsigned long GetTimeoutValue(struct timeval _sour_time)
+{
+    struct timeval _end_time;
+    gettimeofday(&_end_time, NULL);
+
+    return (_end_time.tv_sec - _sour_time.tv_sec);
+}
+
+void RunStatusProc(char *v1, char *v2)
+{
+    printf("OrderCharging = %d \n", pSysInfo->OrderCharging);
+    printf("WaitForPlugit = %d \n", pSysInfo->WaitForPlugit);
+    if (strcmp(v1, "ac") == 0) {
+        pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
+        //if (!FindAcChargingInfoData(0, &ac_chargingInfo[0])) {
+        //    printf("FindChargingInfoData (AC) false \n");
+        //}
+        printf("AC Status = %d \n", pAcChargingInfo->ConnectorPlugIn);
+        return;
+    }
+
+    int _index = atoi(v1);
+
+    if (_index <= 1) {
+        //if (!FindChargingInfoData(_index, &_chargingData[0])) {
+        //    printf ("FindChargingInfoData error\n");
+        //    return;
+        //}
+        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+
+        if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0) {
+            // get
+            printf ("index = %x, status = %x (%d)\n",
+                    _index,
+                    pDcChargingInfo->SystemStatus,
+                    pDcChargingInfo->IsAvailable);
+            printf ("SystemTimeoutFlag = %d, PageIndex = %d\n",
+                    pSysInfo->SystemTimeoutFlag, pSysInfo->PageIndex);
+        } else {
+            // set
+            pDcChargingInfo->SystemStatus = atoi(v2);
+        }
+    } else {
+        //if (!FindAcChargingInfoData(0, &ac_chargingInfo[0])) {
+        //    printf("FindChargingInfoData (AC) false \n");
+        //}
+        pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
+
+        if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0) {
+            // get
+            printf ("AC Type, status = %x (%d)\n",
+                    pAcChargingInfo->SystemStatus,
+                    pAcChargingInfo->IsAvailable);
+        } else {
+            // set
+            pAcChargingInfo->SystemStatus = atoi(v2);
+        }
+    }
+}
+
+void RunCardProc(char *v1, char *v2)
+{
+    if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0) {
+        if (pSysInfo->WaitForPlugit) {
+            pSysInfo->WaitForPlugit = 0x00;
+            printf ("SysInfo.WaitForPlugit = %x \n", pSysInfo->WaitForPlugit);
+        } else {
+            pSysInfo->WaitForPlugit = 0x01;
+            printf ("SysInfo.WaitForPlugit = %x \n", pSysInfo->WaitForPlugit);
+        }
+    } else {
+        strcpy((char *)pSysConfig->UserId, "");
+        memcpy((char *)pSysConfig->UserId, v1, strlen(v1));
+        pSysConfig->UserId[strlen(v1)] = '\0';
+        printf("StartUserId = %s \n", pSysConfig->UserId);
+    }
+}
+
+void RunGunPlugitProc(char *v1, char *v2)
+{
+    if (strcmp(v1, "ac") == 0) {
+        //if (!FindAcChargingInfoData(0, &ac_chargingInfo[0])) {
+        //    printf("FindChargingInfoData (AC) false \n");
+        //}
+        pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
+
+        if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0) {
+            // get
+            printf("ConnectorPlugIn = %d \n", pAcChargingInfo->ConnectorPlugIn);
+        } else {
+            // set
+            pAcChargingInfo->ConnectorPlugIn = atoi(v2);
+        }
+        return;
+    }
+
+    int _index = atoi(v1);
+    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
+    //    printf("FindChargingInfoData error\n");
+    //    return;
+    //}
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+
+    if (strcmp(v2, "-1") == 0 || strcmp(v2, "") == 0) {
+        // get
+        printf("index = %x, plug it = %x\n",
+               _index,
+               pDcChargingInfo->ConnectorPlugIn);
+    } else {
+        // set
+        pDcChargingInfo->ConnectorPlugIn = atoi(v2);
+    }
+}
+
+void GetGunLockStatusProc(char *v1, char *v2)
+{
+    int _index = atoi(v1);
+    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
+    //    printf("FindChargingInfoData error\n");
+    //    return;
+    //}
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+
+    if (strcmp(v2, "-1") != 0 && strcmp(v2, "") != 0) {
+        pDcChargingInfo->GunLocked = atoi(v2);
+    }
+
+    printf("Gun Locked Status = %d \n", pDcChargingInfo->GunLocked);
+}
+
+void SetSystemIDProc()
+{
+    char *systemId = "Alston_Test";
+    memcpy(&pSysConfig->SystemId, systemId, strlen(systemId));
+}
+
+void RunSelfProc()
+{
+    printf("self test status = %x\n", pSysInfo->SelfTestSeq);
+}
+
+void GetFwVerProc(void)
+{
+    int _index = 0;
+    int isContinue = 1;
+    char *usageMsg = "Usage:\n"
+                     "      model\n"
+                     "      407\n"
+                     "      conn index, ex: conn 0 | 1\n"
+                     "      relay\n"
+                     "      fan\n"
+                     "      dc\n"
+                     "      led\n"
+                     "      ac\n"
+                     "      exit | c | C\n"
+                     "      help | ? | h\n";
+
+    while (isContinue) {
+        if (readCmdKey(CMD_KEY_WAIT) == NO) {
+            continue;
+        }
+
+        if (strcmp(newString[0], "407") == 0) {
+            printf("407 FW Version = %s\n", ShmPrimaryMcuData->version);
+        } else if (strcmp(newString[0], "model") == 0) {
+            printf("ModelName = %s\r\n", pSysConfig->ModelName);
+        } else if (strcmp(newString[0], "conn") == 0) {
+            if (strcmp(newString[1], "-1") == 0  ||
+                    strcmp(newString[1], "") == 0 ||
+                    atoi(newString[1]) >= pSysConfig->TotalConnectorCount
+               ) {
+                printf("index over flow\r\n");
+                continue;
+            }
+
+            _index = atoi(newString[1]);
+
+            if (_index == 0) {
+                printf("Gun 0 FW Version = %s \n", pSysInfo->Connector1FwRev);
+            } else if (_index == 1) {
+                printf("Gun 1 FW Version = %s \n", pSysInfo->Connector2FwRev);
+            }
+        } else if (strcmp(newString[0], "relay") == 0) {
+            printf("RB Version = %s \n", pSysInfo->RelayModuleFwRev);
+        } else if (strcmp(newString[0], "fan") == 0) {
+            printf("FAN Version = %s \n", pSysInfo->FanModuleFwRev);
+        } else if (strcmp(newString[0], "dc") == 0) {
+            printf("DC Main Version = %s \n", pSysInfo->CsuRootFsFwRev);
+        } else if (strcmp(newString[0], "led") == 0) {
+            printf("LED Version = %s \n", pSysInfo->LedModuleFwRev);
+        } else if (strcmp(newString[0], "ac") == 0) {
+            pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(0);
+
+            printf("AC Version = %s \n", pAcChargingInfo->version);
+        } else if (exitCmd() == YES) {
+            return;
+        } else if (helpCmd() == YES) {
+            printf ("%s\n", usageMsg);
+        }
+
+    }//while
+}
+
+void CreateOneError(char *v1)
+{
+    int value = atoi(v1);
+
+    pAlarmCode->AlarmEvents.bits.SystemL1InputOVP = value;
+    pSysConfig->BillingData.isBilling = value;
+}
+
+void GetAuthorizeFlag(char *v1)
+{
+    if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0) {
+        printf("AuthorizeFlag = %d \n", pSysInfo->AuthorizeFlag);
+    } else {
+        pSysInfo->AuthorizeFlag = atoi(v1);
+    }
+}
+
+void GetRelayStatus(char *v1)
+{
+    int _index = atoi(v1);
+    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
+    //    printf("FindChargingInfoData error\n");
+    //    return;
+    //}
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+
+    printf("RelayK1K2Status = %d \n", pDcChargingInfo->RelayK1K2Status);
+    printf("RelayKPK2Status = %d \n", pDcChargingInfo->RelayKPK2Status);
+}
+
+void FwUpdateFlagProc()
+{
+    pSysInfo->FirmwareUpdate = 0x01;
+}
+
+void CheckAcStatus(char *v1)
+{
+    if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0) {
+        printf("AC Status = %d \n", pSysInfo->AcContactorStatus);
+    }
+}
+
+void SetCableChkStatus(char *v1, char *v2)
+{
+    int _index = atoi(v1);
+    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
+    //    printf ("FindChargingInfoData error\n");
+    //    return;
+    //}
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+
+    pDcChargingInfo->GroundFaultStatus = atoi(v2);
+}
+
+void SetChargingInfoCCID(char *v1, char *v2)
+{
+    int _index = atoi(v1);
+    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
+    //    printf ("FindChargingInfoData error\n");
+    //    return;
+    //}
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+
+    memcpy(pDcChargingInfo->EVCCID, v2, 8);
+    pDcChargingInfo->EVCCID[8] = '\0';
+}
+
+void SetPowerValue(char *v1, char *v2)
+{
+    int _index = atoi(v1);
+    float _Current = atof(v2);
+
+    //if (!FindChargingInfoData(_index, &_chargingData[0])) {
+    //    printf ("FindChargingInfoData error\n");
+    //    return;
+    //}
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_index);
+
+    // 盲沖的時候才允許使用~
+    if (pDcChargingInfo->Type != 9) {
+        return;
+    }
+
+    pDcChargingInfo->EvBatterytargetCurrent = _Current;
+}
+
+void GetSystemInfo()
+{
+    printf ("ModelName = %s \n", pSysConfig->ModelName);
+    printf ("SerialNumber = %s \n", pSysConfig->SerialNumber);
+    printf ("InternetConn = %d \n", pSysInfo->InternetConn);
+
+    printf ("MaxChargingPower = %d, MaxChargingCurrent = %d \n",
+            pSysConfig->MaxChargingPower,
+            pSysConfig->MaxChargingCurrent);
+}
+
+void ChangeGunNum()
+{
+    if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount) {
+        pSysInfo->CurGunSelected += 1;
+        pSysInfo->CurGunSelectedByAc = NO_DEFINE;
+    } else if (pSysConfig->AcConnectorCount > 0 &&
+               pSysInfo->CurGunSelectedByAc == NO_DEFINE) {
+        pSysInfo->CurGunSelectedByAc = DEFAULT_AC_INDEX;
+    } else {
+        pSysInfo->CurGunSelected = 0;
+        pSysInfo->CurGunSelectedByAc = NO_DEFINE;
+    }
+}
+
+void GetGunSelectedNum(char *v1)
+{
+    if (strcmp(v1, "-1") == 0 || strcmp(v1, "") == 0) {
+        if (AC_QUANTITY > 0 &&
+                pSysInfo->CurGunSelectedByAc != NO_DEFINE) {
+            printf("connector select changed = AC \n");
+        } else {
+            printf("connector selected = %d \n", pSysInfo->CurGunSelected);
+        }
+    } else {
+        int _index = atoi(v1);
+        if (_index <= 1) {
+            pSysInfo->CurGunSelected = _index;
+            pSysInfo->CurGunSelectedByAc = NO_DEFINE;
+            printf("connector select changed = %d \n", _index);
+        } else if (AC_QUANTITY > 0) {
+            pSysInfo->CurGunSelectedByAc = DEFAULT_AC_INDEX;
+            printf("connector select changed = AC \n");
+        }
+    }
+}
+
+void SetFanSpeed(char *v1)
+{
+    int speed = atoi(v1);
+
+    ShmFanModuleData->TestFanSpeed = speed;
+}
+
+void GetFanSpeed()
+{
+    printf("ShmFanModuleData->PresentFan1Speed = %d \n", ShmFanModuleData->PresentFan1Speed);
+    printf("ShmFanModuleData->PresentFan2Speed = %d \n", ShmFanModuleData->PresentFan2Speed);
+    printf("ShmFanModuleData->PresentFan3Speed = %d \n", ShmFanModuleData->PresentFan3Speed);
+    printf("ShmFanModuleData->PresentFan4Speed = %d \n", ShmFanModuleData->PresentFan4Speed);
+}
+
+void SetDebugMode(char *v1)
+{
+    int mode = atoi(v1);
+
+    pSysConfig->SwitchDebugFlag = mode;
+}
+
+void SetGFDMode(char *v1)
+{
+    int mode = atoi(v1);
+
+    pSysConfig->AlwaysGfdFlag = mode;
+}
+
+void GetPsuTemp()
+{
+    for (uint8_t index = 0; index < ShmPsuData->GroupCount; index++) {
+        for (uint8_t count = 0; count < ShmPsuData->PsuGroup[index].GroupPresentPsuQuantity; count++) {
+            printf("PSU Temp = %d \n", ShmPsuData->PsuGroup[index].PsuModule[count].ExletTemp);
+        }
+    }
+}
+
+void GetAcInputVol()
+{
+    printf("L1N_L12 = %f, L2N_L23 = %f, L3N_L31 = %f \n",
+           pSysInfo->InputVoltageR,
+           pSysInfo->InputVoltageS,
+           pSysInfo->InputVoltageT);
+}
+
+void GetPsuInformation(char *v1, char *v2, char *v3)
+{
+    printf("**********************AC Contact needed*************************\n");
+    if (strcmp(v1, "count") == 0) {
+        for (int i = 0; i < 4; i++) {
+            printf("Group Index = %d, Module Count = %d \n",
+                   i,
+                   ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity);
+        }
+    } else if (strcmp(v1, "ver") == 0) {
+        for (int i = 0; i < ShmPsuData->SystemPresentPsuQuantity; i++) {
+            printf("Psu Index = %d, PriVersion = %s, SecVersion = %s \n",
+                   i, ShmPsuData->PsuVersion[i].FwPrimaryVersion,
+                   ShmPsuData->PsuVersion[i].FwSecondVersion);
+        }
+
+        for (int i = 0; i < ShmPsuData->GroupCount; i++) {
+            for (int j = 0; j < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; j++) {
+                printf("Group Index = %d, Psu Index = %d, Version = %s \n",
+                       i,
+                       j,
+                       ShmPsuData->PsuGroup[i].PsuModule[j].FwVersion);
+            }
+        }
+    } else if (strcmp(v1, "cap") == 0) {
+        for (int i = 0; i < ShmPsuData->GroupCount; i++) {
+            printf("Group Index = %d, MaxCur = %d, Power = %d \n",
+                   i,
+                   ShmPsuData->PsuGroup[i].GroupAvailableCurrent,
+                   ShmPsuData->PsuGroup[i].GroupAvailablePower);
+        }
+    } else if (strcmp(v1, "input") == 0) {
+        for (int i = 0; i < ShmPsuData->GroupCount; i++) {
+            for (uint8_t count = 0; count < ShmPsuData->PsuGroup[i].GroupPresentPsuQuantity; count++) {
+                printf("gp = %d, Index = %d, volR = %d, volS = %d, volT = %d \n",
+                       i,
+                       count,
+                       ShmPsuData->PsuGroup[i].PsuModule[count].InputVoltageL1,
+                       ShmPsuData->PsuGroup[i].PsuModule[count].InputVoltageL2,
+                       ShmPsuData->PsuGroup[i].PsuModule[count].InputVoltageL3);
+            }
+        }
+    } else if (strcmp(v1, "output") == 0) {
+        for (int i = 0; i < ShmPsuData->GroupCount; i++) {
+            printf("Group Index = %d, OutputV = %d, OutputC = %d \n",
+                   i,
+                   ShmPsuData->PsuGroup[i].GroupPresentOutputVoltage,
+                   ShmPsuData->PsuGroup[i].GroupPresentOutputCurrent);
+        }
+
+        for (int i = 0; i < pSysConfig->TotalConnectorCount; i++) {
+            //if (!FindChargingInfoData(i, &_chargingData[0])) {
+            //    printf ("FindChargingInfoData error\n");
+            //    continue;
+            //}
+            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
+
+            printf("Form RB : Group Index = %d, OutputV = %f \n",
+                   i,
+                   pDcChargingInfo->FireChargingVoltage);
+        }
+    } else if (strcmp(v1, "test") == 0) {
+        int mode = atoi(v2);
+
+        if (mode >= _TEST_MODE && mode <= _TEST_MODE) {
+            ShmPsuData->Work_Step = mode;
+        }
+    } else if (strcmp(v1, "out") == 0) {
+        float vol = atof(v2);
+        float cur = atof(v3);
+
+        if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE) {
+            //if (!FindChargingInfoData(0, &_chargingData[0])) {
+            //    printf ("FindChargingInfoData error\n");
+            //    return;
+            //}
+            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(0);
+
+            pDcChargingInfo->EvBatterytargetVoltage = vol;
+            pDcChargingInfo->EvBatterytargetCurrent = cur;
+        }
+    }
+    printf("*************************************************\n");
+}
+
+void GetConnectorCapInfo(char *v1)
+{
+    int _GunIndex = atoi(v1);
+
+    //if (!FindChargingInfoData(_GunIndex, &_chargingData[0])) {
+    //    printf ("FindChargingInfoData error\n");
+    //    return;
+    //}
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
+
+    printf ("Charger Max Current = %d, Max Power = %d \n",
+            pSysConfig->MaxChargingCurrent * 10,
+            pSysConfig->MaxChargingPower * 10);
+
+    printf ("Index = %d, MaxPow = %f, MaxVol = %f, MaxCur = %f\n",
+            _GunIndex,
+            pDcChargingInfo->RealMaxPower,
+            pDcChargingInfo->RealMaxVoltage,
+            pDcChargingInfo->RealMaxCurrent);
+}
+
+static void setConfirmSelGun(uint8_t selGun)
+{
+    if (selGun == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_RELEASE) {
+        ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
+        //printf("confirmSelGun left\r\n");
+    } else if (selGun == RIGHT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_RELEASE) {
+        ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
+        //printf("confirmSelGun right\r\n");
+    }
+}
+
+void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
+{
+    int _GunIndex;
+    uint8_t gunIndex = 0;
+    uint8_t stopChg = 0;
+    uint8_t curGun = 0;
+    int isContinue = 1;
+    float _Voltage;
+    float _Current;
+    uint8_t PreviousSystemStatus[2] = {0xff};
+    char *usageMsg = "Usage:\n"
+                     "       strchg <index> <voltage> <current>    ex: strchg 0 150 2\n"
+                     "       chg    <voltage> <current>            ex: chg 500 100\n"
+                     "       c      <index>                        ex: c 0\n"
+                     "       help | ? | h\n"
+                     "\r\n";
+
+    if (strcmp(v1, "auto") == EQUAL) {
+        _usingAutoRun = 0x01;
+        _GunIndex = 0;
+        _Voltage = 500;
+        _Current = (pSysConfig->MaxChargingPower * 1000) / _Voltage;
+    } else {
+        _usingAutoRun = 0x00;
+        _GunIndex = atoi(v1);
+        _Voltage = atof(v2);
+        _Current = atof(v3);
+    }
+
+    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
+
+    printf("Power = %d, ReqVoltage = %f, ReqCurrent = %f\n",
+           pSysConfig->MaxChargingPower,
+           _Voltage,
+           _Current);
+
+    if (_Voltage > 1000 || _Voltage < 50) {
+        printf ("Input Voltage over range\n");
+        return;
+    }
+
+    //kill ev task
+    system("killall Module_EvComm");
+
+    pSysInfo->CurGunSelected = _GunIndex;
+
+    while (isContinue) {
+
+        curGun = pSysInfo->CurGunSelected;
+        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(curGun);
+
+        //fix gun 1
+        switch (pDcChargingInfo->SystemStatus) {
+        case S_IDLE:
+            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
+                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
+#if defined DD360Audi
+                setConfirmSelGun(curGun);
+#endif //defined DD360Audi
+
+                strcpy((char *)pSysConfig->UserId, "AutoStartCharging");
+                pDcChargingInfo->ConnectorPlugIn = 1;
+                printf ("[UnconditionalCharge - S_IDLE]\n");
+                pDcChargingInfo->Type = 9;
+
+            }
+            if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf == 1) {
+                pSysInfo->StartToChargingFlag = 0x01;
+                pDcChargingInfo->SystemStatus = S_PREPARNING;
+            }
+            break;
+
+        case S_PREPARNING:
+            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
+                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
+
+                printf ("[UnconditionalCharge - S_PREPARNIN]\n");
+
+                //等待 AC Relay 搭上且找到模組 (main 在此 statue 其它 task 會去做完)
+                printf ("wait find module\n");
+
+            }
+            //main 會在此階段判斷以下資料跳到下一個 state
+            //用來得知 AC 是否有搭上 (搭上模組的資訊才會出來) 因為每次  AC_Contactor
+            //ShmPsuData->SystemPresentPsuQuantity;
+            //ShmPsuData->PsuGroup[gun_index].GroupPresentPsuQuantity;
+            //ShmPsuData->PsuGroup[gun_index].GroupAvailablePower;
+            //_chargingData[gun_index]->AvailableChargingPower;
+
+            //等待 AC Relay 搭上且找到模組 (main 在此 statue 其它 task 會去做完)
+            //sleep(10);
+
+            //清除 main timeout 機制
+            pDcChargingInfo->TimeoutFlag = 0;
+            //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
+            pDcChargingInfo->Type = 9;
+            break;
+
+        case S_PREPARING_FOR_EV:
+            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
+                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
+
+                printf ("[UnconditionalCharge - S_PREPARING_FOR_EV]\n");
+                printf ("ReqVoltage = %f, ReqCurrent = %f \n", _Voltage * 10, _Current * 10);
+
+            }
+            //清除 main timeout 機制
+            pDcChargingInfo->TimeoutFlag = 0;
+            //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
+            pDcChargingInfo->Type = 9;
+
+            //充電電壓電流
+            pDcChargingInfo->EvBatterySoc             = 50;
+            pDcChargingInfo->EvBatterytargetVoltage   = 500;
+            pDcChargingInfo->EvBatterytargetCurrent   = 2;
+            pDcChargingInfo->AvailableChargingCurrent = 1000;
+
+            //****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
+            //確定模組己升壓完成
+            //if(pDcChargingInfo->PresentChargingVoltage <=  (3000+500) &&
+            //  pDcChargingInfo->PresentChargingVoltage >=  (3000-500) )
+            {
+                printf ("Precharge Done = %f \n",
+                        pDcChargingInfo->PresentChargingVoltage);
+                //EV done
+                pDcChargingInfo->SystemStatus = S_PREPARING_FOR_EVSE;
+            }
+            break;
+
+        case S_PREPARING_FOR_EVSE:
+            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
+                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
+
+                printf ("[UnconditionalCharge - S_PREPARING_FOR_EVSE]\n");
+
+            }
+            //printf ("tar vol = %d \n", _Voltage);
+            //printf ("tar cur = %d \n", _Current);
+
+            //清除 main timeout 機制
+            pDcChargingInfo->TimeoutFlag = 0;
+            //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
+            pDcChargingInfo->Type = 9;
+
+            //充電電壓電流
+            pDcChargingInfo->EvBatterySoc = 50;
+            pDcChargingInfo->EvBatterytargetVoltage = 500;
+            pDcChargingInfo->EvBatterytargetCurrent = 2;
+            pDcChargingInfo->AvailableChargingCurrent = 1000;
+
+            //printf ("tar vol_ = %d \n", pDcChargingInfo->EvBatterytargetVoltage);
+            // printf ("tar cur_ = %d \n", pDcChargingInfo->EvBatterytargetCurrent);
+
+            //****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
+            //確定模組己升壓完成
+            if (pDcChargingInfo->GroundFaultStatus == 0x01 ||
+                    pDcChargingInfo->GroundFaultStatus == 0x03) {
+                printf ("First Ground Fault State (%d)\n",
+                        pDcChargingInfo->GroundFaultStatus);
+                printf ("Wait K1K2 = %f \n", pDcChargingInfo->PresentChargingVoltage);
+                sleep(5);
+                //EV done
+                pDcChargingInfo->SystemStatus = S_CHARGING;
+            } else if (pDcChargingInfo->GroundFaultStatus > 0x02) {
+                printf ("First Ground Fault check Fail (%d)\n",
+                        pDcChargingInfo->GroundFaultStatus);
+                pDcChargingInfo->SystemStatus = S_TERMINATING;
+            }
+            break;
+
+        case S_CHARGING:
+            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
+                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
+
+                if (_usingAutoRun == 0x00) {
+                    //充電電壓電流
+                    pDcChargingInfo->EvBatterytargetVoltage = _Voltage;
+                    pDcChargingInfo->EvBatterytargetCurrent = _Current;
+                } else {
+                    _curAutoRunCount = 0;
+                    gettimeofday(&_autoTime, NULL);
+                }
+
+                pDcChargingInfo->EvBatterySoc = 50;
+                pDcChargingInfo->AvailableChargingCurrent = 1000;
+
+                printf ("[UnconditionalCharge - S_CHARGING]\n");
+            }
+
+            if (_usingAutoRun == 0x01) {
+                if (((GetTimeoutValue(_autoTime)) >= AUTORUN_STEP1_TIME_START * 60 &&
+                        (GetTimeoutValue(_autoTime)) <= AUTORUN_STEP1_TIME_END * 60) ||
+                        ((GetTimeoutValue(_autoTime)) >= AUTORUN_STEP2_TIME_START * 60 &&
+                         (GetTimeoutValue(_autoTime)) <= AUTORUN_STEP2_TIME_END * 60)
+                   ) {
+                    pDcChargingInfo->EvBatterytargetVoltage = _Voltage;
+                    pDcChargingInfo->EvBatterytargetCurrent = _Current;
+                } else if ((GetTimeoutValue(_autoTime)) >= AUTORUN_END_TIME * 60) {
+                    _curAutoRunCount++;
+                    if (_curAutoRunCount >= AUTORUN_CYCLE_COUNT) {
+                        pDcChargingInfo->SystemStatus = S_TERMINATING;
+                    } else {
+                        gettimeofday(&_autoTime, NULL);
+                    }
+                } else {
+                    pDcChargingInfo->EvBatterytargetVoltage = 0;
+                    pDcChargingInfo->EvBatterytargetCurrent = 0;
+                }
+            }
+
+//              printf("out : vol = %f, cur = %f \n",
+//                      pDcChargingInfo->EvBatterytargetVoltage,
+//                      pDcChargingInfo->EvBatterytargetCurrent);
+            //ev task do this
+            pDcChargingInfo->PresentChargingPower =
+                ((float)((pDcChargingInfo->PresentChargingVoltage) *
+                         (pDcChargingInfo->PresentChargingCurrent)) / 1000);
+
+            if (pDcChargingInfo->GroundFaultStatus == 0x02) {
+                printf ("Charging Ground Fault check Fail (%d)\n",
+                        pDcChargingInfo->GroundFaultStatus);
+                pDcChargingInfo->SystemStatus = S_TERMINATING;
+            }
+            break;
+
+        case S_TERMINATING:
+            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
+                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
+
+                printf ("[UnconditionalCharge - S_TERMINATING]\n");
+                //無阻塞偵測 keybaord 結束
+                system(STTY_DEF TTY_PATH);
+            }
+
+            pDcChargingInfo->SystemStatus = S_COMPLETE;
+            break;
+
+        case S_COMPLETE:
+            if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
+                PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
+
+                printf ("[UnconditionalCharge - S_COMPLETE]\n");
+            }
+
+            PreviousSystemStatus[curGun] = 0xFF;
+            stopChg = 0;
+            for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
+                if (PreviousSystemStatus[gunIndex] == 0xFF) {
+                    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(curGun);
+                    pDcChargingInfo->SystemStatus = S_IDLE;
+                } else {
+                    pSysInfo->CurGunSelected = gunIndex;
+                }
+
+                pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
+                if (pDcChargingInfo->SystemStatus == S_IDLE) {
+                    stopChg++;
+                }
+            }
+
+            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(curGun);
+            pDcChargingInfo->PresentChargingPower = 0;
+
+            if (stopChg == pSysConfig->TotalConnectorCount) {
+                system("/root/Module_EvComm &");
+                sleep(3);
+
+                for (_GunIndex = 0; _GunIndex < pSysConfig->TotalConnectorCount; _GunIndex++) {
+                    pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
+
+                    pDcChargingInfo->SystemStatus = S_IDLE;
+                }
+                return;
+            }
+            break;
+        }
+
+        if (readCmdKey(CMD_KEY_DONT_WAIT) == NO) {
+            continue;
+        }
+
+        if (strcmp(newString[0], "strchg") == 0) {
+            if (strcmp(newString[1], "-1") == 0 ||
+                    strcmp(newString[1], "") == 0 ||
+                    strcmp(newString[2], "-1") == 0 ||
+                    strcmp(newString[2], "") == 0
+               ) {
+                printf ("Input cmd fail ------  strchg [vol 150-1000] [cru 2-100]\n");
+                continue;
+            }
+
+            if (atoi(newString[1]) == pSysInfo->CurGunSelected) {
+                continue;
+            }
+
+            _GunIndex = atoi((char *)newString[1]);
+            _Voltage = atof((char *)newString[2]);
+            _Current = atof((char *)newString[3]);
+
+            printf ("Power = %d, ReqVoltage = %f, ReqCurrent = %f\n",
+                    pSysConfig->MaxChargingPower,
+                    _Voltage,
+                    _Current);
+
+            if (_Voltage > 1000 || _Voltage < 50) {
+                _Voltage = 200;
+                printf ("Input Voltage over range\n");
+                continue;
+            }
+
+            pSysInfo->CurGunSelected = _GunIndex;
+            strcpy((char *)pSysConfig->UserId, "");
+        } else if (strcmp(newString[0], "chg") == 0) {
+            if (strcmp(newString[1], "-1") == 0) {
+                continue;
+            }
+
+            if (strcmp(newString[2], "-1") == 0 ||
+                    strcmp(newString[2], "") == 0) {
+                continue;
+            }
+
+            if (strcmp(newString[3], "-1") == 0 ||
+                    strcmp(newString[3], "") == 0) {
+                continue;
+            }
+
+            _GunIndex = atoi((char *)newString[1]);
+            float _vol = atof(newString[2]);
+            float _cur = atof(newString[3]);
+
+            if (_cur <= 0 || _cur <= 0) {
+                continue;
+            }
+
+            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
+
+            printf("reset vol = %f, cur = %f \n", _vol, _cur);
+            pDcChargingInfo->EvBatterytargetVoltage = _vol;
+            pDcChargingInfo->EvBatterytargetCurrent = _cur;
+        } else if (strcmp(newString[0], "c") == 0) {
+            if (strcmp(newString[1], "-1") == 0 ||
+                    strcmp(newString[1], "") == 0) {
+                printf("argc 1 is error parameter\r\n");
+                continue;
+            }
+
+            if (atoi((char *)newString[1]) != -1) {
+                pSysInfo->CurGunSelected = atoi((char *)newString[1]);
+            }
+            printf("stop \n\r");
+
+            pSysInfo->StartToChargingFlag = 0x00;
+
+            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData( pSysInfo->CurGunSelected);
+
+            pDcChargingInfo->SystemStatus = S_TERMINATING;
+        } else if (helpCmd() == YES) {
+            printf("%s\n", usageMsg);
+        }
+
+        usleep(100000);
+    }
+}
+
+int printTimeMsg(const char *fmt, ...)
+{
+    char Buf[4096 + 256] = {0};
+    char buffer[4096] = {0};
+    int rc = -1;
+    va_list args;
+    struct timeb  SeqEndTime;
+    struct tm *tm;
+    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
+
+    va_start(args, fmt);
+    rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
+    va_end(args);
+
+    ftime(&SeqEndTime);
+    SeqEndTime.time = time(NULL);
+    tm = localtime(&SeqEndTime.time);
+
+    sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
+            tm->tm_hour,
+            tm->tm_min,
+            tm->tm_sec,
+            SeqEndTime.millitm,
+            buffer);
+    printf("%s", Buf);
+
+    return rc;
+}
+
+static void resdGunAndChillerTemp(void)
+{
+    int isContinue = 1;
+    uint8_t i = 0;
+    uint32_t sleepTime = 500000;
+    uint32_t loopTime = 1000;
+    struct timeb showTime;
+    struct timeb nowTime;
+
+    char *usageMsg = "Usage:\n"
+                     "       t <index>: loop time, ex: t 1\n"
+                     "       exit | c | C: exit test\n"
+                     "       h | help | ?: show usage message\n"
+                     "\r\n";
+
+    ftime(&showTime);
+
+    while (isContinue) {
+        ftime(&nowTime);
+
+        if (DiffTimeb(showTime, nowTime) > loopTime ||
+                DiffTimeb(showTime, nowTime) < 0) {
+            for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
+
+                pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
+
+                printTimeMsg("get gun %d temp = %3d, chiller = %3d, ConnTemp = %3d, %3d,SysTemp = %3d, %3d, %3d, %3d\r\n",
+                             i,
+                             pDcChargingInfo->ConnectorTemp,
+                             pDcChargingInfo->ChillerTemp,
+                             ShmDcCommonData->ConnectorTemp[i][0],
+                             ShmDcCommonData->ConnectorTemp[i][1],
+                             ShmDcCommonData->SystemTemp[0],
+                             ShmDcCommonData->SystemTemp[1],
+                             ShmDcCommonData->SystemTemp[2],
+                             ShmDcCommonData->SystemTemp[3]);
+            }//for
+            ftime(&showTime);
+        }
+
+        if (readCmdKey(CMD_KEY_DONT_WAIT) == NO) {
+            usleep(sleepTime);
+            continue;
+        }
+
+        if (strcmp(newString[0], "t") == 0) {
+            if (strcmp(newString[1], "-1") == 0 ||
+                    strcmp(newString[1], "") == 0 ||
+                    atoi((char *)newString[1]) > 255
+               ) {
+                printf("argc 1 is error parameter\r\n");
+                continue;
+            }
+
+            loopTime = ((atoi((char *)newString[1])) * 1000);
+            printf("loopTime = %d\r\n", loopTime);
+            ftime(&showTime);
+            continue;
+        } else if (exitCmd() == YES) {
+            return;
+        } else if (helpCmd() == YES) {
+            printf ("%s\n", usageMsg);
+        }
+
+        usleep(sleepTime);
+    }//while
+}
+
+static void writeGunAndChillerTemp(void)
+{
+    uint8_t _GunIndex = 0;
+    int isContinue = 1;
+    uint32_t sleepTime = 500000;
+    char *usageMsg = "Usage:\n"
+                     "       conn    <index> <temp>, ex: conn 0 150\n"
+                     "       chiller <index> <temp>, ex: chiller 0 150\n"
+                     "       tempR\n"
+                     "       exit | c | C\n"
+                     "       help | ? | h\n"
+                     "\r\n";
+
+    ShmDcCommonData->TestTemperature = YES;
+
+    while (isContinue) {
+        if (readCmdKey(CMD_KEY_WAIT) == NO) {
+            sleep(sleepTime);
+            continue;
+        }
+
+        if (helpCmd() == YES) {
+            printf ("%s\n", usageMsg);
+            continue;
+        } else if (exitCmd() == YES) {
+            ShmDcCommonData->TestTemperature = NO;
+            sleep(1);
+            return;
+        } else if (strcmp(newString[0], "tempR") == 0) {
+            resdGunAndChillerTemp();
+        }
+
+        if ((strcmp(newString[0], "chiller") != 0) &&
+                (strcmp(newString[1], "-1") == 0 ||
+                 strcmp(newString[1], "") == 0)
+           ) {
+            printf("argc 1 is error parameter\r\n");
+            continue;
+        }
+
+        if (atoi(newString[2]) > 255 ||
+                atoi(newString[2]) == -1) {
+            printf("temperature value overflow\r\n");
+            continue;
+        }
+
+        _GunIndex = atoi((char *)newString[1]);
+
+        if (_GunIndex >= pSysConfig->TotalConnectorCount) {
+            printf("gun index over total connector\r\n");
+            continue;
+        }
+
+        if (strcmp(newString[0], "chiller") == 0) {//修改水冷機溫度值
+            if (_GunIndex >= 1) {
+                _GunIndex = 0; //只會有一個水冷機
+            }
+
+            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
+            pDcChargingInfo->ChillerTemp = atoi(newString[2]);
+            printf("set %d chiller temperature = %d\r\n",
+                   _GunIndex,
+                   pDcChargingInfo->ChillerTemp);
+        } else if (strcmp(newString[0], "conn") == 0) {//修改槍頭溫度值
+            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
+
+            pDcChargingInfo->ConnectorTemp = atoi(newString[2]);
+            printf("set %d connector temp = %d\r\n",
+                   _GunIndex,
+                   pDcChargingInfo->ConnectorTemp);
+        }
+
+        usleep(sleepTime);
+    }//while
+}
+
+int main(void)
+{
+    uint8_t _GunIndex = 0;
+    int isContinue = 1;
+    char *usageMsg = "Usage:\n"
+                     "       state <index>                     : get gun state\n"
+                     "       card                              : scanning card (x)\n"
+                     "       gun <index>                       : get gun plugit state\n"
+                     "       lock <index>                      : get gun locked state\n"
+                     "       sysid                             : test system ID\n"
+                     "       self                              : self test state (x)\n"
+                     "       version | v | -v                  : version of board (407 or relay or other)\n"
+                     "       update                            : update firmware\n"
+                     "       ac                                : get ac relay state (x) \n"
+                     "       cable <index> <state>             : set ground fault state\n"
+                     "       pow <index> <power>               : set power value\n"
+                     "       model                             : get system information\n"
+                     "       temp                              : get PSU temperature\n"
+                     "       fan <speed>                       : set fan board speed\n"
+                     "       strchg <auto>                     : auto test charging\n"
+                     "       strchg <index> <voltage <current> : select gun test charging\n"
+                     "       tempW                             : write connector header and Chiller temperature\r\n"
+                     "       tempR                             : print connector header and chiller temperature\r\n"
+    			     "       btnl                              : press left button\n"
+    			  	 "       btnr                              : press right button\n"
+                     "\r\n";
+
+    if (CreateAllCsuShareMemory() == FAIL) {
+        printf("create share memory error\r\n");
+        return FAIL;
+    }
+
+    MappingGunChargingInfo("ReadCmdline Task");
+
+    pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
+    pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
+    pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
+
+    pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
+
+    ShmCHAdeMOData = (struct CHAdeMOData *)GetShmCHAdeMOData();
+    ShmGBTData = (struct GBTData *)GetShmGBTData();
+    ShmCcsData = (struct CcsData *)GetShmCcsData();
+
+    ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
+    ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();
+    ShmRelayModuleData = (struct RelayModuleData *)GetShmRelayModuleData();
+    ShmLedModuleData = (struct LedModuleData *)GetShmLedModuleData();
+    ShmPsuData = (struct PsuData *)GetShmPsuData();
+    ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
+    ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
+    ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
+
+//    for (_GunIndex = 0; _GunIndex < pSysConfig->TotalConnectorCount; _GunIndex++) {
+//        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
+
+//        pDcChargingInfo->SystemStatus = S_IDLE;
+//    }
+
+    while (isContinue) {
+        if (readCmdKey(CMD_KEY_WAIT) == NO) {
+            continue;
+        }
+
+        if (strcmp(newString[0], "state") == 0) {
+            if (strcmp(newString[1], "-1") == 0 ||
+                    strcmp(newString[1], "") == 0) {
+                continue;
+            }
+
+            // 槍狀態
+            RunStatusProc(newString[1], newString[2]);
+        } else if (strcmp(newString[0], "card") == 0) {
+            // 刷卡狀態
+            RunCardProc(newString[1], newString[2]);
+        } else if (strcmp(newString[0], "gun") == 0) {
+            if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
+                continue;
+            }
+
+            // 插槍狀態
+            RunGunPlugitProc(newString[1], newString[2]);
+        } else if (strcmp(newString[0], "lock") == 0) {
+            if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
+                continue;
+            }
+
+            // 插槍狀態
+            GetGunLockStatusProc(newString[1], newString[2]);
+        } else if (strcmp(newString[0], "sysid") == 0) {
+            // 測試 sys id
+            SetSystemIDProc();
+        } else if (strcmp(newString[0], "self") == 0) {
+            // CSU 自我檢測狀態
+            RunSelfProc(newString[1]);
+        } else if (strcmp(newString[0], "version") == 0 ||
+                   strcmp(newString[0], "v") == 0 ||
+                   strcmp(newString[0], "-v") == 0) {
+            //if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
+            //    continue;
+            //}
+            // 取 FW 版號
+            GetFwVerProc();
+        } else if (strcmp(newString[0], "update") == 0) {
+            // 更新
+            FwUpdateFlagProc(newString[1]);
+        } else if (strcmp(newString[0], "ac") == 0) {
+            // AC contactor 狀態
+            CheckAcStatus(newString[1]);
+        } else if (strcmp(newString[0], "cable") == 0) {
+            if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
+                continue;
+            }
+
+            // cable check pass
+            SetCableChkStatus(newString[1], newString[2]);
+        } else if (strcmp(newString[0], "pow") == 0) {
+            if (strcmp(newString[1], "-1") == 0 ||
+                    strcmp(newString[1], "") == 0) {
+                continue;
+            }
+            // cable check pass
+            SetPowerValue(newString[1], newString[2]);
+        } else if (strcmp(newString[0], "model") == 0) {
+            GetSystemInfo();
+        } else if (strcmp(newString[0], "select") == 0) {
+            // 取得 / 設定 當前選的槍號
+            GetGunSelectedNum(newString[1]);
+        } else if (strcmp(newString[0], "change") == 0) {
+            // 模擬按鈕改變選槍
+            ChangeGunNum();
+        } else if (strcmp(newString[0], "fan") == 0) {
+            // 設定風扇速度
+            SetFanSpeed(newString[1]);
+        } else if (strcmp(newString[0], "speed") == 0) {
+            // 取得風扇速度
+            GetFanSpeed();
+        } else if (strcmp(newString[0], "debug") == 0) {
+            // 設定 debug mode
+            SetDebugMode(newString[1]);
+        } else if (strcmp(newString[0], "gfd") == 0) {
+            // 設定盲沖使用 GFD 功能
+            SetGFDMode(newString[1]);
+        } else if (strcmp(newString[0], "temp") == 0) {
+            // 取得 PSU 溫度
+            GetPsuTemp();
+        } else if (strcmp(newString[0], "acin") == 0) {
+            // 取得三向輸入電壓
+            GetAcInputVol();
+        } else if (strcmp(newString[0], "psu") == 0) {
+            //如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
+            if (strcmp(newString[1], "-1") == 0 ||
+                    strcmp(newString[1], "") == 0) {
+                printf ("PSU : Param fail..Please retry again......\n");
+                continue;
+            }
+            // 取得 PSU 資訊
+            GetPsuInformation(newString[1], newString[2], newString[3]);
+        } else if (strcmp(newString[0], "cap") == 0) {
+            GetConnectorCapInfo(newString[1]);
+        } else if (strcmp(newString[0], "error") == 0) {
+            CreateOneError(newString[1]);
+        } else if (strcmp(newString[0], "auth") == 0) {
+            GetAuthorizeFlag(newString[1]);
+        } else if (strcmp(newString[0], "relay") == 0) {
+            GetRelayStatus(newString[1]);
+        } else if (strcmp(newString[0], "ccid") == 0) {
+            if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
+                    strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0) {
+                printf ("Input ccid fail.\n");
+                continue;
+            }
+            SetChargingInfoCCID(newString[1], newString[2]);
+        } else if (strcmp(newString[0], "strchg") == 0) {
+            //如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
+            if (strcmp(newString[1], "auto") == 0) {
+                newString[2][0] = 0;
+                newString[3][0] = 0;
+            } else if (strcmp(newString[1], "-1") == 0 ||
+                       strcmp(newString[1], "") == 0   ||
+                       strcmp(newString[2], "-1") == 0 ||
+                       strcmp(newString[2], "") == 0) {
+                printf ("Input cmd fail ------  strchg [vol 150-1000] [cru 2-100]\n");
+                continue;
+            }
+
+            // 槍狀態
+            RunUnconditionalChargeIndex1(newString[1], newString[2], newString[3]);
+        } else if (strcmp(newString[0], "tempW") == 0) { //測試槍頭和水冷機溫度
+            writeGunAndChillerTemp();
+        } else if (strcmp(newString[0], "tempR") == 0) { //讀取槍頭和水冷機溫度
+            resdGunAndChillerTemp();
+        } else if (strcmp(newString[0], "btnl") == 0) {
+        	ShmPrimaryMcuData->InputDet.bits.Button1 = BTN_PRESS;
+        	sleep(1);
+        	ShmPrimaryMcuData->InputDet.bits.Button1 = BTN_RELEASE;
+        } else if (strcmp(newString[0], "btnr") == 0) {
+        	ShmPrimaryMcuData->InputDet.bits.Button2 = BTN_PRESS;
+        	sleep(1);
+        	ShmPrimaryMcuData->InputDet.bits.Button2 = BTN_RELEASE;
+        } else {
+            printf("%s\n", usageMsg);
+        }
+
+        sleep(1);
+    }//while
+
+    return 0;
+}

+ 1 - 1
EVSE/Projects/DD360Tcci/Apps/Readme.md

@@ -6,5 +6,5 @@
     5. 重新commit。
 
 ## 更換DD360 和 DD360ComBox project
-    DD360 和 DD360ComBox 都是用DD360Audi開發和修改,完成後,執行
+    DD360Tcci 和 DD360ComBox 都是用DD360Audi開發和修改,完成後,執行
     DD360Audi/Apps/Script/replaceOtherDD360Project.sh

+ 2 - 0
EVSE/Projects/DD360Tcci/Apps/Script/copy_from_d.sh

@@ -0,0 +1,2 @@
+#!/bin/bash
+sudo cp -r /mnt/d/Phihong/Project/DD360Tcci/Apps/* /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360Tcci/Apps/ 

+ 2 - 0
EVSE/Projects/DD360Tcci/Apps/Script/copy_to_D.sh

@@ -0,0 +1,2 @@
+#!/bin/bash
+sudo cp -r /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360Tcci/Apps/* /mnt/d/Phihong/Project/DD360Tcci/Apps/

+ 2 - 0
EVSE/Projects/DD360Tcci/Apps/Script/copy_to_d.sh

@@ -0,0 +1,2 @@
+#!/bin/bash
+sudo cp -r /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360Tcci/Apps/* /mnt/d/Phihong/Project/DD360Tcci/Apps/

+ 4 - 4
EVSE/Projects/DD360Tcci/Apps/Script/replaceOtherDD360Project.sh

@@ -9,15 +9,15 @@ echo $SCRIPTPATH
 
 ProjectPath="/opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects"
 
-rm -rf $ProjectPath/DD360/Apps/;
-cp -r $ProjectPath/DD360Audi/Apps/ $ProjectPath/DD360/Apps;
-cp -r $ProjectPath/DD360Audi/ModelNameList.txt  $ProjectPath/DD360/ModelNameList.txt;
+rm -rf $ProjectPath/DD360Tcci/Apps/;
+cp -r $ProjectPath/DD360Audi/Apps/ $ProjectPath/DD360Tcci/Apps;
+cp -r $ProjectPath/DD360Audi/ModelNameList.txt  $ProjectPath/DD360Tcci/ModelNameList.txt;
 
 rm -rf $ProjectPath/DD360ComBox/Apps/;
 cp -r $ProjectPath/DD360Audi/Apps/ $ProjectPath/DD360ComBox/Apps;
 cp -r $ProjectPath/DD360Audi/ModelNameList.txt $ProjectPath/DD360ComBox/ModelNameList.txt;
 
-# git add $ProjectPath/DD360;
+# git add $ProjectPath/DD360Tcci;
 # git add $ProjectPath/DD360Audi;
 # git add $ProjectPath/DD360ComBox;
 # git status;

+ 26 - 17
EVSE/Projects/DD360Tcci/Apps/ShareMemory/shmMem.c

@@ -504,11 +504,9 @@ void InitialShareMemoryInfo(void)
 
     memset(pSysInfo->FanModuleFwRev, 0, ARRAY_SIZE(pSysInfo->FanModuleFwRev));
     memset(pSysInfo->RelayModuleFwRev, 0, ARRAY_SIZE(pSysInfo->RelayModuleFwRev));
-#if defined DD360Audi
-    pSysInfo->SystemPage = _LCM_SELECT_GUN;
-#else
-    pSysInfo->SystemPage = _LCM_NONE;
-#endif //defined DD360Audi
+
+    pSysInfo->SystemPage = _PAGE_AUTHORIZE;
+
     pSysInfo->MainChargingMode = _MAIN_CHARGING_MODE_MAX;
     pSysInfo->ReAssignedFlag = _REASSIGNED_NONE;
     pSysInfo->CurGunSelectedByAc = NO_DEFINE;
@@ -550,9 +548,9 @@ int InitSelectGunShmMem(void)
 {
     int MeterSMId = FAIL;
 
-#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#if !defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox && !defined DD360UCar
     return;
-#endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
+#endif //!defined DD360Tcci && !defined DD360Audi && !defined DD360ComBox
 
     if ((MeterSMId = shmget(ShmSelectGunInfoKey, sizeof(SelectGunInfo), IPC_CREAT | 0777)) < 0) {
         return FAIL;
@@ -765,13 +763,13 @@ void ClearAllShmMemParameter(void)
     //memset(ShmCsuMeterInfo, 0, sizeof(struct MeterInformation));
     memset(ShmDcCommonData, 0, sizeof(DcCommonInfo));
 
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
+#if defined DD360Tcci || defined DD360Audi || defined DD360ComBox || defined DD360UCar
     memset(ShmSelectGunInfo, 0, sizeof(SelectGunInfo));
 
     for (i = 0; i < ShmSysConfigAndInfo->SysConfig.TotalConnectorCount; i++) {
         ShmSelectGunInfo->PricesInfo[i].Balance = FAIL_BALANCE_PRICES;
     }
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
+#endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
 }
 
 static void setAcGunTiggerStatus(void)
@@ -880,7 +878,10 @@ static bool addGunInfoByConnector(uint8_t typeValue, uint8_t slots,char *whichta
 
     case '6': // GB/T AC Socket
         break;
-
+    case '7': // CCS2 AC plug
+        break;
+    case '8': // Type E Socket
+        break;
     //DC Gun Type --------------------------------------------------------------
     case 'J':  // CHAdeMO
     case 'K':  // CHAdeMO 200A
@@ -905,16 +906,15 @@ static bool addGunInfoByConnector(uint8_t typeValue, uint8_t slots,char *whichta
         }
         break;
 
+    case 'V': // Liquid CCS1 combo
+    case 'F': // Liquid CCS2 combo
     case 'T': // Rema CCS1
     case 'D': // Rema CCS2
     case 'U': // CCS1 combo
     case 'E': // CCS2 combo
-    case 'V': // Liquid CCS1 combo
-    case 'F': // Liquid CCS2 combo
     case 'M': // 80A CCS2
     case 'N': // 80A CCS1
-    case 'P': // Phoenix CCS2 500A 水冷
-    case 'R': // Phoenix CCS1 500A 水冷
+    case 'P': // 急電弓
         if (CCS_QUANTITY > gGunIndexInfo.CcsIndex) {
             pDcChargingInfo = (struct ChargingInfoData *)&pSysInfo->CcsChargingData[gGunIndexInfo.CcsIndex];
 
@@ -934,16 +934,25 @@ static bool addGunInfoByConnector(uint8_t typeValue, uint8_t slots,char *whichta
                 gGunIndexInfo.CcsIndex++;
                 gGunIndexInfo.DcGunIndex++;
             }
-            if(typeValue == 'P')
-            {
+            if(typeValue == 'P') {
                 pDcChargingInfo->PantographFlag = YES;
-            }
+            } else if (typeValue == 'V') {
+                pDcChargingInfo->CCSGunType = _TYPE_CCS1_Liquid;
+            } else if (typeValue == 'F') {
+                pDcChargingInfo->CCSGunType = _TYPE_CCS2_Liquid;
+            } else if (typeValue == 'T' || typeValue == 'U' || typeValue == 'N') {
+                pDcChargingInfo->CCSGunType = _TYPE_CCS1_Natural;
+            } else if (typeValue == 'D' || typeValue == 'E' || typeValue == 'M') {
+                pDcChargingInfo->CCSGunType = _TYPE_CCS2_Natural;
+            } else
+                pDcChargingInfo->CCSGunType = _TYPE_CCS_NONE;
         } else {
             result = false;
         }
         break;
 
     case 'G':  // GBT DC
+    case 'B': // GBT YG PT100
         if (GB_QUANTITY > gGunIndexInfo.GbIndex) {
             pDcChargingInfo = (struct ChargingInfoData *)&pSysInfo->GbChargingData[gGunIndexInfo.GbIndex];
 

BIN
EVSE/Projects/DD360Tcci/Apps/UnsafetyOutputTask


+ 10 - 6
EVSE/Projects/DD360Tcci/Apps/simulation.c

@@ -53,6 +53,7 @@ void SetFaultTest()
 {
     pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning = NO;
     pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault = NO;
+    pAlarmCode->AlarmEvents.bits.DisconnectedFromDo = NORMAL;
     pSysWarning->Level = WARN_LV_NL;
 
 }
@@ -61,22 +62,18 @@ void SetSelfTest(bool status)
     uint8_t index = 0;
     struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-    struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
 
-    struct PsuData *ShmPsuData = (struct PsuData *)GetShmPsuData();
     struct CHAdeMOData *ShmCHAdeMOData = (struct CHAdeMOData *)GetShmCHAdeMOData();
     struct GBTData *ShmGBTData = (struct GBTData *)GetShmGBTData();
     struct CcsData *ShmCcsData = (struct CcsData *)GetShmCcsData();
 
-    struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
-    struct FanModuleData *ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();
     struct RelayModuleData *ShmRelayModuleData = (struct RelayModuleData *)GetShmRelayModuleData();
     ShmRelayModuleData->SelfTest_Comp = status;
 
     if (status) {
         strcpy((char*)pSysInfo->RelayModuleFwRev,SIM_VERSION);
         strcpy((char*)pSysInfo->FanModuleFwRev,SIM_VERSION);
-        strcpy((char*)ShmPrimaryMcuData->version,SIM_VERSION);
+        strcpy((char*)pSysInfo->CsuPrimFwRev,SIM_VERSION);
         for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
             if (pDcChargingInfo->Type == _Type_Chademo) {
@@ -98,7 +95,7 @@ void main()
 
     if (CreateAllCsuShareMemory() == FAIL) {
         printf("create share memory error");
-        return FAIL;
+        return;
     }
 
     MappingGunChargingInfo("Simulation Task");
@@ -128,13 +125,20 @@ void main()
             case S_REASSIGN:
                 break;
             case S_PREPARNING:
+                //ShmPsuData->SystemPresentPsuQuantity = 500;
+                //ShmPsuData->SystemAvailablePower = 500;
                 break;
             case S_PREPARING_FOR_EV:
+                pDcChargingInfo->GunLocked = START;
                 break;
             case S_PREPARING_FOR_EVSE:
+                pDcChargingInfo->GroundFaultStatus = GFD_PASS;
                 break;
             case S_CCS_PRECHARGE_ST0:
             case S_CCS_PRECHARGE_ST1:
+                ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].PresentMsgFlowStatus = 45;
+                sleep(1);
+                pDcChargingInfo->RelayK1K2Status = YES;
                 break;
 
             case S_CHARGING:

+ 5 - 5
EVSE/Projects/DD360Tcci/Apps/timeout.h

@@ -32,18 +32,14 @@
 #include    <ctype.h>
 #include    <ifaddrs.h>
 
-//------------------------------------------------------------------------------
-#define CONN_PLUG_TIME_OUT                      (40)
-
 //------------------------------------------------------------------------------
 enum Timeout_flag {
     Timeout_None                   = 0,
     Timeout_SelftestChk            = 1,
     Timeout_Authorizing            = 2,
     Timeout_VerifyFail             = 3,
-    Timeout_VerifyComp             = 4,
+    Timeout_ReturnViewPage         = 4,
     Timeout_WaitPlug               = 5,
-
     Timeout_Preparing              = 6,
     Timeout_EvChargingDet          = 7,
     Timeout_EvseChargingDet        = 8,
@@ -54,6 +50,10 @@ enum Timeout_flag {
     Timeout_SelectGun              = 13,
     Timeout_WaitBalance            = 14,
     Timeout_EVCCID_Link            = 15,
+	Timeout_LinkError              = 16,
+	Timeout_DetailView             = 17,
+	Timeout_Terminating            = 18,
+	Timeout_PlugOutGun             = 19,
 };
 
 //------------------------------------------------------------------------------

+ 24 - 7
EVSE/Projects/define.h

@@ -63,6 +63,15 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
     #define GENERAL_GUN_QUANTITY    0
     #define PSU_QUANTITY            0
     #define ONE_CONNECTOR_USE       0
+#elif defined NoodoeAX
+    #define MAX_PSU_QUANTITY        62
+    #define CHAdeMO_QUANTITY        1
+    #define CCS_QUANTITY            1
+    #define GB_QUANTITY             0
+    #define AC_QUANTITY             1
+    #define GENERAL_GUN_QUANTITY    0
+    #define PSU_QUANTITY            0
+    #define ONE_CONNECTOR_USE       0
 #elif defined AX80
     #define MAX_PSU_QUANTITY        62
     #define CHAdeMO_QUANTITY        1
@@ -117,7 +126,7 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
     #define GENERAL_GUN_QUANTITY	0
     #define PSU_QUANTITY            2
     #define ONE_CONNECTOR_USE       0
-#elif defined DD360 || defined DD360Audi || defined DD360ComBox || defined DD360UCar
+#elif defined DD360 || defined DD360Audi || defined DD360ComBox || defined DD360UCar || defined DD360Tcci
     #define MAX_PSU_QUANTITY        62
     #define CHAdeMO_QUANTITY        2
     #define CCS_QUANTITY            2
@@ -454,7 +463,8 @@ typedef union
         unsigned int ManualStop:1;                  // 0: no effect,    1: manual stop
         unsigned int HardResetStop:1;               // 0: no effect,    1: hard reset stop
         unsigned int SoftResetStop:1;               // 0: no effect,    1: soft reset stop
-        unsigned int res:26;
+        unsigned int InvalidIdStop:1;               // 0: no effect,    1: invalid stop when StopTransactionOnInvalidId is true
+        unsigned int res:25;
     }bits;
 }ChargingStop;
 
@@ -662,6 +672,8 @@ struct ChargingInfoData
     unsigned char       Replug_flag;
     unsigned char       isEVCCIDVerify;
     unsigned char       CCSGunType;
+    struct timeval      PreChargeTimer;
+    unsigned char       _SaftyDetect;
 };
 
 typedef struct
@@ -705,7 +717,8 @@ typedef union
         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 res:8;
+        unsigned int LEDIntensityRequest:1;             // 0: no request,   1: LED Intensity has changed                        ( cabinet -> dispenser)
+        unsigned int res:7;
     }bits;
 }DispenserSettingFlag;
 
@@ -823,7 +836,8 @@ typedef union
         unsigned int  FaultStatusRequest:1;
         unsigned int  Disconnection:1;
         unsigned int  GfdDetection:1;                   // 0: stop,         1: start
-        unsigned int  res:9;
+        unsigned int  GetStartChargingSoc:1;            // 0: no effect,    1: get start soc
+        unsigned int  res:8;
     }bits;
 }ConnectorParameter;
 
@@ -854,8 +868,11 @@ struct ConnectorInfoData
 
     unsigned short          MaxTotalChargingCurrent;        // max total output current, unit: 0.1A
     unsigned short          MaxTotalChargingPower;          // max total output power, unit: 0.1kw
-    unsigned short          MaxOutputEnergy;                //0: no limit,  1 ~ 65535   kWh
-    unsigned short          MaxOutputDuration;              //0: no limit,  1 ~ 65535   minutes
+    unsigned short          MaxOutputEnergy;                // 0: no limit,  1 ~ 65535   kWh
+    unsigned short          MaxOutputDuration;              // 0: no limit,  1 ~ 65535   minutes
+    float                   CapabilityVoltage;              // unit 0.1V
+    float                   CapabilityCurrent;              // unit 0.1A
+    float                   CapabilityPower;                // unit 0.1kW
 
     unsigned int            UserPrice;                      // connector user's user price, unit: 0.01 (dollar / kWh)
     unsigned int            TotalCost;                      // connector user's total cost, unit: 0.01 dollar
@@ -1498,7 +1515,7 @@ struct AlarmCodeData
             unsigned char DcInputOVP:1;                             //bit 7
             //AlarmVal[16]
             unsigned char DcInputUVP:1;                             //bit 0
-            unsigned char :7;                                       //reserved bit 0 ~ bit 7
+            unsigned char :7;                                       //reserved bit 1 ~ bit 7
             //AlarmVal[17]
             unsigned char :8;                                       //reserved bit 0 ~ bit 7
             //AlarmVal[18]

+ 14 - 0
build_rootfs_copy.sh

@@ -0,0 +1,14 @@
+#!/bin/bash
+sudo rm /dev/ram*
+sleep 3
+#sudo make DD360Audi-rootfs
+#cp /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360Audi/Images/* /mnt/e/Image/DD360Audi/
+#sudo make DD360-rootfs
+#cp /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360/Images/* /mnt/e/Image/DD360/
+#sudo make DD360ComBox-rootfs
+#cp /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360ComBox/Images/* /mnt/e/Image/DD360ComBox/
+#sudo make DD360UCar-rootfs
+#cp /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360UCar/Images/* /mnt/e/Image/DD360UCar/
+sudo make DD360Tcci-rootfs
+sudo cp /opt/ti-processor-sdk-linux-am335x-evm-04.02.00.09/EVSE/Projects/DD360Tcci/Images/* /mnt/e/Image/DD360Tcci/
+

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov