Browse Source

2021-10-22 / Simon Xue

Simon Xue 3 years ago
parent
commit
52d65eb436
100 changed files with 1886 additions and 3470 deletions
  1. 0 184
      EVSE/Projects/DD360/Apps/CSU/CheckSystemTask.c
  2. 0 60
      EVSE/Projects/DD360/Apps/CSU/CheckSystemTask.h
  3. 2 1
      EVSE/Projects/DD360/Apps/CSU/Ethernet.c
  4. 12 12
      EVSE/Projects/DD360/Apps/CSU/Primary.c
  5. 30 24
      EVSE/Projects/DD360/Apps/CSU/RFID.c
  6. 1 1
      EVSE/Projects/DD360/Apps/CSU/SelfTest.c
  7. 0 403
      EVSE/Projects/DD360/Apps/CSU/UpgradeFW.c
  8. 3 2
      EVSE/Projects/DD360/Apps/CSU/WatchDog.c
  9. 186 156
      EVSE/Projects/DD360/Apps/CSU/main.c
  10. 2 2
      EVSE/Projects/DD360/Apps/CSU/main.h
  11. 42 42
      EVSE/Projects/DD360/Apps/DataBase/DataBase.c
  12. 3 1
      EVSE/Projects/DD360/Apps/Define/define.h
  13. 1 1
      EVSE/Projects/DD360/Apps/Log/log.c
  14. 1 1
      EVSE/Projects/DD360/Apps/Makefile
  15. 35 26
      EVSE/Projects/DD360/Apps/ModuleChkSysTask/Module_ChkSysTask.c
  16. 14 3
      EVSE/Projects/DD360/Apps/ModuleChkSysTask/Module_ChkSysTask.h
  17. 101 109
      EVSE/Projects/DD360/Apps/ModuleDoComm/DoComm.c
  18. 2 0
      EVSE/Projects/DD360/Apps/ModuleDoComm/DoComm.h
  19. 86 42
      EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvRxComm.c
  20. 45 29
      EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvTxComm.c
  21. 22 22
      EVSE/Projects/DD360/Apps/ModuleEventLog/Module_EventLogging.c
  22. 17 0
      EVSE/Projects/DD360/Apps/ModuleInternalComm/LEDlight.c
  23. 3 3
      EVSE/Projects/DD360/Apps/ModuleInternalComm/Module_InternalComm.c
  24. 83 67
      EVSE/Projects/DD360/Apps/ModuleInternalComm/RelayBoard.c
  25. 40 27
      EVSE/Projects/DD360/Apps/ModuleLcmCtrl/Module_LcmControl.c
  26. 25 25
      EVSE/Projects/DD360/Apps/ModulePrimary/Module_PrimaryComm.c
  27. 25 24
      EVSE/Projects/DD360/Apps/ModuleUpdateFW/Module_UpdateFW.c
  28. 1 0
      EVSE/Projects/DD360/Apps/Script/kill.sh
  29. 9 9
      EVSE/Projects/DD360/Apps/SelectGun/SelectGun.c
  30. 16 16
      EVSE/Projects/DD360/Apps/ShareMemory/shmMem.c
  31. 1 0
      EVSE/Projects/DD360/Apps/timeout.h
  32. BIN
      EVSE/Projects/DD360/Images/FactoryDefaultConfig.bin
  33. BIN
      EVSE/Projects/DD360/Images/ramdisk.gz
  34. BIN
      EVSE/Projects/DD360/output/FactoryConfig
  35. BIN
      EVSE/Projects/DD360/output/Module_ChkSysTask
  36. BIN
      EVSE/Projects/DD360/output/Module_DoComm
  37. BIN
      EVSE/Projects/DD360/output/Module_EvComm
  38. BIN
      EVSE/Projects/DD360/output/Module_EventLogging
  39. BIN
      EVSE/Projects/DD360/output/Module_InternalComm
  40. BIN
      EVSE/Projects/DD360/output/Module_LcmControl
  41. BIN
      EVSE/Projects/DD360/output/Module_PrimaryComm
  42. BIN
      EVSE/Projects/DD360/output/Module_UpdateFW
  43. BIN
      EVSE/Projects/DD360/output/ReadCmdline
  44. 1 0
      EVSE/Projects/DD360/output/kill.sh
  45. BIN
      EVSE/Projects/DD360/output/main
  46. 0 184
      EVSE/Projects/DD360Audi/Apps/CSU/CheckSystemTask.c
  47. 0 60
      EVSE/Projects/DD360Audi/Apps/CSU/CheckSystemTask.h
  48. 2 1
      EVSE/Projects/DD360Audi/Apps/CSU/Ethernet.c
  49. 12 12
      EVSE/Projects/DD360Audi/Apps/CSU/Primary.c
  50. 30 24
      EVSE/Projects/DD360Audi/Apps/CSU/RFID.c
  51. 1 1
      EVSE/Projects/DD360Audi/Apps/CSU/SelfTest.c
  52. 0 403
      EVSE/Projects/DD360Audi/Apps/CSU/UpgradeFW.c
  53. 3 2
      EVSE/Projects/DD360Audi/Apps/CSU/WatchDog.c
  54. 179 158
      EVSE/Projects/DD360Audi/Apps/CSU/main.c
  55. 2 2
      EVSE/Projects/DD360Audi/Apps/CSU/main.h
  56. 42 42
      EVSE/Projects/DD360Audi/Apps/DataBase/DataBase.c
  57. 3 1
      EVSE/Projects/DD360Audi/Apps/Define/define.h
  58. 1 1
      EVSE/Projects/DD360Audi/Apps/Log/log.c
  59. 1 1
      EVSE/Projects/DD360Audi/Apps/Makefile
  60. 35 26
      EVSE/Projects/DD360Audi/Apps/ModuleChkSysTask/Module_ChkSysTask.c
  61. 14 3
      EVSE/Projects/DD360Audi/Apps/ModuleChkSysTask/Module_ChkSysTask.h
  62. 101 109
      EVSE/Projects/DD360Audi/Apps/ModuleDoComm/DoComm.c
  63. 2 0
      EVSE/Projects/DD360Audi/Apps/ModuleDoComm/DoComm.h
  64. 86 42
      EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvRxComm.c
  65. 43 26
      EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvTxComm.c
  66. 22 22
      EVSE/Projects/DD360Audi/Apps/ModuleEventLog/Module_EventLogging.c
  67. 17 0
      EVSE/Projects/DD360Audi/Apps/ModuleInternalComm/LEDlight.c
  68. 3 3
      EVSE/Projects/DD360Audi/Apps/ModuleInternalComm/Module_InternalComm.c
  69. 83 67
      EVSE/Projects/DD360Audi/Apps/ModuleInternalComm/RelayBoard.c
  70. 40 27
      EVSE/Projects/DD360Audi/Apps/ModuleLcmCtrl/Module_LcmControl.c
  71. 25 25
      EVSE/Projects/DD360Audi/Apps/ModulePrimary/Module_PrimaryComm.c
  72. 25 24
      EVSE/Projects/DD360Audi/Apps/ModuleUpdateFW/Module_UpdateFW.c
  73. 1 0
      EVSE/Projects/DD360Audi/Apps/Script/kill.sh
  74. 9 9
      EVSE/Projects/DD360Audi/Apps/SelectGun/SelectGun.c
  75. 16 16
      EVSE/Projects/DD360Audi/Apps/ShareMemory/shmMem.c
  76. 1 0
      EVSE/Projects/DD360Audi/Apps/timeout.h
  77. BIN
      EVSE/Projects/DD360Audi/Images/FactoryDefaultConfig.bin
  78. BIN
      EVSE/Projects/DD360Audi/Images/ramdisk.gz
  79. BIN
      EVSE/Projects/DD360Audi/output/FactoryConfig
  80. BIN
      EVSE/Projects/DD360Audi/output/Module_ChkSysTask
  81. BIN
      EVSE/Projects/DD360Audi/output/Module_DoComm
  82. BIN
      EVSE/Projects/DD360Audi/output/Module_EvComm
  83. BIN
      EVSE/Projects/DD360Audi/output/Module_EventLogging
  84. BIN
      EVSE/Projects/DD360Audi/output/Module_InternalComm
  85. BIN
      EVSE/Projects/DD360Audi/output/Module_LcmControl
  86. BIN
      EVSE/Projects/DD360Audi/output/Module_PrimaryComm
  87. BIN
      EVSE/Projects/DD360Audi/output/Module_UpdateFW
  88. BIN
      EVSE/Projects/DD360Audi/output/ReadCmdline
  89. BIN
      EVSE/Projects/DD360Audi/output/main
  90. 0 184
      EVSE/Projects/DD360ComBox/Apps/CSU/CheckSystemTask.c
  91. 0 60
      EVSE/Projects/DD360ComBox/Apps/CSU/CheckSystemTask.h
  92. 2 1
      EVSE/Projects/DD360ComBox/Apps/CSU/Ethernet.c
  93. 12 12
      EVSE/Projects/DD360ComBox/Apps/CSU/Primary.c
  94. 30 24
      EVSE/Projects/DD360ComBox/Apps/CSU/RFID.c
  95. 1 1
      EVSE/Projects/DD360ComBox/Apps/CSU/SelfTest.c
  96. 0 403
      EVSE/Projects/DD360ComBox/Apps/CSU/UpgradeFW.c
  97. 3 2
      EVSE/Projects/DD360ComBox/Apps/CSU/WatchDog.c
  98. 186 156
      EVSE/Projects/DD360ComBox/Apps/CSU/main.c
  99. 2 2
      EVSE/Projects/DD360ComBox/Apps/CSU/main.h
  100. 42 42
      EVSE/Projects/DD360ComBox/Apps/DataBase/DataBase.c

+ 0 - 184
EVSE/Projects/DD360/Apps/CSU/CheckSystemTask.c

@@ -1,184 +0,0 @@
-/*
- * CheckTask.c
- *
- *  Created on: 2021年9月22日
- *      Author: 8513
- */
-
-#include "CheckSystemTask.h"
-
-bool Taskconutstring(char *src, char *taskname)
-{
-    bool result = false;
-
-    if (src == NULL || strlen(src) == 0)
-        return result;
-
-    if (strstr(src, taskname) != NULL &&
-        strstr(src, "grep") == NULL &&
-        strstr(src, "[") == NULL)
-    {
-        result = true;
-    }
-
-    return result;
-}
-
-int GetProcessCount(char *procName)
-{
-	int result = 0;
-	FILE *fp;
-	char cmd[256];
-	char buf[256];
-
-	sprintf(cmd, "ps -ef |grep %s", procName);
-	fp = popen(cmd, "r");
-	if(fp != NULL)
-	{
-		while(fgets(buf, sizeof(buf), fp) != NULL)
-		{
-			if (Taskconutstring(buf, procName))
-				result++;
-		}
-	}
-
-	pclose(fp);
-
-	return result;
-}
-
-unsigned char CheckSystemTask(unsigned char systemPage)
-{
-	unsigned char result = 0;
-	unsigned char count_main 		= GetProcessCount("main");
-	unsigned char count_evComm 		= GetProcessCount("Module_EvComm");
-	unsigned char count_interComm	= GetProcessCount("Module_InternalComm");
-	unsigned char count_eventComm	= GetProcessCount("Module_EventLogging");
-	unsigned char count_primaryComm	= GetProcessCount("Module_PrimaryComm");
-	unsigned char count_lcmComm	    = GetProcessCount("Module_LcmControl");
-	unsigned char count_doComm	    = GetProcessCount("Module_DoComm");
-	unsigned char count_produceComm	= GetProcessCount("Module_ProduceUtils");
-//	unsigned char count_psuComm 	= GetProcessCount("Module_PsuComm");
-
-//	printf("*************************** \n");
-//	printf("count_main = %d \n", count_main);
-//	printf("count_eventLog = %d \n", count_eventLog);
-//	printf("count_primary = %d \n", count_primary);
-//	printf("count_evComm = %d \n", count_evComm);
-//	printf("count_lcmCtrl = %d \n", count_lcmCtrl);
-//	printf("count_interComm = %d \n", count_interComm);
-//	printf("count_psuComm = %d \n", count_psuComm);
-//	printf("*************************** \n");
-
-//	if (systemPage == 0x09 || systemPage == 0x0A)
-	{
-		if (count_main < _SYSTEM_TASK_COUNT_MAIN )
-		{
-			system("killall Module_EventLogging");
-			system("killall Module_PrimaryComm");
-			system("killall Module_EvComm");
-			system("killall Module_LcmControl");
-			system("killall Module_InternalComm");
-			system("killall Module_DoComm");
-//			system("killall Module_PsuComm");
-//			system("killall OcppBackend &");
-//			system("killall Module_4g &");
-//			system("killall Module_Wifi &");
-			system("killall Module_ProduceUtils &");
-			sleep(3);
-			system("/usr/bin/run_evse_restart.sh");
-		}
-		else
-		{
-			/*
-			if(system("pidof -s Module_EventLogging > /dev/null") != 0)
-				system("/root/Module_EventLogging &");
-
-			if(system("pidof -s Module_PrimaryComm > /dev/null") != 0)
-				system("/root/Module_PrimaryComm &");
-
-			if(system("pidof -s Module_LcmControl > /dev/null") != 0)
-				system("/root/Module_LcmControl &");
-
-            if(system("pidof -s Module_DoComm > /dev/null") != 0)
-                system("/root/Module_DoComm &");
-
-            if(system("pidof -s Module_ProduceUtils > /dev/null") != 0)
-                system("/root/Module_ProduceUtils &");
-
-			*/
-			if (count_evComm < _SYSTEM_TASK_COUNT_EVCOMM )
-			{
-				system("killall Module_EvComm");
-				sleep(3);
-				system("/root/Module_EvComm &");
-			}
-        	if (count_interComm < _SYSTEM_TASK_COUNT_INTERNALCOMM )
-			{
-				system("killall Module_InternalComm");
-				sleep(3);
-				system("/root/Module_InternalComm &");
-			}
-			if (count_eventComm < _SYSTEM_TASK_COUNT_EVENTLOGGING )
-			{
-				system("killall Module_EventLogging");
-				sleep(3);
-				system("/root/Module_EventLogging &");
-			}
-			if (count_primaryComm < _SYSTEM_TASK_COUNT_PRIMARYCOMM )
-			{
-				system("killall Module_PrimaryComm");
-				sleep(3);
-				system("/root/Module_PrimaryComm &");
-			}
-			if (count_lcmComm < _SYSTEM_TASK_COUNT_LCM )
-			{
-				system("killall Module_LcmControl");
-				sleep(3);
-				system("/root/Module_LcmControl &");
-			}
-			if (count_doComm < _SYSTEM_TASK_COUNT_DOCOMM )
-			{
-				system("killall Module_DoComm");
-				sleep(3);
-				system("/root/Module_DoComm &");
-			}
-			if (count_produceComm < _SYSTEM_TASK_COUNT_PRODUCEUTILS )
-			{
-				system("killall Module_ProduceUtils");
-				sleep(3);
-				system("/root/Module_ProduceUtils &");
-			}
-			/*
-			if (count_psuComm < 2)
-			{
-				system("killall Module_PsuComm");
-				sleep(3);
-				system("/root/Module_PsuComm &");
-			}*/
-		}
-
-		sleep(2);
-	}
-
-	if (count_main < _SYSTEM_TASK_COUNT_MAIN)
-		result = _SYSTEM_TASK_LOST_ITEM_MAIN;
-	else if (count_evComm < _SYSTEM_TASK_COUNT_EVCOMM)
-		result = _SYSTEM_TASK_LOST_ITEM_EVCOMM;
-/*	else if (count_psuComm < 2)
-		result = 3; */
-    else if (count_eventComm < _SYSTEM_TASK_COUNT_EVENTLOGGING )
-        result = _SYSTEM_TASK_LOST_ITEM_EVENTLOG;
-    else if (count_primaryComm < _SYSTEM_TASK_COUNT_PRIMARYCOMM)
-        result = _SYSTEM_TASK_LOST_ITEM_PRIMARYCOMM;
-    else if (count_lcmComm < _SYSTEM_TASK_COUNT_LCM)
-        result = _SYSTEM_TASK_LOST_ITEM_LCMCONTROL;
-    else if (count_interComm < 2 )
-        result = _SYSTEM_TASK_LOST_ITEM_INTERCOMM;
-    else if (count_doComm < _SYSTEM_TASK_COUNT_DOCOMM)
-        result = _SYSTEM_TASK_LOST_ITEM_DOCOMM;
-    else if (count_produceComm < _SYSTEM_TASK_COUNT_PRODUCEUTILS)
-        result = _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS;
-
-	return result;
-}

+ 0 - 60
EVSE/Projects/DD360/Apps/CSU/CheckSystemTask.h

@@ -1,60 +0,0 @@
-/*
- * CheckTask.h
- *
- *  Created on: 2021年9月2日
- *      Author: 7564
- */
-
-#ifndef CHECKTASK_H_
-#define CHECKTASK_H_
-
-#include 	<sys/timeb.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 	<stdint.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include 	<math.h>
-#include 	<stdbool.h>
-#include 	<dirent.h>
-
-#define _SYSTEM_TASK_LOST_ITEM_MAIN         1
-#define _SYSTEM_TASK_LOST_ITEM_EVCOMM       2
-#define _SYSTEM_TASK_LOST_ITEM_EVENTLOG     3
-#define _SYSTEM_TASK_LOST_ITEM_PRIMARYCOMM  4
-#define _SYSTEM_TASK_LOST_ITEM_LCMCONTROL   5
-#define _SYSTEM_TASK_LOST_ITEM_INTERCOMM    6
-#define _SYSTEM_TASK_LOST_ITEM_DOCOMM       7
-#define _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS 8
-
-#define _SYSTEM_TASK_COUNT_MAIN             5
-#define _SYSTEM_TASK_COUNT_EVCOMM           2
-#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_DOCOMM           1
-#define _SYSTEM_TASK_COUNT_PRODUCEUTILS     1
-
-
-unsigned char CheckSystemTask(unsigned char systemPage);
-
-#endif /* CHECKSYSTEMTASK_H_ */

+ 2 - 1
EVSE/Projects/DD360/Apps/CSU/Ethernet.c

@@ -169,7 +169,7 @@ void InitEthernet(void)
             pSysConfig->Eth0Interface.EthSubmaskAddress);
             pSysConfig->Eth0Interface.EthSubmaskAddress);
     //sprintf(tmpbuf,"/sbin/ifconfig eth0 192.168.100.10 netmask 255.255.255.0 up");
     //sprintf(tmpbuf,"/sbin/ifconfig eth0 192.168.100.10 netmask 255.255.255.0 up");
     system(tmpbuf);
     system(tmpbuf);
-
+    log_info("%s",tmpbuf);
     memset(tmpbuf, 0, 256);
     memset(tmpbuf, 0, 256);
     sprintf(tmpbuf, "route add default gw %s eth0 ",
     sprintf(tmpbuf, "route add default gw %s eth0 ",
             pSysConfig->Eth0Interface.EthGatewayAddress);
             pSysConfig->Eth0Interface.EthGatewayAddress);
@@ -183,6 +183,7 @@ void InitEthernet(void)
     sprintf(tmpbuf, "/sbin/ifconfig eth1 %s netmask %s up",
     sprintf(tmpbuf, "/sbin/ifconfig eth1 %s netmask %s up",
             pSysConfig->Eth1Interface.EthIpAddress,
             pSysConfig->Eth1Interface.EthIpAddress,
             pSysConfig->Eth1Interface.EthSubmaskAddress);
             pSysConfig->Eth1Interface.EthSubmaskAddress);
+    log_info("%s",tmpbuf);
     system(tmpbuf);
     system(tmpbuf);
 
 
     //Run DHCP client if enabled
     //Run DHCP client if enabled

+ 12 - 12
EVSE/Projects/DD360/Apps/CSU/Primary.c

@@ -85,8 +85,8 @@ void PrimaryLedIndicatorCtrlFork(void)
                     continue;
                     continue;
                 }
                 }
 
 
-                //printf("led indicator status = %d\r\n", chargingInfo[gunIndex]->SystemStatus);
-                //printf("level = %d\r\n", pSysWarning->Level);
+                //printf("led indicator status = %d", chargingInfo[gunIndex]->SystemStatus);
+                //printf("level = %d", pSysWarning->Level);
                 switch (pDcChargingInfo->SystemStatus) {
                 switch (pDcChargingInfo->SystemStatus) {
                 case S_BOOTING:
                 case S_BOOTING:
                     if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) {
                     if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) {
@@ -226,11 +226,11 @@ static void checkChargingInfoByDC(uint8_t systemStatus)
 #endif //!defined DD360Audi
 #endif //!defined DD360Audi
 
 
             if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
             if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
-                //printf("destroy gun = %d\r\n", pSysInfo->CurGunSelected);
+                //printf("destroy gun = %d", pSysInfo->CurGunSelected);
                 destroySelGun(pSysInfo->CurGunSelected);
                 destroySelGun(pSysInfo->CurGunSelected);
             } else {
             } else {
                 confirmSelGun(pSysInfo->CurGunSelected);
                 confirmSelGun(pSysInfo->CurGunSelected);
-                log_info("confirm select gun ............................... %d \n",
+                log_info("confirm select gun ............................... %d ",
                          pSysInfo->CurGunSelected);
                          pSysInfo->CurGunSelected);
             }
             }
         }
         }
@@ -433,7 +433,7 @@ void ChkPrimaryStatus(void)
 
 
         if (!leftBtnPush) {
         if (!leftBtnPush) {
             leftBtnPush = true;
             leftBtnPush = true;
-            log_info("left btn down...............................%x\n",
+            log_info("left btn down...............................%x",
                      pDcChargingInfo->SystemStatus);
                      pDcChargingInfo->SystemStatus);
             checkChargingInfoByAC();
             checkChargingInfoByAC();
             checkChargingInfoByDC(pDcChargingInfo->SystemStatus);
             checkChargingInfoByDC(pDcChargingInfo->SystemStatus);
@@ -480,11 +480,11 @@ void ChkPrimaryStatus(void)
                 }             else {
                 }             else {
 #if defined DD360Audi
 #if defined DD360Audi
                     if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
                     if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
-                        //printf("destroy gun = %d\r\n", pSysInfo->CurGunSelected);
+                        //printf("destroy gun = %d", pSysInfo->CurGunSelected);
                         destroySelGun(pSysInfo->CurGunSelected);
                         destroySelGun(pSysInfo->CurGunSelected);
                     } else {
                     } else {
                         confirmSelGun(pSysInfo->CurGunSelected);
                         confirmSelGun(pSysInfo->CurGunSelected);
-                        log_info("confirm select gun ............................... %d \n",
+                        log_info("confirm select gun ............................... %d ",
                                  pSysInfo->CurGunSelected);
                                  pSysInfo->CurGunSelected);
                     }
                     }
 
 
@@ -517,7 +517,7 @@ void ChkPrimaryStatus(void)
 
 
             case S_COMPLETE:
             case S_COMPLETE:
                 // 回 IDLE
                 // 回 IDLE
-                //log_info("right btn down.................S_COMPLETE \n");
+                //log_info("right btn down.................S_COMPLETE ");
                 //pDcChargingInfo->SystemStatus = S_IDLE;
                 //pDcChargingInfo->SystemStatus = S_IDLE;
                 break;
                 break;
             }
             }
@@ -526,7 +526,7 @@ void ChkPrimaryStatus(void)
     } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
     } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
         if (leftBtnPush) {
         if (leftBtnPush) {
             leftBtnPush = false;
             leftBtnPush = false;
-            //log_info("left btn up............................... \n");
+            //log_info("left btn up............................... ");
         }
         }
     }
     }
 
 
@@ -543,7 +543,7 @@ void ChkPrimaryStatus(void)
        ) {
        ) {
         if (!rightBtnPush) {
         if (!rightBtnPush) {
             rightBtnPush = true;
             rightBtnPush = true;
-            //log_info("right btn down............................... %d \n", pSysInfo->CurGunSelected);
+            //log_info("right btn down............................... %d ", pSysInfo->CurGunSelected);
             if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount &&
             if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount &&
                     pSysInfo->IsAlternatvieConf == NO) {
                     pSysInfo->IsAlternatvieConf == NO) {
                 pSysInfo->CurGunSelected++;
                 pSysInfo->CurGunSelected++;
@@ -570,12 +570,12 @@ void ChkPrimaryStatus(void)
                 ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
                 ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
             }
             }
         }
         }
-        log_info("current select gun ............................... %d \n",
+        log_info("current select gun ............................... %d ",
                  pSysInfo->CurGunSelected);
                  pSysInfo->CurGunSelected);
     } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
     } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
         if (rightBtnPush) {
         if (rightBtnPush) {
             rightBtnPush = false;
             rightBtnPush = false;
-            //log_info("right btn up............................... \n");
+            //log_info("right btn up............................... ");
         }
         }
     }
     }
 }
 }

+ 30 - 24
EVSE/Projects/DD360/Apps/CSU/RFID.c

@@ -119,7 +119,11 @@ static void UserScanFunction(void)
         strcpy((char *)pSysConfig->UserId, "");
         strcpy((char *)pSysConfig->UserId, "");
         return;
         return;
     }
     }
-
+    if (pSysConfig->EVCCID_Authorize) {
+        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+        if (strcmp( (char *)pSysConfig->UserId, (char *) pDcChargingInfo->EVCCID) != EQUAL )
+            return;
+    }
     // 先判斷現在是否可以提供刷卡
     // 先判斷現在是否可以提供刷卡
     // 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能
     // 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能
     // 2. 停止充電
     // 2. 停止充電
@@ -160,8 +164,8 @@ static void UserScanFunction(void)
     if (pGunIndexInfo->AcGunIndex > 0 &&
     if (pGunIndexInfo->AcGunIndex > 0 &&
             stopReq == DEFAULT_AC_INDEX &&
             stopReq == DEFAULT_AC_INDEX &&
             pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
             pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
-        log_info("ac stop charging \n");
-        log_info("index = %d, card number = %s, UserId = %s \n",
+        log_info("ac stop charging ");
+        log_info("index = %d, card number = %s, UserId = %s ",
                  pSysInfo->CurGunSelectedByAc,
                  pSysInfo->CurGunSelectedByAc,
                  pAcChargingInfo->StartUserId,
                  pAcChargingInfo->StartUserId,
                  pSysConfig->UserId);
                  pSysConfig->UserId);
@@ -180,8 +184,8 @@ static void UserScanFunction(void)
                 (pGunIndexInfo->AcGunIndex > 0 &&
                 (pGunIndexInfo->AcGunIndex > 0 &&
                  pSysInfo->CurGunSelectedByAc == NO_DEFINE))
                  pSysInfo->CurGunSelectedByAc == NO_DEFINE))
               ) {
               ) {
-        log_info("stop charging \n");
-        log_info("index = %d, card number = %s, UserId = %s \n",
+        log_info("stop charging ");
+        log_info("index = %d, card number = %s, UserId = %s ",
                  pSysInfo->CurGunSelected,
                  pSysInfo->CurGunSelected,
                  pDcChargingInfo->StartUserId,
                  pDcChargingInfo->StartUserId,
                  pSysConfig->UserId);
                  pSysConfig->UserId);
@@ -225,7 +229,7 @@ static void UserScanFunction(void)
         } else if ((pGunIndexInfo->AcGunIndex > 0 &&
         } else if ((pGunIndexInfo->AcGunIndex > 0 &&
                     pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) ||
                     pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) ||
                    pDcChargingInfo->SystemStatus == S_IDLE) {
                    pDcChargingInfo->SystemStatus == S_IDLE) {
-            log_info("// LCM => Authorizing\r\n");
+            log_info("// LCM => Authorizing");
 
 
             setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
             setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
 
 
@@ -272,29 +276,31 @@ void ScannerCardProcess(void)
     }
     }
 
 
     if (pSysInfo->PageIndex == _LCM_AUTHORIZING) {
     if (pSysInfo->PageIndex == _LCM_AUTHORIZING) {
-        StartSystemTimeoutDet(Timeout_Authorizing);
+        if(!isAuthorizedComplete())
+            StartSystemTimeoutDet(Timeout_Authorizing);
 
 
-        //printf("isAuthorizedComplete = %d, %f\r\n", isAuthorizedComplete(), ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
+        //printf("isAuthorizedComplete = %d, %f", isAuthorizedComplete(), ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
         // 確認驗證卡號完成沒
         // 確認驗證卡號完成沒
         if (isAuthorizedComplete()
         if (isAuthorizedComplete()
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
                 || pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING
                 || pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING
 #endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
 #endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
-                && 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, "");
-            }
+                //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();
+            } ClearAuthorizedFlag();
         } else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
         } else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
             // 白名單驗證
             // 白名單驗證
             for (i = 0; i < 10; i++) {
             for (i = 0; i < 10; i++) {
@@ -360,7 +366,7 @@ void CreateRfidFork(void)
         fd = InitialRfidPort();
         fd = InitialRfidPort();
         struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
         struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
 
 
-        log_info("RFID fork Child's PID is %d\r\n", getpid());
+        log_info("RFID fork Child's PID is %d", getpid());
 
 
         while (isContinue) {
         while (isContinue) {
             usleep(500000);
             usleep(500000);
@@ -375,7 +381,7 @@ void CreateRfidFork(void)
                 continue;
                 continue;
             }
             }
 
 
-            //log_info("Get Card..-%s- \n", pSysConfig->UserId);
+            //log_info("Get Card..-%s- ", pSysConfig->UserId);
             if (strlen((char *)pSysConfig->UserId) != 0) {
             if (strlen((char *)pSysConfig->UserId) != 0) {
                 continue;
                 continue;
             }
             }
@@ -447,7 +453,7 @@ void CreateRfidFork(void)
                     break;
                     break;
                 }
                 }
             }
             }
-            log_info("card number = %s\n", pSysConfig->UserId);
+            log_info("card number = %s", pSysConfig->UserId);
         }
         }
     }
     }
 }
 }

+ 1 - 1
EVSE/Projects/DD360/Apps/CSU/SelfTest.c

@@ -51,7 +51,7 @@ void SelfTestRun(void)
         if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) { //自檢完成
         if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) { //自檢完成
             return;
             return;
         }
         }
-
+        
         ChkPrimaryStatus(); //確認硬體有無錯誤,如急停按鈕或門有打開
         ChkPrimaryStatus(); //確認硬體有無錯誤,如急停按鈕或門有打開
 
 
         if (pSysWarning->Level == WARN_LV_ER) {
         if (pSysWarning->Level == WARN_LV_ER) {

+ 0 - 403
EVSE/Projects/DD360/Apps/CSU/UpgradeFW.c

@@ -1,403 +0,0 @@
-#include <stdio.h>      /*標準輸入輸出定義*/
-#include <stdlib.h>     /*標準函數庫定義*/
-#include <string.h>
-#include <stdint.h>
-
-#include <sys/types.h>
-#include <dirent.h>
-
-#include "../Config.h"
-#include "../Log/log.h"
-#include "../Define/define.h"
-#include "../ShareMemory/shmMem.h"
-
-#include "main.h"
-//WatchDog.c
-extern void CreateWatchdog(void);
-extern void TryCloseWatchdog(void);
-extern void TryFeedWatchdog(void);
-
-
-//------------------------------------------------------------------------------
-static char *_priPortName = "/dev/ttyS1";
-static char *_485PortName = "/dev/ttyS5";
-
-//------------------------------------------------------------------------------
-static int InitComPort(uint8_t target)
-{
-    int fd;
-    struct termios tios;
-
-    if (target == UPGRADE_PRI) {
-        fd = open(_priPortName, O_RDWR);
-    } else if (target == UPGRADE_FAN ||
-               target == UPGRADE_RB ||
-               target == UPGRADE_AC ||
-               target == UPGRADE_LED
-              ) {
-        fd = open(_485PortName, O_RDWR);
-    }
-
-    if (fd <= 0) {
-        log_error("open 407 Communication port NG \n");
-        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)1;
-    tios.c_lflag = 0;
-    tcflush(fd, TCIFLUSH);
-    ioctl (fd, TCSETS, &tios);
-
-    return fd;
-}
-
-static int InitCanBus(void)
-{
-    int fd = -1;
-    int nbytes;
-    struct timeval tv;
-    struct ifreq ifr0;
-    struct sockaddr_can addr0;
-
-    system("/sbin/ip link set can0 down");
-    system("/sbin/ip link set can0 type can bitrate 500000 restart-ms 100");
-    system("/sbin/ip link set can0 up");
-
-    fd = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-
-    tv.tv_sec = 0;
-    tv.tv_usec = 10000;
-    if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct  timeval)) < 0) {
-        log_error("Set SO_RCVTIMEO NG");
-    }
-    nbytes = 40960;
-    if (setsockopt(fd, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0) {
-        log_error("Set SO_RCVBUF NG");
-    }
-    nbytes = 40960;
-    if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0) {
-        log_error("Set SO_SNDBUF NG");
-    }
-
-    strcpy(ifr0.ifr_name, "can0");
-    ioctl(fd, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
-    addr0.can_family = AF_CAN;
-    addr0.can_ifindex = ifr0.ifr_ifindex;
-    bind(fd, (struct sockaddr *)&addr0, sizeof(addr0));
-
-    return fd;
-}
-
-static int CheckUpdateProcess(void)
-{
-    //bool isPass = true;
-    uint8_t retSucc = 0;
-    uint8_t retFail = 0;
-    uint8_t index = 0;
-    uint8_t target = 0;
-    char Buf[256];
-    char *new_str = NULL;
-    uint8_t *ptr = NULL;
-    int fd = 0;
-    int CanFd = 0;
-    int uartFd = 0;
-    unsigned int Type = 0;
-    long int MaxLen = 48 * 1024 * 1024, ImageLen = 0;
-    DIR *d;
-    struct dirent *dir;
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
-    struct ChargingInfoData *pDcChargingInfo = NULL;
-
-    d = opendir("/mnt/");
-    if (d) {
-        while ((dir = readdir(d)) != NULL) {
-            if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0) {
-                continue;
-            }
-
-            new_str = calloc(strlen("/mnt/") + strlen(dir->d_name) + 1, sizeof(char));
-            //new_str[0] = '\0';
-            strcat(new_str, "/mnt/");
-            strcat(new_str, dir->d_name);
-            log_info("%s%s\r\n", "/mnt/", dir->d_name);
-            fd = open(new_str, O_RDONLY);
-            if (fd < 0) {
-                return FAIL;
-            }
-
-            ptr = calloc(MaxLen, sizeof(char)); //-48 is take out the header
-            //memset(ptr, 0xFF, MaxLen);  //-48 is take out the header
-
-            //get the image length
-            ImageLen = read(fd, ptr, MaxLen);
-            for (uint8_t i = 0; i < 16; i++) {
-                if (pSysConfig->ModelName[i] != ptr[i]) {
-                    return FAIL;
-                }
-            }
-
-            log_info("model name check pass. \n");
-            if (ImageLen > 20) {
-                Type = (((unsigned int)ptr[16]) << 24 |
-                        ((unsigned int)ptr[17]) << 16 |
-                        ((unsigned int)ptr[18]) << 8  |
-                        ((unsigned int)ptr[19]));
-                log_info("Typed...%x \r\n", Type);
-
-                switch (Type) {
-                case 0x10000001:
-                case 0x10000002:
-                case 0x10000003:
-                case 0x10000004:
-                case 0x10000005:
-                    if (Upgrade_Flash(Type, new_str, (char *)pSysConfig->ModelName) == PASS) {
-                        //return PASS;
-                        retSucc++;
-                    } else {
-                        log_info("Upgrade %x Failed\r\n", Type);
-                        //return FAIL;
-                        retFail++;
-                    }
-                    break;
-
-                case 0x10000007:
-                case 0x10000008:
-                case 0x10000009:
-                case 0x1000000A:
-                    CanFd = InitCanBus();
-                    if (CanFd > 0) {
-                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
-                            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
-
-                            if (pDcChargingInfo->Type == _Type_CCS_2) {
-                                uint8_t targetID = pDcChargingInfo->Evboard_id;
-
-                                if (pSysConfig->TotalConnectorCount == 1 &&
-                                        ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-                                    //targetID += 1;
-                                }
-
-                                system("echo 3 > /proc/sys/vm/drop_caches");
-                                sleep(2);
-                                log_info("Upgrade CCS Processing..target id = %d \n", targetID);
-                                if (Upgrade_CCS(CanFd,
-                                                Type,
-                                                targetID,
-                                                new_str,
-                                                (char *)pSysConfig->ModelName) == FAIL) {
-                                    log_info("Upgrade CCS Failed \n");
-                                    retFail++;
-                                } else {
-                                    retSucc++;
-                                }
-                            }
-                        }
-                        close(CanFd);
-                    }
-                    memset(Buf, 0, sizeof(Buf));
-                    sprintf(Buf, "rm -rvf /mnt/%s", new_str);
-                    system(Buf);
-                    //isPass = true;
-#if 0
-                    CanFd = InitCanBus();
-                    if (CanFd > 0) {
-                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
-                            //if (!isPass) {
-                            //    break;
-                            //}
-                            if (chargingInfo[index]->Type == _Type_CCS_2) {
-                                if (Upgrade_CCS(CanFd, Type, chargingInfo[index]->Evboard_id, new_str, (char *)pSysConfig->ModelName) == FAIL) {
-                                    //isPass = false;
-                                    log_info("Upgrade %x Failed\r\n", Type);
-                                    retFail++;
-                                }
-                            }
-                        }
-                    } else {
-                        log_error("Upgrade CCS open CAN FD fail.\n");
-                        //isPass = false;
-                        return FAIL;
-                    }
-
-                    if (retFail != 0) {
-                        break;
-                    } else {
-                        retSucc++;
-                    }
-                    //return isPass;
-#endif //0
-                    break;
-
-                case 0x10000006:
-                case 0x1000000D:
-                case 0x1000000E:
-                case 0x20000002:
-                case 0x10000014:
-                    // CSU_PRIMARY_CONTROLLER : 0x10000006
-                    target = 0x00;
-
-                    if (Type == 0x10000006) {
-                        target = UPGRADE_PRI;
-                    } else if (Type == 0x1000000D) {
-                        target = UPGRADE_RB;
-                    } else if (Type == 0x1000000E) {
-                        target = UPGRADE_FAN;
-                    } else if (Type == 0x20000002) {
-                        target = UPGRADE_AC;
-                    } else if (Type == 0x10000014) {
-                        target = UPGRADE_LED;
-                    }
-
-                    uartFd = InitComPort(target);
-
-                    if (Upgrade_UART(uartFd, Type, target, new_str, (char *)pSysConfig->ModelName) == PASS) {
-                        //return PASS;
-                        retSucc++;
-                    } else {
-                        log_info("Upgrade %x Failed\r\n", Type);
-                        //return FAIL;
-                        return FAIL;
-                    }
-
-                    if (uartFd > 0) {
-                        close(uartFd);
-                    }
-                    break;
-
-                case 0x1000000B:
-                case 0x1000000C:
-                    // CHAdeMO_BOARD : 0x1000000B, GBT : 0x1000000C
-                    //bool isPass = true;
-                    CanFd = InitCanBus();
-                    if (CanFd > 0) {
-                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
-                            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
-
-                            //if (!isPass) {
-                            //    break;
-                            //}
-
-                            if ((Type == 0x1000000B && pDcChargingInfo->Type == _Type_Chademo) ||
-                                    (Type == 0x1000000C && pDcChargingInfo->Type == _Type_GB)) {
-                                if (Upgrade_CAN(CanFd, Type, pDcChargingInfo->Evboard_id, new_str, (char *)pSysConfig->ModelName) == PASS) {
-                                    //isPass = PASS;
-                                    retSucc++;
-                                } else {
-                                    log_info("Upgrade %x Failed\r\n", Type);
-                                    //isPass = FAIL;
-                                    retFail++;
-                                }
-                            }
-                        }
-                    } else {
-                        log_info("Upgrad FD fail. \n");
-                        //isPass = false;
-                        return FAIL;
-                    }
-
-                    //return isPass;
-                    break;
-                }
-            }
-            free(new_str);
-            free(ptr);
-        }
-    }
-    free(dir);
-    closedir(d);
-
-    if (retFail != 0) {
-        return FAIL;
-    }
-
-    return PASS;
-}
-
-void CheckFwUpdateFunction(void)
-{
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-    struct OCPP16Data *ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
-    struct ChargingInfoData *pAcChargingInfo = NULL;
-
-    //log_info("pSysInfo->FirmwareUpdate = %d \n", pSysInfo->FirmwareUpdate);
-    if (pSysInfo->FirmwareUpdate == YES) {
-        log_info("ftp : update start. \n");
-        TryCloseWatchdog();
-
-        for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
-            setChargerMode(gun_index, MODE_UPDATE);
-        }
-        sleep(1);
-        uint8_t updateResult = CheckUpdateProcess();
-
-        if (updateResult == PASS) {
-            log_info("ftp : update complete. \n");
-        } else if (updateResult == MODELNAME_FAIL) {
-            log_info("ftp : model name is none match. \n");
-            KillAllTask();
-            pSysInfo->FirmwareUpdate = NO;
-            sleep(5);
-            system("/usr/bin/run_evse_restart.sh");
-            return;
-        } else {
-            log_info("ftp : update fail. \n");
-        }
-
-        pSysInfo->FirmwareUpdate = NO;
-        sleep(5);
-        system("reboot -f");
-    } else if (ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq == YES) {
-        ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = NO;
-
-        if (strcmp((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Downloaded") == EQUAL) {
-            log_info("Backend : update start. \n");
-            TryCloseWatchdog();
-            strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "");
-            strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installing");
-            ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
-            KillTask();
-
-            for (uint8_t _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
-                setChargerMode(_index, MODE_UPDATE);
-            }
-
-            for (uint8_t _index = 0; _index < pSysConfig->AcConnectorCount; _index++) {
-                pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(_index);
-
-                pAcChargingInfo->SystemStatus = MODE_UPDATE;
-            }
-            sleep(1);
-
-            uint8_t updateResult = CheckUpdateProcess();
-
-            if (updateResult == PASS) {
-                log_info("Backend : update complete. \n");
-                strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
-            } else if (updateResult == MODELNAME_FAIL) {
-                log_info("Backend : model name is none match. \n");
-                KillAllTask();
-                strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
-                ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
-                sleep(5);
-                system("/usr/bin/run_evse_restart.sh");
-                return;
-            } else {
-                log_info("Backend : update fail. \n");
-                strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
-            }
-
-            strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
-            ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
-            sleep(5);
-            system("reboot -f");
-        }
-    }
-}

+ 3 - 2
EVSE/Projects/DD360/Apps/CSU/WatchDog.c

@@ -28,7 +28,8 @@ int InitWatchDog()
 
 
     if(fd<=0)
     if(fd<=0)
     {
     {
-        log_error("System watch dog initial fail.\r\n");
+        log_info("Open watchdog fd:%d",fd);
+        log_error("System watch dog initial fail.\n");
     }
     }
     ioctl(fd, _IOWR('W', 6, int), &timeout);
     ioctl(fd, _IOWR('W', 6, int), &timeout);
 
 
@@ -47,7 +48,7 @@ void CreateWatchdog(void)
     }
     }
     else
     else
     {
     {
-        log_info("Watchdog Initial Success");
+        log_info("Watchdog Initial Success (%d)",wtdFd);
     }
     }
 }
 }
 
 

File diff suppressed because it is too large
+ 186 - 156
EVSE/Projects/DD360/Apps/CSU/main.c


+ 2 - 2
EVSE/Projects/DD360/Apps/CSU/main.h

@@ -31,7 +31,8 @@
 
 
 #define uSEC_VAL                                (1000000)
 #define uSEC_VAL                                (1000000)
 #define SELFTEST_TIMEOUT                        (60)//45
 #define SELFTEST_TIMEOUT                        (60)//45
-#define AUTHORIZE_TIMEOUT                       (15)//30
+#define AUTHORIZE_TIMEOUT                       (30)//30
+#define BALANCE_TIMEOUT                         (15)//15
 #define AUTHORIZE_COMP_TIMEOUT                  (3)
 #define AUTHORIZE_COMP_TIMEOUT                  (3)
 #define AUTHORIZE_FAIL_TIMEOUT                  (3)
 #define AUTHORIZE_FAIL_TIMEOUT                  (3)
 #define AUTHORIZE_STOP_TIMEOUT                  (30)
 #define AUTHORIZE_STOP_TIMEOUT                  (30)
@@ -43,7 +44,6 @@
 #define GUN_PRECHARGING_TIMEOUT                 (60)
 #define GUN_PRECHARGING_TIMEOUT                 (60)
 
 
 #define WHILE_LOOP_TIME                         (10000)
 #define WHILE_LOOP_TIME                         (10000)
-#define VERIFY_EVCCID                           0   // 0:Not verify 1:for verify
 
 
 //#define log_info(format, args...) StoreLogMsg_1("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 //#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)
 //#define log_warn(format, args...) StoreLogMsg_1("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)

+ 42 - 42
EVSE/Projects/DD360/Apps/DataBase/DataBase.c

@@ -61,38 +61,38 @@ int DB_Open(void)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\r\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local charging record database open successfully.\r\n");
+        log_info( "Local charging record database open successfully.");
 
 
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Create local charging record table error message: %s\n", errMsg);
+            log_info( "Create local charging record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local charging record table successfully\n");
+            log_info( "Opened local charging record table successfully");
         }
         }
 
 
         if (sqlite3_exec(localDb, createCfgSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createCfgSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Create local config table error message: %s\n", errMsg);
+            log_info( "Create local config table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local config table successfully\n");
+            log_info( "Opened local config table successfully");
         }
         }
 
 
         //DS60-120
         //DS60-120
         if (sqlite3_exec(localDb, createrecordSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createrecordSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Create local record table error message: %s\n", errMsg);
+            log_info( "Create local record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local record table successfully\n");
+            log_info( "Opened local record table successfully");
         }
         }
 
 
         if (sqlite3_exec(localDb, createrebootSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createrebootSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Create reboot record table error message: %s\n", errMsg);
+            log_info( "Create reboot record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened reboot record table successfully\n");
+            log_info( "Opened reboot record table successfully");
         }
         }
         //-----
         //-----
 
 
@@ -126,24 +126,24 @@ int DB_Insert_Record(int gunIndex)
     //if (sqlite3_open("/Storage/ChargeLog/localCgargingRecord.db", &db)) {
     //if (sqlite3_open("/Storage/ChargeLog/localCgargingRecord.db", &db)) {
     if (sqlite3_open(DB_FILE, &localDb)) { //DS60-120 add
     if (sqlite3_open(DB_FILE, &localDb)) { //DS60-120 add
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\r\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local charging record database open successfully.\r\n");
+        log_info( "Local charging record database open successfully.");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Insert local charging record error message: %s\n", errMsg);
+            log_info( "Insert local charging record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Insert local charging record successfully\n");
+            log_info( "Insert local charging record successfully");
         }
         }
 
 
         //DS60-120 add
         //DS60-120 add
         sprintf(insertSql, "delete from charging_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
         sprintf(insertSql, "delete from charging_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "delete local charging error message: %s\n", errMsg);
+            log_info( "delete local charging error message: %s", errMsg);
         } else {
         } else {
-            log_info( "delete local charging record successfully\n");
+            log_info( "delete local charging record successfully");
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);
@@ -161,22 +161,22 @@ int DB_Update_Operactive(uint8_t gunIndex, uint8_t IsAvailable)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\r\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local charging record database open successfully (%d).\r\n", IsAvailable);
+        log_info( "Local charging record database open successfully (%d).", IsAvailable);
 
 
         //sprintf(sqlStr, "insert or replace into config (IsAvailable, connector, val) values('IsAvailable', %d, %d);", gunIndex, IsAvailable);
         //sprintf(sqlStr, "insert or replace into config (IsAvailable, connector, val) values('IsAvailable', %d, %d);", gunIndex, IsAvailable);
         sprintf(sqlStr,
         sprintf(sqlStr,
                 "insert or replace into config (item, connector, val) values('IsAvailable', %d, %d);",
                 "insert or replace into config (item, connector, val) values('IsAvailable', %d, %d);",
                 gunIndex,
                 gunIndex,
                 IsAvailable); //DS60-120 add
                 IsAvailable); //DS60-120 add
-        log_info("sqlStr= %s\r\n", sqlStr);
+        log_info("sqlStr= %s", sqlStr);
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "update config error message: %s\n", errMsg);
+            log_info( "update config error message: %s", errMsg);
         } else {
         } else {
-            log_info("update connector-%d config item isOperactive to %d\r\n", gunIndex, IsAvailable);
+            log_info("update connector-%d config item isOperactive to %d", gunIndex, IsAvailable);
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);
@@ -195,24 +195,24 @@ int DB_Get_Operactive(uint8_t gunIndex)
 
 
     //sprintf(sqlStr, "select * from config where IsAvailable='IsAvailable' and connector=%d;", gunIndex);
     //sprintf(sqlStr, "select * from config where IsAvailable='IsAvailable' and connector=%d;", gunIndex);
     sprintf(sqlStr, "select * from config where item='IsAvailable' and connector=%d;", gunIndex); //DS60-120 add
     sprintf(sqlStr, "select * from config where item='IsAvailable' and connector=%d;", gunIndex); //DS60-120 add
-    //DEBUG_INFO("sqlStr= %s\r\n", sqlStr);
+    //DEBUG_INFO("sqlStr= %s", sqlStr);
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\r\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local config query database open successfully.\r\n");
+        log_info( "Local config query database open successfully.");
         sqlite3_get_table(localDb, sqlStr, &rs, &rows, &cols, &errMsg);
         sqlite3_get_table(localDb, sqlStr, &rs, &rows, &cols, &errMsg);
         if (rows > 0) {
         if (rows > 0) {
             for (int idxRow = 1; idxRow <= rows; idxRow++) {
             for (int idxRow = 1; idxRow <= rows; idxRow++) {
                 if (strcmp(rs[(idxRow * cols) + 3], "0") == 0) {
                 if (strcmp(rs[(idxRow * cols) + 3], "0") == 0) {
                     result = false;
                     result = false;
                 }
                 }
-                log_info("Query connector-%d isOperactive: %s\r\n", gunIndex, rs[(idxRow * cols) + 3]);
+                log_info("Query connector-%d isOperactive: %s", gunIndex, rs[(idxRow * cols) + 3]);
             }
             }
         } else {
         } else {
-            log_info("Query connector-%d fail, set default value to operactive.\r\n", gunIndex);
+            log_info("Query connector-%d fail, set default value to operactive.", gunIndex);
         }
         }
 
 
         sqlite3_free_table(rs);
         sqlite3_free_table(rs);
@@ -232,23 +232,23 @@ int DB_Reboot_Record(void)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local charging record database open successfully.\n");
+        log_info( "Local charging record database open successfully.");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Insert reboot record error message: %s\n", errMsg);
+            log_info( "Insert reboot record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Insert reboot record successfully\n");
+            log_info( "Insert reboot record successfully");
         }
         }
 
 
         sprintf(insertSql, "delete from reboot_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
         sprintf(insertSql, "delete from reboot_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "delete reboot record error message: %s\n", errMsg);
+            log_info( "delete reboot record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "delete reboot record successfully\n");
+            log_info( "delete reboot record successfully");
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);
@@ -272,16 +272,16 @@ int CreateEventRecord(void)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_error( "Can't open database: %s\n", sqlite3_errmsg(localDb));
+        log_error( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local event record database open successfully.\n");
+        log_info( "Local event record database open successfully.");
 
 
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_error( "Create local event record table error message: %s\n", errMsg);
+            log_error( "Create local event record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local event record table successfully\n");
+            log_info( "Opened local event record table successfully");
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);
@@ -300,23 +300,23 @@ int InsertEventRecord(uint8_t *statusCode)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local event record database open successfully.\n");
+        log_info( "Local event record database open successfully.");
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Insert local event record error message: %s\n", errMsg);
+            log_info( "Insert local event record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Insert local event record successfully\n");
+            log_info( "Insert local event record successfully");
         }
         }
 
 
         sprintf(sqlStr, "delete from event_record where idx < (select idx from event_record order by idx desc limit 1)-2000;");
         sprintf(sqlStr, "delete from event_record where idx < (select idx from event_record order by idx desc limit 1)-2000;");
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "delete local event_record error message: %s\n", errMsg);
+            log_info( "delete local event_record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "delete local event record successfully\n");
+            log_info( "delete local event record successfully");
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);

+ 3 - 1
EVSE/Projects/DD360/Apps/Define/define.h

@@ -501,6 +501,8 @@ struct SysConfigData
 	unsigned char 			AcConnectorCount;			// For DC type
 	unsigned char 			AcConnectorCount;			// For DC type
 	unsigned char			SwitchDebugFlag;			// Console Debug
 	unsigned char			SwitchDebugFlag;			// Console Debug
 	unsigned char			AlwaysGfdFlag;
 	unsigned char			AlwaysGfdFlag;
+	unsigned char                   AutoAuth_Disable;           //for Auto Authorize, 0:Disable Auto Authorize 1:Auto Authorize
+	unsigned char                   EVCCID_Authorize;           //for EVCCID Authorize enable/disable
 	/**************Charging***************/
 	/**************Charging***************/
 	unsigned short			MaxChargingEnergy;			//0: no limit,	1 ~ 65535	kWh
 	unsigned short			MaxChargingEnergy;			//0: no limit,	1 ~ 65535	kWh
 	unsigned short			MaxChargingPower;			//0: rating value, 1 ~ RATING_POWER	kW
 	unsigned short			MaxChargingPower;			//0: rating value, 1 ~ RATING_POWER	kW
@@ -638,7 +640,7 @@ struct ChargingInfoData
     struct timespec     ConnectorTimeout;
     struct timespec     ConnectorTimeout;
     unsigned char       PantographFlag;                 // 0: normal gun type,  1: pantograph gun type
     unsigned char       PantographFlag;                 // 0: normal gun type,  1: pantograph gun type
 	unsigned char 		Replug_flag;
 	unsigned char 		Replug_flag;
-    unsigned char       isVerify;
+    unsigned char       isEVCCIDVerify;
 };
 };
 
 
 typedef union
 typedef union

+ 1 - 1
EVSE/Projects/DD360/Apps/Log/log.c

@@ -44,7 +44,7 @@ int StoreLogMsg(const char *fmt, ...)
                 tm->tm_sec,
                 tm->tm_sec,
                 SeqEndTime.millitm,
                 SeqEndTime.millitm,
                 buffer);
                 buffer);
-        printf("%s\r\n", Buf);
+        printf("%s", Buf);
     } else {
     } else {
         sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
         sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
                 tm->tm_year + 1900,
                 tm->tm_year + 1900,

+ 1 - 1
EVSE/Projects/DD360/Apps/Makefile

@@ -73,7 +73,7 @@ COMMON_OBJ_FILES = common.o \
 
 
 MAIN_OBJ_FILES = $(COMMON_OBJ_FILES) $(DataBaseLib)/DataBase.o \
 MAIN_OBJ_FILES = $(COMMON_OBJ_FILES) $(DataBaseLib)/DataBase.o \
 					$(CSULib)/main.o  $(CSULib)/Primary.o $(CSULib)/WatchDog.o $(CSULib)/ZipFile.o \
 					$(CSULib)/main.o  $(CSULib)/Primary.o $(CSULib)/WatchDog.o $(CSULib)/ZipFile.o \
-					$(CSULib)/RFID.o $(CSULib)/SelfTest.o $(CSULib)/UpgradeFW.o \
+					$(CSULib)/RFID.o $(CSULib)/SelfTest.o \
 					$(CSULib)/Ethernet.o 
 					$(CSULib)/Ethernet.o 
 					
 					
 MAIN_SRC_FILES = $(patsubst %.o, %.c, $(MAIN_OBJ_FILES))
 MAIN_SRC_FILES = $(patsubst %.o, %.c, $(MAIN_OBJ_FILES))

+ 35 - 26
EVSE/Projects/DD360/Apps/ModuleChkSysTask/Module_ChkSysTask.c

@@ -78,10 +78,15 @@ unsigned char CheckSystemTask(unsigned char systemPage)
 	unsigned char count_produceComm	= GetProcessCount("Module_ProduceUtils");
 	unsigned char count_produceComm	= GetProcessCount("Module_ProduceUtils");
 	unsigned char count_updateFW	= GetProcessCount("Module_UpdateFW");
 	unsigned char count_updateFW	= GetProcessCount("Module_UpdateFW");
 
 
-//	if (systemPage == 0x09 || systemPage == 0x0A)
+	//if (systemPage != _LCM_FIX )
 	{
 	{
 		if (count_main < _SYSTEM_TASK_COUNT_MAIN )
 		if (count_main < _SYSTEM_TASK_COUNT_MAIN )
 		{
 		{
+            ///*
+            system("/usr/bin/fuser -k /dev/watchdog");
+            sleep(1);
+            system("echo V > /dev/watchdog");
+            system("killall main");
 			system("killall Module_EventLogging");
 			system("killall Module_EventLogging");
 			system("killall Module_PrimaryComm");
 			system("killall Module_PrimaryComm");
 			system("killall Module_EvComm");
 			system("killall Module_EvComm");
@@ -90,60 +95,65 @@ unsigned char CheckSystemTask(unsigned char systemPage)
 			system("killall Module_DoComm");
 			system("killall Module_DoComm");
 			system("killall Module_ProduceUtils");
 			system("killall Module_ProduceUtils");
 			system("killall Module_UpdateFW");
 			system("killall Module_UpdateFW");
-			system("pkill main");
-            sleep(1);
             system("echo V > /dev/watchdog");
             system("echo V > /dev/watchdog");
-			system("/usr/bin/run_evse_restart.sh");
-            sleep(10);
+            sleep(3);
+            system("/root/main &");
+            sleep(20);
+            //*/
+            /*
+            log_info("System task lost (CSU). \n");
+            sleep(3);
+            system("reboot -f");
+            */
 		}
 		}
 		else
 		else
 		{
 		{
 			if (count_evComm < _SYSTEM_TASK_COUNT_EVCOMM )
 			if (count_evComm < _SYSTEM_TASK_COUNT_EVCOMM )
 			{
 			{
 				system("killall Module_EvComm");
 				system("killall Module_EvComm");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_EvComm &");
 				system("/root/Module_EvComm &");
 			}
 			}
         	if (count_interComm < _SYSTEM_TASK_COUNT_INTERNALCOMM )
         	if (count_interComm < _SYSTEM_TASK_COUNT_INTERNALCOMM )
 			{
 			{
 				system("killall Module_InternalComm");
 				system("killall Module_InternalComm");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_InternalComm &");
 				system("/root/Module_InternalComm &");
 			}
 			}
 			if (count_eventComm < _SYSTEM_TASK_COUNT_EVENTLOGGING )
 			if (count_eventComm < _SYSTEM_TASK_COUNT_EVENTLOGGING )
 			{
 			{
 				system("killall Module_EventLogging");
 				system("killall Module_EventLogging");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_EventLogging &");
 				system("/root/Module_EventLogging &");
 			}
 			}
 			if (count_primaryComm < _SYSTEM_TASK_COUNT_PRIMARYCOMM )
 			if (count_primaryComm < _SYSTEM_TASK_COUNT_PRIMARYCOMM )
 			{
 			{
 				system("killall Module_PrimaryComm");
 				system("killall Module_PrimaryComm");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_PrimaryComm &");
 				system("/root/Module_PrimaryComm &");
 			}
 			}
 			if (count_lcmComm < _SYSTEM_TASK_COUNT_LCM )
 			if (count_lcmComm < _SYSTEM_TASK_COUNT_LCM )
 			{
 			{
 				system("killall Module_LcmControl");
 				system("killall Module_LcmControl");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_LcmControl &");
 				system("/root/Module_LcmControl &");
 			}
 			}
 			if (count_doComm < _SYSTEM_TASK_COUNT_DOCOMM )
 			if (count_doComm < _SYSTEM_TASK_COUNT_DOCOMM )
 			{
 			{
 				system("killall Module_DoComm");
 				system("killall Module_DoComm");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_DoComm &");
 				system("/root/Module_DoComm &");
 			}
 			}
 			if (count_produceComm < _SYSTEM_TASK_COUNT_PRODUCEUTILS )
 			if (count_produceComm < _SYSTEM_TASK_COUNT_PRODUCEUTILS )
 			{
 			{
 				system("killall Module_ProduceUtils");
 				system("killall Module_ProduceUtils");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_ProduceUtils &");
 				system("/root/Module_ProduceUtils &");
 			}
 			}
 			if (count_updateFW < _SYSTEM_TASK_COUNT_UPDATEFW )
 			if (count_updateFW < _SYSTEM_TASK_COUNT_UPDATEFW )
 			{
 			{
 				system("killall Module_UpdateFW");
 				system("killall Module_UpdateFW");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_UpdateFW &");
 				system("/root/Module_UpdateFW &");
 			}
 			}
 		}
 		}
@@ -182,28 +192,28 @@ void CheckSystemTaskAlive()
 {
 {
     unsigned char lostId = CheckSystemTask(ShmSysConfigAndInfo->SysInfo.SystemPage);
     unsigned char lostId = CheckSystemTask(ShmSysConfigAndInfo->SysInfo.SystemPage);
     if (lostId != 0) {
     if (lostId != 0) {
-        log_info("Check task(%d) lost\n",lostId);
+        log_error("Check task(%d) lost\n",lostId);
         if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemTaskLost == NO) {
         if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemTaskLost == NO) {
            if (lostId == _SYSTEM_TASK_LOST_ITEM_MAIN)
            if (lostId == _SYSTEM_TASK_LOST_ITEM_MAIN)
-               log_info("System task lost (CSU). \n");
+               log_error("System task lost (CSU). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_EVCOMM)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_EVCOMM)
-               log_info("System task lost (EVComm). \n");
+               log_error("System task lost (EVComm). \n");
 //           else if (lostId == _SYSTEM_TASK_LOST_ITEM_PSUCOMM)
 //           else if (lostId == _SYSTEM_TASK_LOST_ITEM_PSUCOMM)
 //               PRINTF_FUNC("System task lost (PSU Task). \n");
 //               PRINTF_FUNC("System task lost (PSU Task). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_EVENTLOG)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_EVENTLOG)
-               log_info("System task lost (Event log). \n");
+               log_error("System task lost (Event log). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_PRIMARYCOMM)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_PRIMARYCOMM)
-               log_info("System task lost (Primary). \n");
+               log_error("System task lost (Primary). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_LCMCONTROL)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_LCMCONTROL)
-               log_info("System task lost (LCM Comm). \n");
+               log_error("System task lost (LCM Comm). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_INTERCOMM)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_INTERCOMM)
-               log_info("System task lost (Internal Comm). \n");
+               log_error("System task lost (Internal Comm). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_DOCOMM)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_DOCOMM)
-               log_info("System task lost (Do Comm). \n");
+               log_error("System task lost (Do Comm). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS)
-               log_info("System task lost (ProcductUtils Comm). \n");
+               log_error("System task lost (ProcductUtils Comm). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_UPDATEFW)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_UPDATEFW)
-               log_info("System task lost (Update FW) \n");
+               log_error("System task lost (Update FW) \n");
            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemTaskLost = YES;
            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemTaskLost = YES;
         }
         }
     } else
     } else
@@ -214,8 +224,8 @@ void CheckSystemTaskAlive()
 void main(void)
 void main(void)
 {
 {
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
-        return FAIL;
+        log_error("create share memory error");
+        return ;
     }
     }
 
 
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
@@ -224,7 +234,6 @@ void main(void)
     ShmSysConfigAndInfo = (struct SysConfigAndInfo *)GetShmSysConfigAndInfo();
     ShmSysConfigAndInfo = (struct SysConfigAndInfo *)GetShmSysConfigAndInfo();
     ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();	
     ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();	
     MappingGunChargingInfo("CheckSystem Task");
     MappingGunChargingInfo("CheckSystem Task");
-    sleep(20);
     while(true)
     while(true)
     {
     {
       	for (uint8_t gun = 0; gun < pSysConfig->TotalConnectorCount; gun++) {
       	for (uint8_t gun = 0; gun < pSysConfig->TotalConnectorCount; gun++) {

+ 14 - 3
EVSE/Projects/DD360/Apps/ModuleChkSysTask/Module_ChkSysTask.h

@@ -46,7 +46,8 @@
 #define _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS 8
 #define _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS 8
 #define _SYSTEM_TASK_LOST_ITEM_UPDATEFW     9
 #define _SYSTEM_TASK_LOST_ITEM_UPDATEFW     9
 
 
-#define _SYSTEM_TASK_COUNT_MAIN             4 
+///*
+#define _SYSTEM_TASK_COUNT_MAIN             5 
 #define _SYSTEM_TASK_COUNT_EVCOMM           2
 #define _SYSTEM_TASK_COUNT_EVCOMM           2
 #define _SYSTEM_TASK_COUNT_INTERNALCOMM     2
 #define _SYSTEM_TASK_COUNT_INTERNALCOMM     2
 #define _SYSTEM_TASK_COUNT_EVENTLOGGING     1
 #define _SYSTEM_TASK_COUNT_EVENTLOGGING     1
@@ -55,8 +56,18 @@
 #define _SYSTEM_TASK_COUNT_DOCOMM           1
 #define _SYSTEM_TASK_COUNT_DOCOMM           1
 #define _SYSTEM_TASK_COUNT_PRODUCEUTILS     1
 #define _SYSTEM_TASK_COUNT_PRODUCEUTILS     1
 #define _SYSTEM_TASK_COUNT_UPDATEFW         1
 #define _SYSTEM_TASK_COUNT_UPDATEFW         1
-
-
+//*/
+/*
+#define _SYSTEM_TASK_COUNT_MAIN             3 
+#define _SYSTEM_TASK_COUNT_EVCOMM           0
+#define _SYSTEM_TASK_COUNT_INTERNALCOMM     0
+#define _SYSTEM_TASK_COUNT_EVENTLOGGING     0
+#define _SYSTEM_TASK_COUNT_PRIMARYCOMM      0
+#define _SYSTEM_TASK_COUNT_LCM              0
+#define _SYSTEM_TASK_COUNT_DOCOMM           0
+#define _SYSTEM_TASK_COUNT_PRODUCEUTILS     0
+#define _SYSTEM_TASK_COUNT_UPDATEFW         0
+*/
 unsigned char CheckSystemTask(unsigned char systemPage);
 unsigned char CheckSystemTask(unsigned char systemPage);
 
 
 #endif /* CHECKSYSTEMTASK_H_ */
 #endif /* CHECKSYSTEMTASK_H_ */

+ 101 - 109
EVSE/Projects/DD360/Apps/ModuleDoComm/DoComm.c

@@ -29,11 +29,6 @@
 #include "../timeout.h"
 #include "../timeout.h"
 #include "DoComm.h"
 #include "DoComm.h"
 
 
-//------------------------------------------------------------------------------
-//#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-//#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-//#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 static DoCommGblData gDoCommGblData             = {0};
 static DoCommGblData gDoCommGblData             = {0};
 
 
@@ -52,6 +47,9 @@ static struct ChargingInfoData *pDcChargingInfo = NULL;
 static struct timeb             gRegTimeUp[2][MAX_REGISTER_NUM] = {0};
 static struct timeb             gRegTimeUp[2][MAX_REGISTER_NUM] = {0};
 static struct WARNING_CODE_INFO gPreSysWarningInfo = {0};
 static struct WARNING_CODE_INFO gPreSysWarningInfo = {0};
 
 
+// Hexdump
+char old_Hexdump[10240];
+
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 static void removeFaultCodeToBuf(uint8_t *Code);
 static void removeFaultCodeToBuf(uint8_t *Code);
 static void addFaultCodeToBuf(uint8_t *Code);
 static void addFaultCodeToBuf(uint8_t *Code);
@@ -67,39 +65,6 @@ void GetClockTime(struct timespec *_now_time, void *null)
     clock_gettime(CLOCK_MONOTONIC, _now_time);
     clock_gettime(CLOCK_MONOTONIC, _now_time);
 }
 }
 
 
-/*static 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 == 1) {
-        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",
-                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;
-}
-*/
-
 static int DiffTimeb(struct timeb ST, struct timeb ET)
 static int DiffTimeb(struct timeb ST, struct timeb ET)
 {
 {
     //return milli-second
     //return milli-second
@@ -127,8 +92,8 @@ static void Hexdump(const void *p, size_t size)
 
 
     assert(p);
     assert(p);
 
 
-    //printf("Dumping %u bytes from %p:\r\n", size, p);
-    message_len += sprintf(&message[message_len], "\r\nDumping %u bytes from %p:\r\n",  (unsigned int)size, p);
+    //printf("Dumping %u bytes from %p:\n", size, p);
+    message_len += sprintf(&message[message_len], "\nDumping %u bytes from %p:\n",  (unsigned int)size, p);
 
 
     while (size > 0) {
     while (size > 0) {
         for (i = 0; i < 16; i++) {
         for (i = 0; i < 16; i++) {
@@ -152,7 +117,7 @@ static void Hexdump(const void *p, size_t size)
         }
         }
 
 
         //printf("\n");
         //printf("\n");
-        message_len += sprintf(&message[message_len], "\r\n");
+        message_len += sprintf(&message[message_len], "\n");
         c += 16;
         c += 16;
 
 
         if (size <= 16) {
         if (size <= 16) {
@@ -162,9 +127,11 @@ static void Hexdump(const void *p, size_t size)
         size -= 16;
         size -= 16;
     }
     }
 
 
-    message_len += sprintf(&message[message_len], "\r\n");
-
-    log_info("%s", message);
+    //message_len += sprintf(&message[message_len], "\n");
+    if( strcmp(old_Hexdump,message) != EQUAL ) {
+        log_info("%s", message);
+        strcpy(old_Hexdump,message);
+    }
 }
 }
 
 
 static int string2ByteArray(char *input, uint8_t *output)
 static int string2ByteArray(char *input, uint8_t *output)
@@ -182,7 +149,7 @@ static int string2ByteArray(char *input, uint8_t *output)
 
 
 static void unixSocketSigPipeHandle(int sig)
 static void unixSocketSigPipeHandle(int sig)
 {
 {
-    log_error("socket packet error %x\r\n", sig);
+    log_error("socket packet error %x", sig);
 }
 }
 
 
 static void InitSocketSigPipe(void)
 static void InitSocketSigPipe(void)
@@ -211,7 +178,7 @@ static int sendTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
     size = send(fd, data, dataLen , 0);
     size = send(fd, data, dataLen , 0);
     if ((size < 0) || (errno == EAGAIN)) {
     if ((size < 0) || (errno == EAGAIN)) {
         if (size < 0) {
         if (size < 0) {
-            log_error("Size = %d, EAGAIN error %d:%s\r\n", size, errno, strerror(errno));
+            log_error("Send Socket Size = %d, EAGAIN error %d:%s", size, errno, strerror(errno));
         }
         }
     }
     }
 
 
@@ -225,7 +192,7 @@ static int recvTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
 
 
     size = recv(fd, pdata, dataLen, MSG_WAITALL);
     size = recv(fd, pdata, dataLen, MSG_WAITALL);
     if ((errno == EAGAIN) || (size < 0)) {
     if ((errno == EAGAIN) || (size < 0)) {
-        log_error("Size = %d, EAGAIN error %d:%s\r\n", size, errno, strerror(errno));
+        log_error("Receive Socket Size = %d, EAGAIN error %d:%s", size, errno, strerror(errno));
     }
     }
 
 
     return size;
     return size;
@@ -237,7 +204,7 @@ static int getSO_ERROR(int fd)
     socklen_t len = sizeof err;
     socklen_t len = sizeof err;
 
 
     if (-1 == getsockopt(fd, SOL_SOCKET, SO_ERROR, (char *)&err, &len)) {
     if (-1 == getsockopt(fd, SOL_SOCKET, SO_ERROR, (char *)&err, &len)) {
-        log_error("getSO_ERROR\r\n");
+        log_error("getSO_ERROR");
     }
     }
 
 
     if (err) {
     if (err) {
@@ -256,12 +223,12 @@ static void closeSocket(int fd)        // *not* the Windows closesocket()
     getSO_ERROR(fd); // first clear any errors, which can cause close to fail
     getSO_ERROR(fd); // first clear any errors, which can cause close to fail
     if (shutdown(fd, SHUT_RDWR) < 0) { // secondly, terminate the 'reliable' delivery
     if (shutdown(fd, SHUT_RDWR) < 0) { // secondly, terminate the 'reliable' delivery
         if (errno != ENOTCONN && errno != EINVAL) { // SGI causes EINVAL
         if (errno != ENOTCONN && errno != EINVAL) { // SGI causes EINVAL
-            log_info("shutdown\r\n");
+            log_info("shutdown");
         }
         }
     }
     }
 
 
     if (close(fd) < 0) { // finally call close()
     if (close(fd) < 0) { // finally call close()
-        log_info("client socket close\r\n");
+        log_info("client socket close");
     }
     }
 }
 }
 
 
@@ -400,10 +367,10 @@ static void setConfirmSelGun(uint8_t selGun)
 {
 {
     if (selGun == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_RELEASE) {
     if (selGun == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_RELEASE) {
         ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
         ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
-        //printf("confirmSelGun left\r\n");
+        //printf("confirmSelGun left");
     } else if (selGun == RIGHT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_RELEASE) {
     } else if (selGun == RIGHT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_RELEASE) {
         ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
         ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
-        //printf("confirmSelGun right\r\n");
+        //printf("confirmSelGun right");
     }
     }
 }
 }
 
 
@@ -413,7 +380,7 @@ static void setConfirmSelGun(uint8_t selGun)
 static int compareOpcode(uint8_t opCode)
 static int compareOpcode(uint8_t opCode)
 {
 {
     if (opCode != OP_WAIT_RESPONSE) {
     if (opCode != OP_WAIT_RESPONSE) {
-        //log_error("response operative code fail\r\n");
+        //log_error("response operative code fail");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -423,7 +390,7 @@ static int compareOpcode(uint8_t opCode)
 static int compareResult(uint8_t result)
 static int compareResult(uint8_t result)
 {
 {
     if (result != COMMAND_RESULT_OK) {
     if (result != COMMAND_RESULT_OK) {
-        //log_error("response result fail\r\n");
+        //log_error("response result fail");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -433,7 +400,7 @@ static int compareResult(uint8_t result)
 static int compareRegister(uint8_t srcReg, uint8_t destReg)
 static int compareRegister(uint8_t srcReg, uint8_t destReg)
 {
 {
     if (srcReg != destReg) {
     if (srcReg != destReg) {
-        //log_error("response register fail\r\n");
+        //log_error("response register fail");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -442,7 +409,7 @@ static int compareRegister(uint8_t srcReg, uint8_t destReg)
 
 
 static float transPricesUnit(int prices)
 static float transPricesUnit(int prices)
 {
 {
-    //printf("prices = %.2f\r\n", prices * PRICES_UNIT);
+    //printf("prices = %.2f", prices * PRICES_UNIT);
     return (prices * PRICES_UNIT);
     return (prices * PRICES_UNIT);
 }
 }
 
 
@@ -461,7 +428,7 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     struct tm *tm;
     struct tm *tm;
 
 
     if ((char *)&data[0] == '\0') {
     if ((char *)&data[0] == '\0') {
-        log_error("QR code date error\r\n");
+        log_error("QR code date error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -479,14 +446,14 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     //copy QR code string
     //copy QR code string
     if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
     if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
         memset(pSysConfig->SystemId, '\0', sizeof(pSysConfig->SystemId));
         memset(pSysConfig->SystemId, '\0', sizeof(pSysConfig->SystemId));
-        //printf("data =  %s\r\n", data);
+        //printf("data =  %s", data);
         //len =
         //len =
         string2ByteArray((char *)data, (uint8_t *)pSysConfig->SystemId);
         string2ByteArray((char *)data, (uint8_t *)pSysConfig->SystemId);
-        //printf("SystemId =  %s\r\n", pSysConfig->SystemId);
+        //printf("SystemId =  %s", pSysConfig->SystemId);
     }
     }
 
 
     //if ((char *)&data[len] == '\0') {
     //if ((char *)&data[len] == '\0') {
-    //    log_error("power cabinet system date error\r\n");
+    //    log_error("power cabinet system date error");
     //    return FAIL;
     //    return FAIL;
     //}
     //}
 
 
@@ -494,7 +461,7 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     //if (strncmp((char *)localTime, (char *)&data[len], timeLen) != 0) {
     //if (strncmp((char *)localTime, (char *)&data[len], timeLen) != 0) {
     //    sprintf(cmdBuf, "date -s \"%s\" >> /dev/null", (char *)&data[len]);
     //    sprintf(cmdBuf, "date -s \"%s\" >> /dev/null", (char *)&data[len]);
     //    system(cmdBuf);
     //    system(cmdBuf);
-    //    log_info("local time = %s, data time = %s\r\n", localTime, (char *)&data[len]);
+    //    log_info("local time = %s, data time = %s", localTime, (char *)&data[len]);
     //    ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
     //    ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
     //    strcpy((char *)ShmOCPP16Data->Reset.Type, "Soft");
     //    strcpy((char *)ShmOCPP16Data->Reset.Type, "Soft");
     //    sleep(3);
     //    sleep(3);
@@ -510,12 +477,12 @@ static int updateFirmwareHandle(uint8_t *imgName)
     char cmdBuf[1024] = {0};
     char cmdBuf[1024] = {0};
 
 
     sprintf(cmdBuf, "/mnt/%s", imgName);
     sprintf(cmdBuf, "/mnt/%s", imgName);
-    log_info("Program ready to check file %s\n", cmdBuf);
+    log_info("Program ready to check file %s", cmdBuf);
     if ( access(cmdBuf, F_OK) != -1) {
     if ( access(cmdBuf, F_OK) != -1) {
-        log_info("File '%s' exist.\n", cmdBuf);
+        log_info("File '%s' exist.", cmdBuf);
         pSysInfo->FirmwareUpdate = YES;
         pSysInfo->FirmwareUpdate = YES;
     } else {
     } else {
-        log_info("File '%s' doesn't exist.\n", cmdBuf);
+        log_info("File '%s' doesn't exist.", cmdBuf);
         ret = FAIL;
         ret = FAIL;
     }
     }
 
 
@@ -535,17 +502,17 @@ static int updateFirmwareHandle(uint8_t *imgName)
     if (-1 == status) {
     if (-1 == status) {
         printf("system error!");
         printf("system error!");
     } else {
     } else {
-        printf("exit status value = [0x%x]\n", status);
+        printf("exit status value = [0x%x]", status);
 
 
         if (WIFEXITED(status)) {
         if (WIFEXITED(status)) {
             if (0 == WEXITSTATUS(status)) {
             if (0 == WEXITSTATUS(status)) {
-                printf("run shell script successfully.\n");
+                printf("run shell script successfully.");
                 pSysInfo->FirmwareUpdate = YES;
                 pSysInfo->FirmwareUpdate = YES;
             } else {
             } else {
-                printf("run shell script fail, script exit code: %d\n", WEXITSTATUS(status));
+                printf("run shell script fail, script exit code: %d", WEXITSTATUS(status));
             }
             }
         } else {
         } else {
-            printf("exit status = [%d]\n", WEXITSTATUS(status));
+            printf("exit status = [%d]", WEXITSTATUS(status));
         }
         }
     }
     }
 
 
@@ -567,7 +534,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
 
 
     if (cmdCount < 1) {
     if (cmdCount < 1) {
         gDoCommGblData.MiscCmd = 0;
         gDoCommGblData.MiscCmd = 0;
-        //printf("cmdCount fail = %d, data len = %d\r\n", cmdCount, dataLen);
+        //printf("cmdCount fail = %d, data len = %d", cmdCount, dataLen);
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -575,13 +542,13 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
         pMiscCmd = (MiscCommand *)data + i;
         pMiscCmd = (MiscCommand *)data + i;
         cmd = ntohs(pMiscCmd->CMD);
         cmd = ntohs(pMiscCmd->CMD);
         value = ntohl(*((uint32_t *)&pMiscCmd->Value[0]));
         value = ntohl(*((uint32_t *)&pMiscCmd->Value[0]));
-        //log_info("misc command = %x, value = %d\r\n", cmd, value);
+        //log_info("misc command = %x, value = %d", cmd, value);
 
 
         switch (cmd) {
         switch (cmd) {
         //--- Execute parameter ---
         //--- Execute parameter ---
         case MISC_CMD_CONNECOTOR_TIMEOUT:
         case MISC_CMD_CONNECOTOR_TIMEOUT:
             ShmSelectGunInfo->RemoteSetup.ConnectionTimeout = value;
             ShmSelectGunInfo->RemoteSetup.ConnectionTimeout = value;
-            log_info("connection timeout = %d\r\n", ShmSelectGunInfo->RemoteSetup.ConnectionTimeout);
+            log_info("connection timeout = %d", ShmSelectGunInfo->RemoteSetup.ConnectionTimeout);
             clearMiscCommand();
             clearMiscCommand();
             break;
             break;
 
 
@@ -593,7 +560,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 break;
                 break;
             }
             }
 
 
-            log_info("change availability plugNum = %d, value = %d\r\n", plugNum, value);
+            log_info("change availability plugNum = %d, value = %d", plugNum, value);
             ShmOCPP16Data->CsMsg.bits[plugNum].ChangeAvailabilityReq = YES;
             ShmOCPP16Data->CsMsg.bits[plugNum].ChangeAvailabilityReq = YES;
             if (value == YES) {
             if (value == YES) {
                 strcpy((char *)ShmOCPP16Data->ChangeAvailability[plugNum].Type, "Operative");
                 strcpy((char *)ShmOCPP16Data->ChangeAvailability[plugNum].Type, "Operative");
@@ -608,7 +575,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
 
 
         case MISC_CMD_DEFAULT_PRICES:
         case MISC_CMD_DEFAULT_PRICES:
             prices = transPricesUnit((int)value);
             prices = transPricesUnit((int)value);
-            log_info("default prices = %.2f\r\n", prices);
+            log_info("default prices = %.2f", prices);
 
 
             //pSysConfig->BillingData.isBilling = YES;
             //pSysConfig->BillingData.isBilling = YES;
             for (j = 0; j < 24; j++) {
             for (j = 0; j < 24; j++) {
@@ -624,8 +591,8 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 return FAIL;
                 return FAIL;
             }
             }
 
 
-            //log_info("default currency = %s%c\r\n", (uint8_t *)Currency[value]);
-            log_info("default currency = %s\r\n", (uint8_t *)GetCurrency(value));
+            //log_info("default currency = %s%c", (uint8_t *)Currency[value]);
+            log_info("default currency = %s", (uint8_t *)GetCurrency(value));
             pSysConfig->BillingData.Currency = value;
             pSysConfig->BillingData.Currency = value;
             clearMiscCommand();
             clearMiscCommand();
             break;
             break;
@@ -638,13 +605,13 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
 
 
 #if defined DD360Audi
 #if defined DD360Audi
             if (getConfirmSelectedGun(plugNum) == FAIL) {
             if (getConfirmSelectedGun(plugNum) == FAIL) {
-                log_info("Remote start not select gun\r\n");
+                log_info("Remote start not select gun");
                 break;
                 break;
             }
             }
 #endif //DD360Audi
 #endif //DD360Audi
 
 
             ShmSelectGunInfo->PricesInfo[plugNum].Balance = transPricesUnit((int)value);
             ShmSelectGunInfo->PricesInfo[plugNum].Balance = transPricesUnit((int)value);
-            log_info("%d misc balance = %.2f\r\n", plugNum, ShmSelectGunInfo->PricesInfo[plugNum].Balance);
+            log_info("%d misc balance = %.2f", plugNum, ShmSelectGunInfo->PricesInfo[plugNum].Balance);
             clearMiscCommand();
             clearMiscCommand();
             break;
             break;
 
 
@@ -679,7 +646,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 break;
                 break;
             }
             }
 
 
-            log_info("Hardware reboot\r\n");
+            log_info("Hardware reboot");
             ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
             ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
             strcpy((char *)ShmOCPP16Data->Reset.Type, "Hard");
             strcpy((char *)ShmOCPP16Data->Reset.Type, "Hard");
             clearMiscCommand();
             clearMiscCommand();
@@ -692,7 +659,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
             }
             }
 
 
             clearMiscCommand();
             clearMiscCommand();
-            log_info("Software reboot\r\n");
+            log_info("Software reboot");
             ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
             ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
             strcpy((char *)ShmOCPP16Data->Reset.Type, "Soft");
             strcpy((char *)ShmOCPP16Data->Reset.Type, "Soft");
             break;
             break;
@@ -704,11 +671,11 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 }
                 }
                 break;
                 break;
             }
             }
-            log_info("Remote start charging plugNum = %d\r\n", plugNum);
+            log_info("Remote start charging plugNum = %d", plugNum);
 
 
 #if defined DD360Audi
 #if defined DD360Audi
             if (getSelGunWaitToAuthor(plugNum) == FAIL) {
             if (getSelGunWaitToAuthor(plugNum) == FAIL) {
-                log_error("Remote start gun already charging\r\n");
+                log_error("Remote start gun already charging");
                 break;
                 break;
             }
             }
 
 
@@ -791,6 +758,16 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
             }
             }
             break;
             break;
+        case MISC_CMD_AUTH_DISABLE:
+            pSysConfig->AutoAuth_Disable = value;
+            log_info("Auto Authorize Disable:%d", pSysConfig->AutoAuth_Disable);
+            //clearMiscCommand();
+        	break;
+        case MISC_CMD_EVCCID_ENABLE:
+            pSysConfig->EVCCID_Authorize = value;
+            log_info("Authorize By EVCCID:%d",pSysConfig->EVCCID_Authorize);
+            //clearMiscCommand();
+        	break;
 
 
         default:
         default:
             clearMiscCommand();
             clearMiscCommand();
@@ -840,7 +817,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
     //MaxVolt = (float)(data[0] << 8 |data[1]);
     //MaxVolt = (float)(data[0] << 8 |data[1]);
     //MaxCurrent = (float)(data[2] << 8 | data[3]);
     //MaxCurrent = (float)(data[2] << 8 | data[3]);
     //MaxPower = (float)(data[4] << 8 | data[5]);
     //MaxPower = (float)(data[4] << 8 | data[5]);
-    //printf("MaxVolt=%f, MaxCurrent=%f, MaxPower=%f,\n", MaxVolt, MaxCurrent, MaxPower);
+    //printf("MaxVolt=%f, MaxCurrent=%f, MaxPower=%f,", MaxVolt, MaxCurrent, MaxPower);
 
 
     //--- user prices information ----------------------------------------------
     //--- user prices information ----------------------------------------------
     addr = (sizeof(CapabilityInfo) - 2); //2 byte reserved
     addr = (sizeof(CapabilityInfo) - 2); //2 byte reserved
@@ -856,7 +833,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
         pricesInfo[plugNum].UserPrices = ShmSelectGunInfo->PricesInfo[plugNum].UserPrices;
         pricesInfo[plugNum].UserPrices = ShmSelectGunInfo->PricesInfo[plugNum].UserPrices;
         pricesInfo[plugNum].Balance = ShmSelectGunInfo->PricesInfo[plugNum].Balance;
         pricesInfo[plugNum].Balance = ShmSelectGunInfo->PricesInfo[plugNum].Balance;
 
 
-        log_info("id = %d, user prices = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s\r\n",
+        log_info("id = %d, user prices = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s",
                  plugNum,
                  plugNum,
                  ShmSelectGunInfo->PricesInfo[plugNum].UserPrices,
                  ShmSelectGunInfo->PricesInfo[plugNum].UserPrices,
                  pDcChargingInfo->ChargingFee,
                  pDcChargingInfo->ChargingFee,
@@ -940,12 +917,12 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
         remaindLen = dataLen % WARNING_CODE_SIZE;
         remaindLen = dataLen % WARNING_CODE_SIZE;
 
 
         if (remaindLen != 0) {
         if (remaindLen != 0) {
-            log_info("fail status code length =  %d\r\n", dataLen);
+            log_info("fail status code length =  %d", dataLen);
             dataLen -= remaindLen;
             dataLen -= remaindLen;
         }
         }
 
 
         if (dataLen < WARNING_CODE_SIZE) {
         if (dataLen < WARNING_CODE_SIZE) {
-            log_error("fail status code length = %d\r\n", dataLen);
+            log_error("fail status code length = %d", dataLen);
             Hexdump(data, dataLen);
             Hexdump(data, dataLen);
             if (pSysWarning->WarningCount > 0) {
             if (pSysWarning->WarningCount > 0) {
                 for (i = 0; i < pSysWarning->WarningCount; i++) {
                 for (i = 0; i < pSysWarning->WarningCount; i++) {
@@ -991,7 +968,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
             if (CompareArrayIsZero((uint8_t *)&data[count], WARNING_CODE_SIZE) == true) {
             if (CompareArrayIsZero((uint8_t *)&data[count], WARNING_CODE_SIZE) == true) {
                 memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
                 memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
                 memcpy(EventCodeTmp, (char *)&data[count], sizeof(EventCodeTmp));
                 memcpy(EventCodeTmp, (char *)&data[count], sizeof(EventCodeTmp));
-                log_error("error status = %s\r\n", EventCodeTmp);
+                log_error("error status = %s", EventCodeTmp);
                 continue;
                 continue;
             }
             }
 
 
@@ -1015,7 +992,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
         }
         }
     } else {
     } else {
         if (CompareArrayIsZero(data, WARNING_CODE_SIZE) == false) {
         if (CompareArrayIsZero(data, WARNING_CODE_SIZE) == false) {
-            log_error("power cabinet status code data length is zero, but have data\r\n");
+            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);
         }
         }
     }
     }
@@ -1077,7 +1054,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
     case REG_CONNECTOR_ID:
     case REG_CONNECTOR_ID:
         gDoCommGblData.ConnectorID[0] = pCsuResult->Data.Data[0];
         gDoCommGblData.ConnectorID[0] = pCsuResult->Data.Data[0];
         gDoCommGblData.ConnectorID[1] = pCsuResult->Data.Data[1];
         gDoCommGblData.ConnectorID[1] = pCsuResult->Data.Data[1];
-        log_info("OK (Left connector ID = %d, Right connector ID = %d)\n",
+        log_info("OK (Left connector ID = %d, Right connector ID = %d)",
                  pCsuResult->Data.Data[0],
                  pCsuResult->Data.Data[0],
                  pCsuResult->Data.Data[1]);
                  pCsuResult->Data.Data[1]);
         break;
         break;
@@ -1121,7 +1098,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
         break;
         break;
 
 
     case REG_USER_ID:
     case REG_USER_ID:
-        //log_info("%s\n", pCsuResult->Data.Data[0] == 1 ? "Accept" : "Reject" );
+        //log_info("%s", pCsuResult->Data.Data[0] == 1 ? "Accept" : "Reject" );
         //if (pCsuResult->Data.Data[0] <= 0) {
         //if (pCsuResult->Data.Data[0] <= 0) {
         //    return FAIL;
         //    return FAIL;
         //}
         //}
@@ -1135,7 +1112,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
         break;
         break;
 
 
     case REG_CHARGING_PERMISSION:
     case REG_CHARGING_PERMISSION:
-        //log_info("id = %d, result = %s, action = %s\r\n",
+        //log_info("id = %d, result = %s, action = %s",
         //           pCsuResult->Head.ID,
         //           pCsuResult->Head.ID,
         //           pCsuResult->Data.Result == 1 ? "OK" : "NG",
         //           pCsuResult->Data.Result == 1 ? "OK" : "NG",
         //           pCsuResult->Data.Data[0] == 1 ? "Permitted" : "NOT permitted");
         //           pCsuResult->Data.Data[0] == 1 ? "Permitted" : "NOT permitted");
@@ -1160,7 +1137,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
 
 
         ShmDcCommonData->PcPsuOutput[plugNum].Voltage = ntohs((uint16_t)pPcPsuOutput->Voltage);
         ShmDcCommonData->PcPsuOutput[plugNum].Voltage = ntohs((uint16_t)pPcPsuOutput->Voltage);
         ShmDcCommonData->PcPsuOutput[plugNum].Current = ntohs((uint16_t)pPcPsuOutput->Current);
         ShmDcCommonData->PcPsuOutput[plugNum].Current = ntohs((uint16_t)pPcPsuOutput->Current);
-        //log_info("%d power cabinet PSU output vol = %f, cur = %f\r\n",
+        //log_info("%d power cabinet PSU output vol = %f, cur = %f",
         //         plugNum,
         //         plugNum,
         //         (float)ShmDcCommonData->PcPsuOutput[plugNum].Voltage,
         //         (float)ShmDcCommonData->PcPsuOutput[plugNum].Voltage,
         //         (float)ShmDcCommonData->PcPsuOutput[plugNum].Current);
         //         (float)ShmDcCommonData->PcPsuOutput[plugNum].Current);
@@ -1185,7 +1162,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
             GroundFaultDetection *gfd = (GroundFaultDetection *)&pCsuResult->Data.Data[0];
             GroundFaultDetection *gfd = (GroundFaultDetection *)&pCsuResult->Data.Data[0];
             if(pDcChargingInfo->GroundFaultStatus != gfd->Status)
             if(pDcChargingInfo->GroundFaultStatus != gfd->Status)
             {
             {
-                log_info("id = %d, GFD Result = %d\r\n",
+                log_info("id = %d, GFD Result = %d",
                            pCsuResult->Head.ID,
                            pCsuResult->Head.ID,
                            gfd->Status);
                            gfd->Status);
             }
             }
@@ -1231,21 +1208,21 @@ static int composeSocketData(int fd,
 
 
     //send command packet
     //send command packet
     if ((size = sendTcpSocket(fd, (uint8_t *)&csuCmdPkt, sendPktLen)) < 0) {
     if ((size = sendTcpSocket(fd, (uint8_t *)&csuCmdPkt, sendPktLen)) < 0) {
-        log_error("TCP socket send packet fail = %d\r\n", size);
+        log_error("TCP socket send packet fail = %d", size);
         gDoCommGblData.DisConnCount++;
         gDoCommGblData.DisConnCount++;
         return FAIL;
         return FAIL;
     }
     }
 
 
     //receive result head
     //receive result head
     if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Head, sizeof(csuResult.Head))) < 0) {
     if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Head, sizeof(csuResult.Head))) < 0) {
-        log_error("TCP socket RX head fail = %d\r\n", size);
+        log_error("TCP socket RX head fail = %d", size);
         gDoCommGblData.DisConnCount++;
         gDoCommGblData.DisConnCount++;
         return FAIL;
         return FAIL;
     }
     }
 
 
     //receive result raw data
     //receive result raw data
     if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Data, csuResult.Head.DataLen)) < 0) {
     if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Data, csuResult.Head.DataLen)) < 0) {
-        log_error("TCP socket RX data fail = %d\r\n", size);
+        log_error("TCP socket RX data fail = %d", size);
         gDoCommGblData.DisConnCount++;
         gDoCommGblData.DisConnCount++;
         return FAIL;
         return FAIL;
     }
     }
@@ -1269,7 +1246,7 @@ static int writeWaitPlugItState(int fd, uint8_t id)
     int ret = PASS;
     int ret = PASS;
     uint8_t data[2] = {pSysInfo->WaitForPlugit, 0};
     uint8_t data[2] = {pSysInfo->WaitForPlugit, 0};
 
 
-    //printf("WaitForPlugit = %d\r\n", pSysInfo->WaitForPlugit);
+    //printf("WaitForPlugit = %d", pSysInfo->WaitForPlugit);
 
 
     if ((ret = composeSocketData(fd,
     if ((ret = composeSocketData(fd,
                                  id,
                                  id,
@@ -1468,7 +1445,7 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
                     (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
                     (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
                     WARNING_CODE_SIZE);
                     WARNING_CODE_SIZE);
             vendorErrorCodeTmp[plugNum][6] = '\0';
             vendorErrorCodeTmp[plugNum][6] = '\0';
-            log_info("1 ID = %d, VendorErrorCode = %s\r\n",
+            log_info("1 ID = %d, VendorErrorCode = %s",
                      plugNum,
                      plugNum,
                      (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
                      (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
         } else {
         } else {
@@ -1480,7 +1457,7 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
                         (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
                         (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
                         WARNING_CODE_SIZE);
                         WARNING_CODE_SIZE);
                 vendorErrorCodeTmp[plugNum][6] = '\0';
                 vendorErrorCodeTmp[plugNum][6] = '\0';
-                log_info("2 ID = %d, VendorErrorCode = %s\r\n",
+                log_info("2 ID = %d, VendorErrorCode = %s",
                          plugNum,
                          plugNum,
                          (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
                          (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
             }
             }
@@ -1755,7 +1732,7 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
                     strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted");
                     strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted");
                 }
                 }
 
 
-                //printf("%d Balance = %.2f, %.2f\r\n",
+                //printf("%d Balance = %.2f, %.2f\n",
                 //       plugNum,
                 //       plugNum,
                 //       ShmSelectGunInfo->PricesInfo[plugNum].Balance,
                 //       ShmSelectGunInfo->PricesInfo[plugNum].Balance,
                 //       FAIL_BALANCE_PRICES);
                 //       FAIL_BALANCE_PRICES);
@@ -1866,7 +1843,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
             //check misc command from power cabinet
             //check misc command from power cabinet
             if (gDoCommGblData.MiscCmd != 0) {
             if (gDoCommGblData.MiscCmd != 0) {
                 if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
                 if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
-                    log_error("misc command failed = %x\r\n", gDoCommGblData.MiscCmd);
+                    log_error("misc command failed = %x", gDoCommGblData.MiscCmd);
                 }
                 }
                 curReg = gDoCommGblData.MiscCmd;
                 curReg = gDoCommGblData.MiscCmd;
             } else {
             } else {
@@ -1931,7 +1908,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         //    break;
         //    break;
 
 
         default:
         default:
-            log_error("error curReg = %x\r\n", curReg);
+            log_error("error curReg = %x", curReg);
             gDoCommGblData.MiscCmd = 0;
             gDoCommGblData.MiscCmd = 0;
             gDoCommGblData.DisConnCount = CHECK_NETWORK_FAIL_COUNT;
             gDoCommGblData.DisConnCount = CHECK_NETWORK_FAIL_COUNT;
             isContinue = 0;
             isContinue = 0;
@@ -1981,7 +1958,15 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
             writeWaitPlugItState(fd, gunID);
             writeWaitPlugItState(fd, gunID);
             ftime(&gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE]);
             ftime(&gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE]);
         }
         }
-
+        /*
+        ftime(&AuthNowTime);
+        if (DiffTimeb(gRegTimeUp[plugNum][REG_MISC_CONTROL], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
+                DiffTimeb(gRegTimeUp[plugNum][REG_MISC_CONTROL], AuthNowTime) < 0
+           ) {
+            readMiscCommand(fd, gunID);
+            ftime(&gRegTimeUp[plugNum][REG_MISC_CONTROL]);
+        }
+        */
         ftime(&AuthNowTime);
         ftime(&AuthNowTime);
         if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
         if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) < 0
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) < 0
@@ -2042,7 +2027,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
            ) {
            ) {
             if (readChargePermission(fd, gunID) == 0) {
             if (readChargePermission(fd, gunID) == 0) {
-                log_info("S_PREPARING_FOR_EV Stop charging by power cabinet's permission = %d, %d\r\n",
+                log_info("S_PREPARING_FOR_EV Stop charging by power cabinet's permission = %d, %d",
                          plugNum,
                          plugNum,
                          REG_CHARGING_PERMISSION);
                          REG_CHARGING_PERMISSION);
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
@@ -2081,7 +2066,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
            ) {
            ) {
             if (readChargePermission(fd, gunID) == 0) {
             if (readChargePermission(fd, gunID) == 0) {
-                log_info("S_PREPARING_FOR_EVSE Stop charging by power cabinet's permission = %d, %d\r\n",
+                log_info("S_PREPARING_FOR_EVSE Stop charging by power cabinet's permission = %d, %d",
                          plugNum,
                          plugNum,
                          REG_CHARGING_PERMISSION);
                          REG_CHARGING_PERMISSION);
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
@@ -2124,11 +2109,11 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
            ) {
            ) {
             if (readChargePermission(fd, gunID) == 0) {
             if (readChargePermission(fd, gunID) == 0) {
-                log_info("Stop charging by power cabinet's permission = %d, %d\r\n",
+                log_info("Stop charging by power cabinet's permission = %d, %d",
                          plugNum,
                          plugNum,
                          REG_CHARGING_PERMISSION);
                          REG_CHARGING_PERMISSION);
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
-                //printf("%d StopChargeFlag = %d\r\n", plugNum, pDcChargingInfo->StopChargeFlag);
+                //printf("%d StopChargeFlag = %d\n", plugNum, pDcChargingInfo->StopChargeFlag);
             }
             }
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
         }
         }
@@ -2178,7 +2163,7 @@ static int networkCreatePorcess(void)
 
 
     while (!CheckNetworkStatus()) {
     while (!CheckNetworkStatus()) {
         calDisconnectCount(&gDoCommGblData.DisConnCount, CHECK_NETWORK_FAIL_COUNT);
         calDisconnectCount(&gDoCommGblData.DisConnCount, CHECK_NETWORK_FAIL_COUNT);
-        log_error("disconnect count = % d\r\n", gDoCommGblData.DisConnCount);
+        log_error("disconnect count = % d", gDoCommGblData.DisConnCount);
     }
     }
     log_info("Dispenser Network Information checked: IP = % s Netmask = % s, Gateway = % s",
     log_info("Dispenser Network Information checked: IP = % s Netmask = % s, Gateway = % s",
              pSysConfig->Eth0Interface.EthIpAddress,
              pSysConfig->Eth0Interface.EthIpAddress,
@@ -2191,7 +2176,7 @@ static int networkCreatePorcess(void)
     log_info("Connect to Power Cabinet");
     log_info("Connect to Power Cabinet");
     while ((fd = doCommConnToServer()) <= 0) {
     while ((fd = doCommConnToServer()) <= 0) {
         calDisconnectCount(&gDoCommGblData.DisConnCount, CONNECT_SERVER_FAIL_COUNT);
         calDisconnectCount(&gDoCommGblData.DisConnCount, CONNECT_SERVER_FAIL_COUNT);
-        log_error("disconnect count = %d, fd = %d\r\n", gDoCommGblData.DisConnCount, fd);
+        log_error("disconnect count = %d, fd = %d", gDoCommGblData.DisConnCount, fd);
     }
     }
     log_info("Power cabinet connected(fd = % d): IP = % s Netmask = % s, Gateway = % s",
     log_info("Power cabinet connected(fd = % d): IP = % s Netmask = % s, Gateway = % s",
              fd,
              fd,
@@ -2223,7 +2208,7 @@ int main(int argc, char *argv[])
 
 
     /**************** Initialization **********/
     /**************** Initialization **********/
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -2280,6 +2265,13 @@ int main(int argc, char *argv[])
                 if (initDone == DISPENSER_SOCKET_RECONN) {
                 if (initDone == DISPENSER_SOCKET_RECONN) {
                     break;
                     break;
                 }
                 }
+                initDone = messageTrigger(fd,
+                                          plugNum,
+                                          gunID,
+                                          REG_MISC_CONTROL);
+                if (initDone == DISPENSER_SOCKET_RECONN) {
+                    break;
+                }
             }
             }
         }
         }
 
 

+ 2 - 0
EVSE/Projects/DD360/Apps/ModuleDoComm/DoComm.h

@@ -109,6 +109,8 @@
 #define MISC_CMD_4G_STATUS                      (0x0009)
 #define MISC_CMD_4G_STATUS                      (0x0009)
 #define MISC_CMD_BILLING_INFO                   (0x000A)
 #define MISC_CMD_BILLING_INFO                   (0x000A)
 #define MISC_CMD_WEB_STOP_CHARGING              (0x000B)
 #define MISC_CMD_WEB_STOP_CHARGING              (0x000B)
+#define MISC_CMD_AUTH_DISABLE					(0x000C)
+#define MISC_CMD_EVCCID_ENABLE					(0x000D)
 
 
 #define MISC_CMD_HARDWARE_REBOOT                (0x0101)
 #define MISC_CMD_HARDWARE_REBOOT                (0x0101)
 #define MISC_CMD_SOFTWARE_RESTART               (0x0102)
 #define MISC_CMD_SOFTWARE_RESTART               (0x0102)

+ 86 - 42
EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -28,6 +28,13 @@ static struct CcsData *ShmCcsData = NULL;
 static struct FanModuleData *ShmFanModuleData = NULL;
 static struct FanModuleData *ShmFanModuleData = NULL;
 static DcCommonInfo *ShmDcCommonData = NULL;
 static DcCommonInfo *ShmDcCommonData = NULL;
 
 
+#define TempArraySize 10
+uint8_t TempArray_1[TempArraySize]={0};
+uint8_t TempArray_2[TempArraySize]={0};
+uint8_t ptemp_1 = 0;
+uint8_t ptemp_2 = 0;
+bool firstcircule = true;
+
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 extern bool AbnormalStopAnalysis(uint8_t gun_index, uint8_t *errCode);
 extern bool AbnormalStopAnalysis(uint8_t gun_index, uint8_t *errCode);
 
 
@@ -66,6 +73,43 @@ extern bool AbnormalStopAnalysis(uint8_t gun_index, uint8_t *errCode);
     return maxTemp;
     return maxTemp;
 }
 }
 */
 */
+static uint8_t getAvageTemp(uint8_t value,uint8_t gun)
+{
+    uint16_t avagetemp = 0;
+    int i;
+    uint8_t ptr = 0;
+    uint8_t *pArray; 
+    if(gun == 0) { 
+        pArray = &TempArray_1;
+        ptr = ptemp_1;
+    } else {
+        pArray = &TempArray_2;
+        ptr = ptemp_2;
+    }
+
+    pArray[ptr] = value;
+    for(i=0;i<TempArraySize;i++) 
+        avagetemp+=pArray[i];
+
+    if (firstcircule) {
+        avagetemp/=(ptr+1);
+    } else {
+        avagetemp/=TempArraySize;
+    }
+    ptr++;
+    if(ptr >= TempArraySize){
+        ptr = 0;
+        firstcircule = false;
+    }
+    if(gun == 0 )
+        ptemp_1 = ptr;
+    else 
+        ptemp_2 = ptr;
+
+    if(avagetemp > TEMP_BOUNDARY)
+        return UNDEFINED_TEMP;
+    return avagetemp;
+}
 
 
 static uint8_t getMaxConnectTemp(uint8_t headTemp1, uint8_t headTemp2)
 static uint8_t getMaxConnectTemp(uint8_t headTemp1, uint8_t headTemp2)
 {
 {
@@ -85,7 +129,6 @@ static uint8_t getMaxConnectTemp(uint8_t headTemp1, uint8_t headTemp2)
             maxTemp = headTemp2;
             maxTemp = headTemp2;
         }
         }
     }
     }
-
     return maxTemp;
     return maxTemp;
 }
 }
 
 
@@ -163,21 +206,21 @@ static void AddrAssignment(uint8_t *data)
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index - 1);
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index - 1);
     //DS60-120 add
     //DS60-120 add
     if (pDcChargingInfo->Type == _Type_Chademo) {
     if (pDcChargingInfo->Type == _Type_Chademo) {
-        log_info("Set EV board info : (Chademo) TargetAddr = %d \n", index);
+        log_info("Set EV board info : (Chademo) TargetAddr = %d ", index);
     } else if (pDcChargingInfo->Type == _Type_CCS_2) {
     } else if (pDcChargingInfo->Type == _Type_CCS_2) {
-        log_info("Set EV board info : (CCS) TargetAddr = %d \n", index);
+        log_info("Set EV board info : (CCS) TargetAddr = %d ", index);
     } else if (pDcChargingInfo->Type == _Type_GB) {
     } else if (pDcChargingInfo->Type == _Type_GB) {
-        log_info("Set EV board info : (GB) TargetAddr = %d \n", index);
+        log_info("Set EV board info : (GB) TargetAddr = %d ", index);
     }
     }
-    //log_info("EV board id = %x \n", index); //DS60-120 remove
+    //log_info("EV board id = %x ", index); //DS60-120 remove
 
 
-    //log_info("target_number[0] = %x \n", target_number[0]);
-    //log_info("target_number[1] = %x \n", target_number[1]);
-    //log_info("target_number[2] = %x \n", target_number[2]);
-    //log_info("target_number[3] = %x \n", target_number[3]);
-    //log_info("target_number[4] = %x \n", target_number[4]);
+    //log_info("target_number[0] = %x ", target_number[0]);
+    //log_info("target_number[1] = %x ", target_number[1]);
+    //log_info("target_number[2] = %x ", target_number[2]);
+    //log_info("target_number[3] = %x ", target_number[3]);
+    //log_info("target_number[4] = %x ", target_number[4]);
 
 
-    log_info("SetTargetAddr = %d, type = %d \n", index, pDcChargingInfo->Type);
+    log_info("SetTargetAddr = %d, type = %d ", index, pDcChargingInfo->Type);
 
 
     SetTargetAddr(target_number, index);
     SetTargetAddr(target_number, index);
     //}
     //}
@@ -190,7 +233,7 @@ void CANReceiver(int fd)
     canRecPid = fork();
     canRecPid = fork();
 
 
     if (canRecPid < 0) {
     if (canRecPid < 0) {
-        log_error("Create CAN Bus receive task failed\r\n");
+        log_error("Create CAN Bus receive task failed");
         return;
         return;
     }
     }
 
 
@@ -226,7 +269,7 @@ void CANReceiver(int fd)
         ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
         ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
         ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();
         ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();
 
 
-        log_info("Module_EvRXComm Child's PID is %d\r\n", getpid());
+        log_info("Module_EvRXComm Child's PID is %d", getpid());
 
 
         while (isContinue) {
         while (isContinue) {
             memset(&frame, 0, sizeof(struct can_frame));
             memset(&frame, 0, sizeof(struct can_frame));
@@ -267,7 +310,7 @@ void CANReceiver(int fd)
             }
             }
 
 
             if ((targetGun < 0) || (targetGun >= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)) {
             if ((targetGun < 0) || (targetGun >= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)) {
-                log_info("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY \n", targetGun);
+                log_info("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY ", targetGun);
                 usleep(10000);
                 usleep(10000);
                 continue;
                 continue;
             }
             }
@@ -291,25 +334,25 @@ void CANReceiver(int fd)
             case NOTIFICATION_EV_STATUS:
             case NOTIFICATION_EV_STATUS:
                 if (pDcChargingInfo->ConnectorPlugIn != frame.data[0]) {
                 if (pDcChargingInfo->ConnectorPlugIn != frame.data[0]) {
                     if (frame.data[0] == PLUG) {
                     if (frame.data[0] == PLUG) {
-                        log_info("Conn %d, Plugin. \n", targetGun);
-                        pDcChargingInfo->isVerify = false;
+                        log_info("Conn %d, Plugin. ", targetGun);
+                        pDcChargingInfo->isEVCCIDVerify = false;
                     } else if (frame.data[0] == UNPLUG) {
                     } else if (frame.data[0] == UNPLUG) {
-                        log_info("Conn %d, Unplug. \n", targetGun);
+                        log_info("Conn %d, Unplug. ", targetGun);
                         strcpy( (char *) pDcChargingInfo->EVCCID, "");
                         strcpy( (char *) pDcChargingInfo->EVCCID, "");
                     } else {
                     } else {
-                        log_info("Conn %d, None Check. (%d) \n", targetGun, frame.data[0]);
+                        log_info("Conn %d, None Check. (%d) ", targetGun, frame.data[0]);
                     }
                     }
                 }
                 }
 
 
                 pDcChargingInfo->ConnectorPlugIn = frame.data[0];
                 pDcChargingInfo->ConnectorPlugIn = frame.data[0];
                 pDcChargingInfo->PilotVoltage = frame.data[1];
                 pDcChargingInfo->PilotVoltage = frame.data[1];
 
 
-                //log_info("index = %d, ConnectorPlugIn = %x, data[0] = %x \n",
+                //log_info("index = %d, ConnectorPlugIn = %x, data[0] = %x ",
                 //         targetGun,
                 //         targetGun,
                 //         pDcChargingInfo->ConnectorPlugIn,
                 //         pDcChargingInfo->ConnectorPlugIn,
                 //         frame.data[0]);
                 //         frame.data[0]);
 
 
-                //log_info("ConnectorPlugIn = %x \n", (-120 + frame.data[1]) / 10);
+                //log_info("ConnectorPlugIn = %x ", (-120 + frame.data[1]) / 10);
                 break;
                 break;
 
 
             case ACK_EV_FW_VERSION:
             case ACK_EV_FW_VERSION:
@@ -318,12 +361,12 @@ void CANReceiver(int fd)
                     memcpy(ver, frame.data, frame.can_dlc);
                     memcpy(ver, frame.data, frame.can_dlc);
                     memcpy(ShmCHAdeMOData->evse[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
                     memcpy(ShmCHAdeMOData->evse[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
                     ShmCHAdeMOData->evse[gunTypeIndex].SelfTest_Comp = PASS;
                     ShmCHAdeMOData->evse[gunTypeIndex].SelfTest_Comp = PASS;
-                    //log_info("chademo ver. : %s\n", ShmCHAdeMOData->evse[gunTypeIndex].version);
+                    log_info("chademo ver. : %s", ShmCHAdeMOData->evse[gunTypeIndex].version);
                 } else if (pDcChargingInfo->Type == _Type_GB) {
                 } else if (pDcChargingInfo->Type == _Type_GB) {
                     memcpy(ver, frame.data, frame.can_dlc);
                     memcpy(ver, frame.data, frame.can_dlc);
                     memcpy(ShmGBTData->evse[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
                     memcpy(ShmGBTData->evse[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
                     ShmGBTData->evse[gunTypeIndex].SelfTest_Comp = PASS;
                     ShmGBTData->evse[gunTypeIndex].SelfTest_Comp = PASS;
-                    //log_info("gbt ver. : %s\n", ShmGBTData->evse[gunTypeIndex].version);
+                    log_info("gbt ver. : %s", ShmGBTData->evse[gunTypeIndex].version);
                 } else if (pDcChargingInfo->Type == _Type_CCS_2) {
                 } else if (pDcChargingInfo->Type == _Type_CCS_2) {
                     if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
                     if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
                         memcpy(ver, frame.data, frame.can_dlc); //DS60-120 add
                         memcpy(ver, frame.data, frame.can_dlc); //DS60-120 add
@@ -340,7 +383,7 @@ void CANReceiver(int fd)
 
 
                         memcpy(&ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
                         memcpy(&ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
                         ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].SelfTest_Comp = PASS;
                         ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].SelfTest_Comp = PASS;
-                        //log_info("CCS FW = %s \n", ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].version);
+                        log_info("CCS FW = %s ", ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].version);
                     }
                     }
                 }
                 }
 
 
@@ -360,7 +403,7 @@ void CANReceiver(int fd)
                 break;
                 break;
 
 
             case ACK_EV_HW_VERSION:
             case ACK_EV_HW_VERSION:
-                //log_info("Get EV HW = %s \n", frame.data);
+                //log_info("Get EV HW = %s ", frame.data);
                 break;
                 break;
 
 
             case ACK_GET_OUTPUT_REQ:
             case ACK_GET_OUTPUT_REQ:
@@ -385,17 +428,17 @@ void CANReceiver(int fd)
                 if (pDcChargingInfo->EvBatterytargetVoltage > (GetMaxChargingVol(targetGun) * 0.1)) {
                 if (pDcChargingInfo->EvBatterytargetVoltage > (GetMaxChargingVol(targetGun) * 0.1)) {
                     pDcChargingInfo->EvBatterytargetVoltage = (GetMaxChargingVol(targetGun) * 0.1);
                     pDcChargingInfo->EvBatterytargetVoltage = (GetMaxChargingVol(targetGun) * 0.1);
                 }
                 }
-                //printf("id = %d, EvBatterytargetVoltage = %.2f\r\n", targetGun, pDcChargingInfo->EvBatterytargetVoltage);
+                //printf("id = %d, EvBatterytargetVoltage = %.2f", targetGun, pDcChargingInfo->EvBatterytargetVoltage);
 
 
                 //Jerry add set currency limit
                 //Jerry add set currency limit
                 pDcChargingInfo->EvBatterytargetCurrent = (float)((frame.data[5] << 8) + frame.data[4]) / 10;
                 pDcChargingInfo->EvBatterytargetCurrent = (float)((frame.data[5] << 8) + frame.data[4]) / 10;
                 if (pDcChargingInfo->EvBatterytargetCurrent > (GetMaxCharginigCur(targetGun) * 0.1)) {
                 if (pDcChargingInfo->EvBatterytargetCurrent > (GetMaxCharginigCur(targetGun) * 0.1)) {
                     pDcChargingInfo->EvBatterytargetCurrent = (GetMaxCharginigCur(targetGun) * 0.1);
                     pDcChargingInfo->EvBatterytargetCurrent = (GetMaxCharginigCur(targetGun) * 0.1);
                 }
                 }
-                //printf("id = %d, EvBatterytargetCurrent = %.2f\r\n", targetGun, pDcChargingInfo->EvBatterytargetCurrent);
+                //printf("id = %d, EvBatterytargetCurrent = %.2f", targetGun, pDcChargingInfo->EvBatterytargetCurrent);
 
 
                 pDcChargingInfo->RemainChargingDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
                 pDcChargingInfo->RemainChargingDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
-                //printf("RemainChargingDuration = %d\r\n",  pDcChargingInfo->RemainChargingDuration);
+                //printf("RemainChargingDuration = %d",  pDcChargingInfo->RemainChargingDuration);
 
 
                 if (pDcChargingInfo->Type == _Type_Chademo) {
                 if (pDcChargingInfo->Type == _Type_Chademo) {
                     //if (ShmCHAdeMOData->ev[gunTypeIndex].EvDetection != frame.data[0])
                     //if (ShmCHAdeMOData->ev[gunTypeIndex].EvDetection != frame.data[0])
@@ -423,11 +466,11 @@ void CANReceiver(int fd)
                     }
                     }
                 }
                 }
 
 
-                //log_info("EvBatterytargetVoltage = %f \n", pDcChargingInfo->EvBatterytargetVoltage);
-                //log_info("EvBatterytargetCurrent = %f \n", pDcChargingInfo->EvBatterytargetCurrent);
-                //log_info("BatteryVoltage = %d \n",
+                //log_info("EvBatterytargetVoltage = %f ", pDcChargingInfo->EvBatterytargetVoltage);
+                //log_info("EvBatterytargetCurrent = %f ", pDcChargingInfo->EvBatterytargetCurrent);
+                //log_info("BatteryVoltage = %d ",
                 //         ShmCHAdeMOData->ev[_chargingData[target]->type_index].TargetBatteryVoltage);
                 //         ShmCHAdeMOData->ev[_chargingData[target]->type_index].TargetBatteryVoltage);
-                //log_info("CurrentRequest = %d \n",
+                //log_info("CurrentRequest = %d ",
                 //         ShmCHAdeMOData->ev[_chargingData[target]->type_index].ChargingCurrentRequest);
                 //         ShmCHAdeMOData->ev[_chargingData[target]->type_index].ChargingCurrentRequest);
                 break;
                 break;
 
 
@@ -441,9 +484,9 @@ void CANReceiver(int fd)
                     ShmCHAdeMOData->ev[gunTypeIndex].TotalBatteryCapacity = ((uint16_t)frame.data[2] << 8) + (uint16_t)frame.data[1];
                     ShmCHAdeMOData->ev[gunTypeIndex].TotalBatteryCapacity = ((uint16_t)frame.data[2] << 8) + (uint16_t)frame.data[1];
                     ShmCHAdeMOData->ev[gunTypeIndex].MaxiBatteryVoltage = pDcChargingInfo->EvBatteryMaxVoltage;
                     ShmCHAdeMOData->ev[gunTypeIndex].MaxiBatteryVoltage = pDcChargingInfo->EvBatteryMaxVoltage;
 
 
-                    //log_info("EvBatteryMaxVoltage = %f \n", _chargingData[target]->EvBatteryMaxVoltage);
-                    //log_info("TotalBatteryCapacity = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TotalBatteryCapacity);
-                    //log_info("MaxiBatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].MaxiBatteryVoltage);
+                    //log_info("EvBatteryMaxVoltage = %f ", _chargingData[target]->EvBatteryMaxVoltage);
+                    //log_info("TotalBatteryCapacity = %d ", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TotalBatteryCapacity);
+                    //log_info("MaxiBatteryVoltage = %d ", ShmCHAdeMOData->ev[_chargingData[target]->type_index].MaxiBatteryVoltage);
                 } else if (pDcChargingInfo->Type == _Type_GB) {
                 } else if (pDcChargingInfo->Type == _Type_GB) {
                     ShmGBTData->ev[gunTypeIndex].TotalBatteryCapacity = ((uint16_t)frame.data[2] << 8) + (uint16_t)frame.data[1];
                     ShmGBTData->ev[gunTypeIndex].TotalBatteryCapacity = ((uint16_t)frame.data[2] << 8) + (uint16_t)frame.data[1];
                     ShmGBTData->ev[gunTypeIndex].MaxiBatteryVoltage = pDcChargingInfo->EvBatteryMaxVoltage;
                     ShmGBTData->ev[gunTypeIndex].MaxiBatteryVoltage = pDcChargingInfo->EvBatteryMaxVoltage;
@@ -506,6 +549,7 @@ void CANReceiver(int fd)
                 //if ((maxConnTemp - 3) >= pDcChargingInfo->ConnectorTemp) {
                 //if ((maxConnTemp - 3) >= pDcChargingInfo->ConnectorTemp) {
                 //    printConnTemp = YES;
                 //    printConnTemp = YES;
                 //}
                 //}
+                maxConnTemp = getAvageTemp(maxConnTemp,targetGun);
                 if(maxConnTemp > (lastConnTemp[targetGun] + 2) || maxConnTemp < (lastConnTemp[targetGun] - 2))
                 if(maxConnTemp > (lastConnTemp[targetGun] + 2) || maxConnTemp < (lastConnTemp[targetGun] - 2))
                 {
                 {
                     lastConnTemp[targetGun] = maxConnTemp;
                     lastConnTemp[targetGun] = maxConnTemp;
@@ -524,7 +568,7 @@ void CANReceiver(int fd)
                         //  (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP)))
                         //  (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP)))
                    ) {
                    ) {
                     ShmDcCommonData->SystemModeChange[targetGun] = NO;
                     ShmDcCommonData->SystemModeChange[targetGun] = NO;
-                    log_info("Conn %d max head temp = %d, max chiller = %d, max chiller2 = %d\r\n",
+                    log_info("Conn %d max head temp = %d, max chiller = %d, max chiller2 = %d",
                              targetGun,
                              targetGun,
                              maxConnTemp,
                              maxConnTemp,
                              chillerTemp[0],
                              chillerTemp[0],
@@ -558,11 +602,11 @@ void CANReceiver(int fd)
                     //ShmFanModuleData->? = NO; //尚未定義
                     //ShmFanModuleData->? = NO; //尚未定義
                 }
                 }
 
 
-                //log_info("EvboardStatus = %x \n",
+                //log_info("EvboardStatus = %x ",
                 //         ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus);
                 //         ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus);
-                //log_info("ConnectorPlug locked = %x \n",
+                //log_info("ConnectorPlug locked = %x ",
                 //         frame.data[0]);
                 //         frame.data[0]);
-                //log_info("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
+                //log_info("PilotVoltage = %x ", (-120 + frame.data[3]) / 10);
                 break;
                 break;
 
 
             case ACK_EVSE_ISOLATION_STATUS:
             case ACK_EVSE_ISOLATION_STATUS:
@@ -579,7 +623,7 @@ void CANReceiver(int fd)
                         (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
                         (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
                          pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
                          pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
                     // frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
                     // frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
-                    log_info("(%d) NOTIFICATION_EV_STOP err level = %d-----------------------------\n",
+                    log_info("----------------------------- (%d) NOTIFICATION_EV_STOP err level = %d -----------------------------",
                              targetGun,
                              targetGun,
                              frame.data[0]);
                              frame.data[0]);
                     if (frame.data[0] == 0x02) {
                     if (frame.data[0] == 0x02) {
@@ -596,7 +640,7 @@ void CANReceiver(int fd)
                 break;
                 break;
             case ACK_EVCCID_REQ:
             case ACK_EVCCID_REQ:
 
 
-                        if (frame.can_dlc > 0 && strcmp ( pDcChargingInfo->EVCCID, "" ) == EQUAL)
+                        if (frame.can_dlc > 0 && strcmp ( (char *)pDcChargingInfo->EVCCID, "" ) == EQUAL)
                         {
                         {
                             if (pDcChargingInfo->Type == _Type_CCS_2)
                             if (pDcChargingInfo->Type == _Type_CCS_2)
                             {
                             {
@@ -613,11 +657,11 @@ void CANReceiver(int fd)
                                     frame.data [1], frame.data [2], frame.data [3], frame.data [4], frame.data [5] );
                                     frame.data [1], frame.data [2], frame.data [3], frame.data [4], frame.data [5] );
 
 
                             pDcChargingInfo->EVCCID [17] = '\0';
                             pDcChargingInfo->EVCCID [17] = '\0';
-                            log_info( "******* Gun %d->EVCCID = %s ************* \n", targetGun, pDcChargingInfo->EVCCID );
+                            log_info( "************* Gun %d->EVCCID = %s ************* ", targetGun, pDcChargingInfo->EVCCID );
                         }
                         }
                 break;
                 break;
             default:
             default:
-                log_info("EV board = %d, Ack none defined. intCmd = %d  \n", targetGun, intCmd);
+                log_info("EV board = %d, Ack none defined. intCmd = %d  ", targetGun, intCmd);
                 break;
                 break;
             }//switch
             }//switch
 
 

+ 45 - 29
EVSE/Projects/DD360/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -115,7 +115,7 @@ int InitCanBus(void)
     rxfilter[2].can_mask = 0x00000FFF;
     rxfilter[2].can_mask = 0x00000FFF;
     if (setsockopt(s0, SOL_CAN_RAW, CAN_RAW_FILTER,
     if (setsockopt(s0, SOL_CAN_RAW, CAN_RAW_FILTER,
                    &rxfilter, sizeof(struct can_filter) * 3) < 0) {
                    &rxfilter, sizeof(struct can_filter) * 3) < 0) {
-        log_error("RX setsockopt CAN_RAW_FILTER failed\r\n");
+        log_error("RX setsockopt CAN_RAW_FILTER failed");
     }
     }
 
 
     strcpy(ifr0.ifr_name, "can0");
     strcpy(ifr0.ifr_name, "can0");
@@ -340,7 +340,7 @@ static void SetPresentChargingOutputCap(void)
             maxCur = (pow1 * 1000) / chargingData_1->FireChargingVoltage;
             maxCur = (pow1 * 1000) / chargingData_1->FireChargingVoltage;
 
 
             if (maxCur * 10 <= cur1) {
             if (maxCur * 10 <= cur1) {
-                //log_info("Gun1 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur1);
+                //log_info("Gun1 -> MaxCharging Current = %f, Cap Current = %f ", (maxCur * 10), cur1);
                 cur1 = maxCur * 10;
                 cur1 = maxCur * 10;
             }
             }
         }
         }
@@ -365,7 +365,7 @@ static void SetPresentChargingOutputCap(void)
             maxCur = (pow2 * 1000) / chargingData_2->FireChargingVoltage;
             maxCur = (pow2 * 1000) / chargingData_2->FireChargingVoltage;
 
 
             if (maxCur * 10 <= cur2) {
             if (maxCur * 10 <= cur2) {
-                //log_info("Gun2 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur2);
+                //log_info("Gun2 -> MaxCharging Current = %f, Cap Current = %f ", (maxCur * 10), cur2);
                 cur2 = maxCur * 10;
                 cur2 = maxCur * 10;
             }
             }
         }
         }
@@ -381,10 +381,10 @@ static void SetPresentChargingOutputCap(void)
             (LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] <= cur2 - 5 ||
             (LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] <= cur2 - 5 ||
              LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] >= cur2 + 5)
              LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] >= cur2 + 5)
        ) {
        ) {
-        //log_info("----------------------------------------------------- \n");
-        log_info("To EV (Real) Power_1 = %.1f, Cur_1 = %.1f, Power_2 = %.1f, Cur_2 = %.1f\r\n",
+        //log_info("----------------------------------------------------- ");
+        log_info("To EV (Real) Power_1 = %.1f, Cur_1 = %.1f, Power_2 = %.1f, Cur_2 = %.1f",
                  pow1 / 10, cur1 / 10, pow2 / 10, cur2 / 10);
                  pow1 / 10, cur1 / 10, pow2 / 10, cur2 / 10);
-        //log_info("----------------------------------------------------- \n");
+        //log_info("----------------------------------------------------- ");
 
 
         LogInfo[0][EV_LOG_OUTPUT_CAP_POW] = pow1;
         LogInfo[0][EV_LOG_OUTPUT_CAP_POW] = pow1;
         LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] = cur1;
         LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] = cur1;
@@ -484,7 +484,7 @@ static void SetPresentChargingOutputFromPcPsu(uint8_t gunCount)
         (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) ||
         (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) ||
         (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
         (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
     ) {
     ) {
-        log_info("G1 -> Output Vol = %.1f, Output Cur = %.1f -- G2 -> Output Vol = %.1f, Output Cur = %.1f\r\n",
+        log_info("G1 -> Output Vol = %.1f, Output Cur = %.1f -- G2 -> Output Vol = %.1f, Output Cur = %.1f",
                  vol1,
                  vol1,
                  cur1 / 10,
                  cur1 / 10,
                  vol2,
                  vol2,
@@ -546,7 +546,7 @@ static void SetPresentChargingOutputPower(void)
             (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) ||
             (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) ||
             (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
             (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
        ) {
        ) {
-        log_info("G1 -> Output Vol(%s) = %.1f, Output Cur = %.1f -- G2 -> Output Vol(%s) = %.1f, Output Cur = %.1f\r\n",
+        log_info("G1 -> Output Vol(%s) = %.1f, Output Cur = %.1f -- G2 -> Output Vol(%s) = %.1f, Output Cur = %.1f",
                  isPsuVol1 == true ? "P" : "R",
                  isPsuVol1 == true ? "P" : "R",
                  vol1 / 10,
                  vol1 / 10,
                  cur1 / 10,
                  cur1 / 10,
@@ -563,7 +563,7 @@ static void SetPresentChargingOutputPower(void)
     //        _outCur_1 != cur1 ||
     //        _outCur_1 != cur1 ||
     //        _outVol_2 != vol2 ||
     //        _outVol_2 != vol2 ||
     //        _outCur_2 != cur2) {
     //        _outCur_2 != cur2) {
-    /*log_info("G1 -> Output Vol = %f, Output Cur = %f -- G2 -> Output Vol = %f, Output Cur = %f \n",
+    /*log_info("G1 -> Output Vol = %f, Output Cur = %f -- G2 -> Output Vol = %f, Output Cur = %f ",
         vol1, cur1, vol2, cur2);
         vol1, cur1, vol2, cur2);
     */
     */
     //    _outVol_1 = vol1; _outCur_1 = cur1; _outVol_2 = vol2; _outCur_2 = cur2;
     //    _outVol_1 = vol1; _outCur_1 = cur1; _outVol_2 = vol2; _outCur_2 = cur2;
@@ -644,7 +644,7 @@ static void FormatVoltageAndCurrent(void)
     RateCurInfo *pRatedCurInfo = NULL;
     RateCurInfo *pRatedCurInfo = NULL;
 
 
     if (RatedCurrentParsing((char *)pSysConfig->ModelName, &parsingRatedCur) != PASS) {
     if (RatedCurrentParsing((char *)pSysConfig->ModelName, &parsingRatedCur) != PASS) {
-        log_error("Parsing rated current failed\r\n");
+        log_error("Parsing rated current failed");
         return;
         return;
     }
     }
 
 
@@ -656,7 +656,7 @@ static void FormatVoltageAndCurrent(void)
         maxChargingVol[gunIndex] = pRatedCurInfo->Voltage;
         maxChargingVol[gunIndex] = pRatedCurInfo->Voltage;
         maxChargingCur[gunIndex] = pRatedCurInfo->Current;
         maxChargingCur[gunIndex] = pRatedCurInfo->Current;
 
 
-        log_info("Conn %d GunType = %d, MaxVol = %f, MaxCur = %f \n",
+        log_info("Conn %d GunType = %d, MaxVol = %f, MaxCur = %f ",
                  gunIndex,
                  gunIndex,
                  pRatedCurInfo->GunType,
                  pRatedCurInfo->GunType,
                  maxChargingVol[gunIndex],
                  maxChargingVol[gunIndex],
@@ -695,7 +695,7 @@ int main(int argc, char *argv[])
     struct timeb nowTime;
     struct timeb nowTime;
 
 
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -743,9 +743,26 @@ int main(int argc, char *argv[])
                         GetFirmwareVersion(gunIndex, pDcChargingInfo->Evboard_id);
                         GetFirmwareVersion(gunIndex, pDcChargingInfo->Evboard_id);
                     }
                     }
                 }
                 }
-
+                /*
+                if (pDcChargingInfo->Type == _Type_Chademo) {
+                    pAlarmCode->AlarmEvents.bits.ChademoboardStestFail = 
+                        (ShmCHAdeMOData->evse[typeIndex].SelfTest_Comp != PASS) ? true : false;
+                    pAlarmCode->AlarmEvents.bits.ChademoModuleCommFail =
+                        ( CanFd < 0 ) ? true : false;
+                } else if (pDcChargingInfo->Type == _Type_GB) {
+                    pAlarmCode->AlarmEvents.bits.GbtboardStestFail = 
+                        (ShmGBTData->evse[typeIndex].SelfTest_Comp != PASS) ? true : false;
+                    pAlarmCode->AlarmEvents.bits.mFail =
+                        ( CanFd < 0 ) ? true : false;
+                } else if (pDcChargingInfo->Type == _Type_CCS_2) {
+                    pAlarmCode->AlarmEvents.bits.CCSboardStestFail = 
+                        (ShmCcsData->V2GMessage_DIN70121[typeIndex].SelfTest_Comp != PASS) ? true : false;
+                    pAlarmCode->AlarmEvents.bits.ChademoModuleCommFail =
+                        ( CanFd < 0 ) ? true : false;
+                        
+                }*/
                 //固定要取得的資訊 : 1.槍鎖狀態, 2."Connector 1" 溫度, 3."Connector 2" 溫度, 4.Pilot Voltage
                 //固定要取得的資訊 : 1.槍鎖狀態, 2."Connector 1" 溫度, 3."Connector 2" 溫度, 4.Pilot Voltage
-                //log_info("GetMiscellaneousInfo. index = %d, Eid = %d \n",
+                //log_info("GetMiscellaneousInfo. index = %d, Eid = %d ",
                 //         gunIndex,
                 //         gunIndex,
                 //         pDcChargingInfo->Evboard_id);
                 //         pDcChargingInfo->Evboard_id);
                 GetMiscellaneousInfo(gunIndex,
                 GetMiscellaneousInfo(gunIndex,
@@ -801,17 +818,16 @@ int main(int argc, char *argv[])
                         pDcChargingInfo->StopChargeFlag = NO;
                         pDcChargingInfo->StopChargeFlag = NO;
                     }
                     }
                 }
                 }
-
-#ifdef DD360ComBox
+#if !defined DD360Audi
                     // Set Ev board in communication mode
                     // Set Ev board in communication mode
                     // Get EVCCID for authorize when gun plug-in only for CCS
                     // Get EVCCID for authorize when gun plug-in only for CCS
                     if(pDcChargingInfo->Type == _Type_CCS_2 && priorityLow == 5) {
                     if(pDcChargingInfo->Type == _Type_CCS_2 && priorityLow == 5) {
-                       if (pDcChargingInfo->ConnectorPlugIn && strcmp(pDcChargingInfo->EVCCID,"") == EQUAL) {
+                       if (pDcChargingInfo->ConnectorPlugIn && strcmp((char *)pDcChargingInfo->EVCCID,"") == EQUAL) {
                            GetEVCCIDReq(gunIndex,pDcChargingInfo->Evboard_id);
                            GetEVCCIDReq(gunIndex,pDcChargingInfo->Evboard_id);
                            SendCommunicationOnly(gunIndex);
                            SendCommunicationOnly(gunIndex);
                         }
                         }
                     }
                     }
-#endif 
+#endif
                 if (priorityLow == 1) {
                 if (priorityLow == 1) {
                     pDcChargingInfo->PresentChargedEnergy   = 0;
                     pDcChargingInfo->PresentChargedEnergy   = 0;
                     pDcChargingInfo->PresentChargingPower   = 0;
                     pDcChargingInfo->PresentChargingPower   = 0;
@@ -867,11 +883,11 @@ int main(int argc, char *argv[])
                 // 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
                 // 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
                 GetOutputReq(gunIndex, pDcChargingInfo->Evboard_id);
                 GetOutputReq(gunIndex, pDcChargingInfo->Evboard_id);
 
 
-                //log_info("PresentChargingVoltage = %f \n", pDcChargingInfo->PresentChargingVoltage);
-                //log_info("PresentChargingCurrent = %f \n", pDcChargingInfo->PresentChargingCurrent);
-                //log_info("AvailableChargingPower = %f \n", pDcChargingInfo->AvailableChargingPower);
-                //log_info("AvailableChargingCurrent = %f \n", pDcChargingInfo->AvailableChargingCurrent);
-                //log_info("MaximumChargingVoltage = %f \n", pDcChargingInfo->MaximumChargingVoltage);
+                //log_info("PresentChargingVoltage = %f ", pDcChargingInfo->PresentChargingVoltage);
+                //log_info("PresentChargingCurrent = %f ", pDcChargingInfo->PresentChargingCurrent);
+                //log_info("AvailableChargingPower = %f ", pDcChargingInfo->AvailableChargingPower);
+                //log_info("AvailableChargingCurrent = %f ", pDcChargingInfo->AvailableChargingCurrent);
+                //log_info("MaximumChargingVoltage = %f ", pDcChargingInfo->MaximumChargingVoltage);
 
 
                 // 設定當前輸出
                 // 設定當前輸出
                 SetPresentChargingOutputPower();
                 SetPresentChargingOutputPower();
@@ -891,7 +907,7 @@ int main(int argc, char *argv[])
                         LogInfo[gunIndex][EV_LOG_EVSE_MAX_VOL] = maxVol;
                         LogInfo[gunIndex][EV_LOG_EVSE_MAX_VOL] = maxVol;
                         LogInfo[gunIndex][EV_LOG_EVSE_MAX_CUR] = maxCur;
                         LogInfo[gunIndex][EV_LOG_EVSE_MAX_CUR] = maxCur;
 
 
-                        log_info("To EV_%d Max_Vol = %.1f, Cap_Cur = %.1f, Cap_Pow = %.1f\n",
+                        log_info("To EV_%d Max_Vol = %.1f, Cap_Cur = %.1f, Cap_Pow = %.1f",
                                  gunIndex,
                                  gunIndex,
                                  maxVol / 10,
                                  maxVol / 10,
                                  maxCur / 10,
                                  maxCur / 10,
@@ -934,14 +950,14 @@ int main(int argc, char *argv[])
                 //DS60-120 add
                 //DS60-120 add
                 if (LogInfo[gunIndex][EV_LOG_MAX_BATT_VOL] != pDcChargingInfo->EvBatteryMaxVoltage) {
                 if (LogInfo[gunIndex][EV_LOG_MAX_BATT_VOL] != pDcChargingInfo->EvBatteryMaxVoltage) {
                     LogInfo[gunIndex][EV_LOG_MAX_BATT_VOL] = pDcChargingInfo->EvBatteryMaxVoltage;
                     LogInfo[gunIndex][EV_LOG_MAX_BATT_VOL] = pDcChargingInfo->EvBatteryMaxVoltage;
-                    log_info("index = %d, Ev Maximum Battery Voltage = %f \n",
+                    log_info("index = %d, Ev Maximum Battery Voltage = %f ",
                              gunIndex,
                              gunIndex,
                              pDcChargingInfo->EvBatteryMaxVoltage);
                              pDcChargingInfo->EvBatteryMaxVoltage);
                 }
                 }
 
 
                 if (LogInfo[gunIndex][EV_LOG_SOC] != pDcChargingInfo->EvBatterySoc) {
                 if (LogInfo[gunIndex][EV_LOG_SOC] != pDcChargingInfo->EvBatterySoc) {
                     LogInfo[gunIndex][EV_LOG_SOC] = pDcChargingInfo->EvBatterySoc;
                     LogInfo[gunIndex][EV_LOG_SOC] = pDcChargingInfo->EvBatterySoc;
-                    log_info("index = %d, SOC = %d \n",
+                    log_info("index = %d, SOC = %d ",
                              gunIndex,
                              gunIndex,
                              pDcChargingInfo->EvBatterySoc);
                              pDcChargingInfo->EvBatterySoc);
                 }
                 }
@@ -952,7 +968,7 @@ int main(int argc, char *argv[])
 //                      if (_chargingData[_index]->FireChargingVoltage >= 3500)
 //                      if (_chargingData[_index]->FireChargingVoltage >= 3500)
 //                         pDcChargingInfo->GroundFaultStatus = GFD_PASS;
 //                         pDcChargingInfo->GroundFaultStatus = GFD_PASS;
 
 
-                    //log_info("To EV_%d GFD = %d \n",   _index,pDcChargingInfo->GroundFaultStatus);
+                    //log_info("To EV_%d GFD = %d ",   _index,pDcChargingInfo->GroundFaultStatus);
                     //if(_chargingData[_index]->GroundFaultStatus != GFD_WAIT)
                     //if(_chargingData[_index]->GroundFaultStatus != GFD_WAIT)
                     {
                     {
                         //if ((GetTimeoutValue(_derating_time) / 1000) > 1000)
                         //if ((GetTimeoutValue(_derating_time) / 1000) > 1000)
@@ -970,14 +986,14 @@ int main(int argc, char *argv[])
                             if (((GetTimeoutValue(_chk_ratingPower_timeout[gunIndex]) / 1000) > 12000 &&
                             if (((GetTimeoutValue(_chk_ratingPower_timeout[gunIndex]) / 1000) > 12000 &&
                                     pDcChargingInfo->RealRatingPower > 0) ||
                                     pDcChargingInfo->RealRatingPower > 0) ||
                                     (GetTimeoutValue(_chk_ratingPower_timeout[gunIndex]) / 1000) > 14000) {
                                     (GetTimeoutValue(_chk_ratingPower_timeout[gunIndex]) / 1000) > 14000) {
-                                //log_info("**********EvComm : gunIndex= %d, RealRatingPower = %d \n",
+                                //log_info("**********EvComm : gunIndex= %d, RealRatingPower = %d ",
                                 //            gunIndex,pDcChargingInfo->RealRatingPower);
                                 //            gunIndex,pDcChargingInfo->RealRatingPower);
                                 //gfgResult = GFD_PASS;
                                 //gfgResult = GFD_PASS;
 
 
                                 //DS60-120 add
                                 //DS60-120 add
                                 if (LogInfo[gunIndex][EV_LOG_REAL_CAP_POW] != pDcChargingInfo->RealRatingPower) {
                                 if (LogInfo[gunIndex][EV_LOG_REAL_CAP_POW] != pDcChargingInfo->RealRatingPower) {
                                     LogInfo[gunIndex][EV_LOG_REAL_CAP_POW] = pDcChargingInfo->RealRatingPower;
                                     LogInfo[gunIndex][EV_LOG_REAL_CAP_POW] = pDcChargingInfo->RealRatingPower;
-                                    log_info("Conn %d, RealRatingPower = %d \n",
+                                    log_info("Conn %d, RealRatingPower = %d ",
                                              gunIndex,
                                              gunIndex,
                                              pDcChargingInfo->RealRatingPower);
                                              pDcChargingInfo->RealRatingPower);
 
 

+ 22 - 22
EVSE/Projects/DD360/Apps/ModuleEventLog/Module_EventLogging.c

@@ -75,7 +75,7 @@ int StoreLogMsg(const char *fmt, ...)
     if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES) {
     if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES) {
         sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
         sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
                 tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
                 tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
-        printf("%s \n", Buf);
+        printf("%s ", Buf);
     } else {
     } else {
         sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
         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,
                 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
@@ -236,16 +236,16 @@ int DB_Open(sqlite3 *db) //DS60-120 add
 
 
     if (sqlite3_open(DB_FILE, &db)) {
     if (sqlite3_open(DB_FILE, &db)) {
         result = FAIL;
         result = FAIL;
-        log_error( "Can't open database: %s\n", sqlite3_errmsg(db));
+        log_error( "Can't open database: %s", sqlite3_errmsg(db));
         sqlite3_close(db);
         sqlite3_close(db);
     } else {
     } else {
-        log_info( "Local event record database open successfully.\n");
+        log_info( "Local event record database open successfully.");
 
 
         if (sqlite3_exec(db, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(db, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_error( "Create local event record table error message: %s\n", errMsg);
+            log_error( "Create local event record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local event record table successfully\n");
+            log_info( "Opened local event record table successfully");
         }
         }
 
 
         sqlite3_close(db);
         sqlite3_close(db);
@@ -264,23 +264,23 @@ int DB_Insert_Record(sqlite3 *db, uint8_t *statusCode) //DS60-120 add
 
 
     if (sqlite3_open(DB_FILE, &db)) {
     if (sqlite3_open(DB_FILE, &db)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\n", sqlite3_errmsg(db));
+        log_info( "Can't open database: %s", sqlite3_errmsg(db));
         sqlite3_close(db);
         sqlite3_close(db);
     } else {
     } else {
-        log_info( "Local event record database open successfully.\n");
+        log_info( "Local event record database open successfully.");
         if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Insert local event record error message: %s\n", errMsg);
+            log_info( "Insert local event record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Insert local event record successfully\n");
+            log_info( "Insert local event record successfully");
         }
         }
 
 
         sprintf(sqlStr, "delete from event_record where idx < (select idx from event_record order by idx desc limit 1)-2000;");
         sprintf(sqlStr, "delete from event_record where idx < (select idx from event_record order by idx desc limit 1)-2000;");
         if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "delete local event_record error message: %s\n", errMsg);
+            log_info( "delete local event_record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "delete local event record successfully\n");
+            log_info( "delete local event record successfully");
         }
         }
 
 
         sqlite3_close(db);
         sqlite3_close(db);
@@ -296,7 +296,7 @@ int main(void)
     uint8_t tmp, EventCodeTmp[7] = {0};
     uint8_t tmp, EventCodeTmp[7] = {0};
 
 
     //if (InitShareMemory() == FAIL) {
     //if (InitShareMemory() == FAIL) {
-    //    log_error("InitShareMemory NG\n");
+    //    log_error("InitShareMemory NG");
     //    if (ShmStatusCodeData != NULL) {
     //    if (ShmStatusCodeData != NULL) {
     //        pAlarmCode->AlarmEvents.bits.FailToCreateShareMemory = 1;
     //        pAlarmCode->AlarmEvents.bits.FailToCreateShareMemory = 1;
     //    }
     //    }
@@ -304,7 +304,7 @@ int main(void)
     //    return 0;
     //    return 0;
     //}
     //}
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -338,16 +338,16 @@ int main(void)
                 memcpy(EventCodeTmp, GetFaultStatusCode(ByteCounter * 8 + BitCounter), sizeof(EventCodeTmp) - 1);
                 memcpy(EventCodeTmp, GetFaultStatusCode(ByteCounter * 8 + BitCounter), sizeof(EventCodeTmp) - 1);
                 if (((tmp >> BitCounter) & 0x01) == 0) { //Recovered
                 if (((tmp >> BitCounter) & 0x01) == 0) { //Recovered
                     //EventCodeTmp[0]=1;
                     //EventCodeTmp[0]=1;
-                    log_info("Recovery Fault Code = %s\n", EventCodeTmp);
+                    log_info("Recovery Fault Code = %s", EventCodeTmp);
                     pFaultCode->PreviousFaultVal[ByteCounter] &= ~(1 << BitCounter);
                     pFaultCode->PreviousFaultVal[ByteCounter] &= ~(1 << BitCounter);
                     RemoveFaultCodeToBuf(EventCodeTmp);
                     RemoveFaultCodeToBuf(EventCodeTmp);
                     EventCodeTmp[0] = '1';//DS60-120 add
                     EventCodeTmp[0] = '1';//DS60-120 add
                 } else {
                 } else {
-                    log_info("Fault Code = %s\n", EventCodeTmp);
+                    log_info("Fault Code = %s", EventCodeTmp);
                     pFaultCode->PreviousFaultVal[ByteCounter] |= (1 << BitCounter);
                     pFaultCode->PreviousFaultVal[ByteCounter] |= (1 << BitCounter);
                     AddFaultCodeToBuf(EventCodeTmp);
                     AddFaultCodeToBuf(EventCodeTmp);
                 }
                 }
-                event_info("%s\n", EventCodeTmp); //DS60-120 add
+                event_info("%s", EventCodeTmp); //DS60-120 add
                 InsertEventRecord(EventCodeTmp); //DS60-120 add
                 InsertEventRecord(EventCodeTmp); //DS60-120 add
             }
             }
         }
         }
@@ -370,16 +370,16 @@ int main(void)
                 memcpy(EventCodeTmp, GetAlarmStatusCode(ByteCounter * 8 + BitCounter), sizeof(EventCodeTmp) - 1);
                 memcpy(EventCodeTmp, GetAlarmStatusCode(ByteCounter * 8 + BitCounter), sizeof(EventCodeTmp) - 1);
                 if (((tmp >> BitCounter) & 0x01) == 0) { //Recovered
                 if (((tmp >> BitCounter) & 0x01) == 0) { //Recovered
                     //EventCodeTmp[0]=1;
                     //EventCodeTmp[0]=1;
-                    log_info("Recovery Alarm Code = %s\n", EventCodeTmp);
+                    log_info("Recovery Alarm Code = %s", EventCodeTmp);
                     pAlarmCode->PreviousAlarmVal[ByteCounter] &= ~(1 << BitCounter);
                     pAlarmCode->PreviousAlarmVal[ByteCounter] &= ~(1 << BitCounter);
                     RemoveFaultCodeToBuf(EventCodeTmp);
                     RemoveFaultCodeToBuf(EventCodeTmp);
                     EventCodeTmp[0] = '1';//DS60-120 add
                     EventCodeTmp[0] = '1';//DS60-120 add
                 } else {
                 } else {
-                    log_info("Alarm Code = %s\n", EventCodeTmp);
+                    log_info("Alarm Code = %s", EventCodeTmp);
                     pAlarmCode->PreviousAlarmVal[ByteCounter] |= (1 << BitCounter);
                     pAlarmCode->PreviousAlarmVal[ByteCounter] |= (1 << BitCounter);
                     AddFaultCodeToBuf(EventCodeTmp);
                     AddFaultCodeToBuf(EventCodeTmp);
                 }
                 }
-                event_info("%s\n", EventCodeTmp); //DS60-120 add
+                event_info("%s", EventCodeTmp); //DS60-120 add
                 InsertEventRecord(EventCodeTmp); //DS60-120 add
                 InsertEventRecord(EventCodeTmp); //DS60-120 add
             }
             }
         }
         }
@@ -402,16 +402,16 @@ int main(void)
                 memcpy(EventCodeTmp, GetInfoStatusCode(ByteCounter * 8 + BitCounter), sizeof(EventCodeTmp) - 1);
                 memcpy(EventCodeTmp, GetInfoStatusCode(ByteCounter * 8 + BitCounter), sizeof(EventCodeTmp) - 1);
                 if (((tmp >> BitCounter) & 0x01) == 0) { //Recovered
                 if (((tmp >> BitCounter) & 0x01) == 0) { //Recovered
                     //EventCodeTmp[0]=1;
                     //EventCodeTmp[0]=1;
-                    log_info("Recovery Info Code = %s\n", EventCodeTmp);
+                    log_info("Recovery Info Code = %s", EventCodeTmp);
                     pInfoCode->PreviousInfoVal[ByteCounter] &= ~(1 << BitCounter);
                     pInfoCode->PreviousInfoVal[ByteCounter] &= ~(1 << BitCounter);
                     RemoveFaultCodeToBuf(EventCodeTmp);
                     RemoveFaultCodeToBuf(EventCodeTmp);
                     EventCodeTmp[0] = '1';//DS60-120 add
                     EventCodeTmp[0] = '1';//DS60-120 add
                 } else {
                 } else {
-                    log_info("Info Code = %s\n", EventCodeTmp);
+                    log_info("Info Code = %s", EventCodeTmp);
                     pInfoCode->PreviousInfoVal[ByteCounter] |= (1 << BitCounter);
                     pInfoCode->PreviousInfoVal[ByteCounter] |= (1 << BitCounter);
                     AddFaultCodeToBuf(EventCodeTmp);
                     AddFaultCodeToBuf(EventCodeTmp);
                 }
                 }
-                event_info("%s\n", EventCodeTmp); //DS60-120 add
+                event_info("%s", EventCodeTmp); //DS60-120 add
                 InsertEventRecord(EventCodeTmp); //DS60-120 add
                 InsertEventRecord(EventCodeTmp); //DS60-120 add
             }
             }
         }
         }

+ 17 - 0
EVSE/Projects/DD360/Apps/ModuleInternalComm/LEDlight.c

@@ -117,6 +117,14 @@ static void SetLedColor(void)
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
+            } else if ( chargingData_1->SystemStatus == S_UPDATE ||
+                    chargingData_2->SystemStatus == S_UPDATE ) {
+                led_color.Connect_1_Green = COLOR_MIN_LV;
+                led_color.Connect_1_Blue = COLOR_MIN_LV;
+                led_color.Connect_1_Red = _colorBuf;
+                led_color.Connect_2_Green = COLOR_MIN_LV;
+                led_color.Connect_2_Blue = COLOR_MIN_LV;
+                led_color.Connect_2_Red = _colorBuf;
             }
             }
         } else {
         } else {
             if (chargingData_1->SystemStatus == S_BOOTING ||
             if (chargingData_1->SystemStatus == S_BOOTING ||
@@ -146,6 +154,10 @@ static void SetLedColor(void)
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Blue = _colorBuf;
                 led_color.Connect_1_Blue = _colorBuf;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
+            } else if ( chargingData_1->SystemStatus == S_UPDATE ) {
+                led_color.Connect_1_Green = COLOR_MIN_LV;
+                led_color.Connect_1_Blue = COLOR_MIN_LV;
+                led_color.Connect_1_Red = _colorBuf;
             }
             }
 
 
             // --------------------------------------------------------------------------
             // --------------------------------------------------------------------------
@@ -175,7 +187,12 @@ static void SetLedColor(void)
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
+            } else if ( chargingData_2->SystemStatus == S_UPDATE ) {
+                led_color.Connect_2_Green = COLOR_MIN_LV;
+                led_color.Connect_2_Blue = COLOR_MIN_LV;
+                led_color.Connect_2_Red = _colorBuf;
             }
             }
+
         }
         }
     }
     }
 
 

+ 3 - 3
EVSE/Projects/DD360/Apps/ModuleInternalComm/Module_InternalComm.c

@@ -53,7 +53,7 @@ static int Init485ComPort(void)
 
 
     fd = open(INTERNAL_COM_PORT, O_RDWR);
     fd = open(INTERNAL_COM_PORT, O_RDWR);
     if (fd <= 0) {
     if (fd <= 0) {
-        log_error("Module_InternalComm. InitComPort NG\r\n");
+        log_error("Module_InternalComm. InitComPort NG");
         sleep(5);
         sleep(5);
         return -1;
         return -1;
     }
     }
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
     struct AlarmCodeData *pAlarmCode = NULL;
     struct AlarmCodeData *pAlarmCode = NULL;
 
 
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -88,7 +88,7 @@ int main(int argc, char *argv[])
     if (fd == FAIL) {
     if (fd == FAIL) {
         pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
         pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
         pAlarmCode->AlarmEvents.bits.CsuInitFailed = YES;
         pAlarmCode->AlarmEvents.bits.CsuInitFailed = YES;
-        log_info("ModuleInternalComTask create port error...\r\n");
+        log_info("ModuleInternalComTask create port error...");
 
 
         return FAIL;
         return FAIL;
     }
     }

+ 83 - 67
EVSE/Projects/DD360/Apps/ModuleInternalComm/RelayBoard.c

@@ -46,6 +46,7 @@ static struct timeval _led_priority_time;
 static bool _isOvpChkTimeFlag[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 static bool _isOvpChkTimeFlag[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 static struct timeval _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 static struct timeval _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 
 
+static void SetLedColor(void);
 static struct timeval _close_ac_contactor;
 static struct timeval _close_ac_contactor;
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
@@ -90,7 +91,7 @@ static void StartCheckRelayInfo(uint8_t _chkIndex, uint8_t toState)
         ShmDcCommonData->CheckRelayStatus[_chkIndex] = START;
         ShmDcCommonData->CheckRelayStatus[_chkIndex] = START;
     } else {
     } else {
         if ((GetTimeoutValue(lastCheckRelayStateTimer[_chkIndex]) / 1000000) >= 1) {
         if ((GetTimeoutValue(lastCheckRelayStateTimer[_chkIndex]) / 1000000) >= 1) {
-            //log_info("relay welding or driving fault = %d \n", _chkIndex);
+            //log_info("relay welding or driving fault = %d ", _chkIndex);
             if (toState == 1) {
             if (toState == 1) {
                 ShmDcCommonData->CheckRelayStatus[_chkIndex] = RELAY_STATUS_ERROR_DRIVING;
                 ShmDcCommonData->CheckRelayStatus[_chkIndex] = RELAY_STATUS_ERROR_DRIVING;
             } else {
             } else {
@@ -160,37 +161,37 @@ static bool IsNoneMatchRelayStatus(void)
 
 
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
     if (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) {
     if (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) {
-        log_info("AC Contact Relay none match. \n");
+        log_info("AC Contact Relay none match. ");
     }
     }
 
 
     if (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) {
     if (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) {
-        log_info("CCS Precharge Relay none match. \n");
+        log_info("CCS Precharge Relay none match. ");
     }
     }
 #endif //
 #endif //
 
 
     if (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) {
     if (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) {
-        //log_info("SMR1:D+ Relay none match. \n");
+        //log_info("SMR1:D+ Relay none match. ");
         StartCheckRelayInfo(RELAY_SMR1_P_STATUS, outputRelay.relay_event.bits.Gun1_P);
         StartCheckRelayInfo(RELAY_SMR1_P_STATUS, outputRelay.relay_event.bits.Gun1_P);
     } else {
     } else {
         StopCheckRelayInfo(RELAY_SMR1_P_STATUS);
         StopCheckRelayInfo(RELAY_SMR1_P_STATUS);
     }
     }
 
 
     if (regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) {
     if (regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) {
-        //log_info("SMR1:D- Relay none match. \n");
+        //log_info("SMR1:D- Relay none match. ");
         StartCheckRelayInfo(RELAY_SMR1_N_STATUS, outputRelay.relay_event.bits.Gun1_N);
         StartCheckRelayInfo(RELAY_SMR1_N_STATUS, outputRelay.relay_event.bits.Gun1_N);
     } else {
     } else {
         StopCheckRelayInfo(RELAY_SMR1_N_STATUS);
         StopCheckRelayInfo(RELAY_SMR1_N_STATUS);
     }
     }
 
 
     if (regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) {
     if (regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) {
-        //log_info("SMR2:D+ Relay none match. \n");
+        //log_info("SMR2:D+ Relay none match. ");
         StartCheckRelayInfo(RELAY_SMR2_P_STATUS, outputRelay.relay_event.bits.Gun2_P);
         StartCheckRelayInfo(RELAY_SMR2_P_STATUS, outputRelay.relay_event.bits.Gun2_P);
     } else {
     } else {
         StopCheckRelayInfo(RELAY_SMR2_P_STATUS);
         StopCheckRelayInfo(RELAY_SMR2_P_STATUS);
     }
     }
 
 
     if (regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N) {
     if (regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N) {
-        //log_info("SMR2:D- Relay none match. \n");
+        //log_info("SMR2:D- Relay none match. ");
         StartCheckRelayInfo(RELAY_SMR2_N_STATUS, outputRelay.relay_event.bits.Gun2_N);
         StartCheckRelayInfo(RELAY_SMR2_N_STATUS, outputRelay.relay_event.bits.Gun2_N);
     } else {
     } else {
         StopCheckRelayInfo(RELAY_SMR2_N_STATUS);
         StopCheckRelayInfo(RELAY_SMR2_N_STATUS);
@@ -198,14 +199,14 @@ static bool IsNoneMatchRelayStatus(void)
 
 
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
     if (regRelay.relay_event.bits.Gun1_Parallel_P != outputRelay.relay_event.bits.Gun1_Parallel_P) {
     if (regRelay.relay_event.bits.Gun1_Parallel_P != outputRelay.relay_event.bits.Gun1_Parallel_P) {
-        //log_info("Parallel:D+ Relay none match. \n");
+        //log_info("Parallel:D+ Relay none match. ");
         StartCheckRelayInfo(RELAY_PARA_P_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_P);
         StartCheckRelayInfo(RELAY_PARA_P_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_P);
     } else {
     } else {
         StopCheckRelayInfo(RELAY_PARA_P_STATUS);
         StopCheckRelayInfo(RELAY_PARA_P_STATUS);
     }
     }
 
 
     if (regRelay.relay_event.bits.Gun1_Parallel_N != outputRelay.relay_event.bits.Gun1_Parallel_N) {
     if (regRelay.relay_event.bits.Gun1_Parallel_N != outputRelay.relay_event.bits.Gun1_Parallel_N) {
-        //log_info("Parallel:D- Relay none match. \n");
+        //log_info("Parallel:D- Relay none match. ");
         StartCheckRelayInfo(RELAY_PARA_N_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_N);
         StartCheckRelayInfo(RELAY_PARA_N_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_N);
     } else {
     } else {
         StopCheckRelayInfo(RELAY_PARA_N_STATUS);
         StopCheckRelayInfo(RELAY_PARA_N_STATUS);
@@ -307,13 +308,13 @@ static void GetGfdAdc(void)
                 //}
                 //}
 
 
                 pDcChargingInfo->GroundFaultStatus = gfd_adc.result_conn1;
                 pDcChargingInfo->GroundFaultStatus = gfd_adc.result_conn1;
-                //log_info("GFD ******** Result = %d, Step = %d, R = %d, Vol = %d \n",
+                //log_info("GFD ******** Result = %d, Step = %d, R = %d, Vol = %d ",
                 //            pDcChargingInfo->GroundFaultStatus,
                 //            pDcChargingInfo->GroundFaultStatus,
                 //            gfd_adc.rb_step_1,
                 //            gfd_adc.rb_step_1,
                 //            gfd_adc.Resister_conn1,
                 //            gfd_adc.Resister_conn1,
                 //            gfd_adc.voltage_conn1);
                 //            gfd_adc.voltage_conn1);
                 if (pDcChargingInfo->GroundFaultStatus == GFD_FAIL) {
                 if (pDcChargingInfo->GroundFaultStatus == GFD_FAIL) {
-                    log_info("GFD Fail. index = %d, Step = %d, R = %d, Vol = %d \n",
+                    log_info("GFD Fail. index = %d, Step = %d, R = %d, Vol = %d ",
                              gunIndex,
                              gunIndex,
                              gfd_adc.rb_step_1,
                              gfd_adc.rb_step_1,
                              gfd_adc.Resister_conn1,
                              gfd_adc.Resister_conn1,
@@ -323,7 +324,7 @@ static void GetGfdAdc(void)
                            pDcChargingInfo->GroundFaultStatus == GFD_WARNING
                            pDcChargingInfo->GroundFaultStatus == GFD_WARNING
                           ) {
                           ) {
                     if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING) {
                     if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING) {
-                        log_info("GFD Warning. index = %d, Result = %d, R = %d, Vol = %d \n",
+                        log_info("GFD Warning. index = %d, Result = %d, R = %d, Vol = %d ",
                                  gunIndex,
                                  gunIndex,
                                  pDcChargingInfo->GroundFaultStatus,
                                  pDcChargingInfo->GroundFaultStatus,
                                  gfd_adc.Resister_conn1,
                                  gfd_adc.Resister_conn1,
@@ -336,7 +337,7 @@ static void GetGfdAdc(void)
                 //}
                 //}
                 pDcChargingInfo->GroundFaultStatus = gfd_adc.result_conn2;
                 pDcChargingInfo->GroundFaultStatus = gfd_adc.result_conn2;
                 if (pDcChargingInfo->GroundFaultStatus == GFD_FAIL) {
                 if (pDcChargingInfo->GroundFaultStatus == GFD_FAIL) {
-                    log_info("GFD Fail. index = %d, Step = %d, R = %d, Vol = %d \n",
+                    log_info("GFD Fail. index = %d, Step = %d, R = %d, Vol = %d ",
                              gunIndex,
                              gunIndex,
                              gfd_adc.rb_step_2,
                              gfd_adc.rb_step_2,
                              gfd_adc.Resister_conn2,
                              gfd_adc.Resister_conn2,
@@ -345,7 +346,7 @@ static void GetGfdAdc(void)
                            pDcChargingInfo->GroundFaultStatus == GFD_WARNING
                            pDcChargingInfo->GroundFaultStatus == GFD_WARNING
                           ) {
                           ) {
                     if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING) {
                     if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING) {
-                        log_info("GFD Warning. index = %d, Result = %d, R = %d, Vol = %d \n",
+                        log_info("GFD Warning. index = %d, Result = %d, R = %d, Vol = %d ",
                                  gunIndex,
                                  gunIndex,
                                  pDcChargingInfo->GroundFaultStatus,
                                  pDcChargingInfo->GroundFaultStatus,
                                  gfd_adc.Resister_conn1,
                                  gfd_adc.Resister_conn1,
@@ -375,11 +376,11 @@ void CheckOutputPowerOverCarReq(uint8_t index)
                     _isOvpChkTimeFlag[index] = YES;
                     _isOvpChkTimeFlag[index] = YES;
                 }
                 }
             } else {
             } else {
-                log_info("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
+                log_info("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f ",
                          pDcChargingInfo->FireChargingVoltage,
                          pDcChargingInfo->FireChargingVoltage,
                          (pDcChargingInfo->EvBatterytargetVoltage * 10));
                          (pDcChargingInfo->EvBatterytargetVoltage * 10));
 
 
-                log_error("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
+                log_error("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f ",
                           pDcChargingInfo->FireChargingVoltage,
                           pDcChargingInfo->FireChargingVoltage,
                           (pDcChargingInfo->EvBatterytargetVoltage * 10));
                           (pDcChargingInfo->EvBatterytargetVoltage * 10));
                 if ((GetTimeoutValue(_checkOutputVolProtectTimer[index]) / 1000) >= OUTPUT_VOL_CHK_TIME) {
                 if ((GetTimeoutValue(_checkOutputVolProtectTimer[index]) / 1000) >= OUTPUT_VOL_CHK_TIME) {
@@ -439,7 +440,7 @@ void CheckAcInputOvpStatus(uint8_t index)
 //                      _psuInputVolS > VIN_MAX_VOLTAGE_IEC ||
 //                      _psuInputVolS > VIN_MAX_VOLTAGE_IEC ||
 //                      _psuInputVolT > VIN_MAX_VOLTAGE_IEC)
 //                      _psuInputVolT > VIN_MAX_VOLTAGE_IEC)
 //              {
 //              {
-//                  log_info("IEC _psuInputVolR = %f, _psuInputVolS = %f, _psuInputVolT = %f \n",
+//                  log_info("IEC _psuInputVolR = %f, _psuInputVolS = %f, _psuInputVolT = %f ",
 //                          _psuInputVolR, _psuInputVolS, _psuInputVolT);
 //                          _psuInputVolR, _psuInputVolS, _psuInputVolT);
 //                  pDcChargingInfo->StopChargeFlag = YES;
 //                  pDcChargingInfo->StopChargeFlag = YES;
 //              }
 //              }
@@ -451,14 +452,14 @@ void CheckAcInputOvpStatus(uint8_t index)
 //                      _psuInputVolS > VIN_MAX_VOLTAGE_UL ||
 //                      _psuInputVolS > VIN_MAX_VOLTAGE_UL ||
 //                      _psuInputVolT > VIN_MAX_VOLTAGE_UL)
 //                      _psuInputVolT > VIN_MAX_VOLTAGE_UL)
 //              {
 //              {
-//                  log_info("UL _psuInputVolR = %f, _psuInputVolS = %f, _psuInputVolT = %f \n",
+//                  log_info("UL _psuInputVolR = %f, _psuInputVolS = %f, _psuInputVolT = %f ",
 //                          _psuInputVolR, _psuInputVolS, _psuInputVolT);
 //                          _psuInputVolR, _psuInputVolS, _psuInputVolT);
 //                  pDcChargingInfo->StopChargeFlag = YES;
 //                  pDcChargingInfo->StopChargeFlag = YES;
 //              }
 //              }
 //          }
 //          }
 //      }
 //      }
 //      else
 //      else
-        //log_info("CheckAcInputOvpStatus\r\n");
+        //log_info("CheckAcInputOvpStatus");
         pDcChargingInfo->StopChargeFlag = YES;
         pDcChargingInfo->StopChargeFlag = YES;
     }
     }
 }
 }
@@ -478,9 +479,9 @@ void CheckAcInputOvpStatus(uint8_t index)
 //                gettimeofday(&_checkOutputNoneMatchTimer[index], NULL);
 //                gettimeofday(&_checkOutputNoneMatchTimer[index], NULL);
 //            } else {
 //            } else {
 //                if ((GetTimeoutValue(_checkOutputNoneMatchTimer[index]) / 1000) >= 5000) {
 //                if ((GetTimeoutValue(_checkOutputNoneMatchTimer[index]) / 1000) >= 5000) {
-//                    /*log_info("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d) : pre = %f, fire = %f \n",
+//                    /*log_info("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d) : pre = %f, fire = %f ",
 //                            index, (pDcChargingInfo->PresentChargingVoltage * 10), pDcChargingInfo->FireChargingVoltage);
 //                            index, (pDcChargingInfo->PresentChargingVoltage * 10), pDcChargingInfo->FireChargingVoltage);
-//                    log_error("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d): pre = %f, fire = %f \n",
+//                    log_error("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d): pre = %f, fire = %f ",
 //                            index, (pDcChargingInfo->PresentChargingVoltage * 10), pDcChargingInfo->FireChargingVoltage);
 //                            index, (pDcChargingInfo->PresentChargingVoltage * 10), pDcChargingInfo->FireChargingVoltage);
 //                    pDcChargingInfo->StopChargeFlag = YES;*/
 //                    pDcChargingInfo->StopChargeFlag = YES;*/
 //                }
 //                }
@@ -498,7 +499,7 @@ void CheckPhaseLossStatus(uint8_t index)
     if (pAlarmCode->AlarmEvents.bits.SystemL1InputUVP == YES ||
     if (pAlarmCode->AlarmEvents.bits.SystemL1InputUVP == YES ||
             pAlarmCode->AlarmEvents.bits.SystemL2InputUVP == YES ||
             pAlarmCode->AlarmEvents.bits.SystemL2InputUVP == YES ||
             pAlarmCode->AlarmEvents.bits.SystemL3InputUVP == YES) {
             pAlarmCode->AlarmEvents.bits.SystemL3InputUVP == YES) {
-        //log_info("CheckPhaseLossStatus\r\n");
+        //log_info("CheckPhaseLossStatus");
         pDcChargingInfo->StopChargeFlag = YES;
         pDcChargingInfo->StopChargeFlag = YES;
     }
     }
 }
 }
@@ -720,9 +721,9 @@ void SetGfdConfig(uint8_t index, uint8_t resister)
         .state = resister,
         .state = resister,
     };
     };
 
 
-    //log_info("************************GFD Vol = %d, GFD Res = %d \n", gfd_config.reqVol, gfd_config.resister);
+    //log_info("************************GFD Vol = %d, GFD Res = %d ", gfd_config.reqVol, gfd_config.resister);
     if (Config_Gfd_Value(Uart5Fd, ADDR_RELAY, &gfd_config) == PASS) {
     if (Config_Gfd_Value(Uart5Fd, ADDR_RELAY, &gfd_config) == PASS) {
-//      log_info("Set reqVol = %f, resister = %d \n",
+//      log_info("Set reqVol = %f, resister = %d ",
 //              gfd_config.reqVol,
 //              gfd_config.reqVol,
 //              gfd_config.resister);
 //              gfd_config.resister);
     }
     }
@@ -821,7 +822,7 @@ void GetPresentInputVol(void)
         if (pSysInfo->ChargerType == _CHARGER_TYPE_IEC) {
         if (pSysInfo->ChargerType == _CHARGER_TYPE_IEC) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputUVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputUVP == NO) {
                 if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_IEC) {
                 if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_IEC) {
-                    log_info("In Uvp L1N_L12 = %f \n", inputVoltage.L1N_L12);
+                    log_info("In Uvp L1N_L12 = %f ", inputVoltage.L1N_L12);
                     if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL1InputUVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL1InputUVP = YES;
                     } else {
                     } else {
@@ -837,7 +838,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputUVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputUVP == NO) {
                 if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_IEC) {
                 if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_IEC) {
-                    log_info("In Uvp L2N_L23 = %f \n", inputVoltage.L2N_L23);
+                    log_info("In Uvp L2N_L23 = %f ", inputVoltage.L2N_L23);
                     if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL2InputUVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL2InputUVP = YES;
                     } else {
                     } else {
@@ -853,7 +854,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL3InputUVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL3InputUVP == NO) {
                 if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_IEC) {
                 if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_IEC) {
-                    log_info("In Uvp L3N_L31 = %f \n", inputVoltage.L3N_L31);
+                    log_info("In Uvp L3N_L31 = %f ", inputVoltage.L3N_L31);
                     if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL3InputUVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL3InputUVP = YES;
                     } else {
                     } else {
@@ -869,7 +870,7 @@ void GetPresentInputVol(void)
         } else if (pSysInfo->ChargerType == _CHARGER_TYPE_UL) {
         } else if (pSysInfo->ChargerType == _CHARGER_TYPE_UL) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputUVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputUVP == NO) {
                 if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_UL) {
                 if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_UL) {
-                    log_info("In Uvp L1N_L12 = %f \n", inputVoltage.L1N_L12);
+                    log_info("In Uvp L1N_L12 = %f ", inputVoltage.L1N_L12);
                     if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL1InputUVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL1InputUVP = YES;
                     } else {
                     } else {
@@ -885,7 +886,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputUVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputUVP == NO) {
                 if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_UL) {
                 if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_UL) {
-                    log_info("In Uvp L2N_L23 = %f \n", inputVoltage.L2N_L23);
+                    log_info("In Uvp L2N_L23 = %f ", inputVoltage.L2N_L23);
                     if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL2InputUVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL2InputUVP = YES;
                     } else {
                     } else {
@@ -901,7 +902,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL3InputUVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL3InputUVP == NO) {
                 if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_UL) {
                 if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_UL) {
-                    log_info("In Uvp L3N_L31 = %f \n", inputVoltage.L3N_L31);
+                    log_info("In Uvp L3N_L31 = %f ", inputVoltage.L3N_L31);
                     if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL3InputUVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL3InputUVP = YES;
                     } else {
                     } else {
@@ -921,7 +922,7 @@ void GetPresentInputVol(void)
         if (pSysInfo->ChargerType == _CHARGER_TYPE_IEC) {
         if (pSysInfo->ChargerType == _CHARGER_TYPE_IEC) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputOVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputOVP == NO) {
                 if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_IEC) {
                 if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_IEC) {
-                    log_info("In Ovp L1N_L12 = %f \n", inputVoltage.L1N_L12);
+                    log_info("In Ovp L1N_L12 = %f ", inputVoltage.L1N_L12);
                     if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL1InputOVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL1InputOVP = YES;
                     } else {
                     } else {
@@ -937,7 +938,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputOVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputOVP == NO) {
                 if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_IEC) {
                 if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_IEC) {
-                    log_info("In Ovp L2N_L23 = %f \n", inputVoltage.L2N_L23);
+                    log_info("In Ovp L2N_L23 = %f ", inputVoltage.L2N_L23);
                     if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL2InputOVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL2InputOVP = YES;
                     } else {
                     } else {
@@ -953,7 +954,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL3InputOVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL3InputOVP == NO) {
                 if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_IEC) {
                 if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_IEC) {
-                    log_info("In Ovp L3N_L31 = %f \n", inputVoltage.L3N_L31);
+                    log_info("In Ovp L3N_L31 = %f ", inputVoltage.L3N_L31);
                     if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL3InputOVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL3InputOVP = YES;
                     } else {
                     } else {
@@ -969,7 +970,7 @@ void GetPresentInputVol(void)
         } else if (pSysInfo->ChargerType == _CHARGER_TYPE_UL) {
         } else if (pSysInfo->ChargerType == _CHARGER_TYPE_UL) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputOVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputOVP == NO) {
                 if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_UL) {
                 if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_UL) {
-                    log_info("In Ovp L1N_L12 = %f \n", inputVoltage.L1N_L12);
+                    log_info("In Ovp L1N_L12 = %f ", inputVoltage.L1N_L12);
                     if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL1InputOVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL1InputOVP = YES;
                     } else {
                     } else {
@@ -985,7 +986,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputOVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputOVP == NO) {
                 if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_UL) {
                 if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_UL) {
-                    log_info("In Ovp L2N_L23 = %f \n", inputVoltage.L2N_L23);
+                    log_info("In Ovp L2N_L23 = %f ", inputVoltage.L2N_L23);
                     if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL2InputOVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL2InputOVP = YES;
                     } else {
                     } else {
@@ -1001,7 +1002,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputOVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputOVP == NO) {
                 if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_UL) {
                 if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_UL) {
-                    log_info("In Ovp L3N_L31 = %f \n", inputVoltage.L3N_L31);
+                    log_info("In Ovp L3N_L31 = %f ", inputVoltage.L3N_L31);
                     if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL3InputOVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL3InputOVP = YES;
                     } else {
                     } else {
@@ -1030,13 +1031,13 @@ void GetPersentOutputVol(void)
         return;
         return;
     }
     }
 
 
-    //log_info("Conn1 fuse 1 = %f \n", outputVoltage.behindFuse_Voltage_C1);
-    //log_info("Conn1 relay 1 = %f \n", outputVoltage.behindRelay_Voltage_C1);
-    //log_info("Conn2 fuse 2 = %f \n", outputVoltage.behindFuse_Voltage_C2);
-    //log_info("Conn2 relay 2 = %f \n", outputVoltage.behindRelay_Voltage_C2);
+    //log_info("Conn1 fuse 1 = %f ", outputVoltage.behindFuse_Voltage_C1);
+    //log_info("Conn1 relay 1 = %f ", outputVoltage.behindRelay_Voltage_C1);
+    //log_info("Conn2 fuse 2 = %f ", outputVoltage.behindFuse_Voltage_C2);
+    //log_info("Conn2 relay 2 = %f ", outputVoltage.behindRelay_Voltage_C2);
 
 
-    //log_info("outputVoltage.behindFuse_Voltage_C1 = %f \n", outputVoltage.behindFuse_Voltage_C1);
-    //log_info("outputVoltage.behindFuse_Voltage_C2 = %f \n", outputVoltage.behindFuse_Voltage_C2);
+    //log_info("outputVoltage.behindFuse_Voltage_C1 = %f ", outputVoltage.behindFuse_Voltage_C1);
+    //log_info("outputVoltage.behindFuse_Voltage_C2 = %f ", outputVoltage.behindFuse_Voltage_C2);
 
 
     ShmRelayModuleData->Gun1FuseOutputVolt = outputVoltage.behindFuse_Voltage_C1;
     ShmRelayModuleData->Gun1FuseOutputVolt = outputVoltage.behindFuse_Voltage_C1;
     ShmRelayModuleData->Gun1RelayOutputVolt = outputVoltage.behindRelay_Voltage_C1;
     ShmRelayModuleData->Gun1RelayOutputVolt = outputVoltage.behindRelay_Voltage_C1;
@@ -1075,7 +1076,7 @@ void GetPersentOutputVol(void)
             break;
             break;
         }
         }
 
 
-        //log_info("%d persent vol = %f, cur = %f\r\n",
+        //log_info("%d persent vol = %f, cur = %f",
         //         index,
         //         index,
         //         pDcChargingInfo->PresentChargingVoltage,
         //         pDcChargingInfo->PresentChargingVoltage,
         //         pDcChargingInfo->PresentChargingCurrent);
         //         pDcChargingInfo->PresentChargingCurrent);
@@ -1100,7 +1101,7 @@ void SetRtcData_Relay(void)
 
 
     ftime(&csuTime);
     ftime(&csuTime);
     tmCSU = localtime(&csuTime.time);
     tmCSU = localtime(&csuTime.time);
-    //  log_info("Time : %04d-%02d-%02d %02d:%02d:%02d \n", tmCSU->tm_year + 1900,
+    //  log_info("Time : %04d-%02d-%02d %02d:%02d:%02d ", tmCSU->tm_year + 1900,
     //          tmCSU->tm_mon + 1, tmCSU->tm_mday, tmCSU->tm_hour, tmCSU->tm_min,
     //          tmCSU->tm_mon + 1, tmCSU->tm_mday, tmCSU->tm_hour, tmCSU->tm_min,
     //          tmCSU->tm_sec);
     //          tmCSU->tm_sec);
 
 
@@ -1125,14 +1126,14 @@ void SetRtcData_Relay(void)
     rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
     rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
 
 
     if (Config_Rtc_Data(Uart5Fd, ADDR_RELAY, &rtc) == PASS) {
     if (Config_Rtc_Data(Uart5Fd, ADDR_RELAY, &rtc) == PASS) {
-        //log_info("SetRtc (RB) sucessfully. \n");
+        //log_info("SetRtc (RB) sucessfully. ");
     }
     }
 }
 }
 
 
 void SetModelName_Relay(void)
 void SetModelName_Relay(void)
 {
 {
     if (Config_Model_Name(Uart5Fd, ADDR_RELAY, pSysConfig->ModelName) == PASS) {
     if (Config_Model_Name(Uart5Fd, ADDR_RELAY, pSysConfig->ModelName) == PASS) {
-        //log_info("Set Model name (RB) PASS = %s \n", pSysConfig->ModelName);
+        //log_info("Set Model name (RB) PASS = %s ", pSysConfig->ModelName);
     }
     }
 }
 }
 
 
@@ -1145,13 +1146,13 @@ void GetFwAndHwVersion_Relay(void)
         strcpy((char *)ShmRelayModuleData->version, ver.Version_FW);
         strcpy((char *)ShmRelayModuleData->version, ver.Version_FW);
         // SystemInfo
         // SystemInfo
         strcpy((char *)pSysInfo->RelayModuleFwRev, ver.Version_FW);
         strcpy((char *)pSysInfo->RelayModuleFwRev, ver.Version_FW);
-        //log_info("GetFwAndHwVersion_Relay s1 = %s \n", ver.Version_FW);
+        //log_info("GetFwAndHwVersion_Relay s1 = %s ", ver.Version_FW);
     }
     }
 
 
     if (Query_HW_Ver(Uart5Fd, ADDR_RELAY, &ver) == PASS) {
     if (Query_HW_Ver(Uart5Fd, ADDR_RELAY, &ver) == PASS) {
         // SystemInfo
         // SystemInfo
         strcpy((char *)pSysInfo->RelayModuleHwRev, ver.Version_FW);
         strcpy((char *)pSysInfo->RelayModuleHwRev, ver.Version_FW);
-        //log_info("GetFwAndHwVersion_Relay s2 = %s \n", ver.Version_HW);
+        //log_info("GetFwAndHwVersion_Relay s2 = %s ", ver.Version_HW);
     }
     }
 }
 }
 
 
@@ -1160,7 +1161,7 @@ static void outputRelayInit(int fd)
     memset((uint8_t *)&outputRelay, 0, sizeof(Relay));
     memset((uint8_t *)&outputRelay, 0, sizeof(Relay));
 
 
     if (Config_Relay_Output(fd, ADDR_RELAY, &outputRelay) != PASS) {
     if (Config_Relay_Output(fd, ADDR_RELAY, &outputRelay) != PASS) {
-        log_info("Config_Relay_Output fail \n");
+        log_info("Config_Relay_Output fail ");
     }
     }
 }
 }
 
 
@@ -1175,12 +1176,13 @@ static bool IsRelayProcessNeedPause(void)
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
         if(pDcChargingInfo->SystemStatus == S_UPDATE)
         if(pDcChargingInfo->SystemStatus == S_UPDATE)
         {
         {
+            SetLedColor();
             _pause = true;
             _pause = true;
         }
         }
     }
     }
     if(isPause != _pause)
     if(isPause != _pause)
     {
     {
-        log_info("Relay Process Now Is %s \n", _pause == true ? "Paused" : "Continued");
+        log_info("Relay Process Now Is %s ", _pause == true ? "Paused" : "Continued");
     }
     }
     isPause = _pause;
     isPause = _pause;
 
 
@@ -1208,7 +1210,7 @@ static void SetFanModuleSpeed(void)
         _fanSpeed.speed[3] = _setFanSpeed;
         _fanSpeed.speed[3] = _setFanSpeed;
 
 
         if (Config_Fan_Speed(Uart5Fd, ADDR_FAN, &_fanSpeed) == PASS) {
         if (Config_Fan_Speed(Uart5Fd, ADDR_FAN, &_fanSpeed) == PASS) {
-            //log_info("successfully Fan\n");
+            //log_info("successfully Fan");
         }
         }
     }
     }
 }
 }
@@ -1218,16 +1220,16 @@ static void GetFanSpeed(void)
 {
 {
     FanSpeed fanSpeed = {0};
     FanSpeed fanSpeed = {0};
 
 
-    //log_info("Get fan board speed \n");
+    //log_info("Get fan board speed ");
     if (Query_Fan_Speed(Uart5Fd, ADDR_FAN, &fanSpeed) == PASS) {
     if (Query_Fan_Speed(Uart5Fd, ADDR_FAN, &fanSpeed) == PASS) {
         ShmFanModuleData->PresentFan1Speed = fanSpeed.speed[0];
         ShmFanModuleData->PresentFan1Speed = fanSpeed.speed[0];
         ShmFanModuleData->PresentFan2Speed = fanSpeed.speed[1];
         ShmFanModuleData->PresentFan2Speed = fanSpeed.speed[1];
         ShmFanModuleData->PresentFan3Speed = fanSpeed.speed[2];
         ShmFanModuleData->PresentFan3Speed = fanSpeed.speed[2];
         ShmFanModuleData->PresentFan4Speed = fanSpeed.speed[3];
         ShmFanModuleData->PresentFan4Speed = fanSpeed.speed[3];
-//      log_info("SystemFanRotaSpeed_1 = %d \n", fanSpeed.speed[0]);
-//      log_info("SystemFanRotaSpeed_2 = %d \n", fanSpeed.speed[1]);
-//      log_info("SystemFanRotaSpeed_3 = %d \n", fanSpeed.speed[2]);
-//      log_info("SystemFanRotaSpeed_4 = %d \n", fanSpeed.speed[3]);
+//      log_info("SystemFanRotaSpeed_1 = %d ", fanSpeed.speed[0]);
+//      log_info("SystemFanRotaSpeed_2 = %d ", fanSpeed.speed[1]);
+//      log_info("SystemFanRotaSpeed_3 = %d ", fanSpeed.speed[2]);
+//      log_info("SystemFanRotaSpeed_4 = %d ", fanSpeed.speed[3]);
         // Config_Fan_Speed(Uart5Fd, ADDR_FAN, &fanSpeed[0]);
         // Config_Fan_Speed(Uart5Fd, ADDR_FAN, &fanSpeed[0]);
         //SysInfoData (SystemFanRotaSpeed)
         //SysInfoData (SystemFanRotaSpeed)
     }
     }
@@ -1316,7 +1318,7 @@ static void SetRtcData_Fan(void)
 
 
     ftime(&csuTime);
     ftime(&csuTime);
     tmCSU = localtime(&csuTime.time);
     tmCSU = localtime(&csuTime.time);
-    //  log_info("Time : %04d-%02d-%02d %02d:%02d:%02d \n", tmCSU->tm_year + 1900,
+    //  log_info("Time : %04d-%02d-%02d %02d:%02d:%02d ", tmCSU->tm_year + 1900,
     //          tmCSU->tm_mon + 1, tmCSU->tm_mday, tmCSU->tm_hour, tmCSU->tm_min,
     //          tmCSU->tm_mon + 1, tmCSU->tm_mday, tmCSU->tm_hour, tmCSU->tm_min,
     //          tmCSU->tm_sec);
     //          tmCSU->tm_sec);
 
 
@@ -1341,14 +1343,14 @@ static void SetRtcData_Fan(void)
     rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
     rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
 
 
     if (Config_Rtc_Data(Uart5Fd, ADDR_FAN, &rtc) == PASS) {
     if (Config_Rtc_Data(Uart5Fd, ADDR_FAN, &rtc) == PASS) {
-        //log_info("SetRtc (FB) sucessfully. \n");
+        //log_info("SetRtc (FB) sucessfully. ");
     }
     }
 }
 }
 
 
 static void SetModelName_Fan(void)
 static void SetModelName_Fan(void)
 {
 {
     if (Config_Model_Name(Uart5Fd, ADDR_FAN, pSysConfig->ModelName) == PASS) {
     if (Config_Model_Name(Uart5Fd, ADDR_FAN, pSysConfig->ModelName) == PASS) {
-        log_info("Set Model name PASS = %s \n", pSysConfig->ModelName);
+        log_info("Set Model name PASS = %s ", pSysConfig->ModelName);
     }
     }
 }
 }
 
 
@@ -1361,13 +1363,13 @@ static void GetFwAndHwVersion_Fan(void)
         strcpy((char *)ShmFanModuleData->version, ver.Version_FW);
         strcpy((char *)ShmFanModuleData->version, ver.Version_FW);
         // SystemInfo
         // SystemInfo
         strcpy((char *)pSysInfo->FanModuleFwRev, ver.Version_FW);
         strcpy((char *)pSysInfo->FanModuleFwRev, ver.Version_FW);
-        //log_info("GetFwAndHwVersion_Fan s1 = %s \n", ver.Version_FW);
+        //log_info("GetFwAndHwVersion_Fan s1 = %s ", ver.Version_FW);
     }
     }
 
 
     if (Query_HW_Ver(Uart5Fd, ADDR_FAN, &ver) == PASS) {
     if (Query_HW_Ver(Uart5Fd, ADDR_FAN, &ver) == PASS) {
         // SystemInfo
         // SystemInfo
         strcpy((char *)pSysInfo->FanModuleHwRev, ver.Version_FW);
         strcpy((char *)pSysInfo->FanModuleHwRev, ver.Version_FW);
-        //log_info("GetFwAndHwVersion_Fan s2 = %s \n", ver.Version_HW);
+        //log_info("GetFwAndHwVersion_Fan s2 = %s ", ver.Version_HW);
     }
     }
 }
 }
 
 
@@ -1407,7 +1409,7 @@ static void fanBoardPorcess(void)
             ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
             ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
             ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
             ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
 
 
-            //log_info("set fan = %d \n", ShmFanModuleData->SetFan1Speed);
+            //log_info("set fan = %d ", ShmFanModuleData->SetFan1Speed);
             SetFanModuleSpeed();
             SetFanModuleSpeed();
         }
         }
     }
     }
@@ -1422,17 +1424,17 @@ static void GetFwAndHwVersion_Led(void)
         strcpy((char *) ShmLedModuleData->version, ver.Version_FW);
         strcpy((char *) ShmLedModuleData->version, ver.Version_FW);
         // SystemInfo
         // SystemInfo
         strcpy((char *) pSysInfo->LedModuleFwRev, ver.Version_FW);
         strcpy((char *) pSysInfo->LedModuleFwRev, ver.Version_FW);
-        log_info("GetFwAndHwVersion_Led s1 = %s \n", ver.Version_FW);
+        log_info("GetFwAndHwVersion_Led s1 = %s ", ver.Version_FW);
         ShmLedModuleData->SelfTest_Comp = YES;
         ShmLedModuleData->SelfTest_Comp = YES;
     } else {
     } else {
-        //log_info("GetFwAndHwVersion_Led fail \n");
+        //log_info("GetFwAndHwVersion_Led fail ");
     }
     }
 
 
 //  if (Query_HW_Ver(Uart5Fd, ADDR_LED, &ver) == PASS)
 //  if (Query_HW_Ver(Uart5Fd, ADDR_LED, &ver) == PASS)
 //  {
 //  {
 //      // SystemInfo
 //      // SystemInfo
 //      strcpy((char *) pSysInfo->RelayModuleHwRev, ver.Version_FW);
 //      strcpy((char *) pSysInfo->RelayModuleHwRev, ver.Version_FW);
-//      //log_info("GetFwAndHwVersion_Relay s2 = %s \n", ver.Version_HW);
+//      //log_info("GetFwAndHwVersion_Relay s2 = %s ", ver.Version_HW);
 //  }
 //  }
 }
 }
 
 
@@ -1523,7 +1525,12 @@ static void SetLedColor(void)
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
+            } else if ( chargingData_1->SystemStatus == S_UPDATE ) {
+                led_color.Connect_1_Green = COLOR_MIN_LV;
+                led_color.Connect_1_Blue = COLOR_MIN_LV;
+                led_color.Connect_1_Red = _colorBuf;
             }
             }
+
         } else {
         } else {
             if (chargingData_1->SystemStatus == S_BOOTING ||
             if (chargingData_1->SystemStatus == S_BOOTING ||
                     chargingData_1->SystemStatus == S_IDLE ||
                     chargingData_1->SystemStatus == S_IDLE ||
@@ -1552,8 +1559,13 @@ static void SetLedColor(void)
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Blue = _colorBuf;
                 led_color.Connect_1_Blue = _colorBuf;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
+            }else if ( chargingData_1->SystemStatus == S_UPDATE ) {
+                led_color.Connect_1_Green = COLOR_MIN_LV;
+                led_color.Connect_1_Blue = COLOR_MIN_LV;
+                led_color.Connect_1_Red = _colorBuf;
             }
             }
 
 
+
             // --------------------------------------------------------------------------
             // --------------------------------------------------------------------------
             if (chargingData_2->SystemStatus == S_BOOTING ||
             if (chargingData_2->SystemStatus == S_BOOTING ||
                     chargingData_2->SystemStatus == S_IDLE ||
                     chargingData_2->SystemStatus == S_IDLE ||
@@ -1581,10 +1593,14 @@ static void SetLedColor(void)
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
+            }else if ( chargingData_2->SystemStatus == S_UPDATE ) {
+                led_color.Connect_2_Green = COLOR_MIN_LV;
+                led_color.Connect_2_Blue = COLOR_MIN_LV;
+                led_color.Connect_2_Red = _colorBuf;
             }
             }
+
         }
         }
     }
     }
-
     if (_checkLedChanged > 0) {
     if (_checkLedChanged > 0) {
         if (Config_Led_Color(Uart5Fd, ADDR_LED, &led_color) == PASS) {
         if (Config_Led_Color(Uart5Fd, ADDR_LED, &led_color) == PASS) {
             _checkLedChanged--;
             _checkLedChanged--;
@@ -1854,7 +1870,7 @@ void RelayBoardTask(int uartFD)
 
 
                             //MatchRelayStatus();
                             //MatchRelayStatus();
 
 
-                            //log_info("Match Relay, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x \n",
+                            //log_info("Match Relay, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x ",
                             //         regRelay.relay_event.bits.AC_Contactor,
                             //         regRelay.relay_event.bits.AC_Contactor,
                             //         regRelay.relay_event.bits.Gun1_P,
                             //         regRelay.relay_event.bits.Gun1_P,
                         //         regRelay.relay_event.bits.Gun1_N,
                         //         regRelay.relay_event.bits.Gun1_N,

+ 40 - 27
EVSE/Projects/DD360/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -256,7 +256,7 @@ uint8_t _showReplugStr_2 = 75;
     if (pSysConfig->SwitchDebugFlag == YES) {
     if (pSysConfig->SwitchDebugFlag == YES) {
         sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
         sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
                 tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
                 tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
-        printf("%s \n", Buf);
+        printf("%s ", Buf);
     } else {
     } else {
         sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
         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,
                 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
@@ -294,12 +294,12 @@ int InitShareMemory()
     //creat ShmSysConfigAndInfo
     //creat ShmSysConfigAndInfo
     if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0) {
     if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("shmget ShmSysConfigAndInfo NG\n");
+        log_error("shmget ShmSysConfigAndInfo NG");
 #endif
 #endif
         result = FAIL;
         result = FAIL;
     } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
     } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("shmat ShmSysConfigAndInfo NG\n");
+        log_error("shmat ShmSysConfigAndInfo NG");
 #endif
 #endif
         result = FAIL;
         result = FAIL;
     } else
     } else
@@ -308,12 +308,12 @@ int InitShareMemory()
     //creat ShmStatusCodeData
     //creat ShmStatusCodeData
     if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0) {
     if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("shmget ShmStatusCodeData NG\n");
+        log_error("shmget ShmStatusCodeData NG");
 #endif
 #endif
         result = FAIL;
         result = FAIL;
     } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
     } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("shmat ShmStatusCodeData NG\n");
+        log_error("shmat ShmStatusCodeData NG");
 #endif
 #endif
         result = FAIL;
         result = FAIL;
     } else
     } else
@@ -321,22 +321,22 @@ int InitShareMemory()
 
 
     //creat Audi customization info
     //creat Audi customization info
     if ((MeterSMId = shmget(ShmSelectGunInfoKey, sizeof(SelectGunInfo), IPC_CREAT | 0777)) < 0) {
     if ((MeterSMId = shmget(ShmSelectGunInfoKey, sizeof(SelectGunInfo), IPC_CREAT | 0777)) < 0) {
-        log_error("[main]CreatShareMemory:shmget select gun info NG \n");
+        log_error("[main]CreatShareMemory:shmget select gun info NG ");
         return 0;
         return 0;
     } else if ((ShmSelectGunInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
     } else if ((ShmSelectGunInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        log_error("[main]CreatShareMemory:shmat shmget select gun info \n");
+        log_error("[main]CreatShareMemory:shmat shmget select gun info ");
         return 0;
         return 0;
     }
     }
 
 
     //creat ShmStatusCodeData
     //creat ShmStatusCodeData
     if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0) {
     if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("shmget ShmPrimaryMcuData NG\n");
+        log_error("shmget ShmPrimaryMcuData NG");
 #endif
 #endif
         result = FAIL;
         result = FAIL;
     } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
     } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
 #ifdef ShmPrimaryMcuData
 #ifdef ShmPrimaryMcuData
-        log_error("shmat ShmPrimaryMcuData NG\n");
+        log_error("shmat ShmPrimaryMcuData NG");
 #endif
 #endif
         result = FAIL;
         result = FAIL;
     }
     }
@@ -356,7 +356,7 @@ int CreateCommunicationLcmPort()
     fd = open(pPortName, O_RDWR);
     fd = open(pPortName, O_RDWR);
     if (fd <= 0) {
     if (fd <= 0) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("open /dev/ttyS3 NG \n");
+        log_error("open /dev/ttyS3 NG ");
 #endif
 #endif
         return -1;
         return -1;
     }
     }
@@ -383,7 +383,7 @@ void WriteCmdToLcm(uint8_t *cmd, uint8_t cmdLen)
 {
 {
     int len = write(_port, cmd, cmdLen);
     int len = write(_port, cmd, cmdLen);
     if (len >= sizeof(cmd)) {
     if (len >= sizeof(cmd)) {
-        //log_info("Write cmd to LCM successfully. \n");
+        //log_info("Write cmd to LCM successfully. ");
     }
     }
 }
 }
 
 
@@ -544,10 +544,10 @@ void ChangeWarningFunc()
     uint8_t cmd[7] = {0};
     uint8_t cmd[7] = {0};
     uint8_t i = 0;
     uint8_t i = 0;
     //uint8_t j = 0;
     //uint8_t j = 0;
-    //log_info("ChangeWarningFunc \n");
+    //log_info("ChangeWarningFunc ");
     // 最多一次五筆
     // 最多一次五筆
-    //log_info("LCM PageIndex = %d \n", pSysWarning->PageIndex);
-    //log_info("WarningCount = %d \n", pSysWarning->WarningCount);
+    //log_info("LCM PageIndex = %d ", pSysWarning->PageIndex);
+    //log_info("WarningCount = %d ", pSysWarning->WarningCount);
 //#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
 //#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
     for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
     for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
         memset(cmd, 0x00, sizeof(cmd));
         memset(cmd, 0x00, sizeof(cmd));
@@ -640,19 +640,19 @@ void ChangeQrCode_Idle(char *input)
         if (len >= 25) {
         if (len >= 25) {
             if (i >= 16 && i <= 19) {
             if (i >= 16 && i <= 19) {
                 tmpBuf[k++] = input[l];
                 tmpBuf[k++] = input[l];
-                //printf("tmpBuf = %s\r\n", tmpBuf);
+                //printf("tmpBuf = %s", tmpBuf);
             } else if (i >= 21 && i <= 23) {
             } else if (i >= 21 && i <= 23) {
                 tmpBuf[k++] = input[l];
                 tmpBuf[k++] = input[l];
             }
             }
         }
         }
     }
     }
     tmpBuf[k] = '\0';
     tmpBuf[k] = '\0';
-    //printf("tmpBuf = %s\r\n", tmpBuf);
+    //printf("tmpBuf = %s", tmpBuf);
     j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
     j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
     cmd[len - 1] = '\0';
     cmd[len - 1] = '\0';
     urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
     urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
     qrUrl[urlLen] = '\0';
     qrUrl[urlLen] = '\0';
-    //printf("qr url = %s\r\n", qrUrl);
+    //printf("qr url = %s", qrUrl);
     DisplayValueToLcm(__qr_code, qrUrl, urlLen);
     DisplayValueToLcm(__qr_code, qrUrl, urlLen);
 
 
     j = 0;
     j = 0;
@@ -717,14 +717,14 @@ void ChangeQrCode_Charge(char *input)
         if (len >= 25) {
         if (len >= 25) {
             if (i >= 16 && i <= 19) {
             if (i >= 16 && i <= 19) {
                 tmpBuf[k++] = input[l];
                 tmpBuf[k++] = input[l];
-                //printf("tmpBuf = %s\r\n", tmpBuf);
+                //printf("tmpBuf = %s", tmpBuf);
             } else if (i >= 21 && i <= 23) {
             } else if (i >= 21 && i <= 23) {
                 tmpBuf[k++] = input[l];
                 tmpBuf[k++] = input[l];
             }
             }
         }
         }
     }
     }
     tmpBuf[k] = '\0';
     tmpBuf[k] = '\0';
-    //printf("tmpBuf = %s\r\n", tmpBuf);
+    //printf("tmpBuf = %s", tmpBuf);
     j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
     j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
     cmd[len - 1] = '\0';
     cmd[len - 1] = '\0';
     urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
     urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
@@ -777,7 +777,7 @@ void ChangeQrCode_Charge(char *input)
 //================================================
 //================================================
 void ChangeCurPage()
 void ChangeCurPage()
 {
 {
-    //log_info("cur = %d, new = %d \n", _currentPage, pSysInfo->PageIndex);
+    //log_info("cur = %d, new = %d ", _currentPage, pSysInfo->PageIndex);
     if (_currentPage != pSysInfo->PageIndex) {
     if (_currentPage != pSysInfo->PageIndex) {
         _currentPage = pSysInfo->PageIndex;
         _currentPage = pSysInfo->PageIndex;
         ChangeToOtherPage(_currentPage);
         ChangeToOtherPage(_currentPage);
@@ -1233,7 +1233,7 @@ void RefreshConnStatus()
     //uint8_t flag[4] = {0};
     //uint8_t flag[4] = {0};
 
 
     /*for (i = 0; i < pSysWarning->WarningCount; i++) {
     /*for (i = 0; i < pSysWarning->WarningCount; i++) {
-        //printf("status code = %s\r\n", &pSysWarning->WarningCode[i][0]);
+        //printf("status code = %s", &pSysWarning->WarningCode[i][0]);
         if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
         if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
             flag[0] = 1;
             flag[0] = 1;
             continue;
             continue;
@@ -2169,7 +2169,7 @@ void ChangeDisplayMoneyInfo()
         isPass = true;
         isPass = true;
         for (uint8_t _index = 0; _index < _totalCount; _index++) {
         for (uint8_t _index = 0; _index < _totalCount; _index++) {
             if (!FindChargingInfoData(_index, &_chargingInfoData[0])) {
             if (!FindChargingInfoData(_index, &_chargingInfoData[0])) {
-                log_error("LcmComm (main) : FindChargingInfoData false \n");
+                log_error("LcmComm (main) : FindChargingInfoData false ");
                 isPass = false;
                 isPass = false;
                 count--;
                 count--;
                 break;
                 break;
@@ -2186,7 +2186,7 @@ void ChangeDisplayMoneyInfo()
             isPass = true;
             isPass = true;
             for (uint8_t _index = 0; _index < acgunCount; _index++) {
             for (uint8_t _index = 0; _index < acgunCount; _index++) {
                 if (!FindAcChargingInfoData(_index, &ac_chargingInfo[0])) {
                 if (!FindAcChargingInfoData(_index, &ac_chargingInfo[0])) {
-                    log_error("LcmComm : FindAcChargingInfoData false \n");
+                    log_error("LcmComm : FindAcChargingInfoData false ");
                     isPass = false;
                     isPass = false;
                     break;
                     break;
                 }
                 }
@@ -2197,7 +2197,7 @@ void ChangeDisplayMoneyInfo()
     }
     }
 
 
     if (count == 0) {
     if (count == 0) {
-        log_info("LCM Initialization Gun Fail.............\n");
+        log_info("LCM Initialization Gun Fail.............");
     }
     }
 }
 }
 */
 */
@@ -2220,7 +2220,7 @@ int main(void)
 {
 {
 
 
     //if (InitShareMemory() == FAIL) {
     //if (InitShareMemory() == FAIL) {
-    //    log_error("InitShareMemory NG\n");
+    //    log_error("InitShareMemory NG");
     //
     //
     //    if (ShmStatusCodeData != NULL) {
     //    if (ShmStatusCodeData != NULL) {
     //        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
     //        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
@@ -2230,7 +2230,7 @@ int main(void)
     //}
     //}
 
 
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -2242,6 +2242,8 @@ int main(void)
     ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();;
     ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();;
     ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
     ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
     ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
     ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
+    struct StatusCodeData *ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();;
+ 
 
 
     _port = CreateCommunicationLcmPort();
     _port = CreateCommunicationLcmPort();
     uint8_t changeWarningPriority = 0;
     uint8_t changeWarningPriority = 0;
@@ -2251,7 +2253,7 @@ int main(void)
     acgunCount = pSysConfig->AcConnectorCount;
     acgunCount = pSysConfig->AcConnectorCount;
     //Initialization();
     //Initialization();
 
 
-    //printf("_LCM_COMPLETE \r\n");
+    //printf("_LCM_COMPLETE ");
     //ChangeToOtherPage(_LCM_COMPLETE);
     //ChangeToOtherPage(_LCM_COMPLETE);
     //return 0;
     //return 0;
 
 
@@ -2265,8 +2267,15 @@ int main(void)
         if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
         if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
             GetCurrentPage();
             GetCurrentPage();
             sleep(1);
             sleep(1);
+#ifndef DD360ComBox
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
+#endif
+
         } else {
         } else {
             //DemoFunction();
             //DemoFunction();
+#ifndef DD360ComBox
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false;
+#endif
 
 
             // Warning 處理
             // Warning 處理
             if (curWarningCount != pSysWarning->WarningCount) {
             if (curWarningCount != pSysWarning->WarningCount) {
@@ -2312,6 +2321,10 @@ int main(void)
         }
         }
     }
     }
 
 
+#ifndef DD360ComBox
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
+#endif
+    log_info("Close LCM Uart Port");
     CloseCommunicationLcmPort();
     CloseCommunicationLcmPort();
 
 
     return FAIL;
     return FAIL;

+ 25 - 25
EVSE/Projects/DD360/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -76,7 +76,7 @@ uint8_t Door_flag = 0;
     if (pSysConfig->SwitchDebugFlag == YES) {
     if (pSysConfig->SwitchDebugFlag == YES) {
         sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
         sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
                 tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
                 tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
-        printf("%s \n", Buf);
+        printf("%s ", Buf);
     } else {
     } else {
         sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
         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,
                 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
@@ -164,13 +164,13 @@ void GetFwAndHwVersion(int fd)
     Ver ver = {0};
     Ver ver = {0};
 
 
     if (Query_FW_Ver(fd, OP_ADDR_IO_EXTEND, &ver) == PASS) {
     if (Query_FW_Ver(fd, OP_ADDR_IO_EXTEND, &ver) == PASS) {
-        //log_info("Primary FW Rev = %s \n", ver.Version_FW);
+        //log_info("Primary FW Rev = %s ", ver.Version_FW);
         strcpy((char *)ShmPrimaryMcuData->version, ver.Version_FW);
         strcpy((char *)ShmPrimaryMcuData->version, ver.Version_FW);
         strcpy((char *) pSysInfo->CsuPrimFwRev, ver.Version_FW);
         strcpy((char *) pSysInfo->CsuPrimFwRev, ver.Version_FW);
     }
     }
 
 
     //if (Query_HW_Ver(fd, OP_ADDR_IO_EXTEND, &ver) == PASS)
     //if (Query_HW_Ver(fd, OP_ADDR_IO_EXTEND, &ver) == PASS)
-    //    ;//log_info("Primary HW Rev  = %s \n", ver.Version_HW);
+    //    ;//log_info("Primary HW Rev  = %s ", ver.Version_HW);
 }
 }
 
 
 void GetInputGpioStatus(int fd)
 void GetInputGpioStatus(int fd)
@@ -179,7 +179,7 @@ void GetInputGpioStatus(int fd)
     Gpio_in gpio_in = {0};
     Gpio_in gpio_in = {0};
     static uint8_t dispenserSw = 0;
     static uint8_t dispenserSw = 0;
 
 
-    //log_info("GetInputGpioStatus \n");
+    //log_info("GetInputGpioStatus ");
     if (Query_Gpio_Input(fd, OP_ADDR_IO_EXTEND, &gpio_in) != PASS) {
     if (Query_Gpio_Input(fd, OP_ADDR_IO_EXTEND, &gpio_in) != PASS) {
         return;
         return;
     }
     }
@@ -212,7 +212,7 @@ void GetInputGpioStatus(int fd)
 
 
     if (dispenserSwTmp != dispenserSw) {
     if (dispenserSwTmp != dispenserSw) {
         dispenserSw = dispenserSwTmp;
         dispenserSw = dispenserSwTmp;
-        log_info("Dispenser switch number =  %d, bit = %d, %d, %d, %d\r\n",
+        log_info("Dispenser switch number =  %d, bit = %d, %d, %d, %d",
                  dispenserSw,
                  dispenserSw,
                  ShmPrimaryMcuData->InputDet.bits.Key3,
                  ShmPrimaryMcuData->InputDet.bits.Key3,
                  ShmPrimaryMcuData->InputDet.bits.Key2,
                  ShmPrimaryMcuData->InputDet.bits.Key2,
@@ -256,9 +256,9 @@ void GetInputGpioStatus(int fd)
 #endif 
 #endif 
     ShmPrimaryMcuData->InputDet.bits.DoorOpen = Door_flag;
     ShmPrimaryMcuData->InputDet.bits.DoorOpen = Door_flag;
 /*
 /*
-    log_info("Emergency Button Count = %d , Emergency flag = %d\n",
+    log_info("Emergency Button Count = %d , Emergency flag = %d",
             EmgBtn_count,EmgBtn_flag);
             EmgBtn_count,EmgBtn_flag);
-    log_info("Door Sensor Count = %d , Door Sensor flag = %d\n",
+    log_info("Door Sensor Count = %d , Door Sensor flag = %d",
             Door_count,Door_flag);
             Door_count,Door_flag);
 */
 */
 
 
@@ -306,17 +306,17 @@ void GetInputGpioStatus(int fd)
     ShmPrimaryMcuData->InputDet.bits.Key3 = gpio_in.Key[3] & 0x01;
     ShmPrimaryMcuData->InputDet.bits.Key3 = gpio_in.Key[3] & 0x01;
     ShmPrimaryMcuData->InputDet.bits.DoorOpen = gpio_in.Door_Open;
     ShmPrimaryMcuData->InputDet.bits.DoorOpen = gpio_in.Door_Open;
 
 
-    /*printf(" gpio_in.Key[0]~ gpio_in.Key[3]=%d, %d, %d, %d\n",
+    /*printf(" gpio_in.Key[0]~ gpio_in.Key[3]=%d, %d, %d, %d",
     ShmPrimaryMcuData->InputDet.bits.Key0 , ShmPrimaryMcuData->InputDet.bits.Key1,
     ShmPrimaryMcuData->InputDet.bits.Key0 , ShmPrimaryMcuData->InputDet.bits.Key1,
     ShmPrimaryMcuData->InputDet.bits.Key2,ShmPrimaryMcuData->InputDet.bits.Key3);
     ShmPrimaryMcuData->InputDet.bits.Key2,ShmPrimaryMcuData->InputDet.bits.Key3);
-    printf("pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning=%d\n", pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning);
-    printf("pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault=%d\n", pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault);
+    printf("pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning=%d", pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning);
+    printf("pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault=%d", pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault);
     */
     */
-    //log_info("left = %d \n", ShmPrimaryMcuData->InputDet.bits.Button1);
-    //log_info("right = %d \n", ShmPrimaryMcuData->InputDet.bits.Button2);
-    //log_info("pSysInfo->AcContactorStatus = %d \n", pSysInfo->AcContactorStatus);
+    //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) {
     if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == YES) {
-        log_error("AC Mainbreaker occur. \n");
+        log_error("AC Mainbreaker occur. ");
     }
     }
 }
 }
 
 
@@ -404,7 +404,7 @@ static void checkChillerStatus(Gpio_out *gpio)
 
 
     if(_chiller.ChillerSwitch != _chillerNeedOn)
     if(_chiller.ChillerSwitch != _chillerNeedOn)
     {
     {
-        log_info("Chiller Need Turn %s\n", _chillerNeedOn == YES ? "ON" : "OFF");
+        log_info("Chiller Need Turn %s", _chillerNeedOn == YES ? "ON" : "OFF");
     }
     }
     _chiller.ChillerSwitch = _chillerNeedOn;
     _chiller.ChillerSwitch = _chillerNeedOn;
     pGpio->AC_Connector = _chiller.ChillerSwitch;//Chiller ON/OFF Control, "0: Chiller disable, 1: Chiller enable"
     pGpio->AC_Connector = _chiller.ChillerSwitch;//Chiller ON/OFF Control, "0: Chiller disable, 1: Chiller enable"
@@ -454,7 +454,7 @@ void SetRtcData(int fd)
 
 
     ftime(&csuTime);
     ftime(&csuTime);
     tmCSU = localtime(&csuTime.time);
     tmCSU = localtime(&csuTime.time);
-    //log_info("Time : %04d-%02d-%02d %02d:%02d:%02d \n",
+    //log_info("Time : %04d-%02d-%02d %02d:%02d:%02d ",
     //         tmCSU->tm_year + 1900,
     //         tmCSU->tm_year + 1900,
     //         tmCSU->tm_mon + 1,
     //         tmCSU->tm_mon + 1,
     //         tmCSU->tm_mday,
     //         tmCSU->tm_mday,
@@ -483,9 +483,9 @@ void SetRtcData(int fd)
     rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
     rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
 
 
     if (Config_Rtc_Data(fd, OP_ADDR_IO_EXTEND, &rtc) == PASS) {
     if (Config_Rtc_Data(fd, OP_ADDR_IO_EXTEND, &rtc) == PASS) {
-        //log_info("SetRtc sucessfully. \n");
+        //log_info("SetRtc sucessfully. ");
     } else {
     } else {
-        //log_info("SetRtc fail. \n");
+        //log_info("SetRtc fail. ");
     }
     }
 }
 }
 
 
@@ -506,7 +506,7 @@ int InitComPort()
     fd = open(priPortName, O_RDWR);
     fd = open(priPortName, O_RDWR);
     if (fd <= 0) {
     if (fd <= 0) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("open 407 Communication port NG \n");
+        log_error("open 407 Communication port NG ");
 #endif
 #endif
         return -1;
         return -1;
     }
     }
@@ -565,7 +565,7 @@ unsigned long GetTimeoutValue(struct timeval _sour_time)
 //        isPass = true;
 //        isPass = true;
 //        for (uint8_t _index = 0; _index < gun_count; _index++) {
 //        for (uint8_t _index = 0; _index < gun_count; _index++) {
 //            if (!FindChargingInfoData(_index, &ChargingData[0])) {
 //            if (!FindChargingInfoData(_index, &ChargingData[0])) {
-//                log_error("EvComm (main) : FindChargingInfoData false \n");
+//                log_error("EvComm (main) : FindChargingInfoData false ");
 //                isPass = false;
 //                isPass = false;
 //                break;
 //                break;
 //            }
 //            }
@@ -590,7 +590,7 @@ static bool IsPrimaryProcessNeedPause(void)
     }
     }
     if(isPause != _pause)
     if(isPause != _pause)
     {
     {
-        log_info("Primary Process Now Is %s \n", _pause == true ? "Paused" : "Continued");
+        log_info("Primary Process Now Is %s ", _pause == true ? "Paused" : "Continued");
     }
     }
     isPause = _pause;
     isPause = _pause;
 
 
@@ -602,7 +602,7 @@ int main(void)
     int Uart1Fd = -1;
     int Uart1Fd = -1;
 
 
     //if (InitShareMemory() == FAIL) {
     //if (InitShareMemory() == FAIL) {
-    //    log_error("InitShareMemory NG\r\n");
+    //    log_error("InitShareMemory NG");
     //    if (ShmStatusCodeData != NULL) {
     //    if (ShmStatusCodeData != NULL) {
     //        pAlarmCode->AlarmEvents.bits.FailToCreateShareMemory = 1;
     //        pAlarmCode->AlarmEvents.bits.FailToCreateShareMemory = 1;
     //    }
     //    }
@@ -611,7 +611,7 @@ int main(void)
     //}
     //}
 
 
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -624,7 +624,7 @@ int main(void)
     ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
     ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
 
 
     Uart1Fd = InitComPort();
     Uart1Fd = InitComPort();
-    //log_info("407 Port id = %d \n", Uart1Fd);
+    //log_info("407 Port id = %d ", Uart1Fd);
 
 
     if (Uart1Fd < 0) {
     if (Uart1Fd < 0) {
         log_error("InitComPort (Uart1 : AM3352 - STM32) NG");
         log_error("InitComPort (Uart1 : AM3352 - STM32) NG");
@@ -653,7 +653,7 @@ int main(void)
         // 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
         // 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
         // 模組更新 FW 後,需重新做
         // 模組更新 FW 後,需重新做
         if (ShmPrimaryMcuData->SelfTest_Comp != PASS) {
         if (ShmPrimaryMcuData->SelfTest_Comp != PASS) {
-            //log_info("(407) Get Fw and Hw Ver. \n");
+            //log_info("(407) Get Fw and Hw Ver. ");
             GetFwAndHwVersion(Uart1Fd);
             GetFwAndHwVersion(Uart1Fd);
             sleep(1);
             sleep(1);
             ShmPrimaryMcuData->SelfTest_Comp = PASS;
             ShmPrimaryMcuData->SelfTest_Comp = PASS;

+ 25 - 24
EVSE/Projects/DD360/Apps/ModuleUpdateFW/Module_UpdateFW.c

@@ -80,6 +80,8 @@ void setChargerMode(uint8_t gunIndex, uint8_t mode)
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
 
 
     pDcChargingInfo->SystemStatus = mode;
     pDcChargingInfo->SystemStatus = mode;
+
+    log_info(" ====== System Status:%d ======",mode);
 }
 }
 void TryCloseWatchdog()
 void TryCloseWatchdog()
 {
 {
@@ -101,7 +103,7 @@ static int InitComPort(uint8_t target)
     }
     }
 
 
     if (fd <= 0) {
     if (fd <= 0) {
-        log_error("open 407 Communication port NG \n");
+        log_error("open 407 Communication port NG ");
         return -1;
         return -1;
     }
     }
 
 
@@ -215,7 +217,7 @@ static int CheckUpdateProcess(void)
             //new_str[0] = '\0';
             //new_str[0] = '\0';
             strcat(new_str, "/mnt/");
             strcat(new_str, "/mnt/");
             strcat(new_str, dir->d_name);
             strcat(new_str, dir->d_name);
-            log_info("%s%s\r\n", "/mnt/", dir->d_name);
+            log_info("%s%s", "/mnt/", dir->d_name);
             
             
             fd = open(new_str, O_RDONLY);
             fd = open(new_str, O_RDONLY);
             if (fd < 0) {
             if (fd < 0) {
@@ -233,13 +235,13 @@ static int CheckUpdateProcess(void)
                 }
                 }
             }
             }
 
 
-            log_info("model name check pass. \n");
+            log_info("model name check pass. ");
             if (ImageLen > 20) {
             if (ImageLen > 20) {
                 Type = (((unsigned int)ptr[16]) << 24 |
                 Type = (((unsigned int)ptr[16]) << 24 |
                         ((unsigned int)ptr[17]) << 16 |
                         ((unsigned int)ptr[17]) << 16 |
                         ((unsigned int)ptr[18]) << 8  |
                         ((unsigned int)ptr[18]) << 8  |
                         ((unsigned int)ptr[19]));
                         ((unsigned int)ptr[19]));
-                log_info("Typed...%x \r\n", Type);
+                log_info("Typed...%x ", Type);
 
 
                 switch (Type) {
                 switch (Type) {
                 case 0x10000001:
                 case 0x10000001:
@@ -251,7 +253,7 @@ static int CheckUpdateProcess(void)
                         //return PASS;
                         //return PASS;
                         retSucc++;
                         retSucc++;
                     } else {
                     } else {
-                        log_info("Upgrade %x Failed\r\n", Type);
+                        log_info("Upgrade %x Failed", Type);
                         //return FAIL;
                         //return FAIL;
                         retFail++;
                         retFail++;
                     }
                     }
@@ -265,7 +267,6 @@ static int CheckUpdateProcess(void)
                     if (CanFd > 0) {
                     if (CanFd > 0) {
                         for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
                         for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
                             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
                             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
-
                             if (pDcChargingInfo->Type == _Type_CCS_2) {
                             if (pDcChargingInfo->Type == _Type_CCS_2) {
                                 uint8_t targetID = pDcChargingInfo->Evboard_id;
                                 uint8_t targetID = pDcChargingInfo->Evboard_id;
 
 
@@ -276,13 +277,13 @@ static int CheckUpdateProcess(void)
 
 
                                 system("echo 3 > /proc/sys/vm/drop_caches");
                                 system("echo 3 > /proc/sys/vm/drop_caches");
                                 sleep(2);
                                 sleep(2);
-                                log_info("Upgrade CCS Processing..target id = %d \n", targetID);
+                                log_info("Upgrade CCS Processing..target id = %d ", targetID);
                                 if (Upgrade_CCS(CanFd,
                                 if (Upgrade_CCS(CanFd,
                                                 Type,
                                                 Type,
                                                 targetID,
                                                 targetID,
                                                 new_str,
                                                 new_str,
                                                 (char *)pSysConfig->ModelName) == FAIL) {
                                                 (char *)pSysConfig->ModelName) == FAIL) {
-                                    log_info("Upgrade CCS Failed \n");
+                                    log_info("Upgrade CCS Failed ");
                                     retFail++;
                                     retFail++;
                                 } else {
                                 } else {
                                     retSucc++;
                                     retSucc++;
@@ -305,13 +306,13 @@ static int CheckUpdateProcess(void)
                             if (chargingInfo[index]->Type == _Type_CCS_2) {
                             if (chargingInfo[index]->Type == _Type_CCS_2) {
                                 if (Upgrade_CCS(CanFd, Type, chargingInfo[index]->Evboard_id, new_str, (char *)pSysConfig->ModelName) == FAIL) {
                                 if (Upgrade_CCS(CanFd, Type, chargingInfo[index]->Evboard_id, new_str, (char *)pSysConfig->ModelName) == FAIL) {
                                     //isPass = false;
                                     //isPass = false;
-                                    log_info("Upgrade %x Failed\r\n", Type);
+                                    log_info("Upgrade %x Failed", Type);
                                     retFail++;
                                     retFail++;
                                 }
                                 }
                             }
                             }
                         }
                         }
                     } else {
                     } else {
-                        log_error("Upgrade CCS open CAN FD fail.\n");
+                        log_error("Upgrade CCS open CAN FD fail.");
                         //isPass = false;
                         //isPass = false;
                         return FAIL;
                         return FAIL;
                     }
                     }
@@ -351,7 +352,7 @@ static int CheckUpdateProcess(void)
                         //return PASS;
                         //return PASS;
                         retSucc++;
                         retSucc++;
                     } else {
                     } else {
-                        log_info("Upgrade %x Failed\r\n", Type);
+                        log_info("Upgrade %x Failed", Type);
                         //return FAIL;
                         //return FAIL;
                         return FAIL;
                         return FAIL;
                     }
                     }
@@ -380,14 +381,14 @@ static int CheckUpdateProcess(void)
                                     //isPass = PASS;
                                     //isPass = PASS;
                                     retSucc++;
                                     retSucc++;
                                 } else {
                                 } else {
-                                    log_info("Upgrade %x Failed\r\n", Type);
+                                    log_info("Upgrade %x Failed", Type);
                                     //isPass = FAIL;
                                     //isPass = FAIL;
                                     retFail++;
                                     retFail++;
                                 }
                                 }
                             }
                             }
                         }
                         }
                     } else {
                     } else {
-                        log_info("Upgrad FD fail. \n");
+                        log_info("Upgrad FD fail. ");
                         //isPass = false;
                         //isPass = false;
                         return FAIL;
                         return FAIL;
                     }
                     }
@@ -412,11 +413,11 @@ static int CheckUpdateProcess(void)
 
 
 void CheckFwUpdateFunction(void)
 void CheckFwUpdateFunction(void)
 {
 {
-    //log_info("pSysInfo->FirmwareUpdate = %d \n", pSysInfo->FirmwareUpdate);
+    //log_info("pSysInfo->FirmwareUpdate = %d ", pSysInfo->FirmwareUpdate);
     if (pSysInfo->FirmwareUpdate == YES) {
     if (pSysInfo->FirmwareUpdate == YES) {
-        log_info("ftp : update start. \n");
+        log_info("ftp : update start. ");
         TryCloseWatchdog();
         TryCloseWatchdog();
-
+        pSysInfo->SystemPage = _LCM_FIX;
         for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
         for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
             setChargerMode(gun_index, MODE_UPDATE);
             setChargerMode(gun_index, MODE_UPDATE);
         }
         }
@@ -424,16 +425,16 @@ void CheckFwUpdateFunction(void)
         uint8_t updateResult = CheckUpdateProcess();
         uint8_t updateResult = CheckUpdateProcess();
 
 
         if (updateResult == PASS) {
         if (updateResult == PASS) {
-            log_info("ftp : update complete. \n");
+            log_info("ftp : update complete. ");
         } else if (updateResult == MODELNAME_FAIL) {
         } else if (updateResult == MODELNAME_FAIL) {
-            log_info("ftp : model name is none match. \n");
+            log_info("ftp : model name is none match. ");
             KillAllTask();
             KillAllTask();
             pSysInfo->FirmwareUpdate = NO;
             pSysInfo->FirmwareUpdate = NO;
             sleep(5);
             sleep(5);
             system("/usr/bin/run_evse_restart.sh");
             system("/usr/bin/run_evse_restart.sh");
             return;
             return;
         } else {
         } else {
-            log_info("ftp : update fail. \n");
+            log_info("ftp : update fail. ");
         }
         }
 
 
         pSysInfo->FirmwareUpdate = NO;
         pSysInfo->FirmwareUpdate = NO;
@@ -443,7 +444,7 @@ void CheckFwUpdateFunction(void)
         ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = NO;
         ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = NO;
 
 
         if (strcmp((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Downloaded") == EQUAL) {
         if (strcmp((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Downloaded") == EQUAL) {
-            log_info("Backend : update start. \n");
+            log_info("Backend : update start. ");
             TryCloseWatchdog();
             TryCloseWatchdog();
             strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "");
             strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "");
             strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installing");
             strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installing");
@@ -464,10 +465,10 @@ void CheckFwUpdateFunction(void)
             uint8_t updateResult = CheckUpdateProcess();
             uint8_t updateResult = CheckUpdateProcess();
 
 
             if (updateResult == PASS) {
             if (updateResult == PASS) {
-                log_info("Backend : update complete. \n");
+                log_info("Backend : update complete. ");
                 strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
                 strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
             } else if (updateResult == MODELNAME_FAIL) {
             } else if (updateResult == MODELNAME_FAIL) {
-                log_info("Backend : model name is none match. \n");
+                log_info("Backend : model name is none match. ");
                 KillAllTask();
                 KillAllTask();
                 strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
                 strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
                 ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
                 ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
@@ -475,7 +476,7 @@ void CheckFwUpdateFunction(void)
                 system("/usr/bin/run_evse_restart.sh");
                 system("/usr/bin/run_evse_restart.sh");
                 return;
                 return;
             } else {
             } else {
-                log_info("Backend : update fail. \n");
+                log_info("Backend : update fail. ");
                 strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
                 strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
             }
             }
 
 
@@ -490,7 +491,7 @@ void CheckFwUpdateFunction(void)
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
     
     

+ 1 - 0
EVSE/Projects/DD360/Apps/Script/kill.sh

@@ -14,6 +14,7 @@ pkill Module_ProduceUtils;
 pkill Module_DoComm;
 pkill Module_DoComm;
 pkill main;
 pkill main;
 
 
+/usr/bin/fuser -k /dev/watchdog
 sleep 1
 sleep 1
 
 
 echo V > /dev/watchdog
 echo V > /dev/watchdog

+ 9 - 9
EVSE/Projects/DD360/Apps/SelectGun/SelectGun.c

@@ -49,7 +49,7 @@ void destroySelGun(uint8_t curGun)
     if (curGun == DESTROY_ALL_SEL) {
     if (curGun == DESTROY_ALL_SEL) {
         pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_RELEASE;
         pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_RELEASE;
         pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_RELEASE;
         pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_RELEASE;
-        log_info("destroy all gun = %d, %d\r\n",
+        log_info("destroy all gun = %d, %d",
                  pSelectGunInfo->SelGunInfo.LeftGun,
                  pSelectGunInfo->SelGunInfo.LeftGun,
                  pSelectGunInfo->SelGunInfo.RightGun);
                  pSelectGunInfo->SelGunInfo.RightGun);
         for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
         for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
@@ -74,9 +74,9 @@ void destroySelGun(uint8_t curGun)
             ClearAuthorizedFlag();
             ClearAuthorizedFlag();
         }
         }
 
 
-        log_info("destroy left gun, cur page = %d\r\n", pSysInfo->SystemPage);
+        log_info("destroy left gun, cur page = %d", pSysInfo->SystemPage);
         //if (pSysInfo->SystemPage == pSysInfo->SystemPage) {
         //if (pSysInfo->SystemPage == pSysInfo->SystemPage) {
-        log_info("clear left balance\r\n");
+        log_info("clear left balance");
         memset(&pSelectGunInfo->PricesInfo[curGun], 0, sizeof(PricesInfo));
         memset(&pSelectGunInfo->PricesInfo[curGun], 0, sizeof(PricesInfo));
         pSelectGunInfo->PricesInfo[curGun].Balance = FAIL_BALANCE_PRICES;
         pSelectGunInfo->PricesInfo[curGun].Balance = FAIL_BALANCE_PRICES;
         //}
         //}
@@ -93,9 +93,9 @@ void destroySelGun(uint8_t curGun)
             ClearAuthorizedFlag();
             ClearAuthorizedFlag();
         }
         }
 
 
-        log_info("destroy right gun, cur page = %d\r\n", pSysInfo->SystemPage);
+        log_info("destroy right gun, cur page = %d", pSysInfo->SystemPage);
         //if (pSysInfo->SystemPage == pSysInfo->SystemPage) {
         //if (pSysInfo->SystemPage == pSysInfo->SystemPage) {
-        log_info("clear right balance\r\n");
+        log_info("clear right balance");
         memset(&pSelectGunInfo->PricesInfo[curGun], 0, sizeof(PricesInfo));
         memset(&pSelectGunInfo->PricesInfo[curGun], 0, sizeof(PricesInfo));
         pSelectGunInfo->PricesInfo[curGun].Balance = FAIL_BALANCE_PRICES;
         pSelectGunInfo->PricesInfo[curGun].Balance = FAIL_BALANCE_PRICES;
         //}
         //}
@@ -143,11 +143,11 @@ void setSelGunWaitToAuthor(uint8_t curSel)
 
 
     if (curSel == LEFT_GUN_NUM && pSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM) {
     if (curSel == LEFT_GUN_NUM && pSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM) {
         pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_ATHOR;
         pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_ATHOR;
-        //printf("setSelGunWaitToAuthor left\r\n");
+        //printf("setSelGunWaitToAuthor left");
         StopGunInfoTimeoutDet(curSel);
         StopGunInfoTimeoutDet(curSel);
     } else if (curSel == RIGHT_GUN_NUM && pSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM) {
     } else if (curSel == RIGHT_GUN_NUM && pSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM) {
         pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_ATHOR;
         pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_ATHOR;
-        //printf("setSelGunWaitToAuthor right\r\n");
+        //printf("setSelGunWaitToAuthor right");
         StopGunInfoTimeoutDet(curSel);
         StopGunInfoTimeoutDet(curSel);
     }
     }
 }
 }
@@ -180,11 +180,11 @@ void confirmSelGun(uint8_t selGun)
     if (selGun == LEFT_GUN_NUM) {
     if (selGun == LEFT_GUN_NUM) {
         pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
         pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
         StopGunInfoTimeoutDet(selGun);
         StopGunInfoTimeoutDet(selGun);
-        //printf("confirmSelGun left\r\n");
+        //printf("confirmSelGun left");
     } else if (selGun == RIGHT_GUN_NUM) {
     } else if (selGun == RIGHT_GUN_NUM) {
         pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
         pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
         StopGunInfoTimeoutDet(selGun);
         StopGunInfoTimeoutDet(selGun);
-        //printf("confirmSelGun right\r\n");
+        //printf("confirmSelGun right");
     }
     }
 
 
     pSysInfo->SystemPage = _LCM_IDLE;
     pSysInfo->SystemPage = _LCM_IDLE;

+ 16 - 16
EVSE/Projects/DD360/Apps/ShareMemory/shmMem.c

@@ -93,7 +93,7 @@ static int findChargingInfoData(uint8_t target, struct ChargingInfoData **chargi
 
 
     for (i = 0; i < CCS_QUANTITY; i++) {
     for (i = 0; i < CCS_QUANTITY; i++) {
         if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[i].Index == target) {
         if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[i].Index == target) {
-            log_info("Index = %d, %d\r\n", target, ShmSysConfigAndInfo->SysInfo.CcsChargingData[i].Index);
+            log_info("Index = %d, %d", target, ShmSysConfigAndInfo->SysInfo.CcsChargingData[i].Index);
             chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[i];
             chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[i];
             return PASS;
             return PASS;
         }
         }
@@ -117,7 +117,7 @@ void MappingChargingInfoData(void) //DS60-120 add
     while (isPass) {
     while (isPass) {
         for (i = 0; i < 2; i++) {
         for (i = 0; i < 2; i++) {
             if (!findChargingInfoData(i, &DcChargingData[0])) {
             if (!findChargingInfoData(i, &DcChargingData[0])) {
-                log_error("Find ChargingInfoData failed\r\n");
+                log_error("Find ChargingInfoData failed");
                 isPass = false;
                 isPass = false;
                 break;
                 break;
             }
             }
@@ -594,10 +594,10 @@ int InitOCPPShmMem(void)
     int MeterSMId = FAIL;
     int MeterSMId = FAIL;
 
 
     if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), IPC_CREAT | 0777)) < 0) {
     if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), IPC_CREAT | 0777)) < 0) {
-        log_info("Get OCPP share memory error\r\n");
+        log_info("Get OCPP share memory error");
         return FAIL;
         return FAIL;
     } else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
     } else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        log_info("Create OCPP share memory error\r\n");
+        log_info("Create OCPP share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -726,10 +726,10 @@ int InitSysConfigAndInfoShmMem(void)
     int MeterSMId = FAIL;
     int MeterSMId = FAIL;
 
 
     if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), IPC_CREAT | 0777)) < 0) {
     if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), IPC_CREAT | 0777)) < 0) {
-        printf("1 InitSysConfigAndInfoShmMem\r\n");
+        printf("1 InitSysConfigAndInfoShmMem");
         return FAIL;
         return FAIL;
     } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0))  == (void *) - 1) {
     } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0))  == (void *) - 1) {
-        printf("2 InitSysConfigAndInfoShmMem\r\n");
+        printf("2 InitSysConfigAndInfoShmMem");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -802,20 +802,20 @@ static int findDcChargingInfoData(uint8_t gunIndex)
     uint8_t i = 0;
     uint8_t i = 0;
     struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
     struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
 
 
-    //printf("Chademo count = %d\r\n", gGunIndexInfo.ChademoIndex);
+    //printf("Chademo count = %d\n", gGunIndexInfo.ChademoIndex);
     for (i = 0; i < gGunIndexInfo.DcGunIndex; i++) {
     for (i = 0; i < gGunIndexInfo.DcGunIndex; i++) {
         if (pSysInfo->ChademoChargingData[i].Index == gunIndex) {
         if (pSysInfo->ChademoChargingData[i].Index == gunIndex) {
-            //printf("chademo index = %d, %d\r\n", pSysInfo->ChademoChargingData[i].Index, gunIndex);
+            //printf("chademo index = %d, %d\n", pSysInfo->ChademoChargingData[i].Index, gunIndex);
             //dcChargingData[gunIndex] = &pSysInfo->ChademoChargingData[i];
             //dcChargingData[gunIndex] = &pSysInfo->ChademoChargingData[i];
             SetDcChargingInfoData(pSysInfo->ChademoChargingData[i].Index, &pSysInfo->ChademoChargingData[i]);
             SetDcChargingInfoData(pSysInfo->ChademoChargingData[i].Index, &pSysInfo->ChademoChargingData[i]);
             return PASS;
             return PASS;
         }
         }
     }
     }
 
 
-    //printf("ccs count = %d\r\n", gGunIndexInfo.CcsIndex);
+    //printf("ccs count = %d\n", gGunIndexInfo.CcsIndex);
     for (i = 0; i < gGunIndexInfo.DcGunIndex; i++) {
     for (i = 0; i < gGunIndexInfo.DcGunIndex; i++) {
         if (pSysInfo->CcsChargingData[i].Index == gunIndex) {
         if (pSysInfo->CcsChargingData[i].Index == gunIndex) {
-            //printf("ccs index = %d, %d\r\n", pSysInfo->CcsChargingData[i].Index, gunIndex);
+            //printf("ccs index = %d, %d\n", pSysInfo->CcsChargingData[i].Index, gunIndex);
             //dcChargingData[gunIndex] = (struct ChargingInfoData *)&pSysInfo->CcsChargingData[i];
             //dcChargingData[gunIndex] = (struct ChargingInfoData *)&pSysInfo->CcsChargingData[i];
             SetDcChargingInfoData(pSysInfo->CcsChargingData[i].Index, &pSysInfo->CcsChargingData[i]);
             SetDcChargingInfoData(pSysInfo->CcsChargingData[i].Index, &pSysInfo->CcsChargingData[i]);
             return PASS;
             return PASS;
@@ -987,23 +987,23 @@ bool MappingGunChargingInfo(char *whichTask)
     struct ChargingInfoData *pAcChargingInfo = NULL;
     struct ChargingInfoData *pAcChargingInfo = NULL;
 
 
     if (ShmSysConfigAndInfo == NULL) {
     if (ShmSysConfigAndInfo == NULL) {
-        log_error("ShmSysConfigAndInfo failed\r\n");
+        log_error("ShmSysConfigAndInfo failed");
         return false;
         return false;
     }
     }
 
 
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
 
 
     if (strlen((char *)pSysConfig->ModelName) < 9) {
     if (strlen((char *)pSysConfig->ModelName) < 9) {
-        log_error("Module name length < 9 get %s\r\n", (char *)pSysConfig->ModelName);
+        log_error("Module name length < 9 get %s", (char *)pSysConfig->ModelName);
         return false;
         return false;
     }
     }
 
 
     ShmDcCommonData->ChillerValve.MultiChillerGun = 0;
     ShmDcCommonData->ChillerValve.MultiChillerGun = 0;
 
 
-    //printf("1 CheckConnectorTypeStatus\r\n");
+    //printf("1 CheckConnectorTypeStatus\n");
     for (typeIndex = 7; typeIndex <= 9; typeIndex++) {
     for (typeIndex = 7; typeIndex <= 9; typeIndex++) {
         if (!addGunInfoByConnector(pSysConfig->ModelName[typeIndex], slots, whichTask)) {
         if (!addGunInfoByConnector(pSysConfig->ModelName[typeIndex], slots, whichTask)) {
-            log_error("%s add gun info failed\r\n", whichTask);
+            log_error("%s add gun info failed", whichTask);
             return false;
             return false;
         }
         }
 
 
@@ -1019,7 +1019,7 @@ bool MappingGunChargingInfo(char *whichTask)
     if (ShmDcCommonData->ChillerValve.MultiChillerGun != 0) {
     if (ShmDcCommonData->ChillerValve.MultiChillerGun != 0) {
         ShmDcCommonData->ChillerValve.MultiChillerGun |= 0x80; //有水冷槍標記
         ShmDcCommonData->ChillerValve.MultiChillerGun |= 0x80; //有水冷槍標記
         if (strncmp(whichTask, "CSU Task", 8) == EQUAL) {
         if (strncmp(whichTask, "CSU Task", 8) == EQUAL) {
-            log_info("get chiller gun = %x, chiller gun count = %d\r\n",
+            log_info("get chiller gun = %x, chiller gun count = %d",
                      (ShmDcCommonData->ChillerValve.MultiChillerGun & 0x80) >> 7,
                      (ShmDcCommonData->ChillerValve.MultiChillerGun & 0x80) >> 7,
                      ShmDcCommonData->ChillerValve.MultiChillerGun & 0x7F);
                      ShmDcCommonData->ChillerValve.MultiChillerGun & 0x7F);
         }
         }
@@ -1049,7 +1049,7 @@ bool MappingGunChargingInfo(char *whichTask)
 
 
     //log_info("Type 0~3 = CHAdeMO, CCS, GB, AC");
     //log_info("Type 0~3 = CHAdeMO, CCS, GB, AC");
     if (pSysConfig->TotalConnectorCount == 0 && pSysConfig->AcConnectorCount == 0) {
     if (pSysConfig->TotalConnectorCount == 0 && pSysConfig->AcConnectorCount == 0) {
-        log_error("DC %d or AC %d connector failed\r\n",
+        log_error("DC %d or AC %d connector failed",
                   pSysConfig->TotalConnectorCount,
                   pSysConfig->TotalConnectorCount,
                   pSysConfig->AcConnectorCount);
                   pSysConfig->AcConnectorCount);
         result = false;
         result = false;

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

@@ -52,6 +52,7 @@ enum Timeout_flag {
     Timeout_ReturnToChargingGunDet = 11,
     Timeout_ReturnToChargingGunDet = 11,
     Timeout_AuthorizingForStop     = 12,
     Timeout_AuthorizingForStop     = 12,
     Timeout_SelectGun              = 13,
     Timeout_SelectGun              = 13,
+    Timeout_WaitBalance            = 14,
 };
 };
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------

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


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


BIN
EVSE/Projects/DD360/output/FactoryConfig


BIN
EVSE/Projects/DD360/output/Module_ChkSysTask


BIN
EVSE/Projects/DD360/output/Module_DoComm


BIN
EVSE/Projects/DD360/output/Module_EvComm


BIN
EVSE/Projects/DD360/output/Module_EventLogging


BIN
EVSE/Projects/DD360/output/Module_InternalComm


BIN
EVSE/Projects/DD360/output/Module_LcmControl


BIN
EVSE/Projects/DD360/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360/output/Module_UpdateFW


BIN
EVSE/Projects/DD360/output/ReadCmdline


+ 1 - 0
EVSE/Projects/DD360/output/kill.sh

@@ -14,6 +14,7 @@ pkill Module_ProduceUtils;
 pkill Module_DoComm;
 pkill Module_DoComm;
 pkill main;
 pkill main;
 
 
+/usr/bin/fuser -k /dev/watchdog
 sleep 1
 sleep 1
 
 
 echo V > /dev/watchdog
 echo V > /dev/watchdog

BIN
EVSE/Projects/DD360/output/main


+ 0 - 184
EVSE/Projects/DD360Audi/Apps/CSU/CheckSystemTask.c

@@ -1,184 +0,0 @@
-/*
- * CheckTask.c
- *
- *  Created on: 2021年9月22日
- *      Author: 8513
- */
-
-#include "CheckSystemTask.h"
-
-bool Taskconutstring(char *src, char *taskname)
-{
-    bool result = false;
-
-    if (src == NULL || strlen(src) == 0)
-        return result;
-
-    if (strstr(src, taskname) != NULL &&
-        strstr(src, "grep") == NULL &&
-        strstr(src, "[") == NULL)
-    {
-        result = true;
-    }
-
-    return result;
-}
-
-int GetProcessCount(char *procName)
-{
-	int result = 0;
-	FILE *fp;
-	char cmd[256];
-	char buf[256];
-
-	sprintf(cmd, "ps -ef |grep %s", procName);
-	fp = popen(cmd, "r");
-	if(fp != NULL)
-	{
-		while(fgets(buf, sizeof(buf), fp) != NULL)
-		{
-			if (Taskconutstring(buf, procName))
-				result++;
-		}
-	}
-
-	pclose(fp);
-
-	return result;
-}
-
-unsigned char CheckSystemTask(unsigned char systemPage)
-{
-	unsigned char result = 0;
-	unsigned char count_main 		= GetProcessCount("main");
-	unsigned char count_evComm 		= GetProcessCount("Module_EvComm");
-	unsigned char count_interComm	= GetProcessCount("Module_InternalComm");
-	unsigned char count_eventComm	= GetProcessCount("Module_EventLogging");
-	unsigned char count_primaryComm	= GetProcessCount("Module_PrimaryComm");
-	unsigned char count_lcmComm	    = GetProcessCount("Module_LcmControl");
-	unsigned char count_doComm	    = GetProcessCount("Module_DoComm");
-	unsigned char count_produceComm	= GetProcessCount("Module_ProduceUtils");
-//	unsigned char count_psuComm 	= GetProcessCount("Module_PsuComm");
-
-//	printf("*************************** \n");
-//	printf("count_main = %d \n", count_main);
-//	printf("count_eventLog = %d \n", count_eventLog);
-//	printf("count_primary = %d \n", count_primary);
-//	printf("count_evComm = %d \n", count_evComm);
-//	printf("count_lcmCtrl = %d \n", count_lcmCtrl);
-//	printf("count_interComm = %d \n", count_interComm);
-//	printf("count_psuComm = %d \n", count_psuComm);
-//	printf("*************************** \n");
-
-//	if (systemPage == 0x09 || systemPage == 0x0A)
-	{
-		if (count_main < _SYSTEM_TASK_COUNT_MAIN )
-		{
-			system("killall Module_EventLogging");
-			system("killall Module_PrimaryComm");
-			system("killall Module_EvComm");
-			system("killall Module_LcmControl");
-			system("killall Module_InternalComm");
-			system("killall Module_DoComm");
-//			system("killall Module_PsuComm");
-//			system("killall OcppBackend &");
-//			system("killall Module_4g &");
-//			system("killall Module_Wifi &");
-			system("killall Module_ProduceUtils &");
-			sleep(3);
-			system("/usr/bin/run_evse_restart.sh");
-		}
-		else
-		{
-			/*
-			if(system("pidof -s Module_EventLogging > /dev/null") != 0)
-				system("/root/Module_EventLogging &");
-
-			if(system("pidof -s Module_PrimaryComm > /dev/null") != 0)
-				system("/root/Module_PrimaryComm &");
-
-			if(system("pidof -s Module_LcmControl > /dev/null") != 0)
-				system("/root/Module_LcmControl &");
-
-            if(system("pidof -s Module_DoComm > /dev/null") != 0)
-                system("/root/Module_DoComm &");
-
-            if(system("pidof -s Module_ProduceUtils > /dev/null") != 0)
-                system("/root/Module_ProduceUtils &");
-
-			*/
-			if (count_evComm < _SYSTEM_TASK_COUNT_EVCOMM )
-			{
-				system("killall Module_EvComm");
-				sleep(3);
-				system("/root/Module_EvComm &");
-			}
-        	if (count_interComm < _SYSTEM_TASK_COUNT_INTERNALCOMM )
-			{
-				system("killall Module_InternalComm");
-				sleep(3);
-				system("/root/Module_InternalComm &");
-			}
-			if (count_eventComm < _SYSTEM_TASK_COUNT_EVENTLOGGING )
-			{
-				system("killall Module_EventLogging");
-				sleep(3);
-				system("/root/Module_EventLogging &");
-			}
-			if (count_primaryComm < _SYSTEM_TASK_COUNT_PRIMARYCOMM )
-			{
-				system("killall Module_PrimaryComm");
-				sleep(3);
-				system("/root/Module_PrimaryComm &");
-			}
-			if (count_lcmComm < _SYSTEM_TASK_COUNT_LCM )
-			{
-				system("killall Module_LcmControl");
-				sleep(3);
-				system("/root/Module_LcmControl &");
-			}
-			if (count_doComm < _SYSTEM_TASK_COUNT_DOCOMM )
-			{
-				system("killall Module_DoComm");
-				sleep(3);
-				system("/root/Module_DoComm &");
-			}
-			if (count_produceComm < _SYSTEM_TASK_COUNT_PRODUCEUTILS )
-			{
-				system("killall Module_ProduceUtils");
-				sleep(3);
-				system("/root/Module_ProduceUtils &");
-			}
-			/*
-			if (count_psuComm < 2)
-			{
-				system("killall Module_PsuComm");
-				sleep(3);
-				system("/root/Module_PsuComm &");
-			}*/
-		}
-
-		sleep(2);
-	}
-
-	if (count_main < _SYSTEM_TASK_COUNT_MAIN)
-		result = _SYSTEM_TASK_LOST_ITEM_MAIN;
-	else if (count_evComm < _SYSTEM_TASK_COUNT_EVCOMM)
-		result = _SYSTEM_TASK_LOST_ITEM_EVCOMM;
-/*	else if (count_psuComm < 2)
-		result = 3; */
-    else if (count_eventComm < _SYSTEM_TASK_COUNT_EVENTLOGGING )
-        result = _SYSTEM_TASK_LOST_ITEM_EVENTLOG;
-    else if (count_primaryComm < _SYSTEM_TASK_COUNT_PRIMARYCOMM)
-        result = _SYSTEM_TASK_LOST_ITEM_PRIMARYCOMM;
-    else if (count_lcmComm < _SYSTEM_TASK_COUNT_LCM)
-        result = _SYSTEM_TASK_LOST_ITEM_LCMCONTROL;
-    else if (count_interComm < 2 )
-        result = _SYSTEM_TASK_LOST_ITEM_INTERCOMM;
-    else if (count_doComm < _SYSTEM_TASK_COUNT_DOCOMM)
-        result = _SYSTEM_TASK_LOST_ITEM_DOCOMM;
-    else if (count_produceComm < _SYSTEM_TASK_COUNT_PRODUCEUTILS)
-        result = _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS;
-
-	return result;
-}

+ 0 - 60
EVSE/Projects/DD360Audi/Apps/CSU/CheckSystemTask.h

@@ -1,60 +0,0 @@
-/*
- * CheckTask.h
- *
- *  Created on: 2021年9月2日
- *      Author: 7564
- */
-
-#ifndef CHECKTASK_H_
-#define CHECKTASK_H_
-
-#include 	<sys/timeb.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 	<stdint.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include 	<math.h>
-#include 	<stdbool.h>
-#include 	<dirent.h>
-
-#define _SYSTEM_TASK_LOST_ITEM_MAIN         1
-#define _SYSTEM_TASK_LOST_ITEM_EVCOMM       2
-#define _SYSTEM_TASK_LOST_ITEM_EVENTLOG     3
-#define _SYSTEM_TASK_LOST_ITEM_PRIMARYCOMM  4
-#define _SYSTEM_TASK_LOST_ITEM_LCMCONTROL   5
-#define _SYSTEM_TASK_LOST_ITEM_INTERCOMM    6
-#define _SYSTEM_TASK_LOST_ITEM_DOCOMM       7
-#define _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS 8
-
-#define _SYSTEM_TASK_COUNT_MAIN             5
-#define _SYSTEM_TASK_COUNT_EVCOMM           2
-#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_DOCOMM           1
-#define _SYSTEM_TASK_COUNT_PRODUCEUTILS     1
-
-
-unsigned char CheckSystemTask(unsigned char systemPage);
-
-#endif /* CHECKSYSTEMTASK_H_ */

+ 2 - 1
EVSE/Projects/DD360Audi/Apps/CSU/Ethernet.c

@@ -169,7 +169,7 @@ void InitEthernet(void)
             pSysConfig->Eth0Interface.EthSubmaskAddress);
             pSysConfig->Eth0Interface.EthSubmaskAddress);
     //sprintf(tmpbuf,"/sbin/ifconfig eth0 192.168.100.10 netmask 255.255.255.0 up");
     //sprintf(tmpbuf,"/sbin/ifconfig eth0 192.168.100.10 netmask 255.255.255.0 up");
     system(tmpbuf);
     system(tmpbuf);
-
+    log_info("%s",tmpbuf);
     memset(tmpbuf, 0, 256);
     memset(tmpbuf, 0, 256);
     sprintf(tmpbuf, "route add default gw %s eth0 ",
     sprintf(tmpbuf, "route add default gw %s eth0 ",
             pSysConfig->Eth0Interface.EthGatewayAddress);
             pSysConfig->Eth0Interface.EthGatewayAddress);
@@ -183,6 +183,7 @@ void InitEthernet(void)
     sprintf(tmpbuf, "/sbin/ifconfig eth1 %s netmask %s up",
     sprintf(tmpbuf, "/sbin/ifconfig eth1 %s netmask %s up",
             pSysConfig->Eth1Interface.EthIpAddress,
             pSysConfig->Eth1Interface.EthIpAddress,
             pSysConfig->Eth1Interface.EthSubmaskAddress);
             pSysConfig->Eth1Interface.EthSubmaskAddress);
+    log_info("%s",tmpbuf);
     system(tmpbuf);
     system(tmpbuf);
 
 
     //Run DHCP client if enabled
     //Run DHCP client if enabled

+ 12 - 12
EVSE/Projects/DD360Audi/Apps/CSU/Primary.c

@@ -85,8 +85,8 @@ void PrimaryLedIndicatorCtrlFork(void)
                     continue;
                     continue;
                 }
                 }
 
 
-                //printf("led indicator status = %d\r\n", chargingInfo[gunIndex]->SystemStatus);
-                //printf("level = %d\r\n", pSysWarning->Level);
+                //printf("led indicator status = %d", chargingInfo[gunIndex]->SystemStatus);
+                //printf("level = %d", pSysWarning->Level);
                 switch (pDcChargingInfo->SystemStatus) {
                 switch (pDcChargingInfo->SystemStatus) {
                 case S_BOOTING:
                 case S_BOOTING:
                     if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) {
                     if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) {
@@ -226,11 +226,11 @@ static void checkChargingInfoByDC(uint8_t systemStatus)
 #endif //!defined DD360Audi
 #endif //!defined DD360Audi
 
 
             if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
             if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
-                //printf("destroy gun = %d\r\n", pSysInfo->CurGunSelected);
+                //printf("destroy gun = %d", pSysInfo->CurGunSelected);
                 destroySelGun(pSysInfo->CurGunSelected);
                 destroySelGun(pSysInfo->CurGunSelected);
             } else {
             } else {
                 confirmSelGun(pSysInfo->CurGunSelected);
                 confirmSelGun(pSysInfo->CurGunSelected);
-                log_info("confirm select gun ............................... %d \n",
+                log_info("confirm select gun ............................... %d ",
                          pSysInfo->CurGunSelected);
                          pSysInfo->CurGunSelected);
             }
             }
         }
         }
@@ -433,7 +433,7 @@ void ChkPrimaryStatus(void)
 
 
         if (!leftBtnPush) {
         if (!leftBtnPush) {
             leftBtnPush = true;
             leftBtnPush = true;
-            log_info("left btn down...............................%x\n",
+            log_info("left btn down...............................%x",
                      pDcChargingInfo->SystemStatus);
                      pDcChargingInfo->SystemStatus);
             checkChargingInfoByAC();
             checkChargingInfoByAC();
             checkChargingInfoByDC(pDcChargingInfo->SystemStatus);
             checkChargingInfoByDC(pDcChargingInfo->SystemStatus);
@@ -480,11 +480,11 @@ void ChkPrimaryStatus(void)
                 }             else {
                 }             else {
 #if defined DD360Audi
 #if defined DD360Audi
                     if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
                     if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
-                        //printf("destroy gun = %d\r\n", pSysInfo->CurGunSelected);
+                        //printf("destroy gun = %d", pSysInfo->CurGunSelected);
                         destroySelGun(pSysInfo->CurGunSelected);
                         destroySelGun(pSysInfo->CurGunSelected);
                     } else {
                     } else {
                         confirmSelGun(pSysInfo->CurGunSelected);
                         confirmSelGun(pSysInfo->CurGunSelected);
-                        log_info("confirm select gun ............................... %d \n",
+                        log_info("confirm select gun ............................... %d ",
                                  pSysInfo->CurGunSelected);
                                  pSysInfo->CurGunSelected);
                     }
                     }
 
 
@@ -517,7 +517,7 @@ void ChkPrimaryStatus(void)
 
 
             case S_COMPLETE:
             case S_COMPLETE:
                 // 回 IDLE
                 // 回 IDLE
-                //log_info("right btn down.................S_COMPLETE \n");
+                //log_info("right btn down.................S_COMPLETE ");
                 //pDcChargingInfo->SystemStatus = S_IDLE;
                 //pDcChargingInfo->SystemStatus = S_IDLE;
                 break;
                 break;
             }
             }
@@ -526,7 +526,7 @@ void ChkPrimaryStatus(void)
     } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
     } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
         if (leftBtnPush) {
         if (leftBtnPush) {
             leftBtnPush = false;
             leftBtnPush = false;
-            //log_info("left btn up............................... \n");
+            //log_info("left btn up............................... ");
         }
         }
     }
     }
 
 
@@ -543,7 +543,7 @@ void ChkPrimaryStatus(void)
        ) {
        ) {
         if (!rightBtnPush) {
         if (!rightBtnPush) {
             rightBtnPush = true;
             rightBtnPush = true;
-            //log_info("right btn down............................... %d \n", pSysInfo->CurGunSelected);
+            //log_info("right btn down............................... %d ", pSysInfo->CurGunSelected);
             if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount &&
             if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount &&
                     pSysInfo->IsAlternatvieConf == NO) {
                     pSysInfo->IsAlternatvieConf == NO) {
                 pSysInfo->CurGunSelected++;
                 pSysInfo->CurGunSelected++;
@@ -570,12 +570,12 @@ void ChkPrimaryStatus(void)
                 ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
                 ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
             }
             }
         }
         }
-        log_info("current select gun ............................... %d \n",
+        log_info("current select gun ............................... %d ",
                  pSysInfo->CurGunSelected);
                  pSysInfo->CurGunSelected);
     } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
     } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
         if (rightBtnPush) {
         if (rightBtnPush) {
             rightBtnPush = false;
             rightBtnPush = false;
-            //log_info("right btn up............................... \n");
+            //log_info("right btn up............................... ");
         }
         }
     }
     }
 }
 }

+ 30 - 24
EVSE/Projects/DD360Audi/Apps/CSU/RFID.c

@@ -119,7 +119,11 @@ static void UserScanFunction(void)
         strcpy((char *)pSysConfig->UserId, "");
         strcpy((char *)pSysConfig->UserId, "");
         return;
         return;
     }
     }
-
+    if (pSysConfig->EVCCID_Authorize) {
+        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+        if (strcmp( (char *)pSysConfig->UserId, (char *) pDcChargingInfo->EVCCID) != EQUAL )
+            return;
+    }
     // 先判斷現在是否可以提供刷卡
     // 先判斷現在是否可以提供刷卡
     // 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能
     // 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能
     // 2. 停止充電
     // 2. 停止充電
@@ -160,8 +164,8 @@ static void UserScanFunction(void)
     if (pGunIndexInfo->AcGunIndex > 0 &&
     if (pGunIndexInfo->AcGunIndex > 0 &&
             stopReq == DEFAULT_AC_INDEX &&
             stopReq == DEFAULT_AC_INDEX &&
             pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
             pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
-        log_info("ac stop charging \n");
-        log_info("index = %d, card number = %s, UserId = %s \n",
+        log_info("ac stop charging ");
+        log_info("index = %d, card number = %s, UserId = %s ",
                  pSysInfo->CurGunSelectedByAc,
                  pSysInfo->CurGunSelectedByAc,
                  pAcChargingInfo->StartUserId,
                  pAcChargingInfo->StartUserId,
                  pSysConfig->UserId);
                  pSysConfig->UserId);
@@ -180,8 +184,8 @@ static void UserScanFunction(void)
                 (pGunIndexInfo->AcGunIndex > 0 &&
                 (pGunIndexInfo->AcGunIndex > 0 &&
                  pSysInfo->CurGunSelectedByAc == NO_DEFINE))
                  pSysInfo->CurGunSelectedByAc == NO_DEFINE))
               ) {
               ) {
-        log_info("stop charging \n");
-        log_info("index = %d, card number = %s, UserId = %s \n",
+        log_info("stop charging ");
+        log_info("index = %d, card number = %s, UserId = %s ",
                  pSysInfo->CurGunSelected,
                  pSysInfo->CurGunSelected,
                  pDcChargingInfo->StartUserId,
                  pDcChargingInfo->StartUserId,
                  pSysConfig->UserId);
                  pSysConfig->UserId);
@@ -225,7 +229,7 @@ static void UserScanFunction(void)
         } else if ((pGunIndexInfo->AcGunIndex > 0 &&
         } else if ((pGunIndexInfo->AcGunIndex > 0 &&
                     pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) ||
                     pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) ||
                    pDcChargingInfo->SystemStatus == S_IDLE) {
                    pDcChargingInfo->SystemStatus == S_IDLE) {
-            log_info("// LCM => Authorizing\r\n");
+            log_info("// LCM => Authorizing");
 
 
             setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
             setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
 
 
@@ -272,29 +276,31 @@ void ScannerCardProcess(void)
     }
     }
 
 
     if (pSysInfo->PageIndex == _LCM_AUTHORIZING) {
     if (pSysInfo->PageIndex == _LCM_AUTHORIZING) {
-        StartSystemTimeoutDet(Timeout_Authorizing);
+        if(!isAuthorizedComplete())
+            StartSystemTimeoutDet(Timeout_Authorizing);
 
 
-        //printf("isAuthorizedComplete = %d, %f\r\n", isAuthorizedComplete(), ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
+        //printf("isAuthorizedComplete = %d, %f", isAuthorizedComplete(), ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
         // 確認驗證卡號完成沒
         // 確認驗證卡號完成沒
         if (isAuthorizedComplete()
         if (isAuthorizedComplete()
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
                 || pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING
                 || pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING
 #endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
 #endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
-                && 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, "");
-            }
+                //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();
+            } ClearAuthorizedFlag();
         } else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
         } else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
             // 白名單驗證
             // 白名單驗證
             for (i = 0; i < 10; i++) {
             for (i = 0; i < 10; i++) {
@@ -360,7 +366,7 @@ void CreateRfidFork(void)
         fd = InitialRfidPort();
         fd = InitialRfidPort();
         struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
         struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
 
 
-        log_info("RFID fork Child's PID is %d\r\n", getpid());
+        log_info("RFID fork Child's PID is %d", getpid());
 
 
         while (isContinue) {
         while (isContinue) {
             usleep(500000);
             usleep(500000);
@@ -375,7 +381,7 @@ void CreateRfidFork(void)
                 continue;
                 continue;
             }
             }
 
 
-            //log_info("Get Card..-%s- \n", pSysConfig->UserId);
+            //log_info("Get Card..-%s- ", pSysConfig->UserId);
             if (strlen((char *)pSysConfig->UserId) != 0) {
             if (strlen((char *)pSysConfig->UserId) != 0) {
                 continue;
                 continue;
             }
             }
@@ -447,7 +453,7 @@ void CreateRfidFork(void)
                     break;
                     break;
                 }
                 }
             }
             }
-            log_info("card number = %s\n", pSysConfig->UserId);
+            log_info("card number = %s", pSysConfig->UserId);
         }
         }
     }
     }
 }
 }

+ 1 - 1
EVSE/Projects/DD360Audi/Apps/CSU/SelfTest.c

@@ -51,7 +51,7 @@ void SelfTestRun(void)
         if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) { //自檢完成
         if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) { //自檢完成
             return;
             return;
         }
         }
-
+        
         ChkPrimaryStatus(); //確認硬體有無錯誤,如急停按鈕或門有打開
         ChkPrimaryStatus(); //確認硬體有無錯誤,如急停按鈕或門有打開
 
 
         if (pSysWarning->Level == WARN_LV_ER) {
         if (pSysWarning->Level == WARN_LV_ER) {

+ 0 - 403
EVSE/Projects/DD360Audi/Apps/CSU/UpgradeFW.c

@@ -1,403 +0,0 @@
-#include <stdio.h>      /*標準輸入輸出定義*/
-#include <stdlib.h>     /*標準函數庫定義*/
-#include <string.h>
-#include <stdint.h>
-
-#include <sys/types.h>
-#include <dirent.h>
-
-#include "../Config.h"
-#include "../Log/log.h"
-#include "../Define/define.h"
-#include "../ShareMemory/shmMem.h"
-
-#include "main.h"
-//WatchDog.c
-extern void CreateWatchdog(void);
-extern void TryCloseWatchdog(void);
-extern void TryFeedWatchdog(void);
-
-
-//------------------------------------------------------------------------------
-static char *_priPortName = "/dev/ttyS1";
-static char *_485PortName = "/dev/ttyS5";
-
-//------------------------------------------------------------------------------
-static int InitComPort(uint8_t target)
-{
-    int fd;
-    struct termios tios;
-
-    if (target == UPGRADE_PRI) {
-        fd = open(_priPortName, O_RDWR);
-    } else if (target == UPGRADE_FAN ||
-               target == UPGRADE_RB ||
-               target == UPGRADE_AC ||
-               target == UPGRADE_LED
-              ) {
-        fd = open(_485PortName, O_RDWR);
-    }
-
-    if (fd <= 0) {
-        log_error("open 407 Communication port NG \n");
-        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)1;
-    tios.c_lflag = 0;
-    tcflush(fd, TCIFLUSH);
-    ioctl (fd, TCSETS, &tios);
-
-    return fd;
-}
-
-static int InitCanBus(void)
-{
-    int fd = -1;
-    int nbytes;
-    struct timeval tv;
-    struct ifreq ifr0;
-    struct sockaddr_can addr0;
-
-    system("/sbin/ip link set can0 down");
-    system("/sbin/ip link set can0 type can bitrate 500000 restart-ms 100");
-    system("/sbin/ip link set can0 up");
-
-    fd = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-
-    tv.tv_sec = 0;
-    tv.tv_usec = 10000;
-    if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct  timeval)) < 0) {
-        log_error("Set SO_RCVTIMEO NG");
-    }
-    nbytes = 40960;
-    if (setsockopt(fd, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0) {
-        log_error("Set SO_RCVBUF NG");
-    }
-    nbytes = 40960;
-    if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0) {
-        log_error("Set SO_SNDBUF NG");
-    }
-
-    strcpy(ifr0.ifr_name, "can0");
-    ioctl(fd, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
-    addr0.can_family = AF_CAN;
-    addr0.can_ifindex = ifr0.ifr_ifindex;
-    bind(fd, (struct sockaddr *)&addr0, sizeof(addr0));
-
-    return fd;
-}
-
-static int CheckUpdateProcess(void)
-{
-    //bool isPass = true;
-    uint8_t retSucc = 0;
-    uint8_t retFail = 0;
-    uint8_t index = 0;
-    uint8_t target = 0;
-    char Buf[256];
-    char *new_str = NULL;
-    uint8_t *ptr = NULL;
-    int fd = 0;
-    int CanFd = 0;
-    int uartFd = 0;
-    unsigned int Type = 0;
-    long int MaxLen = 48 * 1024 * 1024, ImageLen = 0;
-    DIR *d;
-    struct dirent *dir;
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
-    struct ChargingInfoData *pDcChargingInfo = NULL;
-
-    d = opendir("/mnt/");
-    if (d) {
-        while ((dir = readdir(d)) != NULL) {
-            if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0) {
-                continue;
-            }
-
-            new_str = calloc(strlen("/mnt/") + strlen(dir->d_name) + 1, sizeof(char));
-            //new_str[0] = '\0';
-            strcat(new_str, "/mnt/");
-            strcat(new_str, dir->d_name);
-            log_info("%s%s\r\n", "/mnt/", dir->d_name);
-            fd = open(new_str, O_RDONLY);
-            if (fd < 0) {
-                return FAIL;
-            }
-
-            ptr = calloc(MaxLen, sizeof(char)); //-48 is take out the header
-            //memset(ptr, 0xFF, MaxLen);  //-48 is take out the header
-
-            //get the image length
-            ImageLen = read(fd, ptr, MaxLen);
-            for (uint8_t i = 0; i < 16; i++) {
-                if (pSysConfig->ModelName[i] != ptr[i]) {
-                    return FAIL;
-                }
-            }
-
-            log_info("model name check pass. \n");
-            if (ImageLen > 20) {
-                Type = (((unsigned int)ptr[16]) << 24 |
-                        ((unsigned int)ptr[17]) << 16 |
-                        ((unsigned int)ptr[18]) << 8  |
-                        ((unsigned int)ptr[19]));
-                log_info("Typed...%x \r\n", Type);
-
-                switch (Type) {
-                case 0x10000001:
-                case 0x10000002:
-                case 0x10000003:
-                case 0x10000004:
-                case 0x10000005:
-                    if (Upgrade_Flash(Type, new_str, (char *)pSysConfig->ModelName) == PASS) {
-                        //return PASS;
-                        retSucc++;
-                    } else {
-                        log_info("Upgrade %x Failed\r\n", Type);
-                        //return FAIL;
-                        retFail++;
-                    }
-                    break;
-
-                case 0x10000007:
-                case 0x10000008:
-                case 0x10000009:
-                case 0x1000000A:
-                    CanFd = InitCanBus();
-                    if (CanFd > 0) {
-                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
-                            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
-
-                            if (pDcChargingInfo->Type == _Type_CCS_2) {
-                                uint8_t targetID = pDcChargingInfo->Evboard_id;
-
-                                if (pSysConfig->TotalConnectorCount == 1 &&
-                                        ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-                                    //targetID += 1;
-                                }
-
-                                system("echo 3 > /proc/sys/vm/drop_caches");
-                                sleep(2);
-                                log_info("Upgrade CCS Processing..target id = %d \n", targetID);
-                                if (Upgrade_CCS(CanFd,
-                                                Type,
-                                                targetID,
-                                                new_str,
-                                                (char *)pSysConfig->ModelName) == FAIL) {
-                                    log_info("Upgrade CCS Failed \n");
-                                    retFail++;
-                                } else {
-                                    retSucc++;
-                                }
-                            }
-                        }
-                        close(CanFd);
-                    }
-                    memset(Buf, 0, sizeof(Buf));
-                    sprintf(Buf, "rm -rvf /mnt/%s", new_str);
-                    system(Buf);
-                    //isPass = true;
-#if 0
-                    CanFd = InitCanBus();
-                    if (CanFd > 0) {
-                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
-                            //if (!isPass) {
-                            //    break;
-                            //}
-                            if (chargingInfo[index]->Type == _Type_CCS_2) {
-                                if (Upgrade_CCS(CanFd, Type, chargingInfo[index]->Evboard_id, new_str, (char *)pSysConfig->ModelName) == FAIL) {
-                                    //isPass = false;
-                                    log_info("Upgrade %x Failed\r\n", Type);
-                                    retFail++;
-                                }
-                            }
-                        }
-                    } else {
-                        log_error("Upgrade CCS open CAN FD fail.\n");
-                        //isPass = false;
-                        return FAIL;
-                    }
-
-                    if (retFail != 0) {
-                        break;
-                    } else {
-                        retSucc++;
-                    }
-                    //return isPass;
-#endif //0
-                    break;
-
-                case 0x10000006:
-                case 0x1000000D:
-                case 0x1000000E:
-                case 0x20000002:
-                case 0x10000014:
-                    // CSU_PRIMARY_CONTROLLER : 0x10000006
-                    target = 0x00;
-
-                    if (Type == 0x10000006) {
-                        target = UPGRADE_PRI;
-                    } else if (Type == 0x1000000D) {
-                        target = UPGRADE_RB;
-                    } else if (Type == 0x1000000E) {
-                        target = UPGRADE_FAN;
-                    } else if (Type == 0x20000002) {
-                        target = UPGRADE_AC;
-                    } else if (Type == 0x10000014) {
-                        target = UPGRADE_LED;
-                    }
-
-                    uartFd = InitComPort(target);
-
-                    if (Upgrade_UART(uartFd, Type, target, new_str, (char *)pSysConfig->ModelName) == PASS) {
-                        //return PASS;
-                        retSucc++;
-                    } else {
-                        log_info("Upgrade %x Failed\r\n", Type);
-                        //return FAIL;
-                        return FAIL;
-                    }
-
-                    if (uartFd > 0) {
-                        close(uartFd);
-                    }
-                    break;
-
-                case 0x1000000B:
-                case 0x1000000C:
-                    // CHAdeMO_BOARD : 0x1000000B, GBT : 0x1000000C
-                    //bool isPass = true;
-                    CanFd = InitCanBus();
-                    if (CanFd > 0) {
-                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
-                            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
-
-                            //if (!isPass) {
-                            //    break;
-                            //}
-
-                            if ((Type == 0x1000000B && pDcChargingInfo->Type == _Type_Chademo) ||
-                                    (Type == 0x1000000C && pDcChargingInfo->Type == _Type_GB)) {
-                                if (Upgrade_CAN(CanFd, Type, pDcChargingInfo->Evboard_id, new_str, (char *)pSysConfig->ModelName) == PASS) {
-                                    //isPass = PASS;
-                                    retSucc++;
-                                } else {
-                                    log_info("Upgrade %x Failed\r\n", Type);
-                                    //isPass = FAIL;
-                                    retFail++;
-                                }
-                            }
-                        }
-                    } else {
-                        log_info("Upgrad FD fail. \n");
-                        //isPass = false;
-                        return FAIL;
-                    }
-
-                    //return isPass;
-                    break;
-                }
-            }
-            free(new_str);
-            free(ptr);
-        }
-    }
-    free(dir);
-    closedir(d);
-
-    if (retFail != 0) {
-        return FAIL;
-    }
-
-    return PASS;
-}
-
-void CheckFwUpdateFunction(void)
-{
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-    struct OCPP16Data *ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
-    struct ChargingInfoData *pAcChargingInfo = NULL;
-
-    //log_info("pSysInfo->FirmwareUpdate = %d \n", pSysInfo->FirmwareUpdate);
-    if (pSysInfo->FirmwareUpdate == YES) {
-        log_info("ftp : update start. \n");
-        TryCloseWatchdog();
-
-        for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
-            setChargerMode(gun_index, MODE_UPDATE);
-        }
-        sleep(1);
-        uint8_t updateResult = CheckUpdateProcess();
-
-        if (updateResult == PASS) {
-            log_info("ftp : update complete. \n");
-        } else if (updateResult == MODELNAME_FAIL) {
-            log_info("ftp : model name is none match. \n");
-            KillAllTask();
-            pSysInfo->FirmwareUpdate = NO;
-            sleep(5);
-            system("/usr/bin/run_evse_restart.sh");
-            return;
-        } else {
-            log_info("ftp : update fail. \n");
-        }
-
-        pSysInfo->FirmwareUpdate = NO;
-        sleep(5);
-        system("reboot -f");
-    } else if (ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq == YES) {
-        ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = NO;
-
-        if (strcmp((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Downloaded") == EQUAL) {
-            log_info("Backend : update start. \n");
-            TryCloseWatchdog();
-            strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "");
-            strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installing");
-            ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
-            KillTask();
-
-            for (uint8_t _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
-                setChargerMode(_index, MODE_UPDATE);
-            }
-
-            for (uint8_t _index = 0; _index < pSysConfig->AcConnectorCount; _index++) {
-                pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(_index);
-
-                pAcChargingInfo->SystemStatus = MODE_UPDATE;
-            }
-            sleep(1);
-
-            uint8_t updateResult = CheckUpdateProcess();
-
-            if (updateResult == PASS) {
-                log_info("Backend : update complete. \n");
-                strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
-            } else if (updateResult == MODELNAME_FAIL) {
-                log_info("Backend : model name is none match. \n");
-                KillAllTask();
-                strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
-                ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
-                sleep(5);
-                system("/usr/bin/run_evse_restart.sh");
-                return;
-            } else {
-                log_info("Backend : update fail. \n");
-                strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
-            }
-
-            strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
-            ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
-            sleep(5);
-            system("reboot -f");
-        }
-    }
-}

+ 3 - 2
EVSE/Projects/DD360Audi/Apps/CSU/WatchDog.c

@@ -28,7 +28,8 @@ int InitWatchDog()
 
 
     if(fd<=0)
     if(fd<=0)
     {
     {
-        log_error("System watch dog initial fail.\r\n");
+        log_info("Open watchdog fd:%d",fd);
+        log_error("System watch dog initial fail.\n");
     }
     }
     ioctl(fd, _IOWR('W', 6, int), &timeout);
     ioctl(fd, _IOWR('W', 6, int), &timeout);
 
 
@@ -47,7 +48,7 @@ void CreateWatchdog(void)
     }
     }
     else
     else
     {
     {
-        log_info("Watchdog Initial Success");
+        log_info("Watchdog Initial Success (%d)",wtdFd);
     }
     }
 }
 }
 
 

File diff suppressed because it is too large
+ 179 - 158
EVSE/Projects/DD360Audi/Apps/CSU/main.c


+ 2 - 2
EVSE/Projects/DD360Audi/Apps/CSU/main.h

@@ -31,7 +31,8 @@
 
 
 #define uSEC_VAL                                (1000000)
 #define uSEC_VAL                                (1000000)
 #define SELFTEST_TIMEOUT                        (60)//45
 #define SELFTEST_TIMEOUT                        (60)//45
-#define AUTHORIZE_TIMEOUT                       (15)//30
+#define AUTHORIZE_TIMEOUT                       (30)//30
+#define BALANCE_TIMEOUT                         (15)//15
 #define AUTHORIZE_COMP_TIMEOUT                  (3)
 #define AUTHORIZE_COMP_TIMEOUT                  (3)
 #define AUTHORIZE_FAIL_TIMEOUT                  (3)
 #define AUTHORIZE_FAIL_TIMEOUT                  (3)
 #define AUTHORIZE_STOP_TIMEOUT                  (30)
 #define AUTHORIZE_STOP_TIMEOUT                  (30)
@@ -43,7 +44,6 @@
 #define GUN_PRECHARGING_TIMEOUT                 (60)
 #define GUN_PRECHARGING_TIMEOUT                 (60)
 
 
 #define WHILE_LOOP_TIME                         (10000)
 #define WHILE_LOOP_TIME                         (10000)
-#define VERIFY_EVCCID                           0   // 0:Not verify 1:for verify
 
 
 //#define log_info(format, args...) StoreLogMsg_1("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 //#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)
 //#define log_warn(format, args...) StoreLogMsg_1("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)

+ 42 - 42
EVSE/Projects/DD360Audi/Apps/DataBase/DataBase.c

@@ -61,38 +61,38 @@ int DB_Open(void)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\r\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local charging record database open successfully.\r\n");
+        log_info( "Local charging record database open successfully.");
 
 
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Create local charging record table error message: %s\n", errMsg);
+            log_info( "Create local charging record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local charging record table successfully\n");
+            log_info( "Opened local charging record table successfully");
         }
         }
 
 
         if (sqlite3_exec(localDb, createCfgSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createCfgSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Create local config table error message: %s\n", errMsg);
+            log_info( "Create local config table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local config table successfully\n");
+            log_info( "Opened local config table successfully");
         }
         }
 
 
         //DS60-120
         //DS60-120
         if (sqlite3_exec(localDb, createrecordSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createrecordSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Create local record table error message: %s\n", errMsg);
+            log_info( "Create local record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local record table successfully\n");
+            log_info( "Opened local record table successfully");
         }
         }
 
 
         if (sqlite3_exec(localDb, createrebootSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createrebootSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Create reboot record table error message: %s\n", errMsg);
+            log_info( "Create reboot record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened reboot record table successfully\n");
+            log_info( "Opened reboot record table successfully");
         }
         }
         //-----
         //-----
 
 
@@ -126,24 +126,24 @@ int DB_Insert_Record(int gunIndex)
     //if (sqlite3_open("/Storage/ChargeLog/localCgargingRecord.db", &db)) {
     //if (sqlite3_open("/Storage/ChargeLog/localCgargingRecord.db", &db)) {
     if (sqlite3_open(DB_FILE, &localDb)) { //DS60-120 add
     if (sqlite3_open(DB_FILE, &localDb)) { //DS60-120 add
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\r\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local charging record database open successfully.\r\n");
+        log_info( "Local charging record database open successfully.");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Insert local charging record error message: %s\n", errMsg);
+            log_info( "Insert local charging record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Insert local charging record successfully\n");
+            log_info( "Insert local charging record successfully");
         }
         }
 
 
         //DS60-120 add
         //DS60-120 add
         sprintf(insertSql, "delete from charging_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
         sprintf(insertSql, "delete from charging_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "delete local charging error message: %s\n", errMsg);
+            log_info( "delete local charging error message: %s", errMsg);
         } else {
         } else {
-            log_info( "delete local charging record successfully\n");
+            log_info( "delete local charging record successfully");
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);
@@ -161,22 +161,22 @@ int DB_Update_Operactive(uint8_t gunIndex, uint8_t IsAvailable)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\r\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local charging record database open successfully (%d).\r\n", IsAvailable);
+        log_info( "Local charging record database open successfully (%d).", IsAvailable);
 
 
         //sprintf(sqlStr, "insert or replace into config (IsAvailable, connector, val) values('IsAvailable', %d, %d);", gunIndex, IsAvailable);
         //sprintf(sqlStr, "insert or replace into config (IsAvailable, connector, val) values('IsAvailable', %d, %d);", gunIndex, IsAvailable);
         sprintf(sqlStr,
         sprintf(sqlStr,
                 "insert or replace into config (item, connector, val) values('IsAvailable', %d, %d);",
                 "insert or replace into config (item, connector, val) values('IsAvailable', %d, %d);",
                 gunIndex,
                 gunIndex,
                 IsAvailable); //DS60-120 add
                 IsAvailable); //DS60-120 add
-        log_info("sqlStr= %s\r\n", sqlStr);
+        log_info("sqlStr= %s", sqlStr);
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "update config error message: %s\n", errMsg);
+            log_info( "update config error message: %s", errMsg);
         } else {
         } else {
-            log_info("update connector-%d config item isOperactive to %d\r\n", gunIndex, IsAvailable);
+            log_info("update connector-%d config item isOperactive to %d", gunIndex, IsAvailable);
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);
@@ -195,24 +195,24 @@ int DB_Get_Operactive(uint8_t gunIndex)
 
 
     //sprintf(sqlStr, "select * from config where IsAvailable='IsAvailable' and connector=%d;", gunIndex);
     //sprintf(sqlStr, "select * from config where IsAvailable='IsAvailable' and connector=%d;", gunIndex);
     sprintf(sqlStr, "select * from config where item='IsAvailable' and connector=%d;", gunIndex); //DS60-120 add
     sprintf(sqlStr, "select * from config where item='IsAvailable' and connector=%d;", gunIndex); //DS60-120 add
-    //DEBUG_INFO("sqlStr= %s\r\n", sqlStr);
+    //DEBUG_INFO("sqlStr= %s", sqlStr);
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\r\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local config query database open successfully.\r\n");
+        log_info( "Local config query database open successfully.");
         sqlite3_get_table(localDb, sqlStr, &rs, &rows, &cols, &errMsg);
         sqlite3_get_table(localDb, sqlStr, &rs, &rows, &cols, &errMsg);
         if (rows > 0) {
         if (rows > 0) {
             for (int idxRow = 1; idxRow <= rows; idxRow++) {
             for (int idxRow = 1; idxRow <= rows; idxRow++) {
                 if (strcmp(rs[(idxRow * cols) + 3], "0") == 0) {
                 if (strcmp(rs[(idxRow * cols) + 3], "0") == 0) {
                     result = false;
                     result = false;
                 }
                 }
-                log_info("Query connector-%d isOperactive: %s\r\n", gunIndex, rs[(idxRow * cols) + 3]);
+                log_info("Query connector-%d isOperactive: %s", gunIndex, rs[(idxRow * cols) + 3]);
             }
             }
         } else {
         } else {
-            log_info("Query connector-%d fail, set default value to operactive.\r\n", gunIndex);
+            log_info("Query connector-%d fail, set default value to operactive.", gunIndex);
         }
         }
 
 
         sqlite3_free_table(rs);
         sqlite3_free_table(rs);
@@ -232,23 +232,23 @@ int DB_Reboot_Record(void)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local charging record database open successfully.\n");
+        log_info( "Local charging record database open successfully.");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Insert reboot record error message: %s\n", errMsg);
+            log_info( "Insert reboot record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Insert reboot record successfully\n");
+            log_info( "Insert reboot record successfully");
         }
         }
 
 
         sprintf(insertSql, "delete from reboot_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
         sprintf(insertSql, "delete from reboot_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "delete reboot record error message: %s\n", errMsg);
+            log_info( "delete reboot record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "delete reboot record successfully\n");
+            log_info( "delete reboot record successfully");
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);
@@ -272,16 +272,16 @@ int CreateEventRecord(void)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_error( "Can't open database: %s\n", sqlite3_errmsg(localDb));
+        log_error( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local event record database open successfully.\n");
+        log_info( "Local event record database open successfully.");
 
 
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_error( "Create local event record table error message: %s\n", errMsg);
+            log_error( "Create local event record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local event record table successfully\n");
+            log_info( "Opened local event record table successfully");
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);
@@ -300,23 +300,23 @@ int InsertEventRecord(uint8_t *statusCode)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local event record database open successfully.\n");
+        log_info( "Local event record database open successfully.");
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Insert local event record error message: %s\n", errMsg);
+            log_info( "Insert local event record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Insert local event record successfully\n");
+            log_info( "Insert local event record successfully");
         }
         }
 
 
         sprintf(sqlStr, "delete from event_record where idx < (select idx from event_record order by idx desc limit 1)-2000;");
         sprintf(sqlStr, "delete from event_record where idx < (select idx from event_record order by idx desc limit 1)-2000;");
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "delete local event_record error message: %s\n", errMsg);
+            log_info( "delete local event_record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "delete local event record successfully\n");
+            log_info( "delete local event record successfully");
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);

+ 3 - 1
EVSE/Projects/DD360Audi/Apps/Define/define.h

@@ -501,6 +501,8 @@ struct SysConfigData
 	unsigned char 			AcConnectorCount;			// For DC type
 	unsigned char 			AcConnectorCount;			// For DC type
 	unsigned char			SwitchDebugFlag;			// Console Debug
 	unsigned char			SwitchDebugFlag;			// Console Debug
 	unsigned char			AlwaysGfdFlag;
 	unsigned char			AlwaysGfdFlag;
+	unsigned char                   AutoAuth_Disable;           //for Auto Authorize, 0:Disable Auto Authorize 1:Auto Authorize
+	unsigned char                   EVCCID_Authorize;           //for EVCCID Authorize enable/disable
 	/**************Charging***************/
 	/**************Charging***************/
 	unsigned short			MaxChargingEnergy;			//0: no limit,	1 ~ 65535	kWh
 	unsigned short			MaxChargingEnergy;			//0: no limit,	1 ~ 65535	kWh
 	unsigned short			MaxChargingPower;			//0: rating value, 1 ~ RATING_POWER	kW
 	unsigned short			MaxChargingPower;			//0: rating value, 1 ~ RATING_POWER	kW
@@ -638,7 +640,7 @@ struct ChargingInfoData
     struct timespec     ConnectorTimeout;
     struct timespec     ConnectorTimeout;
     unsigned char       PantographFlag;                 // 0: normal gun type,  1: pantograph gun type
     unsigned char       PantographFlag;                 // 0: normal gun type,  1: pantograph gun type
 	unsigned char 		Replug_flag;
 	unsigned char 		Replug_flag;
-    unsigned char       isVerify;
+    unsigned char       isEVCCIDVerify;
 };
 };
 
 
 typedef union
 typedef union

+ 1 - 1
EVSE/Projects/DD360Audi/Apps/Log/log.c

@@ -44,7 +44,7 @@ int StoreLogMsg(const char *fmt, ...)
                 tm->tm_sec,
                 tm->tm_sec,
                 SeqEndTime.millitm,
                 SeqEndTime.millitm,
                 buffer);
                 buffer);
-        printf("%s\r\n", Buf);
+        printf("%s", Buf);
     } else {
     } else {
         sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
         sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
                 tm->tm_year + 1900,
                 tm->tm_year + 1900,

+ 1 - 1
EVSE/Projects/DD360Audi/Apps/Makefile

@@ -73,7 +73,7 @@ COMMON_OBJ_FILES = common.o \
 
 
 MAIN_OBJ_FILES = $(COMMON_OBJ_FILES) $(DataBaseLib)/DataBase.o \
 MAIN_OBJ_FILES = $(COMMON_OBJ_FILES) $(DataBaseLib)/DataBase.o \
 					$(CSULib)/main.o  $(CSULib)/Primary.o $(CSULib)/WatchDog.o $(CSULib)/ZipFile.o \
 					$(CSULib)/main.o  $(CSULib)/Primary.o $(CSULib)/WatchDog.o $(CSULib)/ZipFile.o \
-					$(CSULib)/RFID.o $(CSULib)/SelfTest.o $(CSULib)/UpgradeFW.o \
+					$(CSULib)/RFID.o $(CSULib)/SelfTest.o \
 					$(CSULib)/Ethernet.o 
 					$(CSULib)/Ethernet.o 
 					
 					
 MAIN_SRC_FILES = $(patsubst %.o, %.c, $(MAIN_OBJ_FILES))
 MAIN_SRC_FILES = $(patsubst %.o, %.c, $(MAIN_OBJ_FILES))

+ 35 - 26
EVSE/Projects/DD360Audi/Apps/ModuleChkSysTask/Module_ChkSysTask.c

@@ -78,10 +78,15 @@ unsigned char CheckSystemTask(unsigned char systemPage)
 	unsigned char count_produceComm	= GetProcessCount("Module_ProduceUtils");
 	unsigned char count_produceComm	= GetProcessCount("Module_ProduceUtils");
 	unsigned char count_updateFW	= GetProcessCount("Module_UpdateFW");
 	unsigned char count_updateFW	= GetProcessCount("Module_UpdateFW");
 
 
-//	if (systemPage == 0x09 || systemPage == 0x0A)
+	//if (systemPage != _LCM_FIX )
 	{
 	{
 		if (count_main < _SYSTEM_TASK_COUNT_MAIN )
 		if (count_main < _SYSTEM_TASK_COUNT_MAIN )
 		{
 		{
+            ///*
+            system("/usr/bin/fuser -k /dev/watchdog");
+            sleep(1);
+            system("echo V > /dev/watchdog");
+            system("killall main");
 			system("killall Module_EventLogging");
 			system("killall Module_EventLogging");
 			system("killall Module_PrimaryComm");
 			system("killall Module_PrimaryComm");
 			system("killall Module_EvComm");
 			system("killall Module_EvComm");
@@ -90,60 +95,65 @@ unsigned char CheckSystemTask(unsigned char systemPage)
 			system("killall Module_DoComm");
 			system("killall Module_DoComm");
 			system("killall Module_ProduceUtils");
 			system("killall Module_ProduceUtils");
 			system("killall Module_UpdateFW");
 			system("killall Module_UpdateFW");
-			system("pkill main");
-            sleep(1);
             system("echo V > /dev/watchdog");
             system("echo V > /dev/watchdog");
-			system("/usr/bin/run_evse_restart.sh");
-            sleep(10);
+            sleep(3);
+            system("/root/main &");
+            sleep(20);
+            //*/
+            /*
+            log_info("System task lost (CSU). \n");
+            sleep(3);
+            system("reboot -f");
+            */
 		}
 		}
 		else
 		else
 		{
 		{
 			if (count_evComm < _SYSTEM_TASK_COUNT_EVCOMM )
 			if (count_evComm < _SYSTEM_TASK_COUNT_EVCOMM )
 			{
 			{
 				system("killall Module_EvComm");
 				system("killall Module_EvComm");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_EvComm &");
 				system("/root/Module_EvComm &");
 			}
 			}
         	if (count_interComm < _SYSTEM_TASK_COUNT_INTERNALCOMM )
         	if (count_interComm < _SYSTEM_TASK_COUNT_INTERNALCOMM )
 			{
 			{
 				system("killall Module_InternalComm");
 				system("killall Module_InternalComm");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_InternalComm &");
 				system("/root/Module_InternalComm &");
 			}
 			}
 			if (count_eventComm < _SYSTEM_TASK_COUNT_EVENTLOGGING )
 			if (count_eventComm < _SYSTEM_TASK_COUNT_EVENTLOGGING )
 			{
 			{
 				system("killall Module_EventLogging");
 				system("killall Module_EventLogging");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_EventLogging &");
 				system("/root/Module_EventLogging &");
 			}
 			}
 			if (count_primaryComm < _SYSTEM_TASK_COUNT_PRIMARYCOMM )
 			if (count_primaryComm < _SYSTEM_TASK_COUNT_PRIMARYCOMM )
 			{
 			{
 				system("killall Module_PrimaryComm");
 				system("killall Module_PrimaryComm");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_PrimaryComm &");
 				system("/root/Module_PrimaryComm &");
 			}
 			}
 			if (count_lcmComm < _SYSTEM_TASK_COUNT_LCM )
 			if (count_lcmComm < _SYSTEM_TASK_COUNT_LCM )
 			{
 			{
 				system("killall Module_LcmControl");
 				system("killall Module_LcmControl");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_LcmControl &");
 				system("/root/Module_LcmControl &");
 			}
 			}
 			if (count_doComm < _SYSTEM_TASK_COUNT_DOCOMM )
 			if (count_doComm < _SYSTEM_TASK_COUNT_DOCOMM )
 			{
 			{
 				system("killall Module_DoComm");
 				system("killall Module_DoComm");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_DoComm &");
 				system("/root/Module_DoComm &");
 			}
 			}
 			if (count_produceComm < _SYSTEM_TASK_COUNT_PRODUCEUTILS )
 			if (count_produceComm < _SYSTEM_TASK_COUNT_PRODUCEUTILS )
 			{
 			{
 				system("killall Module_ProduceUtils");
 				system("killall Module_ProduceUtils");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_ProduceUtils &");
 				system("/root/Module_ProduceUtils &");
 			}
 			}
 			if (count_updateFW < _SYSTEM_TASK_COUNT_UPDATEFW )
 			if (count_updateFW < _SYSTEM_TASK_COUNT_UPDATEFW )
 			{
 			{
 				system("killall Module_UpdateFW");
 				system("killall Module_UpdateFW");
-				sleep(1);
+				sleep(3);
 				system("/root/Module_UpdateFW &");
 				system("/root/Module_UpdateFW &");
 			}
 			}
 		}
 		}
@@ -182,28 +192,28 @@ void CheckSystemTaskAlive()
 {
 {
     unsigned char lostId = CheckSystemTask(ShmSysConfigAndInfo->SysInfo.SystemPage);
     unsigned char lostId = CheckSystemTask(ShmSysConfigAndInfo->SysInfo.SystemPage);
     if (lostId != 0) {
     if (lostId != 0) {
-        log_info("Check task(%d) lost\n",lostId);
+        log_error("Check task(%d) lost\n",lostId);
         if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemTaskLost == NO) {
         if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemTaskLost == NO) {
            if (lostId == _SYSTEM_TASK_LOST_ITEM_MAIN)
            if (lostId == _SYSTEM_TASK_LOST_ITEM_MAIN)
-               log_info("System task lost (CSU). \n");
+               log_error("System task lost (CSU). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_EVCOMM)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_EVCOMM)
-               log_info("System task lost (EVComm). \n");
+               log_error("System task lost (EVComm). \n");
 //           else if (lostId == _SYSTEM_TASK_LOST_ITEM_PSUCOMM)
 //           else if (lostId == _SYSTEM_TASK_LOST_ITEM_PSUCOMM)
 //               PRINTF_FUNC("System task lost (PSU Task). \n");
 //               PRINTF_FUNC("System task lost (PSU Task). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_EVENTLOG)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_EVENTLOG)
-               log_info("System task lost (Event log). \n");
+               log_error("System task lost (Event log). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_PRIMARYCOMM)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_PRIMARYCOMM)
-               log_info("System task lost (Primary). \n");
+               log_error("System task lost (Primary). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_LCMCONTROL)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_LCMCONTROL)
-               log_info("System task lost (LCM Comm). \n");
+               log_error("System task lost (LCM Comm). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_INTERCOMM)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_INTERCOMM)
-               log_info("System task lost (Internal Comm). \n");
+               log_error("System task lost (Internal Comm). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_DOCOMM)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_DOCOMM)
-               log_info("System task lost (Do Comm). \n");
+               log_error("System task lost (Do Comm). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS)
-               log_info("System task lost (ProcductUtils Comm). \n");
+               log_error("System task lost (ProcductUtils Comm). \n");
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_UPDATEFW)
            else if (lostId == _SYSTEM_TASK_LOST_ITEM_UPDATEFW)
-               log_info("System task lost (Update FW) \n");
+               log_error("System task lost (Update FW) \n");
            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemTaskLost = YES;
            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemTaskLost = YES;
         }
         }
     } else
     } else
@@ -214,8 +224,8 @@ void CheckSystemTaskAlive()
 void main(void)
 void main(void)
 {
 {
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
-        return FAIL;
+        log_error("create share memory error");
+        return ;
     }
     }
 
 
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
@@ -224,7 +234,6 @@ void main(void)
     ShmSysConfigAndInfo = (struct SysConfigAndInfo *)GetShmSysConfigAndInfo();
     ShmSysConfigAndInfo = (struct SysConfigAndInfo *)GetShmSysConfigAndInfo();
     ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();	
     ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();	
     MappingGunChargingInfo("CheckSystem Task");
     MappingGunChargingInfo("CheckSystem Task");
-    sleep(20);
     while(true)
     while(true)
     {
     {
       	for (uint8_t gun = 0; gun < pSysConfig->TotalConnectorCount; gun++) {
       	for (uint8_t gun = 0; gun < pSysConfig->TotalConnectorCount; gun++) {

+ 14 - 3
EVSE/Projects/DD360Audi/Apps/ModuleChkSysTask/Module_ChkSysTask.h

@@ -46,7 +46,8 @@
 #define _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS 8
 #define _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS 8
 #define _SYSTEM_TASK_LOST_ITEM_UPDATEFW     9
 #define _SYSTEM_TASK_LOST_ITEM_UPDATEFW     9
 
 
-#define _SYSTEM_TASK_COUNT_MAIN             4 
+///*
+#define _SYSTEM_TASK_COUNT_MAIN             5 
 #define _SYSTEM_TASK_COUNT_EVCOMM           2
 #define _SYSTEM_TASK_COUNT_EVCOMM           2
 #define _SYSTEM_TASK_COUNT_INTERNALCOMM     2
 #define _SYSTEM_TASK_COUNT_INTERNALCOMM     2
 #define _SYSTEM_TASK_COUNT_EVENTLOGGING     1
 #define _SYSTEM_TASK_COUNT_EVENTLOGGING     1
@@ -55,8 +56,18 @@
 #define _SYSTEM_TASK_COUNT_DOCOMM           1
 #define _SYSTEM_TASK_COUNT_DOCOMM           1
 #define _SYSTEM_TASK_COUNT_PRODUCEUTILS     1
 #define _SYSTEM_TASK_COUNT_PRODUCEUTILS     1
 #define _SYSTEM_TASK_COUNT_UPDATEFW         1
 #define _SYSTEM_TASK_COUNT_UPDATEFW         1
-
-
+//*/
+/*
+#define _SYSTEM_TASK_COUNT_MAIN             3 
+#define _SYSTEM_TASK_COUNT_EVCOMM           0
+#define _SYSTEM_TASK_COUNT_INTERNALCOMM     0
+#define _SYSTEM_TASK_COUNT_EVENTLOGGING     0
+#define _SYSTEM_TASK_COUNT_PRIMARYCOMM      0
+#define _SYSTEM_TASK_COUNT_LCM              0
+#define _SYSTEM_TASK_COUNT_DOCOMM           0
+#define _SYSTEM_TASK_COUNT_PRODUCEUTILS     0
+#define _SYSTEM_TASK_COUNT_UPDATEFW         0
+*/
 unsigned char CheckSystemTask(unsigned char systemPage);
 unsigned char CheckSystemTask(unsigned char systemPage);
 
 
 #endif /* CHECKSYSTEMTASK_H_ */
 #endif /* CHECKSYSTEMTASK_H_ */

+ 101 - 109
EVSE/Projects/DD360Audi/Apps/ModuleDoComm/DoComm.c

@@ -29,11 +29,6 @@
 #include "../timeout.h"
 #include "../timeout.h"
 #include "DoComm.h"
 #include "DoComm.h"
 
 
-//------------------------------------------------------------------------------
-//#define log_info(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-//#define log_warn(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-//#define log_error(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
-
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 static DoCommGblData gDoCommGblData             = {0};
 static DoCommGblData gDoCommGblData             = {0};
 
 
@@ -52,6 +47,9 @@ static struct ChargingInfoData *pDcChargingInfo = NULL;
 static struct timeb             gRegTimeUp[2][MAX_REGISTER_NUM] = {0};
 static struct timeb             gRegTimeUp[2][MAX_REGISTER_NUM] = {0};
 static struct WARNING_CODE_INFO gPreSysWarningInfo = {0};
 static struct WARNING_CODE_INFO gPreSysWarningInfo = {0};
 
 
+// Hexdump
+char old_Hexdump[10240];
+
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 static void removeFaultCodeToBuf(uint8_t *Code);
 static void removeFaultCodeToBuf(uint8_t *Code);
 static void addFaultCodeToBuf(uint8_t *Code);
 static void addFaultCodeToBuf(uint8_t *Code);
@@ -67,39 +65,6 @@ void GetClockTime(struct timespec *_now_time, void *null)
     clock_gettime(CLOCK_MONOTONIC, _now_time);
     clock_gettime(CLOCK_MONOTONIC, _now_time);
 }
 }
 
 
-/*static 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 == 1) {
-        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",
-                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;
-}
-*/
-
 static int DiffTimeb(struct timeb ST, struct timeb ET)
 static int DiffTimeb(struct timeb ST, struct timeb ET)
 {
 {
     //return milli-second
     //return milli-second
@@ -127,8 +92,8 @@ static void Hexdump(const void *p, size_t size)
 
 
     assert(p);
     assert(p);
 
 
-    //printf("Dumping %u bytes from %p:\r\n", size, p);
-    message_len += sprintf(&message[message_len], "\r\nDumping %u bytes from %p:\r\n",  (unsigned int)size, p);
+    //printf("Dumping %u bytes from %p:\n", size, p);
+    message_len += sprintf(&message[message_len], "\nDumping %u bytes from %p:\n",  (unsigned int)size, p);
 
 
     while (size > 0) {
     while (size > 0) {
         for (i = 0; i < 16; i++) {
         for (i = 0; i < 16; i++) {
@@ -152,7 +117,7 @@ static void Hexdump(const void *p, size_t size)
         }
         }
 
 
         //printf("\n");
         //printf("\n");
-        message_len += sprintf(&message[message_len], "\r\n");
+        message_len += sprintf(&message[message_len], "\n");
         c += 16;
         c += 16;
 
 
         if (size <= 16) {
         if (size <= 16) {
@@ -162,9 +127,11 @@ static void Hexdump(const void *p, size_t size)
         size -= 16;
         size -= 16;
     }
     }
 
 
-    message_len += sprintf(&message[message_len], "\r\n");
-
-    log_info("%s", message);
+    //message_len += sprintf(&message[message_len], "\n");
+    if( strcmp(old_Hexdump,message) != EQUAL ) {
+        log_info("%s", message);
+        strcpy(old_Hexdump,message);
+    }
 }
 }
 
 
 static int string2ByteArray(char *input, uint8_t *output)
 static int string2ByteArray(char *input, uint8_t *output)
@@ -182,7 +149,7 @@ static int string2ByteArray(char *input, uint8_t *output)
 
 
 static void unixSocketSigPipeHandle(int sig)
 static void unixSocketSigPipeHandle(int sig)
 {
 {
-    log_error("socket packet error %x\r\n", sig);
+    log_error("socket packet error %x", sig);
 }
 }
 
 
 static void InitSocketSigPipe(void)
 static void InitSocketSigPipe(void)
@@ -211,7 +178,7 @@ static int sendTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
     size = send(fd, data, dataLen , 0);
     size = send(fd, data, dataLen , 0);
     if ((size < 0) || (errno == EAGAIN)) {
     if ((size < 0) || (errno == EAGAIN)) {
         if (size < 0) {
         if (size < 0) {
-            log_error("Size = %d, EAGAIN error %d:%s\r\n", size, errno, strerror(errno));
+            log_error("Send Socket Size = %d, EAGAIN error %d:%s", size, errno, strerror(errno));
         }
         }
     }
     }
 
 
@@ -225,7 +192,7 @@ static int recvTcpSocket(int fd, uint8_t *data, uint16_t dataLen)
 
 
     size = recv(fd, pdata, dataLen, MSG_WAITALL);
     size = recv(fd, pdata, dataLen, MSG_WAITALL);
     if ((errno == EAGAIN) || (size < 0)) {
     if ((errno == EAGAIN) || (size < 0)) {
-        log_error("Size = %d, EAGAIN error %d:%s\r\n", size, errno, strerror(errno));
+        log_error("Receive Socket Size = %d, EAGAIN error %d:%s", size, errno, strerror(errno));
     }
     }
 
 
     return size;
     return size;
@@ -237,7 +204,7 @@ static int getSO_ERROR(int fd)
     socklen_t len = sizeof err;
     socklen_t len = sizeof err;
 
 
     if (-1 == getsockopt(fd, SOL_SOCKET, SO_ERROR, (char *)&err, &len)) {
     if (-1 == getsockopt(fd, SOL_SOCKET, SO_ERROR, (char *)&err, &len)) {
-        log_error("getSO_ERROR\r\n");
+        log_error("getSO_ERROR");
     }
     }
 
 
     if (err) {
     if (err) {
@@ -256,12 +223,12 @@ static void closeSocket(int fd)        // *not* the Windows closesocket()
     getSO_ERROR(fd); // first clear any errors, which can cause close to fail
     getSO_ERROR(fd); // first clear any errors, which can cause close to fail
     if (shutdown(fd, SHUT_RDWR) < 0) { // secondly, terminate the 'reliable' delivery
     if (shutdown(fd, SHUT_RDWR) < 0) { // secondly, terminate the 'reliable' delivery
         if (errno != ENOTCONN && errno != EINVAL) { // SGI causes EINVAL
         if (errno != ENOTCONN && errno != EINVAL) { // SGI causes EINVAL
-            log_info("shutdown\r\n");
+            log_info("shutdown");
         }
         }
     }
     }
 
 
     if (close(fd) < 0) { // finally call close()
     if (close(fd) < 0) { // finally call close()
-        log_info("client socket close\r\n");
+        log_info("client socket close");
     }
     }
 }
 }
 
 
@@ -400,10 +367,10 @@ static void setConfirmSelGun(uint8_t selGun)
 {
 {
     if (selGun == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_RELEASE) {
     if (selGun == LEFT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_RELEASE) {
         ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
         ShmSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
-        //printf("confirmSelGun left\r\n");
+        //printf("confirmSelGun left");
     } else if (selGun == RIGHT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_RELEASE) {
     } else if (selGun == RIGHT_GUN_NUM && ShmSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_RELEASE) {
         ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
         ShmSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
-        //printf("confirmSelGun right\r\n");
+        //printf("confirmSelGun right");
     }
     }
 }
 }
 
 
@@ -413,7 +380,7 @@ static void setConfirmSelGun(uint8_t selGun)
 static int compareOpcode(uint8_t opCode)
 static int compareOpcode(uint8_t opCode)
 {
 {
     if (opCode != OP_WAIT_RESPONSE) {
     if (opCode != OP_WAIT_RESPONSE) {
-        //log_error("response operative code fail\r\n");
+        //log_error("response operative code fail");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -423,7 +390,7 @@ static int compareOpcode(uint8_t opCode)
 static int compareResult(uint8_t result)
 static int compareResult(uint8_t result)
 {
 {
     if (result != COMMAND_RESULT_OK) {
     if (result != COMMAND_RESULT_OK) {
-        //log_error("response result fail\r\n");
+        //log_error("response result fail");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -433,7 +400,7 @@ static int compareResult(uint8_t result)
 static int compareRegister(uint8_t srcReg, uint8_t destReg)
 static int compareRegister(uint8_t srcReg, uint8_t destReg)
 {
 {
     if (srcReg != destReg) {
     if (srcReg != destReg) {
-        //log_error("response register fail\r\n");
+        //log_error("response register fail");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -442,7 +409,7 @@ static int compareRegister(uint8_t srcReg, uint8_t destReg)
 
 
 static float transPricesUnit(int prices)
 static float transPricesUnit(int prices)
 {
 {
-    //printf("prices = %.2f\r\n", prices * PRICES_UNIT);
+    //printf("prices = %.2f", prices * PRICES_UNIT);
     return (prices * PRICES_UNIT);
     return (prices * PRICES_UNIT);
 }
 }
 
 
@@ -461,7 +428,7 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     struct tm *tm;
     struct tm *tm;
 
 
     if ((char *)&data[0] == '\0') {
     if ((char *)&data[0] == '\0') {
-        log_error("QR code date error\r\n");
+        log_error("QR code date error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -479,14 +446,14 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     //copy QR code string
     //copy QR code string
     if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
     if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
         memset(pSysConfig->SystemId, '\0', sizeof(pSysConfig->SystemId));
         memset(pSysConfig->SystemId, '\0', sizeof(pSysConfig->SystemId));
-        //printf("data =  %s\r\n", data);
+        //printf("data =  %s", data);
         //len =
         //len =
         string2ByteArray((char *)data, (uint8_t *)pSysConfig->SystemId);
         string2ByteArray((char *)data, (uint8_t *)pSysConfig->SystemId);
-        //printf("SystemId =  %s\r\n", pSysConfig->SystemId);
+        //printf("SystemId =  %s", pSysConfig->SystemId);
     }
     }
 
 
     //if ((char *)&data[len] == '\0') {
     //if ((char *)&data[len] == '\0') {
-    //    log_error("power cabinet system date error\r\n");
+    //    log_error("power cabinet system date error");
     //    return FAIL;
     //    return FAIL;
     //}
     //}
 
 
@@ -494,7 +461,7 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     //if (strncmp((char *)localTime, (char *)&data[len], timeLen) != 0) {
     //if (strncmp((char *)localTime, (char *)&data[len], timeLen) != 0) {
     //    sprintf(cmdBuf, "date -s \"%s\" >> /dev/null", (char *)&data[len]);
     //    sprintf(cmdBuf, "date -s \"%s\" >> /dev/null", (char *)&data[len]);
     //    system(cmdBuf);
     //    system(cmdBuf);
-    //    log_info("local time = %s, data time = %s\r\n", localTime, (char *)&data[len]);
+    //    log_info("local time = %s, data time = %s", localTime, (char *)&data[len]);
     //    ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
     //    ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
     //    strcpy((char *)ShmOCPP16Data->Reset.Type, "Soft");
     //    strcpy((char *)ShmOCPP16Data->Reset.Type, "Soft");
     //    sleep(3);
     //    sleep(3);
@@ -510,12 +477,12 @@ static int updateFirmwareHandle(uint8_t *imgName)
     char cmdBuf[1024] = {0};
     char cmdBuf[1024] = {0};
 
 
     sprintf(cmdBuf, "/mnt/%s", imgName);
     sprintf(cmdBuf, "/mnt/%s", imgName);
-    log_info("Program ready to check file %s\n", cmdBuf);
+    log_info("Program ready to check file %s", cmdBuf);
     if ( access(cmdBuf, F_OK) != -1) {
     if ( access(cmdBuf, F_OK) != -1) {
-        log_info("File '%s' exist.\n", cmdBuf);
+        log_info("File '%s' exist.", cmdBuf);
         pSysInfo->FirmwareUpdate = YES;
         pSysInfo->FirmwareUpdate = YES;
     } else {
     } else {
-        log_info("File '%s' doesn't exist.\n", cmdBuf);
+        log_info("File '%s' doesn't exist.", cmdBuf);
         ret = FAIL;
         ret = FAIL;
     }
     }
 
 
@@ -535,17 +502,17 @@ static int updateFirmwareHandle(uint8_t *imgName)
     if (-1 == status) {
     if (-1 == status) {
         printf("system error!");
         printf("system error!");
     } else {
     } else {
-        printf("exit status value = [0x%x]\n", status);
+        printf("exit status value = [0x%x]", status);
 
 
         if (WIFEXITED(status)) {
         if (WIFEXITED(status)) {
             if (0 == WEXITSTATUS(status)) {
             if (0 == WEXITSTATUS(status)) {
-                printf("run shell script successfully.\n");
+                printf("run shell script successfully.");
                 pSysInfo->FirmwareUpdate = YES;
                 pSysInfo->FirmwareUpdate = YES;
             } else {
             } else {
-                printf("run shell script fail, script exit code: %d\n", WEXITSTATUS(status));
+                printf("run shell script fail, script exit code: %d", WEXITSTATUS(status));
             }
             }
         } else {
         } else {
-            printf("exit status = [%d]\n", WEXITSTATUS(status));
+            printf("exit status = [%d]", WEXITSTATUS(status));
         }
         }
     }
     }
 
 
@@ -567,7 +534,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
 
 
     if (cmdCount < 1) {
     if (cmdCount < 1) {
         gDoCommGblData.MiscCmd = 0;
         gDoCommGblData.MiscCmd = 0;
-        //printf("cmdCount fail = %d, data len = %d\r\n", cmdCount, dataLen);
+        //printf("cmdCount fail = %d, data len = %d", cmdCount, dataLen);
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -575,13 +542,13 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
         pMiscCmd = (MiscCommand *)data + i;
         pMiscCmd = (MiscCommand *)data + i;
         cmd = ntohs(pMiscCmd->CMD);
         cmd = ntohs(pMiscCmd->CMD);
         value = ntohl(*((uint32_t *)&pMiscCmd->Value[0]));
         value = ntohl(*((uint32_t *)&pMiscCmd->Value[0]));
-        //log_info("misc command = %x, value = %d\r\n", cmd, value);
+        //log_info("misc command = %x, value = %d", cmd, value);
 
 
         switch (cmd) {
         switch (cmd) {
         //--- Execute parameter ---
         //--- Execute parameter ---
         case MISC_CMD_CONNECOTOR_TIMEOUT:
         case MISC_CMD_CONNECOTOR_TIMEOUT:
             ShmSelectGunInfo->RemoteSetup.ConnectionTimeout = value;
             ShmSelectGunInfo->RemoteSetup.ConnectionTimeout = value;
-            log_info("connection timeout = %d\r\n", ShmSelectGunInfo->RemoteSetup.ConnectionTimeout);
+            log_info("connection timeout = %d", ShmSelectGunInfo->RemoteSetup.ConnectionTimeout);
             clearMiscCommand();
             clearMiscCommand();
             break;
             break;
 
 
@@ -593,7 +560,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 break;
                 break;
             }
             }
 
 
-            log_info("change availability plugNum = %d, value = %d\r\n", plugNum, value);
+            log_info("change availability plugNum = %d, value = %d", plugNum, value);
             ShmOCPP16Data->CsMsg.bits[plugNum].ChangeAvailabilityReq = YES;
             ShmOCPP16Data->CsMsg.bits[plugNum].ChangeAvailabilityReq = YES;
             if (value == YES) {
             if (value == YES) {
                 strcpy((char *)ShmOCPP16Data->ChangeAvailability[plugNum].Type, "Operative");
                 strcpy((char *)ShmOCPP16Data->ChangeAvailability[plugNum].Type, "Operative");
@@ -608,7 +575,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
 
 
         case MISC_CMD_DEFAULT_PRICES:
         case MISC_CMD_DEFAULT_PRICES:
             prices = transPricesUnit((int)value);
             prices = transPricesUnit((int)value);
-            log_info("default prices = %.2f\r\n", prices);
+            log_info("default prices = %.2f", prices);
 
 
             //pSysConfig->BillingData.isBilling = YES;
             //pSysConfig->BillingData.isBilling = YES;
             for (j = 0; j < 24; j++) {
             for (j = 0; j < 24; j++) {
@@ -624,8 +591,8 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 return FAIL;
                 return FAIL;
             }
             }
 
 
-            //log_info("default currency = %s%c\r\n", (uint8_t *)Currency[value]);
-            log_info("default currency = %s\r\n", (uint8_t *)GetCurrency(value));
+            //log_info("default currency = %s%c", (uint8_t *)Currency[value]);
+            log_info("default currency = %s", (uint8_t *)GetCurrency(value));
             pSysConfig->BillingData.Currency = value;
             pSysConfig->BillingData.Currency = value;
             clearMiscCommand();
             clearMiscCommand();
             break;
             break;
@@ -638,13 +605,13 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
 
 
 #if defined DD360Audi
 #if defined DD360Audi
             if (getConfirmSelectedGun(plugNum) == FAIL) {
             if (getConfirmSelectedGun(plugNum) == FAIL) {
-                log_info("Remote start not select gun\r\n");
+                log_info("Remote start not select gun");
                 break;
                 break;
             }
             }
 #endif //DD360Audi
 #endif //DD360Audi
 
 
             ShmSelectGunInfo->PricesInfo[plugNum].Balance = transPricesUnit((int)value);
             ShmSelectGunInfo->PricesInfo[plugNum].Balance = transPricesUnit((int)value);
-            log_info("%d misc balance = %.2f\r\n", plugNum, ShmSelectGunInfo->PricesInfo[plugNum].Balance);
+            log_info("%d misc balance = %.2f", plugNum, ShmSelectGunInfo->PricesInfo[plugNum].Balance);
             clearMiscCommand();
             clearMiscCommand();
             break;
             break;
 
 
@@ -679,7 +646,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 break;
                 break;
             }
             }
 
 
-            log_info("Hardware reboot\r\n");
+            log_info("Hardware reboot");
             ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
             ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
             strcpy((char *)ShmOCPP16Data->Reset.Type, "Hard");
             strcpy((char *)ShmOCPP16Data->Reset.Type, "Hard");
             clearMiscCommand();
             clearMiscCommand();
@@ -692,7 +659,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
             }
             }
 
 
             clearMiscCommand();
             clearMiscCommand();
-            log_info("Software reboot\r\n");
+            log_info("Software reboot");
             ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
             ShmOCPP16Data->MsMsg.bits.ResetReq = YES;
             strcpy((char *)ShmOCPP16Data->Reset.Type, "Soft");
             strcpy((char *)ShmOCPP16Data->Reset.Type, "Soft");
             break;
             break;
@@ -704,11 +671,11 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 }
                 }
                 break;
                 break;
             }
             }
-            log_info("Remote start charging plugNum = %d\r\n", plugNum);
+            log_info("Remote start charging plugNum = %d", plugNum);
 
 
 #if defined DD360Audi
 #if defined DD360Audi
             if (getSelGunWaitToAuthor(plugNum) == FAIL) {
             if (getSelGunWaitToAuthor(plugNum) == FAIL) {
-                log_error("Remote start gun already charging\r\n");
+                log_error("Remote start gun already charging");
                 break;
                 break;
             }
             }
 
 
@@ -791,6 +758,16 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t plugNum, uint8_t *data)
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
             }
             }
             break;
             break;
+        case MISC_CMD_AUTH_DISABLE:
+            pSysConfig->AutoAuth_Disable = value;
+            log_info("Auto Authorize Disable:%d", pSysConfig->AutoAuth_Disable);
+            //clearMiscCommand();
+        	break;
+        case MISC_CMD_EVCCID_ENABLE:
+            pSysConfig->EVCCID_Authorize = value;
+            log_info("Authorize By EVCCID:%d",pSysConfig->EVCCID_Authorize);
+            //clearMiscCommand();
+        	break;
 
 
         default:
         default:
             clearMiscCommand();
             clearMiscCommand();
@@ -840,7 +817,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
     //MaxVolt = (float)(data[0] << 8 |data[1]);
     //MaxVolt = (float)(data[0] << 8 |data[1]);
     //MaxCurrent = (float)(data[2] << 8 | data[3]);
     //MaxCurrent = (float)(data[2] << 8 | data[3]);
     //MaxPower = (float)(data[4] << 8 | data[5]);
     //MaxPower = (float)(data[4] << 8 | data[5]);
-    //printf("MaxVolt=%f, MaxCurrent=%f, MaxPower=%f,\n", MaxVolt, MaxCurrent, MaxPower);
+    //printf("MaxVolt=%f, MaxCurrent=%f, MaxPower=%f,", MaxVolt, MaxCurrent, MaxPower);
 
 
     //--- user prices information ----------------------------------------------
     //--- user prices information ----------------------------------------------
     addr = (sizeof(CapabilityInfo) - 2); //2 byte reserved
     addr = (sizeof(CapabilityInfo) - 2); //2 byte reserved
@@ -856,7 +833,7 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t plugNum)
         pricesInfo[plugNum].UserPrices = ShmSelectGunInfo->PricesInfo[plugNum].UserPrices;
         pricesInfo[plugNum].UserPrices = ShmSelectGunInfo->PricesInfo[plugNum].UserPrices;
         pricesInfo[plugNum].Balance = ShmSelectGunInfo->PricesInfo[plugNum].Balance;
         pricesInfo[plugNum].Balance = ShmSelectGunInfo->PricesInfo[plugNum].Balance;
 
 
-        log_info("id = %d, user prices = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s\r\n",
+        log_info("id = %d, user prices = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s",
                  plugNum,
                  plugNum,
                  ShmSelectGunInfo->PricesInfo[plugNum].UserPrices,
                  ShmSelectGunInfo->PricesInfo[plugNum].UserPrices,
                  pDcChargingInfo->ChargingFee,
                  pDcChargingInfo->ChargingFee,
@@ -940,12 +917,12 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
         remaindLen = dataLen % WARNING_CODE_SIZE;
         remaindLen = dataLen % WARNING_CODE_SIZE;
 
 
         if (remaindLen != 0) {
         if (remaindLen != 0) {
-            log_info("fail status code length =  %d\r\n", dataLen);
+            log_info("fail status code length =  %d", dataLen);
             dataLen -= remaindLen;
             dataLen -= remaindLen;
         }
         }
 
 
         if (dataLen < WARNING_CODE_SIZE) {
         if (dataLen < WARNING_CODE_SIZE) {
-            log_error("fail status code length = %d\r\n", dataLen);
+            log_error("fail status code length = %d", dataLen);
             Hexdump(data, dataLen);
             Hexdump(data, dataLen);
             if (pSysWarning->WarningCount > 0) {
             if (pSysWarning->WarningCount > 0) {
                 for (i = 0; i < pSysWarning->WarningCount; i++) {
                 for (i = 0; i < pSysWarning->WarningCount; i++) {
@@ -991,7 +968,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
             if (CompareArrayIsZero((uint8_t *)&data[count], WARNING_CODE_SIZE) == true) {
             if (CompareArrayIsZero((uint8_t *)&data[count], WARNING_CODE_SIZE) == true) {
                 memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
                 memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
                 memcpy(EventCodeTmp, (char *)&data[count], sizeof(EventCodeTmp));
                 memcpy(EventCodeTmp, (char *)&data[count], sizeof(EventCodeTmp));
-                log_error("error status = %s\r\n", EventCodeTmp);
+                log_error("error status = %s", EventCodeTmp);
                 continue;
                 continue;
             }
             }
 
 
@@ -1015,7 +992,7 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
         }
         }
     } else {
     } else {
         if (CompareArrayIsZero(data, WARNING_CODE_SIZE) == false) {
         if (CompareArrayIsZero(data, WARNING_CODE_SIZE) == false) {
-            log_error("power cabinet status code data length is zero, but have data\r\n");
+            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);
         }
         }
     }
     }
@@ -1077,7 +1054,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
     case REG_CONNECTOR_ID:
     case REG_CONNECTOR_ID:
         gDoCommGblData.ConnectorID[0] = pCsuResult->Data.Data[0];
         gDoCommGblData.ConnectorID[0] = pCsuResult->Data.Data[0];
         gDoCommGblData.ConnectorID[1] = pCsuResult->Data.Data[1];
         gDoCommGblData.ConnectorID[1] = pCsuResult->Data.Data[1];
-        log_info("OK (Left connector ID = %d, Right connector ID = %d)\n",
+        log_info("OK (Left connector ID = %d, Right connector ID = %d)",
                  pCsuResult->Data.Data[0],
                  pCsuResult->Data.Data[0],
                  pCsuResult->Data.Data[1]);
                  pCsuResult->Data.Data[1]);
         break;
         break;
@@ -1121,7 +1098,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
         break;
         break;
 
 
     case REG_USER_ID:
     case REG_USER_ID:
-        //log_info("%s\n", pCsuResult->Data.Data[0] == 1 ? "Accept" : "Reject" );
+        //log_info("%s", pCsuResult->Data.Data[0] == 1 ? "Accept" : "Reject" );
         //if (pCsuResult->Data.Data[0] <= 0) {
         //if (pCsuResult->Data.Data[0] <= 0) {
         //    return FAIL;
         //    return FAIL;
         //}
         //}
@@ -1135,7 +1112,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
         break;
         break;
 
 
     case REG_CHARGING_PERMISSION:
     case REG_CHARGING_PERMISSION:
-        //log_info("id = %d, result = %s, action = %s\r\n",
+        //log_info("id = %d, result = %s, action = %s",
         //           pCsuResult->Head.ID,
         //           pCsuResult->Head.ID,
         //           pCsuResult->Data.Result == 1 ? "OK" : "NG",
         //           pCsuResult->Data.Result == 1 ? "OK" : "NG",
         //           pCsuResult->Data.Data[0] == 1 ? "Permitted" : "NOT permitted");
         //           pCsuResult->Data.Data[0] == 1 ? "Permitted" : "NOT permitted");
@@ -1160,7 +1137,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
 
 
         ShmDcCommonData->PcPsuOutput[plugNum].Voltage = ntohs((uint16_t)pPcPsuOutput->Voltage);
         ShmDcCommonData->PcPsuOutput[plugNum].Voltage = ntohs((uint16_t)pPcPsuOutput->Voltage);
         ShmDcCommonData->PcPsuOutput[plugNum].Current = ntohs((uint16_t)pPcPsuOutput->Current);
         ShmDcCommonData->PcPsuOutput[plugNum].Current = ntohs((uint16_t)pPcPsuOutput->Current);
-        //log_info("%d power cabinet PSU output vol = %f, cur = %f\r\n",
+        //log_info("%d power cabinet PSU output vol = %f, cur = %f",
         //         plugNum,
         //         plugNum,
         //         (float)ShmDcCommonData->PcPsuOutput[plugNum].Voltage,
         //         (float)ShmDcCommonData->PcPsuOutput[plugNum].Voltage,
         //         (float)ShmDcCommonData->PcPsuOutput[plugNum].Current);
         //         (float)ShmDcCommonData->PcPsuOutput[plugNum].Current);
@@ -1185,7 +1162,7 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t plugNum, uint8_
             GroundFaultDetection *gfd = (GroundFaultDetection *)&pCsuResult->Data.Data[0];
             GroundFaultDetection *gfd = (GroundFaultDetection *)&pCsuResult->Data.Data[0];
             if(pDcChargingInfo->GroundFaultStatus != gfd->Status)
             if(pDcChargingInfo->GroundFaultStatus != gfd->Status)
             {
             {
-                log_info("id = %d, GFD Result = %d\r\n",
+                log_info("id = %d, GFD Result = %d",
                            pCsuResult->Head.ID,
                            pCsuResult->Head.ID,
                            gfd->Status);
                            gfd->Status);
             }
             }
@@ -1231,21 +1208,21 @@ static int composeSocketData(int fd,
 
 
     //send command packet
     //send command packet
     if ((size = sendTcpSocket(fd, (uint8_t *)&csuCmdPkt, sendPktLen)) < 0) {
     if ((size = sendTcpSocket(fd, (uint8_t *)&csuCmdPkt, sendPktLen)) < 0) {
-        log_error("TCP socket send packet fail = %d\r\n", size);
+        log_error("TCP socket send packet fail = %d", size);
         gDoCommGblData.DisConnCount++;
         gDoCommGblData.DisConnCount++;
         return FAIL;
         return FAIL;
     }
     }
 
 
     //receive result head
     //receive result head
     if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Head, sizeof(csuResult.Head))) < 0) {
     if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Head, sizeof(csuResult.Head))) < 0) {
-        log_error("TCP socket RX head fail = %d\r\n", size);
+        log_error("TCP socket RX head fail = %d", size);
         gDoCommGblData.DisConnCount++;
         gDoCommGblData.DisConnCount++;
         return FAIL;
         return FAIL;
     }
     }
 
 
     //receive result raw data
     //receive result raw data
     if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Data, csuResult.Head.DataLen)) < 0) {
     if ((size = recvTcpSocket(fd, (uint8_t *)&csuResult.Data, csuResult.Head.DataLen)) < 0) {
-        log_error("TCP socket RX data fail = %d\r\n", size);
+        log_error("TCP socket RX data fail = %d", size);
         gDoCommGblData.DisConnCount++;
         gDoCommGblData.DisConnCount++;
         return FAIL;
         return FAIL;
     }
     }
@@ -1269,7 +1246,7 @@ static int writeWaitPlugItState(int fd, uint8_t id)
     int ret = PASS;
     int ret = PASS;
     uint8_t data[2] = {pSysInfo->WaitForPlugit, 0};
     uint8_t data[2] = {pSysInfo->WaitForPlugit, 0};
 
 
-    //printf("WaitForPlugit = %d\r\n", pSysInfo->WaitForPlugit);
+    //printf("WaitForPlugit = %d", pSysInfo->WaitForPlugit);
 
 
     if ((ret = composeSocketData(fd,
     if ((ret = composeSocketData(fd,
                                  id,
                                  id,
@@ -1468,7 +1445,7 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
                     (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
                     (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
                     WARNING_CODE_SIZE);
                     WARNING_CODE_SIZE);
             vendorErrorCodeTmp[plugNum][6] = '\0';
             vendorErrorCodeTmp[plugNum][6] = '\0';
-            log_info("1 ID = %d, VendorErrorCode = %s\r\n",
+            log_info("1 ID = %d, VendorErrorCode = %s",
                      plugNum,
                      plugNum,
                      (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
                      (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
         } else {
         } else {
@@ -1480,7 +1457,7 @@ static int writeConnectorState(int fd, uint8_t plugNum, uint8_t id)
                         (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
                         (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode,
                         WARNING_CODE_SIZE);
                         WARNING_CODE_SIZE);
                 vendorErrorCodeTmp[plugNum][6] = '\0';
                 vendorErrorCodeTmp[plugNum][6] = '\0';
-                log_info("2 ID = %d, VendorErrorCode = %s\r\n",
+                log_info("2 ID = %d, VendorErrorCode = %s",
                          plugNum,
                          plugNum,
                          (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
                          (char *)ShmOCPP16Data->StatusNotification[plugNum].VendorErrorCode);
             }
             }
@@ -1755,7 +1732,7 @@ static void checkAuthorProcess(int fd, uint8_t plugNum)
                     strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted");
                     strcpy((char *)ShmOCPP16Data->Authorize.ResponseIdTagInfo.Status, "Accepted");
                 }
                 }
 
 
-                //printf("%d Balance = %.2f, %.2f\r\n",
+                //printf("%d Balance = %.2f, %.2f\n",
                 //       plugNum,
                 //       plugNum,
                 //       ShmSelectGunInfo->PricesInfo[plugNum].Balance,
                 //       ShmSelectGunInfo->PricesInfo[plugNum].Balance,
                 //       FAIL_BALANCE_PRICES);
                 //       FAIL_BALANCE_PRICES);
@@ -1866,7 +1843,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
             //check misc command from power cabinet
             //check misc command from power cabinet
             if (gDoCommGblData.MiscCmd != 0) {
             if (gDoCommGblData.MiscCmd != 0) {
                 if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
                 if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
-                    log_error("misc command failed = %x\r\n", gDoCommGblData.MiscCmd);
+                    log_error("misc command failed = %x", gDoCommGblData.MiscCmd);
                 }
                 }
                 curReg = gDoCommGblData.MiscCmd;
                 curReg = gDoCommGblData.MiscCmd;
             } else {
             } else {
@@ -1931,7 +1908,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         //    break;
         //    break;
 
 
         default:
         default:
-            log_error("error curReg = %x\r\n", curReg);
+            log_error("error curReg = %x", curReg);
             gDoCommGblData.MiscCmd = 0;
             gDoCommGblData.MiscCmd = 0;
             gDoCommGblData.DisConnCount = CHECK_NETWORK_FAIL_COUNT;
             gDoCommGblData.DisConnCount = CHECK_NETWORK_FAIL_COUNT;
             isContinue = 0;
             isContinue = 0;
@@ -1981,7 +1958,15 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
             writeWaitPlugItState(fd, gunID);
             writeWaitPlugItState(fd, gunID);
             ftime(&gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE]);
             ftime(&gRegTimeUp[plugNum][REG_WAIT_PLUG_IT_STATE]);
         }
         }
-
+        /*
+        ftime(&AuthNowTime);
+        if (DiffTimeb(gRegTimeUp[plugNum][REG_MISC_CONTROL], AuthNowTime) > (LOOP_RETRY_TIME / 10) ||
+                DiffTimeb(gRegTimeUp[plugNum][REG_MISC_CONTROL], AuthNowTime) < 0
+           ) {
+            readMiscCommand(fd, gunID);
+            ftime(&gRegTimeUp[plugNum][REG_MISC_CONTROL]);
+        }
+        */
         ftime(&AuthNowTime);
         ftime(&AuthNowTime);
         if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
         if (DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) > LOOP_RETRY_TIME ||
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) < 0
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_CAP], AuthNowTime) < 0
@@ -2042,7 +2027,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
            ) {
            ) {
             if (readChargePermission(fd, gunID) == 0) {
             if (readChargePermission(fd, gunID) == 0) {
-                log_info("S_PREPARING_FOR_EV Stop charging by power cabinet's permission = %d, %d\r\n",
+                log_info("S_PREPARING_FOR_EV Stop charging by power cabinet's permission = %d, %d",
                          plugNum,
                          plugNum,
                          REG_CHARGING_PERMISSION);
                          REG_CHARGING_PERMISSION);
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
@@ -2081,7 +2066,7 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
            ) {
            ) {
             if (readChargePermission(fd, gunID) == 0) {
             if (readChargePermission(fd, gunID) == 0) {
-                log_info("S_PREPARING_FOR_EVSE Stop charging by power cabinet's permission = %d, %d\r\n",
+                log_info("S_PREPARING_FOR_EVSE Stop charging by power cabinet's permission = %d, %d",
                          plugNum,
                          plugNum,
                          REG_CHARGING_PERMISSION);
                          REG_CHARGING_PERMISSION);
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
@@ -2124,11 +2109,11 @@ static void systemStatusProcess(int fd, uint8_t totalGun, uint8_t plugNum, uint8
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
                 DiffTimeb(gRegTimeUp[plugNum][REG_CHARGING_PERMISSION], AuthNowTime) < 0
            ) {
            ) {
             if (readChargePermission(fd, gunID) == 0) {
             if (readChargePermission(fd, gunID) == 0) {
-                log_info("Stop charging by power cabinet's permission = %d, %d\r\n",
+                log_info("Stop charging by power cabinet's permission = %d, %d",
                          plugNum,
                          plugNum,
                          REG_CHARGING_PERMISSION);
                          REG_CHARGING_PERMISSION);
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
                 pDcChargingInfo->StopChargeFlag = POWER_CABINET_STOP_CHARGING;
-                //printf("%d StopChargeFlag = %d\r\n", plugNum, pDcChargingInfo->StopChargeFlag);
+                //printf("%d StopChargeFlag = %d\n", plugNum, pDcChargingInfo->StopChargeFlag);
             }
             }
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
             ftime(&gRegTimeUp[plugNum][REG_CHARGING_PERMISSION]);
         }
         }
@@ -2178,7 +2163,7 @@ static int networkCreatePorcess(void)
 
 
     while (!CheckNetworkStatus()) {
     while (!CheckNetworkStatus()) {
         calDisconnectCount(&gDoCommGblData.DisConnCount, CHECK_NETWORK_FAIL_COUNT);
         calDisconnectCount(&gDoCommGblData.DisConnCount, CHECK_NETWORK_FAIL_COUNT);
-        log_error("disconnect count = % d\r\n", gDoCommGblData.DisConnCount);
+        log_error("disconnect count = % d", gDoCommGblData.DisConnCount);
     }
     }
     log_info("Dispenser Network Information checked: IP = % s Netmask = % s, Gateway = % s",
     log_info("Dispenser Network Information checked: IP = % s Netmask = % s, Gateway = % s",
              pSysConfig->Eth0Interface.EthIpAddress,
              pSysConfig->Eth0Interface.EthIpAddress,
@@ -2191,7 +2176,7 @@ static int networkCreatePorcess(void)
     log_info("Connect to Power Cabinet");
     log_info("Connect to Power Cabinet");
     while ((fd = doCommConnToServer()) <= 0) {
     while ((fd = doCommConnToServer()) <= 0) {
         calDisconnectCount(&gDoCommGblData.DisConnCount, CONNECT_SERVER_FAIL_COUNT);
         calDisconnectCount(&gDoCommGblData.DisConnCount, CONNECT_SERVER_FAIL_COUNT);
-        log_error("disconnect count = %d, fd = %d\r\n", gDoCommGblData.DisConnCount, fd);
+        log_error("disconnect count = %d, fd = %d", gDoCommGblData.DisConnCount, fd);
     }
     }
     log_info("Power cabinet connected(fd = % d): IP = % s Netmask = % s, Gateway = % s",
     log_info("Power cabinet connected(fd = % d): IP = % s Netmask = % s, Gateway = % s",
              fd,
              fd,
@@ -2223,7 +2208,7 @@ int main(int argc, char *argv[])
 
 
     /**************** Initialization **********/
     /**************** Initialization **********/
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -2280,6 +2265,13 @@ int main(int argc, char *argv[])
                 if (initDone == DISPENSER_SOCKET_RECONN) {
                 if (initDone == DISPENSER_SOCKET_RECONN) {
                     break;
                     break;
                 }
                 }
+                initDone = messageTrigger(fd,
+                                          plugNum,
+                                          gunID,
+                                          REG_MISC_CONTROL);
+                if (initDone == DISPENSER_SOCKET_RECONN) {
+                    break;
+                }
             }
             }
         }
         }
 
 

+ 2 - 0
EVSE/Projects/DD360Audi/Apps/ModuleDoComm/DoComm.h

@@ -109,6 +109,8 @@
 #define MISC_CMD_4G_STATUS                      (0x0009)
 #define MISC_CMD_4G_STATUS                      (0x0009)
 #define MISC_CMD_BILLING_INFO                   (0x000A)
 #define MISC_CMD_BILLING_INFO                   (0x000A)
 #define MISC_CMD_WEB_STOP_CHARGING              (0x000B)
 #define MISC_CMD_WEB_STOP_CHARGING              (0x000B)
+#define MISC_CMD_AUTH_DISABLE					(0x000C)
+#define MISC_CMD_EVCCID_ENABLE					(0x000D)
 
 
 #define MISC_CMD_HARDWARE_REBOOT                (0x0101)
 #define MISC_CMD_HARDWARE_REBOOT                (0x0101)
 #define MISC_CMD_SOFTWARE_RESTART               (0x0102)
 #define MISC_CMD_SOFTWARE_RESTART               (0x0102)

+ 86 - 42
EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvRxComm.c

@@ -28,6 +28,13 @@ static struct CcsData *ShmCcsData = NULL;
 static struct FanModuleData *ShmFanModuleData = NULL;
 static struct FanModuleData *ShmFanModuleData = NULL;
 static DcCommonInfo *ShmDcCommonData = NULL;
 static DcCommonInfo *ShmDcCommonData = NULL;
 
 
+#define TempArraySize 10
+uint8_t TempArray_1[TempArraySize]={0};
+uint8_t TempArray_2[TempArraySize]={0};
+uint8_t ptemp_1 = 0;
+uint8_t ptemp_2 = 0;
+bool firstcircule = true;
+
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 extern bool AbnormalStopAnalysis(uint8_t gun_index, uint8_t *errCode);
 extern bool AbnormalStopAnalysis(uint8_t gun_index, uint8_t *errCode);
 
 
@@ -66,6 +73,43 @@ extern bool AbnormalStopAnalysis(uint8_t gun_index, uint8_t *errCode);
     return maxTemp;
     return maxTemp;
 }
 }
 */
 */
+static uint8_t getAvageTemp(uint8_t value,uint8_t gun)
+{
+    uint16_t avagetemp = 0;
+    int i;
+    uint8_t ptr = 0;
+    uint8_t *pArray; 
+    if(gun == 0) { 
+        pArray = &TempArray_1;
+        ptr = ptemp_1;
+    } else {
+        pArray = &TempArray_2;
+        ptr = ptemp_2;
+    }
+
+    pArray[ptr] = value;
+    for(i=0;i<TempArraySize;i++) 
+        avagetemp+=pArray[i];
+
+    if (firstcircule) {
+        avagetemp/=(ptr+1);
+    } else {
+        avagetemp/=TempArraySize;
+    }
+    ptr++;
+    if(ptr >= TempArraySize){
+        ptr = 0;
+        firstcircule = false;
+    }
+    if(gun == 0 )
+        ptemp_1 = ptr;
+    else 
+        ptemp_2 = ptr;
+
+    if(avagetemp > TEMP_BOUNDARY)
+        return UNDEFINED_TEMP;
+    return avagetemp;
+}
 
 
 static uint8_t getMaxConnectTemp(uint8_t headTemp1, uint8_t headTemp2)
 static uint8_t getMaxConnectTemp(uint8_t headTemp1, uint8_t headTemp2)
 {
 {
@@ -85,7 +129,6 @@ static uint8_t getMaxConnectTemp(uint8_t headTemp1, uint8_t headTemp2)
             maxTemp = headTemp2;
             maxTemp = headTemp2;
         }
         }
     }
     }
-
     return maxTemp;
     return maxTemp;
 }
 }
 
 
@@ -163,21 +206,21 @@ static void AddrAssignment(uint8_t *data)
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index - 1);
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index - 1);
     //DS60-120 add
     //DS60-120 add
     if (pDcChargingInfo->Type == _Type_Chademo) {
     if (pDcChargingInfo->Type == _Type_Chademo) {
-        log_info("Set EV board info : (Chademo) TargetAddr = %d \n", index);
+        log_info("Set EV board info : (Chademo) TargetAddr = %d ", index);
     } else if (pDcChargingInfo->Type == _Type_CCS_2) {
     } else if (pDcChargingInfo->Type == _Type_CCS_2) {
-        log_info("Set EV board info : (CCS) TargetAddr = %d \n", index);
+        log_info("Set EV board info : (CCS) TargetAddr = %d ", index);
     } else if (pDcChargingInfo->Type == _Type_GB) {
     } else if (pDcChargingInfo->Type == _Type_GB) {
-        log_info("Set EV board info : (GB) TargetAddr = %d \n", index);
+        log_info("Set EV board info : (GB) TargetAddr = %d ", index);
     }
     }
-    //log_info("EV board id = %x \n", index); //DS60-120 remove
+    //log_info("EV board id = %x ", index); //DS60-120 remove
 
 
-    //log_info("target_number[0] = %x \n", target_number[0]);
-    //log_info("target_number[1] = %x \n", target_number[1]);
-    //log_info("target_number[2] = %x \n", target_number[2]);
-    //log_info("target_number[3] = %x \n", target_number[3]);
-    //log_info("target_number[4] = %x \n", target_number[4]);
+    //log_info("target_number[0] = %x ", target_number[0]);
+    //log_info("target_number[1] = %x ", target_number[1]);
+    //log_info("target_number[2] = %x ", target_number[2]);
+    //log_info("target_number[3] = %x ", target_number[3]);
+    //log_info("target_number[4] = %x ", target_number[4]);
 
 
-    log_info("SetTargetAddr = %d, type = %d \n", index, pDcChargingInfo->Type);
+    log_info("SetTargetAddr = %d, type = %d ", index, pDcChargingInfo->Type);
 
 
     SetTargetAddr(target_number, index);
     SetTargetAddr(target_number, index);
     //}
     //}
@@ -190,7 +233,7 @@ void CANReceiver(int fd)
     canRecPid = fork();
     canRecPid = fork();
 
 
     if (canRecPid < 0) {
     if (canRecPid < 0) {
-        log_error("Create CAN Bus receive task failed\r\n");
+        log_error("Create CAN Bus receive task failed");
         return;
         return;
     }
     }
 
 
@@ -226,7 +269,7 @@ void CANReceiver(int fd)
         ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
         ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
         ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();
         ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();
 
 
-        log_info("Module_EvRXComm Child's PID is %d\r\n", getpid());
+        log_info("Module_EvRXComm Child's PID is %d", getpid());
 
 
         while (isContinue) {
         while (isContinue) {
             memset(&frame, 0, sizeof(struct can_frame));
             memset(&frame, 0, sizeof(struct can_frame));
@@ -267,7 +310,7 @@ void CANReceiver(int fd)
             }
             }
 
 
             if ((targetGun < 0) || (targetGun >= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)) {
             if ((targetGun < 0) || (targetGun >= CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY)) {
-                log_info("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY \n", targetGun);
+                log_info("EvComm (CANReceiver) : Target index = %x is < 0 or > QUANTITY ", targetGun);
                 usleep(10000);
                 usleep(10000);
                 continue;
                 continue;
             }
             }
@@ -291,25 +334,25 @@ void CANReceiver(int fd)
             case NOTIFICATION_EV_STATUS:
             case NOTIFICATION_EV_STATUS:
                 if (pDcChargingInfo->ConnectorPlugIn != frame.data[0]) {
                 if (pDcChargingInfo->ConnectorPlugIn != frame.data[0]) {
                     if (frame.data[0] == PLUG) {
                     if (frame.data[0] == PLUG) {
-                        log_info("Conn %d, Plugin. \n", targetGun);
-                        pDcChargingInfo->isVerify = false;
+                        log_info("Conn %d, Plugin. ", targetGun);
+                        pDcChargingInfo->isEVCCIDVerify = false;
                     } else if (frame.data[0] == UNPLUG) {
                     } else if (frame.data[0] == UNPLUG) {
-                        log_info("Conn %d, Unplug. \n", targetGun);
+                        log_info("Conn %d, Unplug. ", targetGun);
                         strcpy( (char *) pDcChargingInfo->EVCCID, "");
                         strcpy( (char *) pDcChargingInfo->EVCCID, "");
                     } else {
                     } else {
-                        log_info("Conn %d, None Check. (%d) \n", targetGun, frame.data[0]);
+                        log_info("Conn %d, None Check. (%d) ", targetGun, frame.data[0]);
                     }
                     }
                 }
                 }
 
 
                 pDcChargingInfo->ConnectorPlugIn = frame.data[0];
                 pDcChargingInfo->ConnectorPlugIn = frame.data[0];
                 pDcChargingInfo->PilotVoltage = frame.data[1];
                 pDcChargingInfo->PilotVoltage = frame.data[1];
 
 
-                //log_info("index = %d, ConnectorPlugIn = %x, data[0] = %x \n",
+                //log_info("index = %d, ConnectorPlugIn = %x, data[0] = %x ",
                 //         targetGun,
                 //         targetGun,
                 //         pDcChargingInfo->ConnectorPlugIn,
                 //         pDcChargingInfo->ConnectorPlugIn,
                 //         frame.data[0]);
                 //         frame.data[0]);
 
 
-                //log_info("ConnectorPlugIn = %x \n", (-120 + frame.data[1]) / 10);
+                //log_info("ConnectorPlugIn = %x ", (-120 + frame.data[1]) / 10);
                 break;
                 break;
 
 
             case ACK_EV_FW_VERSION:
             case ACK_EV_FW_VERSION:
@@ -318,12 +361,12 @@ void CANReceiver(int fd)
                     memcpy(ver, frame.data, frame.can_dlc);
                     memcpy(ver, frame.data, frame.can_dlc);
                     memcpy(ShmCHAdeMOData->evse[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
                     memcpy(ShmCHAdeMOData->evse[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
                     ShmCHAdeMOData->evse[gunTypeIndex].SelfTest_Comp = PASS;
                     ShmCHAdeMOData->evse[gunTypeIndex].SelfTest_Comp = PASS;
-                    //log_info("chademo ver. : %s\n", ShmCHAdeMOData->evse[gunTypeIndex].version);
+                    log_info("chademo ver. : %s", ShmCHAdeMOData->evse[gunTypeIndex].version);
                 } else if (pDcChargingInfo->Type == _Type_GB) {
                 } else if (pDcChargingInfo->Type == _Type_GB) {
                     memcpy(ver, frame.data, frame.can_dlc);
                     memcpy(ver, frame.data, frame.can_dlc);
                     memcpy(ShmGBTData->evse[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
                     memcpy(ShmGBTData->evse[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
                     ShmGBTData->evse[gunTypeIndex].SelfTest_Comp = PASS;
                     ShmGBTData->evse[gunTypeIndex].SelfTest_Comp = PASS;
-                    //log_info("gbt ver. : %s\n", ShmGBTData->evse[gunTypeIndex].version);
+                    log_info("gbt ver. : %s", ShmGBTData->evse[gunTypeIndex].version);
                 } else if (pDcChargingInfo->Type == _Type_CCS_2) {
                 } else if (pDcChargingInfo->Type == _Type_CCS_2) {
                     if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
                     if (ShmCcsData->CommProtocol == _CCS_COMM_V2GMessage_DIN70121) {
                         memcpy(ver, frame.data, frame.can_dlc); //DS60-120 add
                         memcpy(ver, frame.data, frame.can_dlc); //DS60-120 add
@@ -340,7 +383,7 @@ void CANReceiver(int fd)
 
 
                         memcpy(&ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
                         memcpy(&ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].version, ver, ARRAY_SIZE(ver));
                         ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].SelfTest_Comp = PASS;
                         ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].SelfTest_Comp = PASS;
-                        //log_info("CCS FW = %s \n", ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].version);
+                        log_info("CCS FW = %s ", ShmCcsData->V2GMessage_DIN70121[gunTypeIndex].version);
                     }
                     }
                 }
                 }
 
 
@@ -360,7 +403,7 @@ void CANReceiver(int fd)
                 break;
                 break;
 
 
             case ACK_EV_HW_VERSION:
             case ACK_EV_HW_VERSION:
-                //log_info("Get EV HW = %s \n", frame.data);
+                //log_info("Get EV HW = %s ", frame.data);
                 break;
                 break;
 
 
             case ACK_GET_OUTPUT_REQ:
             case ACK_GET_OUTPUT_REQ:
@@ -385,17 +428,17 @@ void CANReceiver(int fd)
                 if (pDcChargingInfo->EvBatterytargetVoltage > (GetMaxChargingVol(targetGun) * 0.1)) {
                 if (pDcChargingInfo->EvBatterytargetVoltage > (GetMaxChargingVol(targetGun) * 0.1)) {
                     pDcChargingInfo->EvBatterytargetVoltage = (GetMaxChargingVol(targetGun) * 0.1);
                     pDcChargingInfo->EvBatterytargetVoltage = (GetMaxChargingVol(targetGun) * 0.1);
                 }
                 }
-                //printf("id = %d, EvBatterytargetVoltage = %.2f\r\n", targetGun, pDcChargingInfo->EvBatterytargetVoltage);
+                //printf("id = %d, EvBatterytargetVoltage = %.2f", targetGun, pDcChargingInfo->EvBatterytargetVoltage);
 
 
                 //Jerry add set currency limit
                 //Jerry add set currency limit
                 pDcChargingInfo->EvBatterytargetCurrent = (float)((frame.data[5] << 8) + frame.data[4]) / 10;
                 pDcChargingInfo->EvBatterytargetCurrent = (float)((frame.data[5] << 8) + frame.data[4]) / 10;
                 if (pDcChargingInfo->EvBatterytargetCurrent > (GetMaxCharginigCur(targetGun) * 0.1)) {
                 if (pDcChargingInfo->EvBatterytargetCurrent > (GetMaxCharginigCur(targetGun) * 0.1)) {
                     pDcChargingInfo->EvBatterytargetCurrent = (GetMaxCharginigCur(targetGun) * 0.1);
                     pDcChargingInfo->EvBatterytargetCurrent = (GetMaxCharginigCur(targetGun) * 0.1);
                 }
                 }
-                //printf("id = %d, EvBatterytargetCurrent = %.2f\r\n", targetGun, pDcChargingInfo->EvBatterytargetCurrent);
+                //printf("id = %d, EvBatterytargetCurrent = %.2f", targetGun, pDcChargingInfo->EvBatterytargetCurrent);
 
 
                 pDcChargingInfo->RemainChargingDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
                 pDcChargingInfo->RemainChargingDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
-                //printf("RemainChargingDuration = %d\r\n",  pDcChargingInfo->RemainChargingDuration);
+                //printf("RemainChargingDuration = %d",  pDcChargingInfo->RemainChargingDuration);
 
 
                 if (pDcChargingInfo->Type == _Type_Chademo) {
                 if (pDcChargingInfo->Type == _Type_Chademo) {
                     //if (ShmCHAdeMOData->ev[gunTypeIndex].EvDetection != frame.data[0])
                     //if (ShmCHAdeMOData->ev[gunTypeIndex].EvDetection != frame.data[0])
@@ -423,11 +466,11 @@ void CANReceiver(int fd)
                     }
                     }
                 }
                 }
 
 
-                //log_info("EvBatterytargetVoltage = %f \n", pDcChargingInfo->EvBatterytargetVoltage);
-                //log_info("EvBatterytargetCurrent = %f \n", pDcChargingInfo->EvBatterytargetCurrent);
-                //log_info("BatteryVoltage = %d \n",
+                //log_info("EvBatterytargetVoltage = %f ", pDcChargingInfo->EvBatterytargetVoltage);
+                //log_info("EvBatterytargetCurrent = %f ", pDcChargingInfo->EvBatterytargetCurrent);
+                //log_info("BatteryVoltage = %d ",
                 //         ShmCHAdeMOData->ev[_chargingData[target]->type_index].TargetBatteryVoltage);
                 //         ShmCHAdeMOData->ev[_chargingData[target]->type_index].TargetBatteryVoltage);
-                //log_info("CurrentRequest = %d \n",
+                //log_info("CurrentRequest = %d ",
                 //         ShmCHAdeMOData->ev[_chargingData[target]->type_index].ChargingCurrentRequest);
                 //         ShmCHAdeMOData->ev[_chargingData[target]->type_index].ChargingCurrentRequest);
                 break;
                 break;
 
 
@@ -441,9 +484,9 @@ void CANReceiver(int fd)
                     ShmCHAdeMOData->ev[gunTypeIndex].TotalBatteryCapacity = ((uint16_t)frame.data[2] << 8) + (uint16_t)frame.data[1];
                     ShmCHAdeMOData->ev[gunTypeIndex].TotalBatteryCapacity = ((uint16_t)frame.data[2] << 8) + (uint16_t)frame.data[1];
                     ShmCHAdeMOData->ev[gunTypeIndex].MaxiBatteryVoltage = pDcChargingInfo->EvBatteryMaxVoltage;
                     ShmCHAdeMOData->ev[gunTypeIndex].MaxiBatteryVoltage = pDcChargingInfo->EvBatteryMaxVoltage;
 
 
-                    //log_info("EvBatteryMaxVoltage = %f \n", _chargingData[target]->EvBatteryMaxVoltage);
-                    //log_info("TotalBatteryCapacity = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TotalBatteryCapacity);
-                    //log_info("MaxiBatteryVoltage = %d \n", ShmCHAdeMOData->ev[_chargingData[target]->type_index].MaxiBatteryVoltage);
+                    //log_info("EvBatteryMaxVoltage = %f ", _chargingData[target]->EvBatteryMaxVoltage);
+                    //log_info("TotalBatteryCapacity = %d ", ShmCHAdeMOData->ev[_chargingData[target]->type_index].TotalBatteryCapacity);
+                    //log_info("MaxiBatteryVoltage = %d ", ShmCHAdeMOData->ev[_chargingData[target]->type_index].MaxiBatteryVoltage);
                 } else if (pDcChargingInfo->Type == _Type_GB) {
                 } else if (pDcChargingInfo->Type == _Type_GB) {
                     ShmGBTData->ev[gunTypeIndex].TotalBatteryCapacity = ((uint16_t)frame.data[2] << 8) + (uint16_t)frame.data[1];
                     ShmGBTData->ev[gunTypeIndex].TotalBatteryCapacity = ((uint16_t)frame.data[2] << 8) + (uint16_t)frame.data[1];
                     ShmGBTData->ev[gunTypeIndex].MaxiBatteryVoltage = pDcChargingInfo->EvBatteryMaxVoltage;
                     ShmGBTData->ev[gunTypeIndex].MaxiBatteryVoltage = pDcChargingInfo->EvBatteryMaxVoltage;
@@ -506,6 +549,7 @@ void CANReceiver(int fd)
                 //if ((maxConnTemp - 3) >= pDcChargingInfo->ConnectorTemp) {
                 //if ((maxConnTemp - 3) >= pDcChargingInfo->ConnectorTemp) {
                 //    printConnTemp = YES;
                 //    printConnTemp = YES;
                 //}
                 //}
+                maxConnTemp = getAvageTemp(maxConnTemp,targetGun);
                 if(maxConnTemp > (lastConnTemp[targetGun] + 2) || maxConnTemp < (lastConnTemp[targetGun] - 2))
                 if(maxConnTemp > (lastConnTemp[targetGun] + 2) || maxConnTemp < (lastConnTemp[targetGun] - 2))
                 {
                 {
                     lastConnTemp[targetGun] = maxConnTemp;
                     lastConnTemp[targetGun] = maxConnTemp;
@@ -524,7 +568,7 @@ void CANReceiver(int fd)
                         //  (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP)))
                         //  (pDcChargingInfo->ChillerTemp != UNDEFINED_TEMP)))
                    ) {
                    ) {
                     ShmDcCommonData->SystemModeChange[targetGun] = NO;
                     ShmDcCommonData->SystemModeChange[targetGun] = NO;
-                    log_info("Conn %d max head temp = %d, max chiller = %d, max chiller2 = %d\r\n",
+                    log_info("Conn %d max head temp = %d, max chiller = %d, max chiller2 = %d",
                              targetGun,
                              targetGun,
                              maxConnTemp,
                              maxConnTemp,
                              chillerTemp[0],
                              chillerTemp[0],
@@ -558,11 +602,11 @@ void CANReceiver(int fd)
                     //ShmFanModuleData->? = NO; //尚未定義
                     //ShmFanModuleData->? = NO; //尚未定義
                 }
                 }
 
 
-                //log_info("EvboardStatus = %x \n",
+                //log_info("EvboardStatus = %x ",
                 //         ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus);
                 //         ShmCHAdeMOData->evse[gunTypeIndex].EvboardStatus);
-                //log_info("ConnectorPlug locked = %x \n",
+                //log_info("ConnectorPlug locked = %x ",
                 //         frame.data[0]);
                 //         frame.data[0]);
-                //log_info("PilotVoltage = %x \n", (-120 + frame.data[3]) / 10);
+                //log_info("PilotVoltage = %x ", (-120 + frame.data[3]) / 10);
                 break;
                 break;
 
 
             case ACK_EVSE_ISOLATION_STATUS:
             case ACK_EVSE_ISOLATION_STATUS:
@@ -579,7 +623,7 @@ void CANReceiver(int fd)
                         (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
                         (pDcChargingInfo->SystemStatus >= S_CCS_PRECHARGE_ST0 &&
                          pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
                          pDcChargingInfo->SystemStatus <= S_CCS_PRECHARGE_ST1)) {
                     // frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
                     // frame.data[0] : 0x01 => normal stop, 0x02 => ev emergency stop
-                    log_info("(%d) NOTIFICATION_EV_STOP err level = %d-----------------------------\n",
+                    log_info("----------------------------- (%d) NOTIFICATION_EV_STOP err level = %d -----------------------------",
                              targetGun,
                              targetGun,
                              frame.data[0]);
                              frame.data[0]);
                     if (frame.data[0] == 0x02) {
                     if (frame.data[0] == 0x02) {
@@ -596,7 +640,7 @@ void CANReceiver(int fd)
                 break;
                 break;
             case ACK_EVCCID_REQ:
             case ACK_EVCCID_REQ:
 
 
-                        if (frame.can_dlc > 0 && strcmp ( pDcChargingInfo->EVCCID, "" ) == EQUAL)
+                        if (frame.can_dlc > 0 && strcmp ( (char *)pDcChargingInfo->EVCCID, "" ) == EQUAL)
                         {
                         {
                             if (pDcChargingInfo->Type == _Type_CCS_2)
                             if (pDcChargingInfo->Type == _Type_CCS_2)
                             {
                             {
@@ -613,11 +657,11 @@ void CANReceiver(int fd)
                                     frame.data [1], frame.data [2], frame.data [3], frame.data [4], frame.data [5] );
                                     frame.data [1], frame.data [2], frame.data [3], frame.data [4], frame.data [5] );
 
 
                             pDcChargingInfo->EVCCID [17] = '\0';
                             pDcChargingInfo->EVCCID [17] = '\0';
-                            log_info( "******* Gun %d->EVCCID = %s ************* \n", targetGun, pDcChargingInfo->EVCCID );
+                            log_info( "************* Gun %d->EVCCID = %s ************* ", targetGun, pDcChargingInfo->EVCCID );
                         }
                         }
                 break;
                 break;
             default:
             default:
-                log_info("EV board = %d, Ack none defined. intCmd = %d  \n", targetGun, intCmd);
+                log_info("EV board = %d, Ack none defined. intCmd = %d  ", targetGun, intCmd);
                 break;
                 break;
             }//switch
             }//switch
 
 

+ 43 - 26
EVSE/Projects/DD360Audi/Apps/ModuleEvComm/Module_EvTxComm.c

@@ -115,7 +115,7 @@ int InitCanBus(void)
     rxfilter[2].can_mask = 0x00000FFF;
     rxfilter[2].can_mask = 0x00000FFF;
     if (setsockopt(s0, SOL_CAN_RAW, CAN_RAW_FILTER,
     if (setsockopt(s0, SOL_CAN_RAW, CAN_RAW_FILTER,
                    &rxfilter, sizeof(struct can_filter) * 3) < 0) {
                    &rxfilter, sizeof(struct can_filter) * 3) < 0) {
-        log_error("RX setsockopt CAN_RAW_FILTER failed\r\n");
+        log_error("RX setsockopt CAN_RAW_FILTER failed");
     }
     }
 
 
     strcpy(ifr0.ifr_name, "can0");
     strcpy(ifr0.ifr_name, "can0");
@@ -340,7 +340,7 @@ static void SetPresentChargingOutputCap(void)
             maxCur = (pow1 * 1000) / chargingData_1->FireChargingVoltage;
             maxCur = (pow1 * 1000) / chargingData_1->FireChargingVoltage;
 
 
             if (maxCur * 10 <= cur1) {
             if (maxCur * 10 <= cur1) {
-                //log_info("Gun1 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur1);
+                //log_info("Gun1 -> MaxCharging Current = %f, Cap Current = %f ", (maxCur * 10), cur1);
                 cur1 = maxCur * 10;
                 cur1 = maxCur * 10;
             }
             }
         }
         }
@@ -365,7 +365,7 @@ static void SetPresentChargingOutputCap(void)
             maxCur = (pow2 * 1000) / chargingData_2->FireChargingVoltage;
             maxCur = (pow2 * 1000) / chargingData_2->FireChargingVoltage;
 
 
             if (maxCur * 10 <= cur2) {
             if (maxCur * 10 <= cur2) {
-                //log_info("Gun2 -> MaxCharging Current = %f, Cap Current = %f \n", (maxCur * 10), cur2);
+                //log_info("Gun2 -> MaxCharging Current = %f, Cap Current = %f ", (maxCur * 10), cur2);
                 cur2 = maxCur * 10;
                 cur2 = maxCur * 10;
             }
             }
         }
         }
@@ -381,10 +381,10 @@ static void SetPresentChargingOutputCap(void)
             (LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] <= cur2 - 5 ||
             (LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] <= cur2 - 5 ||
              LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] >= cur2 + 5)
              LogInfo[1][EV_LOG_OUTPUT_CAP_CUR] >= cur2 + 5)
        ) {
        ) {
-        //log_info("----------------------------------------------------- \n");
-        log_info("To EV (Real) Power_1 = %.1f, Cur_1 = %.1f, Power_2 = %.1f, Cur_2 = %.1f\r\n",
+        //log_info("----------------------------------------------------- ");
+        log_info("To EV (Real) Power_1 = %.1f, Cur_1 = %.1f, Power_2 = %.1f, Cur_2 = %.1f",
                  pow1 / 10, cur1 / 10, pow2 / 10, cur2 / 10);
                  pow1 / 10, cur1 / 10, pow2 / 10, cur2 / 10);
-        //log_info("----------------------------------------------------- \n");
+        //log_info("----------------------------------------------------- ");
 
 
         LogInfo[0][EV_LOG_OUTPUT_CAP_POW] = pow1;
         LogInfo[0][EV_LOG_OUTPUT_CAP_POW] = pow1;
         LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] = cur1;
         LogInfo[0][EV_LOG_OUTPUT_CAP_CUR] = cur1;
@@ -484,7 +484,7 @@ static void SetPresentChargingOutputFromPcPsu(uint8_t gunCount)
         (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) ||
         (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) ||
         (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
         (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
     ) {
     ) {
-        log_info("G1 -> Output Vol = %.1f, Output Cur = %.1f -- G2 -> Output Vol = %.1f, Output Cur = %.1f\r\n",
+        log_info("G1 -> Output Vol = %.1f, Output Cur = %.1f -- G2 -> Output Vol = %.1f, Output Cur = %.1f",
                  vol1,
                  vol1,
                  cur1 / 10,
                  cur1 / 10,
                  vol2,
                  vol2,
@@ -546,7 +546,7 @@ static void SetPresentChargingOutputPower(void)
             (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) ||
             (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] >= cur2 + CHK_CUR_RANGE) ||
             (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
             (LogInfo[1][EV_LOG_NOW_OUTPUT_CUR] <= cur2 - CHK_CUR_RANGE)
        ) {
        ) {
-        log_info("G1 -> Output Vol(%s) = %.1f, Output Cur = %.1f -- G2 -> Output Vol(%s) = %.1f, Output Cur = %.1f\r\n",
+        log_info("G1 -> Output Vol(%s) = %.1f, Output Cur = %.1f -- G2 -> Output Vol(%s) = %.1f, Output Cur = %.1f",
                  isPsuVol1 == true ? "P" : "R",
                  isPsuVol1 == true ? "P" : "R",
                  vol1 / 10,
                  vol1 / 10,
                  cur1 / 10,
                  cur1 / 10,
@@ -563,7 +563,7 @@ static void SetPresentChargingOutputPower(void)
     //        _outCur_1 != cur1 ||
     //        _outCur_1 != cur1 ||
     //        _outVol_2 != vol2 ||
     //        _outVol_2 != vol2 ||
     //        _outCur_2 != cur2) {
     //        _outCur_2 != cur2) {
-    /*log_info("G1 -> Output Vol = %f, Output Cur = %f -- G2 -> Output Vol = %f, Output Cur = %f \n",
+    /*log_info("G1 -> Output Vol = %f, Output Cur = %f -- G2 -> Output Vol = %f, Output Cur = %f ",
         vol1, cur1, vol2, cur2);
         vol1, cur1, vol2, cur2);
     */
     */
     //    _outVol_1 = vol1; _outCur_1 = cur1; _outVol_2 = vol2; _outCur_2 = cur2;
     //    _outVol_1 = vol1; _outCur_1 = cur1; _outVol_2 = vol2; _outCur_2 = cur2;
@@ -644,7 +644,7 @@ static void FormatVoltageAndCurrent(void)
     RateCurInfo *pRatedCurInfo = NULL;
     RateCurInfo *pRatedCurInfo = NULL;
 
 
     if (RatedCurrentParsing((char *)pSysConfig->ModelName, &parsingRatedCur) != PASS) {
     if (RatedCurrentParsing((char *)pSysConfig->ModelName, &parsingRatedCur) != PASS) {
-        log_error("Parsing rated current failed\r\n");
+        log_error("Parsing rated current failed");
         return;
         return;
     }
     }
 
 
@@ -656,7 +656,7 @@ static void FormatVoltageAndCurrent(void)
         maxChargingVol[gunIndex] = pRatedCurInfo->Voltage;
         maxChargingVol[gunIndex] = pRatedCurInfo->Voltage;
         maxChargingCur[gunIndex] = pRatedCurInfo->Current;
         maxChargingCur[gunIndex] = pRatedCurInfo->Current;
 
 
-        log_info("Conn %d GunType = %d, MaxVol = %f, MaxCur = %f \n",
+        log_info("Conn %d GunType = %d, MaxVol = %f, MaxCur = %f ",
                  gunIndex,
                  gunIndex,
                  pRatedCurInfo->GunType,
                  pRatedCurInfo->GunType,
                  maxChargingVol[gunIndex],
                  maxChargingVol[gunIndex],
@@ -695,7 +695,7 @@ int main(int argc, char *argv[])
     struct timeb nowTime;
     struct timeb nowTime;
 
 
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -743,9 +743,26 @@ int main(int argc, char *argv[])
                         GetFirmwareVersion(gunIndex, pDcChargingInfo->Evboard_id);
                         GetFirmwareVersion(gunIndex, pDcChargingInfo->Evboard_id);
                     }
                     }
                 }
                 }
-
+                /*
+                if (pDcChargingInfo->Type == _Type_Chademo) {
+                    pAlarmCode->AlarmEvents.bits.ChademoboardStestFail = 
+                        (ShmCHAdeMOData->evse[typeIndex].SelfTest_Comp != PASS) ? true : false;
+                    pAlarmCode->AlarmEvents.bits.ChademoModuleCommFail =
+                        ( CanFd < 0 ) ? true : false;
+                } else if (pDcChargingInfo->Type == _Type_GB) {
+                    pAlarmCode->AlarmEvents.bits.GbtboardStestFail = 
+                        (ShmGBTData->evse[typeIndex].SelfTest_Comp != PASS) ? true : false;
+                    pAlarmCode->AlarmEvents.bits.mFail =
+                        ( CanFd < 0 ) ? true : false;
+                } else if (pDcChargingInfo->Type == _Type_CCS_2) {
+                    pAlarmCode->AlarmEvents.bits.CCSboardStestFail = 
+                        (ShmCcsData->V2GMessage_DIN70121[typeIndex].SelfTest_Comp != PASS) ? true : false;
+                    pAlarmCode->AlarmEvents.bits.ChademoModuleCommFail =
+                        ( CanFd < 0 ) ? true : false;
+                        
+                }*/
                 //固定要取得的資訊 : 1.槍鎖狀態, 2."Connector 1" 溫度, 3."Connector 2" 溫度, 4.Pilot Voltage
                 //固定要取得的資訊 : 1.槍鎖狀態, 2."Connector 1" 溫度, 3."Connector 2" 溫度, 4.Pilot Voltage
-                //log_info("GetMiscellaneousInfo. index = %d, Eid = %d \n",
+                //log_info("GetMiscellaneousInfo. index = %d, Eid = %d ",
                 //         gunIndex,
                 //         gunIndex,
                 //         pDcChargingInfo->Evboard_id);
                 //         pDcChargingInfo->Evboard_id);
                 GetMiscellaneousInfo(gunIndex,
                 GetMiscellaneousInfo(gunIndex,
@@ -805,7 +822,7 @@ int main(int argc, char *argv[])
                     // Set Ev board in communication mode
                     // Set Ev board in communication mode
                     // Get EVCCID for authorize when gun plug-in only for CCS
                     // Get EVCCID for authorize when gun plug-in only for CCS
                     if(pDcChargingInfo->Type == _Type_CCS_2 && priorityLow == 5) {
                     if(pDcChargingInfo->Type == _Type_CCS_2 && priorityLow == 5) {
-                       if (pDcChargingInfo->ConnectorPlugIn && strcmp(pDcChargingInfo->EVCCID,"") == EQUAL) {
+                       if (pDcChargingInfo->ConnectorPlugIn && strcmp((char *)pDcChargingInfo->EVCCID,"") == EQUAL) {
                            GetEVCCIDReq(gunIndex,pDcChargingInfo->Evboard_id);
                            GetEVCCIDReq(gunIndex,pDcChargingInfo->Evboard_id);
                            SendCommunicationOnly(gunIndex);
                            SendCommunicationOnly(gunIndex);
                         }
                         }
@@ -866,11 +883,11 @@ int main(int argc, char *argv[])
                 // 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
                 // 開始確認車端是否同意開始充電 : 1.SOC, 2.Target Vol, 3.Target Cur, 4.Charging remaining time
                 GetOutputReq(gunIndex, pDcChargingInfo->Evboard_id);
                 GetOutputReq(gunIndex, pDcChargingInfo->Evboard_id);
 
 
-                //log_info("PresentChargingVoltage = %f \n", pDcChargingInfo->PresentChargingVoltage);
-                //log_info("PresentChargingCurrent = %f \n", pDcChargingInfo->PresentChargingCurrent);
-                //log_info("AvailableChargingPower = %f \n", pDcChargingInfo->AvailableChargingPower);
-                //log_info("AvailableChargingCurrent = %f \n", pDcChargingInfo->AvailableChargingCurrent);
-                //log_info("MaximumChargingVoltage = %f \n", pDcChargingInfo->MaximumChargingVoltage);
+                //log_info("PresentChargingVoltage = %f ", pDcChargingInfo->PresentChargingVoltage);
+                //log_info("PresentChargingCurrent = %f ", pDcChargingInfo->PresentChargingCurrent);
+                //log_info("AvailableChargingPower = %f ", pDcChargingInfo->AvailableChargingPower);
+                //log_info("AvailableChargingCurrent = %f ", pDcChargingInfo->AvailableChargingCurrent);
+                //log_info("MaximumChargingVoltage = %f ", pDcChargingInfo->MaximumChargingVoltage);
 
 
                 // 設定當前輸出
                 // 設定當前輸出
                 SetPresentChargingOutputPower();
                 SetPresentChargingOutputPower();
@@ -890,7 +907,7 @@ int main(int argc, char *argv[])
                         LogInfo[gunIndex][EV_LOG_EVSE_MAX_VOL] = maxVol;
                         LogInfo[gunIndex][EV_LOG_EVSE_MAX_VOL] = maxVol;
                         LogInfo[gunIndex][EV_LOG_EVSE_MAX_CUR] = maxCur;
                         LogInfo[gunIndex][EV_LOG_EVSE_MAX_CUR] = maxCur;
 
 
-                        log_info("To EV_%d Max_Vol = %.1f, Cap_Cur = %.1f, Cap_Pow = %.1f\n",
+                        log_info("To EV_%d Max_Vol = %.1f, Cap_Cur = %.1f, Cap_Pow = %.1f",
                                  gunIndex,
                                  gunIndex,
                                  maxVol / 10,
                                  maxVol / 10,
                                  maxCur / 10,
                                  maxCur / 10,
@@ -933,14 +950,14 @@ int main(int argc, char *argv[])
                 //DS60-120 add
                 //DS60-120 add
                 if (LogInfo[gunIndex][EV_LOG_MAX_BATT_VOL] != pDcChargingInfo->EvBatteryMaxVoltage) {
                 if (LogInfo[gunIndex][EV_LOG_MAX_BATT_VOL] != pDcChargingInfo->EvBatteryMaxVoltage) {
                     LogInfo[gunIndex][EV_LOG_MAX_BATT_VOL] = pDcChargingInfo->EvBatteryMaxVoltage;
                     LogInfo[gunIndex][EV_LOG_MAX_BATT_VOL] = pDcChargingInfo->EvBatteryMaxVoltage;
-                    log_info("index = %d, Ev Maximum Battery Voltage = %f \n",
+                    log_info("index = %d, Ev Maximum Battery Voltage = %f ",
                              gunIndex,
                              gunIndex,
                              pDcChargingInfo->EvBatteryMaxVoltage);
                              pDcChargingInfo->EvBatteryMaxVoltage);
                 }
                 }
 
 
                 if (LogInfo[gunIndex][EV_LOG_SOC] != pDcChargingInfo->EvBatterySoc) {
                 if (LogInfo[gunIndex][EV_LOG_SOC] != pDcChargingInfo->EvBatterySoc) {
                     LogInfo[gunIndex][EV_LOG_SOC] = pDcChargingInfo->EvBatterySoc;
                     LogInfo[gunIndex][EV_LOG_SOC] = pDcChargingInfo->EvBatterySoc;
-                    log_info("index = %d, SOC = %d \n",
+                    log_info("index = %d, SOC = %d ",
                              gunIndex,
                              gunIndex,
                              pDcChargingInfo->EvBatterySoc);
                              pDcChargingInfo->EvBatterySoc);
                 }
                 }
@@ -951,7 +968,7 @@ int main(int argc, char *argv[])
 //                      if (_chargingData[_index]->FireChargingVoltage >= 3500)
 //                      if (_chargingData[_index]->FireChargingVoltage >= 3500)
 //                         pDcChargingInfo->GroundFaultStatus = GFD_PASS;
 //                         pDcChargingInfo->GroundFaultStatus = GFD_PASS;
 
 
-                    //log_info("To EV_%d GFD = %d \n",   _index,pDcChargingInfo->GroundFaultStatus);
+                    //log_info("To EV_%d GFD = %d ",   _index,pDcChargingInfo->GroundFaultStatus);
                     //if(_chargingData[_index]->GroundFaultStatus != GFD_WAIT)
                     //if(_chargingData[_index]->GroundFaultStatus != GFD_WAIT)
                     {
                     {
                         //if ((GetTimeoutValue(_derating_time) / 1000) > 1000)
                         //if ((GetTimeoutValue(_derating_time) / 1000) > 1000)
@@ -969,14 +986,14 @@ int main(int argc, char *argv[])
                             if (((GetTimeoutValue(_chk_ratingPower_timeout[gunIndex]) / 1000) > 12000 &&
                             if (((GetTimeoutValue(_chk_ratingPower_timeout[gunIndex]) / 1000) > 12000 &&
                                     pDcChargingInfo->RealRatingPower > 0) ||
                                     pDcChargingInfo->RealRatingPower > 0) ||
                                     (GetTimeoutValue(_chk_ratingPower_timeout[gunIndex]) / 1000) > 14000) {
                                     (GetTimeoutValue(_chk_ratingPower_timeout[gunIndex]) / 1000) > 14000) {
-                                //log_info("**********EvComm : gunIndex= %d, RealRatingPower = %d \n",
+                                //log_info("**********EvComm : gunIndex= %d, RealRatingPower = %d ",
                                 //            gunIndex,pDcChargingInfo->RealRatingPower);
                                 //            gunIndex,pDcChargingInfo->RealRatingPower);
                                 //gfgResult = GFD_PASS;
                                 //gfgResult = GFD_PASS;
 
 
                                 //DS60-120 add
                                 //DS60-120 add
                                 if (LogInfo[gunIndex][EV_LOG_REAL_CAP_POW] != pDcChargingInfo->RealRatingPower) {
                                 if (LogInfo[gunIndex][EV_LOG_REAL_CAP_POW] != pDcChargingInfo->RealRatingPower) {
                                     LogInfo[gunIndex][EV_LOG_REAL_CAP_POW] = pDcChargingInfo->RealRatingPower;
                                     LogInfo[gunIndex][EV_LOG_REAL_CAP_POW] = pDcChargingInfo->RealRatingPower;
-                                    log_info("Conn %d, RealRatingPower = %d \n",
+                                    log_info("Conn %d, RealRatingPower = %d ",
                                              gunIndex,
                                              gunIndex,
                                              pDcChargingInfo->RealRatingPower);
                                              pDcChargingInfo->RealRatingPower);
 
 

+ 22 - 22
EVSE/Projects/DD360Audi/Apps/ModuleEventLog/Module_EventLogging.c

@@ -75,7 +75,7 @@ int StoreLogMsg(const char *fmt, ...)
     if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES) {
     if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES) {
         sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
         sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
                 tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
                 tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
-        printf("%s \n", Buf);
+        printf("%s ", Buf);
     } else {
     } else {
         sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
         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,
                 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
@@ -236,16 +236,16 @@ int DB_Open(sqlite3 *db) //DS60-120 add
 
 
     if (sqlite3_open(DB_FILE, &db)) {
     if (sqlite3_open(DB_FILE, &db)) {
         result = FAIL;
         result = FAIL;
-        log_error( "Can't open database: %s\n", sqlite3_errmsg(db));
+        log_error( "Can't open database: %s", sqlite3_errmsg(db));
         sqlite3_close(db);
         sqlite3_close(db);
     } else {
     } else {
-        log_info( "Local event record database open successfully.\n");
+        log_info( "Local event record database open successfully.");
 
 
         if (sqlite3_exec(db, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(db, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_error( "Create local event record table error message: %s\n", errMsg);
+            log_error( "Create local event record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local event record table successfully\n");
+            log_info( "Opened local event record table successfully");
         }
         }
 
 
         sqlite3_close(db);
         sqlite3_close(db);
@@ -264,23 +264,23 @@ int DB_Insert_Record(sqlite3 *db, uint8_t *statusCode) //DS60-120 add
 
 
     if (sqlite3_open(DB_FILE, &db)) {
     if (sqlite3_open(DB_FILE, &db)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\n", sqlite3_errmsg(db));
+        log_info( "Can't open database: %s", sqlite3_errmsg(db));
         sqlite3_close(db);
         sqlite3_close(db);
     } else {
     } else {
-        log_info( "Local event record database open successfully.\n");
+        log_info( "Local event record database open successfully.");
         if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Insert local event record error message: %s\n", errMsg);
+            log_info( "Insert local event record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Insert local event record successfully\n");
+            log_info( "Insert local event record successfully");
         }
         }
 
 
         sprintf(sqlStr, "delete from event_record where idx < (select idx from event_record order by idx desc limit 1)-2000;");
         sprintf(sqlStr, "delete from event_record where idx < (select idx from event_record order by idx desc limit 1)-2000;");
         if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(db, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "delete local event_record error message: %s\n", errMsg);
+            log_info( "delete local event_record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "delete local event record successfully\n");
+            log_info( "delete local event record successfully");
         }
         }
 
 
         sqlite3_close(db);
         sqlite3_close(db);
@@ -296,7 +296,7 @@ int main(void)
     uint8_t tmp, EventCodeTmp[7] = {0};
     uint8_t tmp, EventCodeTmp[7] = {0};
 
 
     //if (InitShareMemory() == FAIL) {
     //if (InitShareMemory() == FAIL) {
-    //    log_error("InitShareMemory NG\n");
+    //    log_error("InitShareMemory NG");
     //    if (ShmStatusCodeData != NULL) {
     //    if (ShmStatusCodeData != NULL) {
     //        pAlarmCode->AlarmEvents.bits.FailToCreateShareMemory = 1;
     //        pAlarmCode->AlarmEvents.bits.FailToCreateShareMemory = 1;
     //    }
     //    }
@@ -304,7 +304,7 @@ int main(void)
     //    return 0;
     //    return 0;
     //}
     //}
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -338,16 +338,16 @@ int main(void)
                 memcpy(EventCodeTmp, GetFaultStatusCode(ByteCounter * 8 + BitCounter), sizeof(EventCodeTmp) - 1);
                 memcpy(EventCodeTmp, GetFaultStatusCode(ByteCounter * 8 + BitCounter), sizeof(EventCodeTmp) - 1);
                 if (((tmp >> BitCounter) & 0x01) == 0) { //Recovered
                 if (((tmp >> BitCounter) & 0x01) == 0) { //Recovered
                     //EventCodeTmp[0]=1;
                     //EventCodeTmp[0]=1;
-                    log_info("Recovery Fault Code = %s\n", EventCodeTmp);
+                    log_info("Recovery Fault Code = %s", EventCodeTmp);
                     pFaultCode->PreviousFaultVal[ByteCounter] &= ~(1 << BitCounter);
                     pFaultCode->PreviousFaultVal[ByteCounter] &= ~(1 << BitCounter);
                     RemoveFaultCodeToBuf(EventCodeTmp);
                     RemoveFaultCodeToBuf(EventCodeTmp);
                     EventCodeTmp[0] = '1';//DS60-120 add
                     EventCodeTmp[0] = '1';//DS60-120 add
                 } else {
                 } else {
-                    log_info("Fault Code = %s\n", EventCodeTmp);
+                    log_info("Fault Code = %s", EventCodeTmp);
                     pFaultCode->PreviousFaultVal[ByteCounter] |= (1 << BitCounter);
                     pFaultCode->PreviousFaultVal[ByteCounter] |= (1 << BitCounter);
                     AddFaultCodeToBuf(EventCodeTmp);
                     AddFaultCodeToBuf(EventCodeTmp);
                 }
                 }
-                event_info("%s\n", EventCodeTmp); //DS60-120 add
+                event_info("%s", EventCodeTmp); //DS60-120 add
                 InsertEventRecord(EventCodeTmp); //DS60-120 add
                 InsertEventRecord(EventCodeTmp); //DS60-120 add
             }
             }
         }
         }
@@ -370,16 +370,16 @@ int main(void)
                 memcpy(EventCodeTmp, GetAlarmStatusCode(ByteCounter * 8 + BitCounter), sizeof(EventCodeTmp) - 1);
                 memcpy(EventCodeTmp, GetAlarmStatusCode(ByteCounter * 8 + BitCounter), sizeof(EventCodeTmp) - 1);
                 if (((tmp >> BitCounter) & 0x01) == 0) { //Recovered
                 if (((tmp >> BitCounter) & 0x01) == 0) { //Recovered
                     //EventCodeTmp[0]=1;
                     //EventCodeTmp[0]=1;
-                    log_info("Recovery Alarm Code = %s\n", EventCodeTmp);
+                    log_info("Recovery Alarm Code = %s", EventCodeTmp);
                     pAlarmCode->PreviousAlarmVal[ByteCounter] &= ~(1 << BitCounter);
                     pAlarmCode->PreviousAlarmVal[ByteCounter] &= ~(1 << BitCounter);
                     RemoveFaultCodeToBuf(EventCodeTmp);
                     RemoveFaultCodeToBuf(EventCodeTmp);
                     EventCodeTmp[0] = '1';//DS60-120 add
                     EventCodeTmp[0] = '1';//DS60-120 add
                 } else {
                 } else {
-                    log_info("Alarm Code = %s\n", EventCodeTmp);
+                    log_info("Alarm Code = %s", EventCodeTmp);
                     pAlarmCode->PreviousAlarmVal[ByteCounter] |= (1 << BitCounter);
                     pAlarmCode->PreviousAlarmVal[ByteCounter] |= (1 << BitCounter);
                     AddFaultCodeToBuf(EventCodeTmp);
                     AddFaultCodeToBuf(EventCodeTmp);
                 }
                 }
-                event_info("%s\n", EventCodeTmp); //DS60-120 add
+                event_info("%s", EventCodeTmp); //DS60-120 add
                 InsertEventRecord(EventCodeTmp); //DS60-120 add
                 InsertEventRecord(EventCodeTmp); //DS60-120 add
             }
             }
         }
         }
@@ -402,16 +402,16 @@ int main(void)
                 memcpy(EventCodeTmp, GetInfoStatusCode(ByteCounter * 8 + BitCounter), sizeof(EventCodeTmp) - 1);
                 memcpy(EventCodeTmp, GetInfoStatusCode(ByteCounter * 8 + BitCounter), sizeof(EventCodeTmp) - 1);
                 if (((tmp >> BitCounter) & 0x01) == 0) { //Recovered
                 if (((tmp >> BitCounter) & 0x01) == 0) { //Recovered
                     //EventCodeTmp[0]=1;
                     //EventCodeTmp[0]=1;
-                    log_info("Recovery Info Code = %s\n", EventCodeTmp);
+                    log_info("Recovery Info Code = %s", EventCodeTmp);
                     pInfoCode->PreviousInfoVal[ByteCounter] &= ~(1 << BitCounter);
                     pInfoCode->PreviousInfoVal[ByteCounter] &= ~(1 << BitCounter);
                     RemoveFaultCodeToBuf(EventCodeTmp);
                     RemoveFaultCodeToBuf(EventCodeTmp);
                     EventCodeTmp[0] = '1';//DS60-120 add
                     EventCodeTmp[0] = '1';//DS60-120 add
                 } else {
                 } else {
-                    log_info("Info Code = %s\n", EventCodeTmp);
+                    log_info("Info Code = %s", EventCodeTmp);
                     pInfoCode->PreviousInfoVal[ByteCounter] |= (1 << BitCounter);
                     pInfoCode->PreviousInfoVal[ByteCounter] |= (1 << BitCounter);
                     AddFaultCodeToBuf(EventCodeTmp);
                     AddFaultCodeToBuf(EventCodeTmp);
                 }
                 }
-                event_info("%s\n", EventCodeTmp); //DS60-120 add
+                event_info("%s", EventCodeTmp); //DS60-120 add
                 InsertEventRecord(EventCodeTmp); //DS60-120 add
                 InsertEventRecord(EventCodeTmp); //DS60-120 add
             }
             }
         }
         }

+ 17 - 0
EVSE/Projects/DD360Audi/Apps/ModuleInternalComm/LEDlight.c

@@ -117,6 +117,14 @@ static void SetLedColor(void)
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
+            } else if ( chargingData_1->SystemStatus == S_UPDATE ||
+                    chargingData_2->SystemStatus == S_UPDATE ) {
+                led_color.Connect_1_Green = COLOR_MIN_LV;
+                led_color.Connect_1_Blue = COLOR_MIN_LV;
+                led_color.Connect_1_Red = _colorBuf;
+                led_color.Connect_2_Green = COLOR_MIN_LV;
+                led_color.Connect_2_Blue = COLOR_MIN_LV;
+                led_color.Connect_2_Red = _colorBuf;
             }
             }
         } else {
         } else {
             if (chargingData_1->SystemStatus == S_BOOTING ||
             if (chargingData_1->SystemStatus == S_BOOTING ||
@@ -146,6 +154,10 @@ static void SetLedColor(void)
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Blue = _colorBuf;
                 led_color.Connect_1_Blue = _colorBuf;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
+            } else if ( chargingData_1->SystemStatus == S_UPDATE ) {
+                led_color.Connect_1_Green = COLOR_MIN_LV;
+                led_color.Connect_1_Blue = COLOR_MIN_LV;
+                led_color.Connect_1_Red = _colorBuf;
             }
             }
 
 
             // --------------------------------------------------------------------------
             // --------------------------------------------------------------------------
@@ -175,7 +187,12 @@ static void SetLedColor(void)
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
+            } else if ( chargingData_2->SystemStatus == S_UPDATE ) {
+                led_color.Connect_2_Green = COLOR_MIN_LV;
+                led_color.Connect_2_Blue = COLOR_MIN_LV;
+                led_color.Connect_2_Red = _colorBuf;
             }
             }
+
         }
         }
     }
     }
 
 

+ 3 - 3
EVSE/Projects/DD360Audi/Apps/ModuleInternalComm/Module_InternalComm.c

@@ -53,7 +53,7 @@ static int Init485ComPort(void)
 
 
     fd = open(INTERNAL_COM_PORT, O_RDWR);
     fd = open(INTERNAL_COM_PORT, O_RDWR);
     if (fd <= 0) {
     if (fd <= 0) {
-        log_error("Module_InternalComm. InitComPort NG\r\n");
+        log_error("Module_InternalComm. InitComPort NG");
         sleep(5);
         sleep(5);
         return -1;
         return -1;
     }
     }
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
     struct AlarmCodeData *pAlarmCode = NULL;
     struct AlarmCodeData *pAlarmCode = NULL;
 
 
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -88,7 +88,7 @@ int main(int argc, char *argv[])
     if (fd == FAIL) {
     if (fd == FAIL) {
         pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
         pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
         pAlarmCode->AlarmEvents.bits.CsuInitFailed = YES;
         pAlarmCode->AlarmEvents.bits.CsuInitFailed = YES;
-        log_info("ModuleInternalComTask create port error...\r\n");
+        log_info("ModuleInternalComTask create port error...");
 
 
         return FAIL;
         return FAIL;
     }
     }

+ 83 - 67
EVSE/Projects/DD360Audi/Apps/ModuleInternalComm/RelayBoard.c

@@ -46,6 +46,7 @@ static struct timeval _led_priority_time;
 static bool _isOvpChkTimeFlag[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 static bool _isOvpChkTimeFlag[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 static struct timeval _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 static struct timeval _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY]; //DS60-120 add
 
 
+static void SetLedColor(void);
 static struct timeval _close_ac_contactor;
 static struct timeval _close_ac_contactor;
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
@@ -90,7 +91,7 @@ static void StartCheckRelayInfo(uint8_t _chkIndex, uint8_t toState)
         ShmDcCommonData->CheckRelayStatus[_chkIndex] = START;
         ShmDcCommonData->CheckRelayStatus[_chkIndex] = START;
     } else {
     } else {
         if ((GetTimeoutValue(lastCheckRelayStateTimer[_chkIndex]) / 1000000) >= 1) {
         if ((GetTimeoutValue(lastCheckRelayStateTimer[_chkIndex]) / 1000000) >= 1) {
-            //log_info("relay welding or driving fault = %d \n", _chkIndex);
+            //log_info("relay welding or driving fault = %d ", _chkIndex);
             if (toState == 1) {
             if (toState == 1) {
                 ShmDcCommonData->CheckRelayStatus[_chkIndex] = RELAY_STATUS_ERROR_DRIVING;
                 ShmDcCommonData->CheckRelayStatus[_chkIndex] = RELAY_STATUS_ERROR_DRIVING;
             } else {
             } else {
@@ -160,37 +161,37 @@ static bool IsNoneMatchRelayStatus(void)
 
 
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
     if (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) {
     if (regRelay.relay_event.bits.AC_Contactor != outputRelay.relay_event.bits.AC_Contactor) {
-        log_info("AC Contact Relay none match. \n");
+        log_info("AC Contact Relay none match. ");
     }
     }
 
 
     if (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) {
     if (regRelay.relay_event.bits.CCS_Precharge != outputRelay.relay_event.bits.CCS_Precharge) {
-        log_info("CCS Precharge Relay none match. \n");
+        log_info("CCS Precharge Relay none match. ");
     }
     }
 #endif //
 #endif //
 
 
     if (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) {
     if (regRelay.relay_event.bits.Gun1_P != outputRelay.relay_event.bits.Gun1_P) {
-        //log_info("SMR1:D+ Relay none match. \n");
+        //log_info("SMR1:D+ Relay none match. ");
         StartCheckRelayInfo(RELAY_SMR1_P_STATUS, outputRelay.relay_event.bits.Gun1_P);
         StartCheckRelayInfo(RELAY_SMR1_P_STATUS, outputRelay.relay_event.bits.Gun1_P);
     } else {
     } else {
         StopCheckRelayInfo(RELAY_SMR1_P_STATUS);
         StopCheckRelayInfo(RELAY_SMR1_P_STATUS);
     }
     }
 
 
     if (regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) {
     if (regRelay.relay_event.bits.Gun1_N != outputRelay.relay_event.bits.Gun1_N) {
-        //log_info("SMR1:D- Relay none match. \n");
+        //log_info("SMR1:D- Relay none match. ");
         StartCheckRelayInfo(RELAY_SMR1_N_STATUS, outputRelay.relay_event.bits.Gun1_N);
         StartCheckRelayInfo(RELAY_SMR1_N_STATUS, outputRelay.relay_event.bits.Gun1_N);
     } else {
     } else {
         StopCheckRelayInfo(RELAY_SMR1_N_STATUS);
         StopCheckRelayInfo(RELAY_SMR1_N_STATUS);
     }
     }
 
 
     if (regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) {
     if (regRelay.relay_event.bits.Gun2_P != outputRelay.relay_event.bits.Gun2_P) {
-        //log_info("SMR2:D+ Relay none match. \n");
+        //log_info("SMR2:D+ Relay none match. ");
         StartCheckRelayInfo(RELAY_SMR2_P_STATUS, outputRelay.relay_event.bits.Gun2_P);
         StartCheckRelayInfo(RELAY_SMR2_P_STATUS, outputRelay.relay_event.bits.Gun2_P);
     } else {
     } else {
         StopCheckRelayInfo(RELAY_SMR2_P_STATUS);
         StopCheckRelayInfo(RELAY_SMR2_P_STATUS);
     }
     }
 
 
     if (regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N) {
     if (regRelay.relay_event.bits.Gun2_N != outputRelay.relay_event.bits.Gun2_N) {
-        //log_info("SMR2:D- Relay none match. \n");
+        //log_info("SMR2:D- Relay none match. ");
         StartCheckRelayInfo(RELAY_SMR2_N_STATUS, outputRelay.relay_event.bits.Gun2_N);
         StartCheckRelayInfo(RELAY_SMR2_N_STATUS, outputRelay.relay_event.bits.Gun2_N);
     } else {
     } else {
         StopCheckRelayInfo(RELAY_SMR2_N_STATUS);
         StopCheckRelayInfo(RELAY_SMR2_N_STATUS);
@@ -198,14 +199,14 @@ static bool IsNoneMatchRelayStatus(void)
 
 
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
     if (regRelay.relay_event.bits.Gun1_Parallel_P != outputRelay.relay_event.bits.Gun1_Parallel_P) {
     if (regRelay.relay_event.bits.Gun1_Parallel_P != outputRelay.relay_event.bits.Gun1_Parallel_P) {
-        //log_info("Parallel:D+ Relay none match. \n");
+        //log_info("Parallel:D+ Relay none match. ");
         StartCheckRelayInfo(RELAY_PARA_P_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_P);
         StartCheckRelayInfo(RELAY_PARA_P_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_P);
     } else {
     } else {
         StopCheckRelayInfo(RELAY_PARA_P_STATUS);
         StopCheckRelayInfo(RELAY_PARA_P_STATUS);
     }
     }
 
 
     if (regRelay.relay_event.bits.Gun1_Parallel_N != outputRelay.relay_event.bits.Gun1_Parallel_N) {
     if (regRelay.relay_event.bits.Gun1_Parallel_N != outputRelay.relay_event.bits.Gun1_Parallel_N) {
-        //log_info("Parallel:D- Relay none match. \n");
+        //log_info("Parallel:D- Relay none match. ");
         StartCheckRelayInfo(RELAY_PARA_N_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_N);
         StartCheckRelayInfo(RELAY_PARA_N_STATUS, outputRelay.relay_event.bits.Gun1_Parallel_N);
     } else {
     } else {
         StopCheckRelayInfo(RELAY_PARA_N_STATUS);
         StopCheckRelayInfo(RELAY_PARA_N_STATUS);
@@ -307,13 +308,13 @@ static void GetGfdAdc(void)
                 //}
                 //}
 
 
                 pDcChargingInfo->GroundFaultStatus = gfd_adc.result_conn1;
                 pDcChargingInfo->GroundFaultStatus = gfd_adc.result_conn1;
-                //log_info("GFD ******** Result = %d, Step = %d, R = %d, Vol = %d \n",
+                //log_info("GFD ******** Result = %d, Step = %d, R = %d, Vol = %d ",
                 //            pDcChargingInfo->GroundFaultStatus,
                 //            pDcChargingInfo->GroundFaultStatus,
                 //            gfd_adc.rb_step_1,
                 //            gfd_adc.rb_step_1,
                 //            gfd_adc.Resister_conn1,
                 //            gfd_adc.Resister_conn1,
                 //            gfd_adc.voltage_conn1);
                 //            gfd_adc.voltage_conn1);
                 if (pDcChargingInfo->GroundFaultStatus == GFD_FAIL) {
                 if (pDcChargingInfo->GroundFaultStatus == GFD_FAIL) {
-                    log_info("GFD Fail. index = %d, Step = %d, R = %d, Vol = %d \n",
+                    log_info("GFD Fail. index = %d, Step = %d, R = %d, Vol = %d ",
                              gunIndex,
                              gunIndex,
                              gfd_adc.rb_step_1,
                              gfd_adc.rb_step_1,
                              gfd_adc.Resister_conn1,
                              gfd_adc.Resister_conn1,
@@ -323,7 +324,7 @@ static void GetGfdAdc(void)
                            pDcChargingInfo->GroundFaultStatus == GFD_WARNING
                            pDcChargingInfo->GroundFaultStatus == GFD_WARNING
                           ) {
                           ) {
                     if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING) {
                     if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING) {
-                        log_info("GFD Warning. index = %d, Result = %d, R = %d, Vol = %d \n",
+                        log_info("GFD Warning. index = %d, Result = %d, R = %d, Vol = %d ",
                                  gunIndex,
                                  gunIndex,
                                  pDcChargingInfo->GroundFaultStatus,
                                  pDcChargingInfo->GroundFaultStatus,
                                  gfd_adc.Resister_conn1,
                                  gfd_adc.Resister_conn1,
@@ -336,7 +337,7 @@ static void GetGfdAdc(void)
                 //}
                 //}
                 pDcChargingInfo->GroundFaultStatus = gfd_adc.result_conn2;
                 pDcChargingInfo->GroundFaultStatus = gfd_adc.result_conn2;
                 if (pDcChargingInfo->GroundFaultStatus == GFD_FAIL) {
                 if (pDcChargingInfo->GroundFaultStatus == GFD_FAIL) {
-                    log_info("GFD Fail. index = %d, Step = %d, R = %d, Vol = %d \n",
+                    log_info("GFD Fail. index = %d, Step = %d, R = %d, Vol = %d ",
                              gunIndex,
                              gunIndex,
                              gfd_adc.rb_step_2,
                              gfd_adc.rb_step_2,
                              gfd_adc.Resister_conn2,
                              gfd_adc.Resister_conn2,
@@ -345,7 +346,7 @@ static void GetGfdAdc(void)
                            pDcChargingInfo->GroundFaultStatus == GFD_WARNING
                            pDcChargingInfo->GroundFaultStatus == GFD_WARNING
                           ) {
                           ) {
                     if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING) {
                     if (pDcChargingInfo->GroundFaultStatus == GFD_WARNING) {
-                        log_info("GFD Warning. index = %d, Result = %d, R = %d, Vol = %d \n",
+                        log_info("GFD Warning. index = %d, Result = %d, R = %d, Vol = %d ",
                                  gunIndex,
                                  gunIndex,
                                  pDcChargingInfo->GroundFaultStatus,
                                  pDcChargingInfo->GroundFaultStatus,
                                  gfd_adc.Resister_conn1,
                                  gfd_adc.Resister_conn1,
@@ -375,11 +376,11 @@ void CheckOutputPowerOverCarReq(uint8_t index)
                     _isOvpChkTimeFlag[index] = YES;
                     _isOvpChkTimeFlag[index] = YES;
                 }
                 }
             } else {
             } else {
-                log_info("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
+                log_info("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f ",
                          pDcChargingInfo->FireChargingVoltage,
                          pDcChargingInfo->FireChargingVoltage,
                          (pDcChargingInfo->EvBatterytargetVoltage * 10));
                          (pDcChargingInfo->EvBatterytargetVoltage * 10));
 
 
-                log_error("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
+                log_error("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f ",
                           pDcChargingInfo->FireChargingVoltage,
                           pDcChargingInfo->FireChargingVoltage,
                           (pDcChargingInfo->EvBatterytargetVoltage * 10));
                           (pDcChargingInfo->EvBatterytargetVoltage * 10));
                 if ((GetTimeoutValue(_checkOutputVolProtectTimer[index]) / 1000) >= OUTPUT_VOL_CHK_TIME) {
                 if ((GetTimeoutValue(_checkOutputVolProtectTimer[index]) / 1000) >= OUTPUT_VOL_CHK_TIME) {
@@ -439,7 +440,7 @@ void CheckAcInputOvpStatus(uint8_t index)
 //                      _psuInputVolS > VIN_MAX_VOLTAGE_IEC ||
 //                      _psuInputVolS > VIN_MAX_VOLTAGE_IEC ||
 //                      _psuInputVolT > VIN_MAX_VOLTAGE_IEC)
 //                      _psuInputVolT > VIN_MAX_VOLTAGE_IEC)
 //              {
 //              {
-//                  log_info("IEC _psuInputVolR = %f, _psuInputVolS = %f, _psuInputVolT = %f \n",
+//                  log_info("IEC _psuInputVolR = %f, _psuInputVolS = %f, _psuInputVolT = %f ",
 //                          _psuInputVolR, _psuInputVolS, _psuInputVolT);
 //                          _psuInputVolR, _psuInputVolS, _psuInputVolT);
 //                  pDcChargingInfo->StopChargeFlag = YES;
 //                  pDcChargingInfo->StopChargeFlag = YES;
 //              }
 //              }
@@ -451,14 +452,14 @@ void CheckAcInputOvpStatus(uint8_t index)
 //                      _psuInputVolS > VIN_MAX_VOLTAGE_UL ||
 //                      _psuInputVolS > VIN_MAX_VOLTAGE_UL ||
 //                      _psuInputVolT > VIN_MAX_VOLTAGE_UL)
 //                      _psuInputVolT > VIN_MAX_VOLTAGE_UL)
 //              {
 //              {
-//                  log_info("UL _psuInputVolR = %f, _psuInputVolS = %f, _psuInputVolT = %f \n",
+//                  log_info("UL _psuInputVolR = %f, _psuInputVolS = %f, _psuInputVolT = %f ",
 //                          _psuInputVolR, _psuInputVolS, _psuInputVolT);
 //                          _psuInputVolR, _psuInputVolS, _psuInputVolT);
 //                  pDcChargingInfo->StopChargeFlag = YES;
 //                  pDcChargingInfo->StopChargeFlag = YES;
 //              }
 //              }
 //          }
 //          }
 //      }
 //      }
 //      else
 //      else
-        //log_info("CheckAcInputOvpStatus\r\n");
+        //log_info("CheckAcInputOvpStatus");
         pDcChargingInfo->StopChargeFlag = YES;
         pDcChargingInfo->StopChargeFlag = YES;
     }
     }
 }
 }
@@ -478,9 +479,9 @@ void CheckAcInputOvpStatus(uint8_t index)
 //                gettimeofday(&_checkOutputNoneMatchTimer[index], NULL);
 //                gettimeofday(&_checkOutputNoneMatchTimer[index], NULL);
 //            } else {
 //            } else {
 //                if ((GetTimeoutValue(_checkOutputNoneMatchTimer[index]) / 1000) >= 5000) {
 //                if ((GetTimeoutValue(_checkOutputNoneMatchTimer[index]) / 1000) >= 5000) {
-//                    /*log_info("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d) : pre = %f, fire = %f \n",
+//                    /*log_info("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d) : pre = %f, fire = %f ",
 //                            index, (pDcChargingInfo->PresentChargingVoltage * 10), pDcChargingInfo->FireChargingVoltage);
 //                            index, (pDcChargingInfo->PresentChargingVoltage * 10), pDcChargingInfo->FireChargingVoltage);
-//                    log_error("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d): pre = %f, fire = %f \n",
+//                    log_error("[Module_InternalComm]CheckOutputVolNoneMatchFire NG (%d): pre = %f, fire = %f ",
 //                            index, (pDcChargingInfo->PresentChargingVoltage * 10), pDcChargingInfo->FireChargingVoltage);
 //                            index, (pDcChargingInfo->PresentChargingVoltage * 10), pDcChargingInfo->FireChargingVoltage);
 //                    pDcChargingInfo->StopChargeFlag = YES;*/
 //                    pDcChargingInfo->StopChargeFlag = YES;*/
 //                }
 //                }
@@ -498,7 +499,7 @@ void CheckPhaseLossStatus(uint8_t index)
     if (pAlarmCode->AlarmEvents.bits.SystemL1InputUVP == YES ||
     if (pAlarmCode->AlarmEvents.bits.SystemL1InputUVP == YES ||
             pAlarmCode->AlarmEvents.bits.SystemL2InputUVP == YES ||
             pAlarmCode->AlarmEvents.bits.SystemL2InputUVP == YES ||
             pAlarmCode->AlarmEvents.bits.SystemL3InputUVP == YES) {
             pAlarmCode->AlarmEvents.bits.SystemL3InputUVP == YES) {
-        //log_info("CheckPhaseLossStatus\r\n");
+        //log_info("CheckPhaseLossStatus");
         pDcChargingInfo->StopChargeFlag = YES;
         pDcChargingInfo->StopChargeFlag = YES;
     }
     }
 }
 }
@@ -720,9 +721,9 @@ void SetGfdConfig(uint8_t index, uint8_t resister)
         .state = resister,
         .state = resister,
     };
     };
 
 
-    //log_info("************************GFD Vol = %d, GFD Res = %d \n", gfd_config.reqVol, gfd_config.resister);
+    //log_info("************************GFD Vol = %d, GFD Res = %d ", gfd_config.reqVol, gfd_config.resister);
     if (Config_Gfd_Value(Uart5Fd, ADDR_RELAY, &gfd_config) == PASS) {
     if (Config_Gfd_Value(Uart5Fd, ADDR_RELAY, &gfd_config) == PASS) {
-//      log_info("Set reqVol = %f, resister = %d \n",
+//      log_info("Set reqVol = %f, resister = %d ",
 //              gfd_config.reqVol,
 //              gfd_config.reqVol,
 //              gfd_config.resister);
 //              gfd_config.resister);
     }
     }
@@ -821,7 +822,7 @@ void GetPresentInputVol(void)
         if (pSysInfo->ChargerType == _CHARGER_TYPE_IEC) {
         if (pSysInfo->ChargerType == _CHARGER_TYPE_IEC) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputUVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputUVP == NO) {
                 if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_IEC) {
                 if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_IEC) {
-                    log_info("In Uvp L1N_L12 = %f \n", inputVoltage.L1N_L12);
+                    log_info("In Uvp L1N_L12 = %f ", inputVoltage.L1N_L12);
                     if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL1InputUVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL1InputUVP = YES;
                     } else {
                     } else {
@@ -837,7 +838,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputUVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputUVP == NO) {
                 if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_IEC) {
                 if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_IEC) {
-                    log_info("In Uvp L2N_L23 = %f \n", inputVoltage.L2N_L23);
+                    log_info("In Uvp L2N_L23 = %f ", inputVoltage.L2N_L23);
                     if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL2InputUVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL2InputUVP = YES;
                     } else {
                     } else {
@@ -853,7 +854,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL3InputUVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL3InputUVP == NO) {
                 if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_IEC) {
                 if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_IEC) {
-                    log_info("In Uvp L3N_L31 = %f \n", inputVoltage.L3N_L31);
+                    log_info("In Uvp L3N_L31 = %f ", inputVoltage.L3N_L31);
                     if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL3InputUVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL3InputUVP = YES;
                     } else {
                     } else {
@@ -869,7 +870,7 @@ void GetPresentInputVol(void)
         } else if (pSysInfo->ChargerType == _CHARGER_TYPE_UL) {
         } else if (pSysInfo->ChargerType == _CHARGER_TYPE_UL) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputUVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputUVP == NO) {
                 if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_UL) {
                 if (inputVoltage.L1N_L12 < VIN_MIN_VOLTAGE_UL) {
-                    log_info("In Uvp L1N_L12 = %f \n", inputVoltage.L1N_L12);
+                    log_info("In Uvp L1N_L12 = %f ", inputVoltage.L1N_L12);
                     if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseUvp[0] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL1InputUVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL1InputUVP = YES;
                     } else {
                     } else {
@@ -885,7 +886,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputUVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputUVP == NO) {
                 if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_UL) {
                 if (inputVoltage.L2N_L23 < VIN_MIN_VOLTAGE_UL) {
-                    log_info("In Uvp L2N_L23 = %f \n", inputVoltage.L2N_L23);
+                    log_info("In Uvp L2N_L23 = %f ", inputVoltage.L2N_L23);
                     if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseUvp[1] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL2InputUVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL2InputUVP = YES;
                     } else {
                     } else {
@@ -901,7 +902,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL3InputUVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL3InputUVP == NO) {
                 if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_UL) {
                 if (inputVoltage.L3N_L31 < VIN_MIN_VOLTAGE_UL) {
-                    log_info("In Uvp L3N_L31 = %f \n", inputVoltage.L3N_L31);
+                    log_info("In Uvp L3N_L31 = %f ", inputVoltage.L3N_L31);
                     if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseUvp[2] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL3InputUVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL3InputUVP = YES;
                     } else {
                     } else {
@@ -921,7 +922,7 @@ void GetPresentInputVol(void)
         if (pSysInfo->ChargerType == _CHARGER_TYPE_IEC) {
         if (pSysInfo->ChargerType == _CHARGER_TYPE_IEC) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputOVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputOVP == NO) {
                 if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_IEC) {
                 if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_IEC) {
-                    log_info("In Ovp L1N_L12 = %f \n", inputVoltage.L1N_L12);
+                    log_info("In Ovp L1N_L12 = %f ", inputVoltage.L1N_L12);
                     if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL1InputOVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL1InputOVP = YES;
                     } else {
                     } else {
@@ -937,7 +938,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputOVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputOVP == NO) {
                 if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_IEC) {
                 if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_IEC) {
-                    log_info("In Ovp L2N_L23 = %f \n", inputVoltage.L2N_L23);
+                    log_info("In Ovp L2N_L23 = %f ", inputVoltage.L2N_L23);
                     if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL2InputOVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL2InputOVP = YES;
                     } else {
                     } else {
@@ -953,7 +954,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL3InputOVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL3InputOVP == NO) {
                 if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_IEC) {
                 if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_IEC) {
-                    log_info("In Ovp L3N_L31 = %f \n", inputVoltage.L3N_L31);
+                    log_info("In Ovp L3N_L31 = %f ", inputVoltage.L3N_L31);
                     if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL3InputOVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL3InputOVP = YES;
                     } else {
                     } else {
@@ -969,7 +970,7 @@ void GetPresentInputVol(void)
         } else if (pSysInfo->ChargerType == _CHARGER_TYPE_UL) {
         } else if (pSysInfo->ChargerType == _CHARGER_TYPE_UL) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputOVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL1InputOVP == NO) {
                 if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_UL) {
                 if (inputVoltage.L1N_L12 > VIN_MAX_VOLTAGE_UL) {
-                    log_info("In Ovp L1N_L12 = %f \n", inputVoltage.L1N_L12);
+                    log_info("In Ovp L1N_L12 = %f ", inputVoltage.L1N_L12);
                     if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseOvp[0] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL1InputOVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL1InputOVP = YES;
                     } else {
                     } else {
@@ -985,7 +986,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputOVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputOVP == NO) {
                 if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_UL) {
                 if (inputVoltage.L2N_L23 > VIN_MAX_VOLTAGE_UL) {
-                    log_info("In Ovp L2N_L23 = %f \n", inputVoltage.L2N_L23);
+                    log_info("In Ovp L2N_L23 = %f ", inputVoltage.L2N_L23);
                     if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseOvp[1] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL2InputOVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL2InputOVP = YES;
                     } else {
                     } else {
@@ -1001,7 +1002,7 @@ void GetPresentInputVol(void)
 
 
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputOVP == NO) {
             if (pAlarmCode->AlarmEvents.bits.SystemL2InputOVP == NO) {
                 if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_UL) {
                 if (inputVoltage.L3N_L31 > VIN_MAX_VOLTAGE_UL) {
-                    log_info("In Ovp L3N_L31 = %f \n", inputVoltage.L3N_L31);
+                    log_info("In Ovp L3N_L31 = %f ", inputVoltage.L3N_L31);
                     if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT) {
                     if (_threePhaseOvp[2] >= OVP_UVP_CHK_COUNT) {
                         pAlarmCode->AlarmEvents.bits.SystemL3InputOVP = YES;
                         pAlarmCode->AlarmEvents.bits.SystemL3InputOVP = YES;
                     } else {
                     } else {
@@ -1030,13 +1031,13 @@ void GetPersentOutputVol(void)
         return;
         return;
     }
     }
 
 
-    //log_info("Conn1 fuse 1 = %f \n", outputVoltage.behindFuse_Voltage_C1);
-    //log_info("Conn1 relay 1 = %f \n", outputVoltage.behindRelay_Voltage_C1);
-    //log_info("Conn2 fuse 2 = %f \n", outputVoltage.behindFuse_Voltage_C2);
-    //log_info("Conn2 relay 2 = %f \n", outputVoltage.behindRelay_Voltage_C2);
+    //log_info("Conn1 fuse 1 = %f ", outputVoltage.behindFuse_Voltage_C1);
+    //log_info("Conn1 relay 1 = %f ", outputVoltage.behindRelay_Voltage_C1);
+    //log_info("Conn2 fuse 2 = %f ", outputVoltage.behindFuse_Voltage_C2);
+    //log_info("Conn2 relay 2 = %f ", outputVoltage.behindRelay_Voltage_C2);
 
 
-    //log_info("outputVoltage.behindFuse_Voltage_C1 = %f \n", outputVoltage.behindFuse_Voltage_C1);
-    //log_info("outputVoltage.behindFuse_Voltage_C2 = %f \n", outputVoltage.behindFuse_Voltage_C2);
+    //log_info("outputVoltage.behindFuse_Voltage_C1 = %f ", outputVoltage.behindFuse_Voltage_C1);
+    //log_info("outputVoltage.behindFuse_Voltage_C2 = %f ", outputVoltage.behindFuse_Voltage_C2);
 
 
     ShmRelayModuleData->Gun1FuseOutputVolt = outputVoltage.behindFuse_Voltage_C1;
     ShmRelayModuleData->Gun1FuseOutputVolt = outputVoltage.behindFuse_Voltage_C1;
     ShmRelayModuleData->Gun1RelayOutputVolt = outputVoltage.behindRelay_Voltage_C1;
     ShmRelayModuleData->Gun1RelayOutputVolt = outputVoltage.behindRelay_Voltage_C1;
@@ -1075,7 +1076,7 @@ void GetPersentOutputVol(void)
             break;
             break;
         }
         }
 
 
-        //log_info("%d persent vol = %f, cur = %f\r\n",
+        //log_info("%d persent vol = %f, cur = %f",
         //         index,
         //         index,
         //         pDcChargingInfo->PresentChargingVoltage,
         //         pDcChargingInfo->PresentChargingVoltage,
         //         pDcChargingInfo->PresentChargingCurrent);
         //         pDcChargingInfo->PresentChargingCurrent);
@@ -1100,7 +1101,7 @@ void SetRtcData_Relay(void)
 
 
     ftime(&csuTime);
     ftime(&csuTime);
     tmCSU = localtime(&csuTime.time);
     tmCSU = localtime(&csuTime.time);
-    //  log_info("Time : %04d-%02d-%02d %02d:%02d:%02d \n", tmCSU->tm_year + 1900,
+    //  log_info("Time : %04d-%02d-%02d %02d:%02d:%02d ", tmCSU->tm_year + 1900,
     //          tmCSU->tm_mon + 1, tmCSU->tm_mday, tmCSU->tm_hour, tmCSU->tm_min,
     //          tmCSU->tm_mon + 1, tmCSU->tm_mday, tmCSU->tm_hour, tmCSU->tm_min,
     //          tmCSU->tm_sec);
     //          tmCSU->tm_sec);
 
 
@@ -1125,14 +1126,14 @@ void SetRtcData_Relay(void)
     rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
     rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
 
 
     if (Config_Rtc_Data(Uart5Fd, ADDR_RELAY, &rtc) == PASS) {
     if (Config_Rtc_Data(Uart5Fd, ADDR_RELAY, &rtc) == PASS) {
-        //log_info("SetRtc (RB) sucessfully. \n");
+        //log_info("SetRtc (RB) sucessfully. ");
     }
     }
 }
 }
 
 
 void SetModelName_Relay(void)
 void SetModelName_Relay(void)
 {
 {
     if (Config_Model_Name(Uart5Fd, ADDR_RELAY, pSysConfig->ModelName) == PASS) {
     if (Config_Model_Name(Uart5Fd, ADDR_RELAY, pSysConfig->ModelName) == PASS) {
-        //log_info("Set Model name (RB) PASS = %s \n", pSysConfig->ModelName);
+        //log_info("Set Model name (RB) PASS = %s ", pSysConfig->ModelName);
     }
     }
 }
 }
 
 
@@ -1145,13 +1146,13 @@ void GetFwAndHwVersion_Relay(void)
         strcpy((char *)ShmRelayModuleData->version, ver.Version_FW);
         strcpy((char *)ShmRelayModuleData->version, ver.Version_FW);
         // SystemInfo
         // SystemInfo
         strcpy((char *)pSysInfo->RelayModuleFwRev, ver.Version_FW);
         strcpy((char *)pSysInfo->RelayModuleFwRev, ver.Version_FW);
-        //log_info("GetFwAndHwVersion_Relay s1 = %s \n", ver.Version_FW);
+        //log_info("GetFwAndHwVersion_Relay s1 = %s ", ver.Version_FW);
     }
     }
 
 
     if (Query_HW_Ver(Uart5Fd, ADDR_RELAY, &ver) == PASS) {
     if (Query_HW_Ver(Uart5Fd, ADDR_RELAY, &ver) == PASS) {
         // SystemInfo
         // SystemInfo
         strcpy((char *)pSysInfo->RelayModuleHwRev, ver.Version_FW);
         strcpy((char *)pSysInfo->RelayModuleHwRev, ver.Version_FW);
-        //log_info("GetFwAndHwVersion_Relay s2 = %s \n", ver.Version_HW);
+        //log_info("GetFwAndHwVersion_Relay s2 = %s ", ver.Version_HW);
     }
     }
 }
 }
 
 
@@ -1160,7 +1161,7 @@ static void outputRelayInit(int fd)
     memset((uint8_t *)&outputRelay, 0, sizeof(Relay));
     memset((uint8_t *)&outputRelay, 0, sizeof(Relay));
 
 
     if (Config_Relay_Output(fd, ADDR_RELAY, &outputRelay) != PASS) {
     if (Config_Relay_Output(fd, ADDR_RELAY, &outputRelay) != PASS) {
-        log_info("Config_Relay_Output fail \n");
+        log_info("Config_Relay_Output fail ");
     }
     }
 }
 }
 
 
@@ -1175,12 +1176,13 @@ static bool IsRelayProcessNeedPause(void)
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
         pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
         if(pDcChargingInfo->SystemStatus == S_UPDATE)
         if(pDcChargingInfo->SystemStatus == S_UPDATE)
         {
         {
+            SetLedColor();
             _pause = true;
             _pause = true;
         }
         }
     }
     }
     if(isPause != _pause)
     if(isPause != _pause)
     {
     {
-        log_info("Relay Process Now Is %s \n", _pause == true ? "Paused" : "Continued");
+        log_info("Relay Process Now Is %s ", _pause == true ? "Paused" : "Continued");
     }
     }
     isPause = _pause;
     isPause = _pause;
 
 
@@ -1208,7 +1210,7 @@ static void SetFanModuleSpeed(void)
         _fanSpeed.speed[3] = _setFanSpeed;
         _fanSpeed.speed[3] = _setFanSpeed;
 
 
         if (Config_Fan_Speed(Uart5Fd, ADDR_FAN, &_fanSpeed) == PASS) {
         if (Config_Fan_Speed(Uart5Fd, ADDR_FAN, &_fanSpeed) == PASS) {
-            //log_info("successfully Fan\n");
+            //log_info("successfully Fan");
         }
         }
     }
     }
 }
 }
@@ -1218,16 +1220,16 @@ static void GetFanSpeed(void)
 {
 {
     FanSpeed fanSpeed = {0};
     FanSpeed fanSpeed = {0};
 
 
-    //log_info("Get fan board speed \n");
+    //log_info("Get fan board speed ");
     if (Query_Fan_Speed(Uart5Fd, ADDR_FAN, &fanSpeed) == PASS) {
     if (Query_Fan_Speed(Uart5Fd, ADDR_FAN, &fanSpeed) == PASS) {
         ShmFanModuleData->PresentFan1Speed = fanSpeed.speed[0];
         ShmFanModuleData->PresentFan1Speed = fanSpeed.speed[0];
         ShmFanModuleData->PresentFan2Speed = fanSpeed.speed[1];
         ShmFanModuleData->PresentFan2Speed = fanSpeed.speed[1];
         ShmFanModuleData->PresentFan3Speed = fanSpeed.speed[2];
         ShmFanModuleData->PresentFan3Speed = fanSpeed.speed[2];
         ShmFanModuleData->PresentFan4Speed = fanSpeed.speed[3];
         ShmFanModuleData->PresentFan4Speed = fanSpeed.speed[3];
-//      log_info("SystemFanRotaSpeed_1 = %d \n", fanSpeed.speed[0]);
-//      log_info("SystemFanRotaSpeed_2 = %d \n", fanSpeed.speed[1]);
-//      log_info("SystemFanRotaSpeed_3 = %d \n", fanSpeed.speed[2]);
-//      log_info("SystemFanRotaSpeed_4 = %d \n", fanSpeed.speed[3]);
+//      log_info("SystemFanRotaSpeed_1 = %d ", fanSpeed.speed[0]);
+//      log_info("SystemFanRotaSpeed_2 = %d ", fanSpeed.speed[1]);
+//      log_info("SystemFanRotaSpeed_3 = %d ", fanSpeed.speed[2]);
+//      log_info("SystemFanRotaSpeed_4 = %d ", fanSpeed.speed[3]);
         // Config_Fan_Speed(Uart5Fd, ADDR_FAN, &fanSpeed[0]);
         // Config_Fan_Speed(Uart5Fd, ADDR_FAN, &fanSpeed[0]);
         //SysInfoData (SystemFanRotaSpeed)
         //SysInfoData (SystemFanRotaSpeed)
     }
     }
@@ -1316,7 +1318,7 @@ static void SetRtcData_Fan(void)
 
 
     ftime(&csuTime);
     ftime(&csuTime);
     tmCSU = localtime(&csuTime.time);
     tmCSU = localtime(&csuTime.time);
-    //  log_info("Time : %04d-%02d-%02d %02d:%02d:%02d \n", tmCSU->tm_year + 1900,
+    //  log_info("Time : %04d-%02d-%02d %02d:%02d:%02d ", tmCSU->tm_year + 1900,
     //          tmCSU->tm_mon + 1, tmCSU->tm_mday, tmCSU->tm_hour, tmCSU->tm_min,
     //          tmCSU->tm_mon + 1, tmCSU->tm_mday, tmCSU->tm_hour, tmCSU->tm_min,
     //          tmCSU->tm_sec);
     //          tmCSU->tm_sec);
 
 
@@ -1341,14 +1343,14 @@ static void SetRtcData_Fan(void)
     rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
     rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
 
 
     if (Config_Rtc_Data(Uart5Fd, ADDR_FAN, &rtc) == PASS) {
     if (Config_Rtc_Data(Uart5Fd, ADDR_FAN, &rtc) == PASS) {
-        //log_info("SetRtc (FB) sucessfully. \n");
+        //log_info("SetRtc (FB) sucessfully. ");
     }
     }
 }
 }
 
 
 static void SetModelName_Fan(void)
 static void SetModelName_Fan(void)
 {
 {
     if (Config_Model_Name(Uart5Fd, ADDR_FAN, pSysConfig->ModelName) == PASS) {
     if (Config_Model_Name(Uart5Fd, ADDR_FAN, pSysConfig->ModelName) == PASS) {
-        log_info("Set Model name PASS = %s \n", pSysConfig->ModelName);
+        log_info("Set Model name PASS = %s ", pSysConfig->ModelName);
     }
     }
 }
 }
 
 
@@ -1361,13 +1363,13 @@ static void GetFwAndHwVersion_Fan(void)
         strcpy((char *)ShmFanModuleData->version, ver.Version_FW);
         strcpy((char *)ShmFanModuleData->version, ver.Version_FW);
         // SystemInfo
         // SystemInfo
         strcpy((char *)pSysInfo->FanModuleFwRev, ver.Version_FW);
         strcpy((char *)pSysInfo->FanModuleFwRev, ver.Version_FW);
-        //log_info("GetFwAndHwVersion_Fan s1 = %s \n", ver.Version_FW);
+        //log_info("GetFwAndHwVersion_Fan s1 = %s ", ver.Version_FW);
     }
     }
 
 
     if (Query_HW_Ver(Uart5Fd, ADDR_FAN, &ver) == PASS) {
     if (Query_HW_Ver(Uart5Fd, ADDR_FAN, &ver) == PASS) {
         // SystemInfo
         // SystemInfo
         strcpy((char *)pSysInfo->FanModuleHwRev, ver.Version_FW);
         strcpy((char *)pSysInfo->FanModuleHwRev, ver.Version_FW);
-        //log_info("GetFwAndHwVersion_Fan s2 = %s \n", ver.Version_HW);
+        //log_info("GetFwAndHwVersion_Fan s2 = %s ", ver.Version_HW);
     }
     }
 }
 }
 
 
@@ -1407,7 +1409,7 @@ static void fanBoardPorcess(void)
             ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
             ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
             ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
             ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
 
 
-            //log_info("set fan = %d \n", ShmFanModuleData->SetFan1Speed);
+            //log_info("set fan = %d ", ShmFanModuleData->SetFan1Speed);
             SetFanModuleSpeed();
             SetFanModuleSpeed();
         }
         }
     }
     }
@@ -1422,17 +1424,17 @@ static void GetFwAndHwVersion_Led(void)
         strcpy((char *) ShmLedModuleData->version, ver.Version_FW);
         strcpy((char *) ShmLedModuleData->version, ver.Version_FW);
         // SystemInfo
         // SystemInfo
         strcpy((char *) pSysInfo->LedModuleFwRev, ver.Version_FW);
         strcpy((char *) pSysInfo->LedModuleFwRev, ver.Version_FW);
-        log_info("GetFwAndHwVersion_Led s1 = %s \n", ver.Version_FW);
+        log_info("GetFwAndHwVersion_Led s1 = %s ", ver.Version_FW);
         ShmLedModuleData->SelfTest_Comp = YES;
         ShmLedModuleData->SelfTest_Comp = YES;
     } else {
     } else {
-        //log_info("GetFwAndHwVersion_Led fail \n");
+        //log_info("GetFwAndHwVersion_Led fail ");
     }
     }
 
 
 //  if (Query_HW_Ver(Uart5Fd, ADDR_LED, &ver) == PASS)
 //  if (Query_HW_Ver(Uart5Fd, ADDR_LED, &ver) == PASS)
 //  {
 //  {
 //      // SystemInfo
 //      // SystemInfo
 //      strcpy((char *) pSysInfo->RelayModuleHwRev, ver.Version_FW);
 //      strcpy((char *) pSysInfo->RelayModuleHwRev, ver.Version_FW);
-//      //log_info("GetFwAndHwVersion_Relay s2 = %s \n", ver.Version_HW);
+//      //log_info("GetFwAndHwVersion_Relay s2 = %s ", ver.Version_HW);
 //  }
 //  }
 }
 }
 
 
@@ -1523,7 +1525,12 @@ static void SetLedColor(void)
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
+            } else if ( chargingData_1->SystemStatus == S_UPDATE ) {
+                led_color.Connect_1_Green = COLOR_MIN_LV;
+                led_color.Connect_1_Blue = COLOR_MIN_LV;
+                led_color.Connect_1_Red = _colorBuf;
             }
             }
+
         } else {
         } else {
             if (chargingData_1->SystemStatus == S_BOOTING ||
             if (chargingData_1->SystemStatus == S_BOOTING ||
                     chargingData_1->SystemStatus == S_IDLE ||
                     chargingData_1->SystemStatus == S_IDLE ||
@@ -1552,8 +1559,13 @@ static void SetLedColor(void)
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Green = COLOR_MIN_LV;
                 led_color.Connect_1_Blue = _colorBuf;
                 led_color.Connect_1_Blue = _colorBuf;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
                 led_color.Connect_1_Red = COLOR_MIN_LV;
+            }else if ( chargingData_1->SystemStatus == S_UPDATE ) {
+                led_color.Connect_1_Green = COLOR_MIN_LV;
+                led_color.Connect_1_Blue = COLOR_MIN_LV;
+                led_color.Connect_1_Red = _colorBuf;
             }
             }
 
 
+
             // --------------------------------------------------------------------------
             // --------------------------------------------------------------------------
             if (chargingData_2->SystemStatus == S_BOOTING ||
             if (chargingData_2->SystemStatus == S_BOOTING ||
                     chargingData_2->SystemStatus == S_IDLE ||
                     chargingData_2->SystemStatus == S_IDLE ||
@@ -1581,10 +1593,14 @@ static void SetLedColor(void)
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Green = COLOR_MIN_LV;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Blue = _colorBuf;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
                 led_color.Connect_2_Red = COLOR_MIN_LV;
+            }else if ( chargingData_2->SystemStatus == S_UPDATE ) {
+                led_color.Connect_2_Green = COLOR_MIN_LV;
+                led_color.Connect_2_Blue = COLOR_MIN_LV;
+                led_color.Connect_2_Red = _colorBuf;
             }
             }
+
         }
         }
     }
     }
-
     if (_checkLedChanged > 0) {
     if (_checkLedChanged > 0) {
         if (Config_Led_Color(Uart5Fd, ADDR_LED, &led_color) == PASS) {
         if (Config_Led_Color(Uart5Fd, ADDR_LED, &led_color) == PASS) {
             _checkLedChanged--;
             _checkLedChanged--;
@@ -1854,7 +1870,7 @@ void RelayBoardTask(int uartFD)
 
 
                             //MatchRelayStatus();
                             //MatchRelayStatus();
 
 
-                            //log_info("Match Relay, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x \n",
+                            //log_info("Match Relay, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x ",
                             //         regRelay.relay_event.bits.AC_Contactor,
                             //         regRelay.relay_event.bits.AC_Contactor,
                             //         regRelay.relay_event.bits.Gun1_P,
                             //         regRelay.relay_event.bits.Gun1_P,
                         //         regRelay.relay_event.bits.Gun1_N,
                         //         regRelay.relay_event.bits.Gun1_N,

+ 40 - 27
EVSE/Projects/DD360Audi/Apps/ModuleLcmCtrl/Module_LcmControl.c

@@ -256,7 +256,7 @@ uint8_t _showReplugStr_2 = 75;
     if (pSysConfig->SwitchDebugFlag == YES) {
     if (pSysConfig->SwitchDebugFlag == YES) {
         sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
         sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
                 tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
                 tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
-        printf("%s \n", Buf);
+        printf("%s ", Buf);
     } else {
     } else {
         sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
         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,
                 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
@@ -294,12 +294,12 @@ int InitShareMemory()
     //creat ShmSysConfigAndInfo
     //creat ShmSysConfigAndInfo
     if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0) {
     if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("shmget ShmSysConfigAndInfo NG\n");
+        log_error("shmget ShmSysConfigAndInfo NG");
 #endif
 #endif
         result = FAIL;
         result = FAIL;
     } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
     } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("shmat ShmSysConfigAndInfo NG\n");
+        log_error("shmat ShmSysConfigAndInfo NG");
 #endif
 #endif
         result = FAIL;
         result = FAIL;
     } else
     } else
@@ -308,12 +308,12 @@ int InitShareMemory()
     //creat ShmStatusCodeData
     //creat ShmStatusCodeData
     if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0) {
     if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("shmget ShmStatusCodeData NG\n");
+        log_error("shmget ShmStatusCodeData NG");
 #endif
 #endif
         result = FAIL;
         result = FAIL;
     } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
     } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("shmat ShmStatusCodeData NG\n");
+        log_error("shmat ShmStatusCodeData NG");
 #endif
 #endif
         result = FAIL;
         result = FAIL;
     } else
     } else
@@ -321,22 +321,22 @@ int InitShareMemory()
 
 
     //creat Audi customization info
     //creat Audi customization info
     if ((MeterSMId = shmget(ShmSelectGunInfoKey, sizeof(SelectGunInfo), IPC_CREAT | 0777)) < 0) {
     if ((MeterSMId = shmget(ShmSelectGunInfoKey, sizeof(SelectGunInfo), IPC_CREAT | 0777)) < 0) {
-        log_error("[main]CreatShareMemory:shmget select gun info NG \n");
+        log_error("[main]CreatShareMemory:shmget select gun info NG ");
         return 0;
         return 0;
     } else if ((ShmSelectGunInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
     } else if ((ShmSelectGunInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        log_error("[main]CreatShareMemory:shmat shmget select gun info \n");
+        log_error("[main]CreatShareMemory:shmat shmget select gun info ");
         return 0;
         return 0;
     }
     }
 
 
     //creat ShmStatusCodeData
     //creat ShmStatusCodeData
     if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0) {
     if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("shmget ShmPrimaryMcuData NG\n");
+        log_error("shmget ShmPrimaryMcuData NG");
 #endif
 #endif
         result = FAIL;
         result = FAIL;
     } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
     } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
 #ifdef ShmPrimaryMcuData
 #ifdef ShmPrimaryMcuData
-        log_error("shmat ShmPrimaryMcuData NG\n");
+        log_error("shmat ShmPrimaryMcuData NG");
 #endif
 #endif
         result = FAIL;
         result = FAIL;
     }
     }
@@ -356,7 +356,7 @@ int CreateCommunicationLcmPort()
     fd = open(pPortName, O_RDWR);
     fd = open(pPortName, O_RDWR);
     if (fd <= 0) {
     if (fd <= 0) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("open /dev/ttyS3 NG \n");
+        log_error("open /dev/ttyS3 NG ");
 #endif
 #endif
         return -1;
         return -1;
     }
     }
@@ -383,7 +383,7 @@ void WriteCmdToLcm(uint8_t *cmd, uint8_t cmdLen)
 {
 {
     int len = write(_port, cmd, cmdLen);
     int len = write(_port, cmd, cmdLen);
     if (len >= sizeof(cmd)) {
     if (len >= sizeof(cmd)) {
-        //log_info("Write cmd to LCM successfully. \n");
+        //log_info("Write cmd to LCM successfully. ");
     }
     }
 }
 }
 
 
@@ -544,10 +544,10 @@ void ChangeWarningFunc()
     uint8_t cmd[7] = {0};
     uint8_t cmd[7] = {0};
     uint8_t i = 0;
     uint8_t i = 0;
     //uint8_t j = 0;
     //uint8_t j = 0;
-    //log_info("ChangeWarningFunc \n");
+    //log_info("ChangeWarningFunc ");
     // 最多一次五筆
     // 最多一次五筆
-    //log_info("LCM PageIndex = %d \n", pSysWarning->PageIndex);
-    //log_info("WarningCount = %d \n", pSysWarning->WarningCount);
+    //log_info("LCM PageIndex = %d ", pSysWarning->PageIndex);
+    //log_info("WarningCount = %d ", pSysWarning->WarningCount);
 //#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
 //#if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
     for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
     for (i = 0; (i + pSysWarning->PageIndex * 5) < pSysWarning->WarningCount; i++) {
         memset(cmd, 0x00, sizeof(cmd));
         memset(cmd, 0x00, sizeof(cmd));
@@ -640,19 +640,19 @@ void ChangeQrCode_Idle(char *input)
         if (len >= 25) {
         if (len >= 25) {
             if (i >= 16 && i <= 19) {
             if (i >= 16 && i <= 19) {
                 tmpBuf[k++] = input[l];
                 tmpBuf[k++] = input[l];
-                //printf("tmpBuf = %s\r\n", tmpBuf);
+                //printf("tmpBuf = %s", tmpBuf);
             } else if (i >= 21 && i <= 23) {
             } else if (i >= 21 && i <= 23) {
                 tmpBuf[k++] = input[l];
                 tmpBuf[k++] = input[l];
             }
             }
         }
         }
     }
     }
     tmpBuf[k] = '\0';
     tmpBuf[k] = '\0';
-    //printf("tmpBuf = %s\r\n", tmpBuf);
+    //printf("tmpBuf = %s", tmpBuf);
     j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
     j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
     cmd[len - 1] = '\0';
     cmd[len - 1] = '\0';
     urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
     urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
     qrUrl[urlLen] = '\0';
     qrUrl[urlLen] = '\0';
-    //printf("qr url = %s\r\n", qrUrl);
+    //printf("qr url = %s", qrUrl);
     DisplayValueToLcm(__qr_code, qrUrl, urlLen);
     DisplayValueToLcm(__qr_code, qrUrl, urlLen);
 
 
     j = 0;
     j = 0;
@@ -717,14 +717,14 @@ void ChangeQrCode_Charge(char *input)
         if (len >= 25) {
         if (len >= 25) {
             if (i >= 16 && i <= 19) {
             if (i >= 16 && i <= 19) {
                 tmpBuf[k++] = input[l];
                 tmpBuf[k++] = input[l];
-                //printf("tmpBuf = %s\r\n", tmpBuf);
+                //printf("tmpBuf = %s", tmpBuf);
             } else if (i >= 21 && i <= 23) {
             } else if (i >= 21 && i <= 23) {
                 tmpBuf[k++] = input[l];
                 tmpBuf[k++] = input[l];
             }
             }
         }
         }
     }
     }
     tmpBuf[k] = '\0';
     tmpBuf[k] = '\0';
-    //printf("tmpBuf = %s\r\n", tmpBuf);
+    //printf("tmpBuf = %s", tmpBuf);
     j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
     j += sprintf((char *)&cmd[i], ":%d", pSysInfo->CurGunSelected); ////For Audi
     cmd[len - 1] = '\0';
     cmd[len - 1] = '\0';
     urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
     urlLen = sprintf((char *)qrUrl, "%s%s", NOODOE_QR_CODE_URL, cmd);
@@ -777,7 +777,7 @@ void ChangeQrCode_Charge(char *input)
 //================================================
 //================================================
 void ChangeCurPage()
 void ChangeCurPage()
 {
 {
-    //log_info("cur = %d, new = %d \n", _currentPage, pSysInfo->PageIndex);
+    //log_info("cur = %d, new = %d ", _currentPage, pSysInfo->PageIndex);
     if (_currentPage != pSysInfo->PageIndex) {
     if (_currentPage != pSysInfo->PageIndex) {
         _currentPage = pSysInfo->PageIndex;
         _currentPage = pSysInfo->PageIndex;
         ChangeToOtherPage(_currentPage);
         ChangeToOtherPage(_currentPage);
@@ -1233,7 +1233,7 @@ void RefreshConnStatus()
     //uint8_t flag[4] = {0};
     //uint8_t flag[4] = {0};
 
 
     /*for (i = 0; i < pSysWarning->WarningCount; i++) {
     /*for (i = 0; i < pSysWarning->WarningCount; i++) {
-        //printf("status code = %s\r\n", &pSysWarning->WarningCode[i][0]);
+        //printf("status code = %s", &pSysWarning->WarningCode[i][0]);
         if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
         if (memcmp(&pSysWarning->WarningCode[i][0], "012304", 6) == 0) {
             flag[0] = 1;
             flag[0] = 1;
             continue;
             continue;
@@ -2169,7 +2169,7 @@ void ChangeDisplayMoneyInfo()
         isPass = true;
         isPass = true;
         for (uint8_t _index = 0; _index < _totalCount; _index++) {
         for (uint8_t _index = 0; _index < _totalCount; _index++) {
             if (!FindChargingInfoData(_index, &_chargingInfoData[0])) {
             if (!FindChargingInfoData(_index, &_chargingInfoData[0])) {
-                log_error("LcmComm (main) : FindChargingInfoData false \n");
+                log_error("LcmComm (main) : FindChargingInfoData false ");
                 isPass = false;
                 isPass = false;
                 count--;
                 count--;
                 break;
                 break;
@@ -2186,7 +2186,7 @@ void ChangeDisplayMoneyInfo()
             isPass = true;
             isPass = true;
             for (uint8_t _index = 0; _index < acgunCount; _index++) {
             for (uint8_t _index = 0; _index < acgunCount; _index++) {
                 if (!FindAcChargingInfoData(_index, &ac_chargingInfo[0])) {
                 if (!FindAcChargingInfoData(_index, &ac_chargingInfo[0])) {
-                    log_error("LcmComm : FindAcChargingInfoData false \n");
+                    log_error("LcmComm : FindAcChargingInfoData false ");
                     isPass = false;
                     isPass = false;
                     break;
                     break;
                 }
                 }
@@ -2197,7 +2197,7 @@ void ChangeDisplayMoneyInfo()
     }
     }
 
 
     if (count == 0) {
     if (count == 0) {
-        log_info("LCM Initialization Gun Fail.............\n");
+        log_info("LCM Initialization Gun Fail.............");
     }
     }
 }
 }
 */
 */
@@ -2220,7 +2220,7 @@ int main(void)
 {
 {
 
 
     //if (InitShareMemory() == FAIL) {
     //if (InitShareMemory() == FAIL) {
-    //    log_error("InitShareMemory NG\n");
+    //    log_error("InitShareMemory NG");
     //
     //
     //    if (ShmStatusCodeData != NULL) {
     //    if (ShmStatusCodeData != NULL) {
     //        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
     //        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
@@ -2230,7 +2230,7 @@ int main(void)
     //}
     //}
 
 
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -2242,6 +2242,8 @@ int main(void)
     ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();;
     ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();;
     ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
     ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
     ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
     ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
+    struct StatusCodeData *ShmStatusCodeData = (struct StatusCodeData *)GetShmStatusCodeData();;
+ 
 
 
     _port = CreateCommunicationLcmPort();
     _port = CreateCommunicationLcmPort();
     uint8_t changeWarningPriority = 0;
     uint8_t changeWarningPriority = 0;
@@ -2251,7 +2253,7 @@ int main(void)
     acgunCount = pSysConfig->AcConnectorCount;
     acgunCount = pSysConfig->AcConnectorCount;
     //Initialization();
     //Initialization();
 
 
-    //printf("_LCM_COMPLETE \r\n");
+    //printf("_LCM_COMPLETE ");
     //ChangeToOtherPage(_LCM_COMPLETE);
     //ChangeToOtherPage(_LCM_COMPLETE);
     //return 0;
     //return 0;
 
 
@@ -2265,8 +2267,15 @@ int main(void)
         if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
         if (strcmp((char *)pSysInfo->LcmHwRev, moduleName) != 0x00) {
             GetCurrentPage();
             GetCurrentPage();
             sleep(1);
             sleep(1);
+#ifndef DD360ComBox
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
+#endif
+
         } else {
         } else {
             //DemoFunction();
             //DemoFunction();
+#ifndef DD360ComBox
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = false;
+#endif
 
 
             // Warning 處理
             // Warning 處理
             if (curWarningCount != pSysWarning->WarningCount) {
             if (curWarningCount != pSysWarning->WarningCount) {
@@ -2312,6 +2321,10 @@ int main(void)
         }
         }
     }
     }
 
 
+#ifndef DD360ComBox
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LcmModuleCommFail = true;
+#endif
+    log_info("Close LCM Uart Port");
     CloseCommunicationLcmPort();
     CloseCommunicationLcmPort();
 
 
     return FAIL;
     return FAIL;

+ 25 - 25
EVSE/Projects/DD360Audi/Apps/ModulePrimary/Module_PrimaryComm.c

@@ -76,7 +76,7 @@ uint8_t Door_flag = 0;
     if (pSysConfig->SwitchDebugFlag == YES) {
     if (pSysConfig->SwitchDebugFlag == YES) {
         sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
         sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
                 tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
                 tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
-        printf("%s \n", Buf);
+        printf("%s ", Buf);
     } else {
     } else {
         sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
         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,
                 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
@@ -164,13 +164,13 @@ void GetFwAndHwVersion(int fd)
     Ver ver = {0};
     Ver ver = {0};
 
 
     if (Query_FW_Ver(fd, OP_ADDR_IO_EXTEND, &ver) == PASS) {
     if (Query_FW_Ver(fd, OP_ADDR_IO_EXTEND, &ver) == PASS) {
-        //log_info("Primary FW Rev = %s \n", ver.Version_FW);
+        //log_info("Primary FW Rev = %s ", ver.Version_FW);
         strcpy((char *)ShmPrimaryMcuData->version, ver.Version_FW);
         strcpy((char *)ShmPrimaryMcuData->version, ver.Version_FW);
         strcpy((char *) pSysInfo->CsuPrimFwRev, ver.Version_FW);
         strcpy((char *) pSysInfo->CsuPrimFwRev, ver.Version_FW);
     }
     }
 
 
     //if (Query_HW_Ver(fd, OP_ADDR_IO_EXTEND, &ver) == PASS)
     //if (Query_HW_Ver(fd, OP_ADDR_IO_EXTEND, &ver) == PASS)
-    //    ;//log_info("Primary HW Rev  = %s \n", ver.Version_HW);
+    //    ;//log_info("Primary HW Rev  = %s ", ver.Version_HW);
 }
 }
 
 
 void GetInputGpioStatus(int fd)
 void GetInputGpioStatus(int fd)
@@ -179,7 +179,7 @@ void GetInputGpioStatus(int fd)
     Gpio_in gpio_in = {0};
     Gpio_in gpio_in = {0};
     static uint8_t dispenserSw = 0;
     static uint8_t dispenserSw = 0;
 
 
-    //log_info("GetInputGpioStatus \n");
+    //log_info("GetInputGpioStatus ");
     if (Query_Gpio_Input(fd, OP_ADDR_IO_EXTEND, &gpio_in) != PASS) {
     if (Query_Gpio_Input(fd, OP_ADDR_IO_EXTEND, &gpio_in) != PASS) {
         return;
         return;
     }
     }
@@ -212,7 +212,7 @@ void GetInputGpioStatus(int fd)
 
 
     if (dispenserSwTmp != dispenserSw) {
     if (dispenserSwTmp != dispenserSw) {
         dispenserSw = dispenserSwTmp;
         dispenserSw = dispenserSwTmp;
-        log_info("Dispenser switch number =  %d, bit = %d, %d, %d, %d\r\n",
+        log_info("Dispenser switch number =  %d, bit = %d, %d, %d, %d",
                  dispenserSw,
                  dispenserSw,
                  ShmPrimaryMcuData->InputDet.bits.Key3,
                  ShmPrimaryMcuData->InputDet.bits.Key3,
                  ShmPrimaryMcuData->InputDet.bits.Key2,
                  ShmPrimaryMcuData->InputDet.bits.Key2,
@@ -256,9 +256,9 @@ void GetInputGpioStatus(int fd)
 #endif 
 #endif 
     ShmPrimaryMcuData->InputDet.bits.DoorOpen = Door_flag;
     ShmPrimaryMcuData->InputDet.bits.DoorOpen = Door_flag;
 /*
 /*
-    log_info("Emergency Button Count = %d , Emergency flag = %d\n",
+    log_info("Emergency Button Count = %d , Emergency flag = %d",
             EmgBtn_count,EmgBtn_flag);
             EmgBtn_count,EmgBtn_flag);
-    log_info("Door Sensor Count = %d , Door Sensor flag = %d\n",
+    log_info("Door Sensor Count = %d , Door Sensor flag = %d",
             Door_count,Door_flag);
             Door_count,Door_flag);
 */
 */
 
 
@@ -306,17 +306,17 @@ void GetInputGpioStatus(int fd)
     ShmPrimaryMcuData->InputDet.bits.Key3 = gpio_in.Key[3] & 0x01;
     ShmPrimaryMcuData->InputDet.bits.Key3 = gpio_in.Key[3] & 0x01;
     ShmPrimaryMcuData->InputDet.bits.DoorOpen = gpio_in.Door_Open;
     ShmPrimaryMcuData->InputDet.bits.DoorOpen = gpio_in.Door_Open;
 
 
-    /*printf(" gpio_in.Key[0]~ gpio_in.Key[3]=%d, %d, %d, %d\n",
+    /*printf(" gpio_in.Key[0]~ gpio_in.Key[3]=%d, %d, %d, %d",
     ShmPrimaryMcuData->InputDet.bits.Key0 , ShmPrimaryMcuData->InputDet.bits.Key1,
     ShmPrimaryMcuData->InputDet.bits.Key0 , ShmPrimaryMcuData->InputDet.bits.Key1,
     ShmPrimaryMcuData->InputDet.bits.Key2,ShmPrimaryMcuData->InputDet.bits.Key3);
     ShmPrimaryMcuData->InputDet.bits.Key2,ShmPrimaryMcuData->InputDet.bits.Key3);
-    printf("pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning=%d\n", pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning);
-    printf("pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault=%d\n", pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault);
+    printf("pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning=%d", pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning);
+    printf("pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault=%d", pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault);
     */
     */
-    //log_info("left = %d \n", ShmPrimaryMcuData->InputDet.bits.Button1);
-    //log_info("right = %d \n", ShmPrimaryMcuData->InputDet.bits.Button2);
-    //log_info("pSysInfo->AcContactorStatus = %d \n", pSysInfo->AcContactorStatus);
+    //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) {
     if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == YES) {
-        log_error("AC Mainbreaker occur. \n");
+        log_error("AC Mainbreaker occur. ");
     }
     }
 }
 }
 
 
@@ -404,7 +404,7 @@ static void checkChillerStatus(Gpio_out *gpio)
 
 
     if(_chiller.ChillerSwitch != _chillerNeedOn)
     if(_chiller.ChillerSwitch != _chillerNeedOn)
     {
     {
-        log_info("Chiller Need Turn %s\n", _chillerNeedOn == YES ? "ON" : "OFF");
+        log_info("Chiller Need Turn %s", _chillerNeedOn == YES ? "ON" : "OFF");
     }
     }
     _chiller.ChillerSwitch = _chillerNeedOn;
     _chiller.ChillerSwitch = _chillerNeedOn;
     pGpio->AC_Connector = _chiller.ChillerSwitch;//Chiller ON/OFF Control, "0: Chiller disable, 1: Chiller enable"
     pGpio->AC_Connector = _chiller.ChillerSwitch;//Chiller ON/OFF Control, "0: Chiller disable, 1: Chiller enable"
@@ -454,7 +454,7 @@ void SetRtcData(int fd)
 
 
     ftime(&csuTime);
     ftime(&csuTime);
     tmCSU = localtime(&csuTime.time);
     tmCSU = localtime(&csuTime.time);
-    //log_info("Time : %04d-%02d-%02d %02d:%02d:%02d \n",
+    //log_info("Time : %04d-%02d-%02d %02d:%02d:%02d ",
     //         tmCSU->tm_year + 1900,
     //         tmCSU->tm_year + 1900,
     //         tmCSU->tm_mon + 1,
     //         tmCSU->tm_mon + 1,
     //         tmCSU->tm_mday,
     //         tmCSU->tm_mday,
@@ -483,9 +483,9 @@ void SetRtcData(int fd)
     rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
     rtc.RtcData[13] = '0' + (tmCSU->tm_sec) / 1 % 10;
 
 
     if (Config_Rtc_Data(fd, OP_ADDR_IO_EXTEND, &rtc) == PASS) {
     if (Config_Rtc_Data(fd, OP_ADDR_IO_EXTEND, &rtc) == PASS) {
-        //log_info("SetRtc sucessfully. \n");
+        //log_info("SetRtc sucessfully. ");
     } else {
     } else {
-        //log_info("SetRtc fail. \n");
+        //log_info("SetRtc fail. ");
     }
     }
 }
 }
 
 
@@ -506,7 +506,7 @@ int InitComPort()
     fd = open(priPortName, O_RDWR);
     fd = open(priPortName, O_RDWR);
     if (fd <= 0) {
     if (fd <= 0) {
 #ifdef SystemLogMessage
 #ifdef SystemLogMessage
-        log_error("open 407 Communication port NG \n");
+        log_error("open 407 Communication port NG ");
 #endif
 #endif
         return -1;
         return -1;
     }
     }
@@ -565,7 +565,7 @@ unsigned long GetTimeoutValue(struct timeval _sour_time)
 //        isPass = true;
 //        isPass = true;
 //        for (uint8_t _index = 0; _index < gun_count; _index++) {
 //        for (uint8_t _index = 0; _index < gun_count; _index++) {
 //            if (!FindChargingInfoData(_index, &ChargingData[0])) {
 //            if (!FindChargingInfoData(_index, &ChargingData[0])) {
-//                log_error("EvComm (main) : FindChargingInfoData false \n");
+//                log_error("EvComm (main) : FindChargingInfoData false ");
 //                isPass = false;
 //                isPass = false;
 //                break;
 //                break;
 //            }
 //            }
@@ -590,7 +590,7 @@ static bool IsPrimaryProcessNeedPause(void)
     }
     }
     if(isPause != _pause)
     if(isPause != _pause)
     {
     {
-        log_info("Primary Process Now Is %s \n", _pause == true ? "Paused" : "Continued");
+        log_info("Primary Process Now Is %s ", _pause == true ? "Paused" : "Continued");
     }
     }
     isPause = _pause;
     isPause = _pause;
 
 
@@ -602,7 +602,7 @@ int main(void)
     int Uart1Fd = -1;
     int Uart1Fd = -1;
 
 
     //if (InitShareMemory() == FAIL) {
     //if (InitShareMemory() == FAIL) {
-    //    log_error("InitShareMemory NG\r\n");
+    //    log_error("InitShareMemory NG");
     //    if (ShmStatusCodeData != NULL) {
     //    if (ShmStatusCodeData != NULL) {
     //        pAlarmCode->AlarmEvents.bits.FailToCreateShareMemory = 1;
     //        pAlarmCode->AlarmEvents.bits.FailToCreateShareMemory = 1;
     //    }
     //    }
@@ -611,7 +611,7 @@ int main(void)
     //}
     //}
 
 
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -624,7 +624,7 @@ int main(void)
     ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
     ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
 
 
     Uart1Fd = InitComPort();
     Uart1Fd = InitComPort();
-    //log_info("407 Port id = %d \n", Uart1Fd);
+    //log_info("407 Port id = %d ", Uart1Fd);
 
 
     if (Uart1Fd < 0) {
     if (Uart1Fd < 0) {
         log_error("InitComPort (Uart1 : AM3352 - STM32) NG");
         log_error("InitComPort (Uart1 : AM3352 - STM32) NG");
@@ -653,7 +653,7 @@ int main(void)
         // 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
         // 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
         // 模組更新 FW 後,需重新做
         // 模組更新 FW 後,需重新做
         if (ShmPrimaryMcuData->SelfTest_Comp != PASS) {
         if (ShmPrimaryMcuData->SelfTest_Comp != PASS) {
-            //log_info("(407) Get Fw and Hw Ver. \n");
+            //log_info("(407) Get Fw and Hw Ver. ");
             GetFwAndHwVersion(Uart1Fd);
             GetFwAndHwVersion(Uart1Fd);
             sleep(1);
             sleep(1);
             ShmPrimaryMcuData->SelfTest_Comp = PASS;
             ShmPrimaryMcuData->SelfTest_Comp = PASS;

+ 25 - 24
EVSE/Projects/DD360Audi/Apps/ModuleUpdateFW/Module_UpdateFW.c

@@ -80,6 +80,8 @@ void setChargerMode(uint8_t gunIndex, uint8_t mode)
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
     pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
 
 
     pDcChargingInfo->SystemStatus = mode;
     pDcChargingInfo->SystemStatus = mode;
+
+    log_info(" ====== System Status:%d ======",mode);
 }
 }
 void TryCloseWatchdog()
 void TryCloseWatchdog()
 {
 {
@@ -101,7 +103,7 @@ static int InitComPort(uint8_t target)
     }
     }
 
 
     if (fd <= 0) {
     if (fd <= 0) {
-        log_error("open 407 Communication port NG \n");
+        log_error("open 407 Communication port NG ");
         return -1;
         return -1;
     }
     }
 
 
@@ -215,7 +217,7 @@ static int CheckUpdateProcess(void)
             //new_str[0] = '\0';
             //new_str[0] = '\0';
             strcat(new_str, "/mnt/");
             strcat(new_str, "/mnt/");
             strcat(new_str, dir->d_name);
             strcat(new_str, dir->d_name);
-            log_info("%s%s\r\n", "/mnt/", dir->d_name);
+            log_info("%s%s", "/mnt/", dir->d_name);
             
             
             fd = open(new_str, O_RDONLY);
             fd = open(new_str, O_RDONLY);
             if (fd < 0) {
             if (fd < 0) {
@@ -233,13 +235,13 @@ static int CheckUpdateProcess(void)
                 }
                 }
             }
             }
 
 
-            log_info("model name check pass. \n");
+            log_info("model name check pass. ");
             if (ImageLen > 20) {
             if (ImageLen > 20) {
                 Type = (((unsigned int)ptr[16]) << 24 |
                 Type = (((unsigned int)ptr[16]) << 24 |
                         ((unsigned int)ptr[17]) << 16 |
                         ((unsigned int)ptr[17]) << 16 |
                         ((unsigned int)ptr[18]) << 8  |
                         ((unsigned int)ptr[18]) << 8  |
                         ((unsigned int)ptr[19]));
                         ((unsigned int)ptr[19]));
-                log_info("Typed...%x \r\n", Type);
+                log_info("Typed...%x ", Type);
 
 
                 switch (Type) {
                 switch (Type) {
                 case 0x10000001:
                 case 0x10000001:
@@ -251,7 +253,7 @@ static int CheckUpdateProcess(void)
                         //return PASS;
                         //return PASS;
                         retSucc++;
                         retSucc++;
                     } else {
                     } else {
-                        log_info("Upgrade %x Failed\r\n", Type);
+                        log_info("Upgrade %x Failed", Type);
                         //return FAIL;
                         //return FAIL;
                         retFail++;
                         retFail++;
                     }
                     }
@@ -265,7 +267,6 @@ static int CheckUpdateProcess(void)
                     if (CanFd > 0) {
                     if (CanFd > 0) {
                         for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
                         for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
                             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
                             pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
-
                             if (pDcChargingInfo->Type == _Type_CCS_2) {
                             if (pDcChargingInfo->Type == _Type_CCS_2) {
                                 uint8_t targetID = pDcChargingInfo->Evboard_id;
                                 uint8_t targetID = pDcChargingInfo->Evboard_id;
 
 
@@ -276,13 +277,13 @@ static int CheckUpdateProcess(void)
 
 
                                 system("echo 3 > /proc/sys/vm/drop_caches");
                                 system("echo 3 > /proc/sys/vm/drop_caches");
                                 sleep(2);
                                 sleep(2);
-                                log_info("Upgrade CCS Processing..target id = %d \n", targetID);
+                                log_info("Upgrade CCS Processing..target id = %d ", targetID);
                                 if (Upgrade_CCS(CanFd,
                                 if (Upgrade_CCS(CanFd,
                                                 Type,
                                                 Type,
                                                 targetID,
                                                 targetID,
                                                 new_str,
                                                 new_str,
                                                 (char *)pSysConfig->ModelName) == FAIL) {
                                                 (char *)pSysConfig->ModelName) == FAIL) {
-                                    log_info("Upgrade CCS Failed \n");
+                                    log_info("Upgrade CCS Failed ");
                                     retFail++;
                                     retFail++;
                                 } else {
                                 } else {
                                     retSucc++;
                                     retSucc++;
@@ -305,13 +306,13 @@ static int CheckUpdateProcess(void)
                             if (chargingInfo[index]->Type == _Type_CCS_2) {
                             if (chargingInfo[index]->Type == _Type_CCS_2) {
                                 if (Upgrade_CCS(CanFd, Type, chargingInfo[index]->Evboard_id, new_str, (char *)pSysConfig->ModelName) == FAIL) {
                                 if (Upgrade_CCS(CanFd, Type, chargingInfo[index]->Evboard_id, new_str, (char *)pSysConfig->ModelName) == FAIL) {
                                     //isPass = false;
                                     //isPass = false;
-                                    log_info("Upgrade %x Failed\r\n", Type);
+                                    log_info("Upgrade %x Failed", Type);
                                     retFail++;
                                     retFail++;
                                 }
                                 }
                             }
                             }
                         }
                         }
                     } else {
                     } else {
-                        log_error("Upgrade CCS open CAN FD fail.\n");
+                        log_error("Upgrade CCS open CAN FD fail.");
                         //isPass = false;
                         //isPass = false;
                         return FAIL;
                         return FAIL;
                     }
                     }
@@ -351,7 +352,7 @@ static int CheckUpdateProcess(void)
                         //return PASS;
                         //return PASS;
                         retSucc++;
                         retSucc++;
                     } else {
                     } else {
-                        log_info("Upgrade %x Failed\r\n", Type);
+                        log_info("Upgrade %x Failed", Type);
                         //return FAIL;
                         //return FAIL;
                         return FAIL;
                         return FAIL;
                     }
                     }
@@ -380,14 +381,14 @@ static int CheckUpdateProcess(void)
                                     //isPass = PASS;
                                     //isPass = PASS;
                                     retSucc++;
                                     retSucc++;
                                 } else {
                                 } else {
-                                    log_info("Upgrade %x Failed\r\n", Type);
+                                    log_info("Upgrade %x Failed", Type);
                                     //isPass = FAIL;
                                     //isPass = FAIL;
                                     retFail++;
                                     retFail++;
                                 }
                                 }
                             }
                             }
                         }
                         }
                     } else {
                     } else {
-                        log_info("Upgrad FD fail. \n");
+                        log_info("Upgrad FD fail. ");
                         //isPass = false;
                         //isPass = false;
                         return FAIL;
                         return FAIL;
                     }
                     }
@@ -412,11 +413,11 @@ static int CheckUpdateProcess(void)
 
 
 void CheckFwUpdateFunction(void)
 void CheckFwUpdateFunction(void)
 {
 {
-    //log_info("pSysInfo->FirmwareUpdate = %d \n", pSysInfo->FirmwareUpdate);
+    //log_info("pSysInfo->FirmwareUpdate = %d ", pSysInfo->FirmwareUpdate);
     if (pSysInfo->FirmwareUpdate == YES) {
     if (pSysInfo->FirmwareUpdate == YES) {
-        log_info("ftp : update start. \n");
+        log_info("ftp : update start. ");
         TryCloseWatchdog();
         TryCloseWatchdog();
-
+        pSysInfo->SystemPage = _LCM_FIX;
         for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
         for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
             setChargerMode(gun_index, MODE_UPDATE);
             setChargerMode(gun_index, MODE_UPDATE);
         }
         }
@@ -424,16 +425,16 @@ void CheckFwUpdateFunction(void)
         uint8_t updateResult = CheckUpdateProcess();
         uint8_t updateResult = CheckUpdateProcess();
 
 
         if (updateResult == PASS) {
         if (updateResult == PASS) {
-            log_info("ftp : update complete. \n");
+            log_info("ftp : update complete. ");
         } else if (updateResult == MODELNAME_FAIL) {
         } else if (updateResult == MODELNAME_FAIL) {
-            log_info("ftp : model name is none match. \n");
+            log_info("ftp : model name is none match. ");
             KillAllTask();
             KillAllTask();
             pSysInfo->FirmwareUpdate = NO;
             pSysInfo->FirmwareUpdate = NO;
             sleep(5);
             sleep(5);
             system("/usr/bin/run_evse_restart.sh");
             system("/usr/bin/run_evse_restart.sh");
             return;
             return;
         } else {
         } else {
-            log_info("ftp : update fail. \n");
+            log_info("ftp : update fail. ");
         }
         }
 
 
         pSysInfo->FirmwareUpdate = NO;
         pSysInfo->FirmwareUpdate = NO;
@@ -443,7 +444,7 @@ void CheckFwUpdateFunction(void)
         ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = NO;
         ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = NO;
 
 
         if (strcmp((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Downloaded") == EQUAL) {
         if (strcmp((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Downloaded") == EQUAL) {
-            log_info("Backend : update start. \n");
+            log_info("Backend : update start. ");
             TryCloseWatchdog();
             TryCloseWatchdog();
             strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "");
             strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "");
             strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installing");
             strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installing");
@@ -464,10 +465,10 @@ void CheckFwUpdateFunction(void)
             uint8_t updateResult = CheckUpdateProcess();
             uint8_t updateResult = CheckUpdateProcess();
 
 
             if (updateResult == PASS) {
             if (updateResult == PASS) {
-                log_info("Backend : update complete. \n");
+                log_info("Backend : update complete. ");
                 strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
                 strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
             } else if (updateResult == MODELNAME_FAIL) {
             } else if (updateResult == MODELNAME_FAIL) {
-                log_info("Backend : model name is none match. \n");
+                log_info("Backend : model name is none match. ");
                 KillAllTask();
                 KillAllTask();
                 strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
                 strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
                 ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
                 ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
@@ -475,7 +476,7 @@ void CheckFwUpdateFunction(void)
                 system("/usr/bin/run_evse_restart.sh");
                 system("/usr/bin/run_evse_restart.sh");
                 return;
                 return;
             } else {
             } else {
-                log_info("Backend : update fail. \n");
+                log_info("Backend : update fail. ");
                 strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
                 strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
             }
             }
 
 
@@ -490,7 +491,7 @@ void CheckFwUpdateFunction(void)
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
     if (CreateAllCsuShareMemory() == FAIL) {
     if (CreateAllCsuShareMemory() == FAIL) {
-        log_error("create share memory error\r\n");
+        log_error("create share memory error");
         return FAIL;
         return FAIL;
     }
     }
     
     

+ 1 - 0
EVSE/Projects/DD360Audi/Apps/Script/kill.sh

@@ -14,6 +14,7 @@ pkill Module_ProduceUtils;
 pkill Module_DoComm;
 pkill Module_DoComm;
 pkill main;
 pkill main;
 
 
+/usr/bin/fuser -k /dev/watchdog
 sleep 1
 sleep 1
 
 
 echo V > /dev/watchdog
 echo V > /dev/watchdog

+ 9 - 9
EVSE/Projects/DD360Audi/Apps/SelectGun/SelectGun.c

@@ -49,7 +49,7 @@ void destroySelGun(uint8_t curGun)
     if (curGun == DESTROY_ALL_SEL) {
     if (curGun == DESTROY_ALL_SEL) {
         pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_RELEASE;
         pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_RELEASE;
         pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_RELEASE;
         pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_RELEASE;
-        log_info("destroy all gun = %d, %d\r\n",
+        log_info("destroy all gun = %d, %d",
                  pSelectGunInfo->SelGunInfo.LeftGun,
                  pSelectGunInfo->SelGunInfo.LeftGun,
                  pSelectGunInfo->SelGunInfo.RightGun);
                  pSelectGunInfo->SelGunInfo.RightGun);
         for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
         for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
@@ -74,9 +74,9 @@ void destroySelGun(uint8_t curGun)
             ClearAuthorizedFlag();
             ClearAuthorizedFlag();
         }
         }
 
 
-        log_info("destroy left gun, cur page = %d\r\n", pSysInfo->SystemPage);
+        log_info("destroy left gun, cur page = %d", pSysInfo->SystemPage);
         //if (pSysInfo->SystemPage == pSysInfo->SystemPage) {
         //if (pSysInfo->SystemPage == pSysInfo->SystemPage) {
-        log_info("clear left balance\r\n");
+        log_info("clear left balance");
         memset(&pSelectGunInfo->PricesInfo[curGun], 0, sizeof(PricesInfo));
         memset(&pSelectGunInfo->PricesInfo[curGun], 0, sizeof(PricesInfo));
         pSelectGunInfo->PricesInfo[curGun].Balance = FAIL_BALANCE_PRICES;
         pSelectGunInfo->PricesInfo[curGun].Balance = FAIL_BALANCE_PRICES;
         //}
         //}
@@ -93,9 +93,9 @@ void destroySelGun(uint8_t curGun)
             ClearAuthorizedFlag();
             ClearAuthorizedFlag();
         }
         }
 
 
-        log_info("destroy right gun, cur page = %d\r\n", pSysInfo->SystemPage);
+        log_info("destroy right gun, cur page = %d", pSysInfo->SystemPage);
         //if (pSysInfo->SystemPage == pSysInfo->SystemPage) {
         //if (pSysInfo->SystemPage == pSysInfo->SystemPage) {
-        log_info("clear right balance\r\n");
+        log_info("clear right balance");
         memset(&pSelectGunInfo->PricesInfo[curGun], 0, sizeof(PricesInfo));
         memset(&pSelectGunInfo->PricesInfo[curGun], 0, sizeof(PricesInfo));
         pSelectGunInfo->PricesInfo[curGun].Balance = FAIL_BALANCE_PRICES;
         pSelectGunInfo->PricesInfo[curGun].Balance = FAIL_BALANCE_PRICES;
         //}
         //}
@@ -143,11 +143,11 @@ void setSelGunWaitToAuthor(uint8_t curSel)
 
 
     if (curSel == LEFT_GUN_NUM && pSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM) {
     if (curSel == LEFT_GUN_NUM && pSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM) {
         pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_ATHOR;
         pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_ATHOR;
-        //printf("setSelGunWaitToAuthor left\r\n");
+        //printf("setSelGunWaitToAuthor left");
         StopGunInfoTimeoutDet(curSel);
         StopGunInfoTimeoutDet(curSel);
     } else if (curSel == RIGHT_GUN_NUM && pSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM) {
     } else if (curSel == RIGHT_GUN_NUM && pSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM) {
         pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_ATHOR;
         pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_ATHOR;
-        //printf("setSelGunWaitToAuthor right\r\n");
+        //printf("setSelGunWaitToAuthor right");
         StopGunInfoTimeoutDet(curSel);
         StopGunInfoTimeoutDet(curSel);
     }
     }
 }
 }
@@ -180,11 +180,11 @@ void confirmSelGun(uint8_t selGun)
     if (selGun == LEFT_GUN_NUM) {
     if (selGun == LEFT_GUN_NUM) {
         pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
         pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
         StopGunInfoTimeoutDet(selGun);
         StopGunInfoTimeoutDet(selGun);
-        //printf("confirmSelGun left\r\n");
+        //printf("confirmSelGun left");
     } else if (selGun == RIGHT_GUN_NUM) {
     } else if (selGun == RIGHT_GUN_NUM) {
         pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
         pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
         StopGunInfoTimeoutDet(selGun);
         StopGunInfoTimeoutDet(selGun);
-        //printf("confirmSelGun right\r\n");
+        //printf("confirmSelGun right");
     }
     }
 
 
     pSysInfo->SystemPage = _LCM_IDLE;
     pSysInfo->SystemPage = _LCM_IDLE;

+ 16 - 16
EVSE/Projects/DD360Audi/Apps/ShareMemory/shmMem.c

@@ -93,7 +93,7 @@ static int findChargingInfoData(uint8_t target, struct ChargingInfoData **chargi
 
 
     for (i = 0; i < CCS_QUANTITY; i++) {
     for (i = 0; i < CCS_QUANTITY; i++) {
         if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[i].Index == target) {
         if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[i].Index == target) {
-            log_info("Index = %d, %d\r\n", target, ShmSysConfigAndInfo->SysInfo.CcsChargingData[i].Index);
+            log_info("Index = %d, %d", target, ShmSysConfigAndInfo->SysInfo.CcsChargingData[i].Index);
             chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[i];
             chargingData[target] = &ShmSysConfigAndInfo->SysInfo.CcsChargingData[i];
             return PASS;
             return PASS;
         }
         }
@@ -117,7 +117,7 @@ void MappingChargingInfoData(void) //DS60-120 add
     while (isPass) {
     while (isPass) {
         for (i = 0; i < 2; i++) {
         for (i = 0; i < 2; i++) {
             if (!findChargingInfoData(i, &DcChargingData[0])) {
             if (!findChargingInfoData(i, &DcChargingData[0])) {
-                log_error("Find ChargingInfoData failed\r\n");
+                log_error("Find ChargingInfoData failed");
                 isPass = false;
                 isPass = false;
                 break;
                 break;
             }
             }
@@ -594,10 +594,10 @@ int InitOCPPShmMem(void)
     int MeterSMId = FAIL;
     int MeterSMId = FAIL;
 
 
     if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), IPC_CREAT | 0777)) < 0) {
     if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), IPC_CREAT | 0777)) < 0) {
-        log_info("Get OCPP share memory error\r\n");
+        log_info("Get OCPP share memory error");
         return FAIL;
         return FAIL;
     } else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
     } else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
-        log_info("Create OCPP share memory error\r\n");
+        log_info("Create OCPP share memory error");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -726,10 +726,10 @@ int InitSysConfigAndInfoShmMem(void)
     int MeterSMId = FAIL;
     int MeterSMId = FAIL;
 
 
     if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), IPC_CREAT | 0777)) < 0) {
     if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), IPC_CREAT | 0777)) < 0) {
-        printf("1 InitSysConfigAndInfoShmMem\r\n");
+        printf("1 InitSysConfigAndInfoShmMem");
         return FAIL;
         return FAIL;
     } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0))  == (void *) - 1) {
     } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0))  == (void *) - 1) {
-        printf("2 InitSysConfigAndInfoShmMem\r\n");
+        printf("2 InitSysConfigAndInfoShmMem");
         return FAIL;
         return FAIL;
     }
     }
 
 
@@ -802,20 +802,20 @@ static int findDcChargingInfoData(uint8_t gunIndex)
     uint8_t i = 0;
     uint8_t i = 0;
     struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
     struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
 
 
-    //printf("Chademo count = %d\r\n", gGunIndexInfo.ChademoIndex);
+    //printf("Chademo count = %d\n", gGunIndexInfo.ChademoIndex);
     for (i = 0; i < gGunIndexInfo.DcGunIndex; i++) {
     for (i = 0; i < gGunIndexInfo.DcGunIndex; i++) {
         if (pSysInfo->ChademoChargingData[i].Index == gunIndex) {
         if (pSysInfo->ChademoChargingData[i].Index == gunIndex) {
-            //printf("chademo index = %d, %d\r\n", pSysInfo->ChademoChargingData[i].Index, gunIndex);
+            //printf("chademo index = %d, %d\n", pSysInfo->ChademoChargingData[i].Index, gunIndex);
             //dcChargingData[gunIndex] = &pSysInfo->ChademoChargingData[i];
             //dcChargingData[gunIndex] = &pSysInfo->ChademoChargingData[i];
             SetDcChargingInfoData(pSysInfo->ChademoChargingData[i].Index, &pSysInfo->ChademoChargingData[i]);
             SetDcChargingInfoData(pSysInfo->ChademoChargingData[i].Index, &pSysInfo->ChademoChargingData[i]);
             return PASS;
             return PASS;
         }
         }
     }
     }
 
 
-    //printf("ccs count = %d\r\n", gGunIndexInfo.CcsIndex);
+    //printf("ccs count = %d\n", gGunIndexInfo.CcsIndex);
     for (i = 0; i < gGunIndexInfo.DcGunIndex; i++) {
     for (i = 0; i < gGunIndexInfo.DcGunIndex; i++) {
         if (pSysInfo->CcsChargingData[i].Index == gunIndex) {
         if (pSysInfo->CcsChargingData[i].Index == gunIndex) {
-            //printf("ccs index = %d, %d\r\n", pSysInfo->CcsChargingData[i].Index, gunIndex);
+            //printf("ccs index = %d, %d\n", pSysInfo->CcsChargingData[i].Index, gunIndex);
             //dcChargingData[gunIndex] = (struct ChargingInfoData *)&pSysInfo->CcsChargingData[i];
             //dcChargingData[gunIndex] = (struct ChargingInfoData *)&pSysInfo->CcsChargingData[i];
             SetDcChargingInfoData(pSysInfo->CcsChargingData[i].Index, &pSysInfo->CcsChargingData[i]);
             SetDcChargingInfoData(pSysInfo->CcsChargingData[i].Index, &pSysInfo->CcsChargingData[i]);
             return PASS;
             return PASS;
@@ -987,23 +987,23 @@ bool MappingGunChargingInfo(char *whichTask)
     struct ChargingInfoData *pAcChargingInfo = NULL;
     struct ChargingInfoData *pAcChargingInfo = NULL;
 
 
     if (ShmSysConfigAndInfo == NULL) {
     if (ShmSysConfigAndInfo == NULL) {
-        log_error("ShmSysConfigAndInfo failed\r\n");
+        log_error("ShmSysConfigAndInfo failed");
         return false;
         return false;
     }
     }
 
 
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
     pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
 
 
     if (strlen((char *)pSysConfig->ModelName) < 9) {
     if (strlen((char *)pSysConfig->ModelName) < 9) {
-        log_error("Module name length < 9 get %s\r\n", (char *)pSysConfig->ModelName);
+        log_error("Module name length < 9 get %s", (char *)pSysConfig->ModelName);
         return false;
         return false;
     }
     }
 
 
     ShmDcCommonData->ChillerValve.MultiChillerGun = 0;
     ShmDcCommonData->ChillerValve.MultiChillerGun = 0;
 
 
-    //printf("1 CheckConnectorTypeStatus\r\n");
+    //printf("1 CheckConnectorTypeStatus\n");
     for (typeIndex = 7; typeIndex <= 9; typeIndex++) {
     for (typeIndex = 7; typeIndex <= 9; typeIndex++) {
         if (!addGunInfoByConnector(pSysConfig->ModelName[typeIndex], slots, whichTask)) {
         if (!addGunInfoByConnector(pSysConfig->ModelName[typeIndex], slots, whichTask)) {
-            log_error("%s add gun info failed\r\n", whichTask);
+            log_error("%s add gun info failed", whichTask);
             return false;
             return false;
         }
         }
 
 
@@ -1019,7 +1019,7 @@ bool MappingGunChargingInfo(char *whichTask)
     if (ShmDcCommonData->ChillerValve.MultiChillerGun != 0) {
     if (ShmDcCommonData->ChillerValve.MultiChillerGun != 0) {
         ShmDcCommonData->ChillerValve.MultiChillerGun |= 0x80; //有水冷槍標記
         ShmDcCommonData->ChillerValve.MultiChillerGun |= 0x80; //有水冷槍標記
         if (strncmp(whichTask, "CSU Task", 8) == EQUAL) {
         if (strncmp(whichTask, "CSU Task", 8) == EQUAL) {
-            log_info("get chiller gun = %x, chiller gun count = %d\r\n",
+            log_info("get chiller gun = %x, chiller gun count = %d",
                      (ShmDcCommonData->ChillerValve.MultiChillerGun & 0x80) >> 7,
                      (ShmDcCommonData->ChillerValve.MultiChillerGun & 0x80) >> 7,
                      ShmDcCommonData->ChillerValve.MultiChillerGun & 0x7F);
                      ShmDcCommonData->ChillerValve.MultiChillerGun & 0x7F);
         }
         }
@@ -1049,7 +1049,7 @@ bool MappingGunChargingInfo(char *whichTask)
 
 
     //log_info("Type 0~3 = CHAdeMO, CCS, GB, AC");
     //log_info("Type 0~3 = CHAdeMO, CCS, GB, AC");
     if (pSysConfig->TotalConnectorCount == 0 && pSysConfig->AcConnectorCount == 0) {
     if (pSysConfig->TotalConnectorCount == 0 && pSysConfig->AcConnectorCount == 0) {
-        log_error("DC %d or AC %d connector failed\r\n",
+        log_error("DC %d or AC %d connector failed",
                   pSysConfig->TotalConnectorCount,
                   pSysConfig->TotalConnectorCount,
                   pSysConfig->AcConnectorCount);
                   pSysConfig->AcConnectorCount);
         result = false;
         result = false;

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

@@ -52,6 +52,7 @@ enum Timeout_flag {
     Timeout_ReturnToChargingGunDet = 11,
     Timeout_ReturnToChargingGunDet = 11,
     Timeout_AuthorizingForStop     = 12,
     Timeout_AuthorizingForStop     = 12,
     Timeout_SelectGun              = 13,
     Timeout_SelectGun              = 13,
+    Timeout_WaitBalance            = 14,
 };
 };
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------

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


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


BIN
EVSE/Projects/DD360Audi/output/FactoryConfig


BIN
EVSE/Projects/DD360Audi/output/Module_ChkSysTask


BIN
EVSE/Projects/DD360Audi/output/Module_DoComm


BIN
EVSE/Projects/DD360Audi/output/Module_EvComm


BIN
EVSE/Projects/DD360Audi/output/Module_EventLogging


BIN
EVSE/Projects/DD360Audi/output/Module_InternalComm


BIN
EVSE/Projects/DD360Audi/output/Module_LcmControl


BIN
EVSE/Projects/DD360Audi/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360Audi/output/Module_UpdateFW


BIN
EVSE/Projects/DD360Audi/output/ReadCmdline


BIN
EVSE/Projects/DD360Audi/output/main


+ 0 - 184
EVSE/Projects/DD360ComBox/Apps/CSU/CheckSystemTask.c

@@ -1,184 +0,0 @@
-/*
- * CheckTask.c
- *
- *  Created on: 2021年9月22日
- *      Author: 8513
- */
-
-#include "CheckSystemTask.h"
-
-bool Taskconutstring(char *src, char *taskname)
-{
-    bool result = false;
-
-    if (src == NULL || strlen(src) == 0)
-        return result;
-
-    if (strstr(src, taskname) != NULL &&
-        strstr(src, "grep") == NULL &&
-        strstr(src, "[") == NULL)
-    {
-        result = true;
-    }
-
-    return result;
-}
-
-int GetProcessCount(char *procName)
-{
-	int result = 0;
-	FILE *fp;
-	char cmd[256];
-	char buf[256];
-
-	sprintf(cmd, "ps -ef |grep %s", procName);
-	fp = popen(cmd, "r");
-	if(fp != NULL)
-	{
-		while(fgets(buf, sizeof(buf), fp) != NULL)
-		{
-			if (Taskconutstring(buf, procName))
-				result++;
-		}
-	}
-
-	pclose(fp);
-
-	return result;
-}
-
-unsigned char CheckSystemTask(unsigned char systemPage)
-{
-	unsigned char result = 0;
-	unsigned char count_main 		= GetProcessCount("main");
-	unsigned char count_evComm 		= GetProcessCount("Module_EvComm");
-	unsigned char count_interComm	= GetProcessCount("Module_InternalComm");
-	unsigned char count_eventComm	= GetProcessCount("Module_EventLogging");
-	unsigned char count_primaryComm	= GetProcessCount("Module_PrimaryComm");
-	unsigned char count_lcmComm	    = GetProcessCount("Module_LcmControl");
-	unsigned char count_doComm	    = GetProcessCount("Module_DoComm");
-	unsigned char count_produceComm	= GetProcessCount("Module_ProduceUtils");
-//	unsigned char count_psuComm 	= GetProcessCount("Module_PsuComm");
-
-//	printf("*************************** \n");
-//	printf("count_main = %d \n", count_main);
-//	printf("count_eventLog = %d \n", count_eventLog);
-//	printf("count_primary = %d \n", count_primary);
-//	printf("count_evComm = %d \n", count_evComm);
-//	printf("count_lcmCtrl = %d \n", count_lcmCtrl);
-//	printf("count_interComm = %d \n", count_interComm);
-//	printf("count_psuComm = %d \n", count_psuComm);
-//	printf("*************************** \n");
-
-//	if (systemPage == 0x09 || systemPage == 0x0A)
-	{
-		if (count_main < _SYSTEM_TASK_COUNT_MAIN )
-		{
-			system("killall Module_EventLogging");
-			system("killall Module_PrimaryComm");
-			system("killall Module_EvComm");
-			system("killall Module_LcmControl");
-			system("killall Module_InternalComm");
-			system("killall Module_DoComm");
-//			system("killall Module_PsuComm");
-//			system("killall OcppBackend &");
-//			system("killall Module_4g &");
-//			system("killall Module_Wifi &");
-			system("killall Module_ProduceUtils &");
-			sleep(3);
-			system("/usr/bin/run_evse_restart.sh");
-		}
-		else
-		{
-			/*
-			if(system("pidof -s Module_EventLogging > /dev/null") != 0)
-				system("/root/Module_EventLogging &");
-
-			if(system("pidof -s Module_PrimaryComm > /dev/null") != 0)
-				system("/root/Module_PrimaryComm &");
-
-			if(system("pidof -s Module_LcmControl > /dev/null") != 0)
-				system("/root/Module_LcmControl &");
-
-            if(system("pidof -s Module_DoComm > /dev/null") != 0)
-                system("/root/Module_DoComm &");
-
-            if(system("pidof -s Module_ProduceUtils > /dev/null") != 0)
-                system("/root/Module_ProduceUtils &");
-
-			*/
-			if (count_evComm < _SYSTEM_TASK_COUNT_EVCOMM )
-			{
-				system("killall Module_EvComm");
-				sleep(3);
-				system("/root/Module_EvComm &");
-			}
-        	if (count_interComm < _SYSTEM_TASK_COUNT_INTERNALCOMM )
-			{
-				system("killall Module_InternalComm");
-				sleep(3);
-				system("/root/Module_InternalComm &");
-			}
-			if (count_eventComm < _SYSTEM_TASK_COUNT_EVENTLOGGING )
-			{
-				system("killall Module_EventLogging");
-				sleep(3);
-				system("/root/Module_EventLogging &");
-			}
-			if (count_primaryComm < _SYSTEM_TASK_COUNT_PRIMARYCOMM )
-			{
-				system("killall Module_PrimaryComm");
-				sleep(3);
-				system("/root/Module_PrimaryComm &");
-			}
-			if (count_lcmComm < _SYSTEM_TASK_COUNT_LCM )
-			{
-				system("killall Module_LcmControl");
-				sleep(3);
-				system("/root/Module_LcmControl &");
-			}
-			if (count_doComm < _SYSTEM_TASK_COUNT_DOCOMM )
-			{
-				system("killall Module_DoComm");
-				sleep(3);
-				system("/root/Module_DoComm &");
-			}
-			if (count_produceComm < _SYSTEM_TASK_COUNT_PRODUCEUTILS )
-			{
-				system("killall Module_ProduceUtils");
-				sleep(3);
-				system("/root/Module_ProduceUtils &");
-			}
-			/*
-			if (count_psuComm < 2)
-			{
-				system("killall Module_PsuComm");
-				sleep(3);
-				system("/root/Module_PsuComm &");
-			}*/
-		}
-
-		sleep(2);
-	}
-
-	if (count_main < _SYSTEM_TASK_COUNT_MAIN)
-		result = _SYSTEM_TASK_LOST_ITEM_MAIN;
-	else if (count_evComm < _SYSTEM_TASK_COUNT_EVCOMM)
-		result = _SYSTEM_TASK_LOST_ITEM_EVCOMM;
-/*	else if (count_psuComm < 2)
-		result = 3; */
-    else if (count_eventComm < _SYSTEM_TASK_COUNT_EVENTLOGGING )
-        result = _SYSTEM_TASK_LOST_ITEM_EVENTLOG;
-    else if (count_primaryComm < _SYSTEM_TASK_COUNT_PRIMARYCOMM)
-        result = _SYSTEM_TASK_LOST_ITEM_PRIMARYCOMM;
-    else if (count_lcmComm < _SYSTEM_TASK_COUNT_LCM)
-        result = _SYSTEM_TASK_LOST_ITEM_LCMCONTROL;
-    else if (count_interComm < 2 )
-        result = _SYSTEM_TASK_LOST_ITEM_INTERCOMM;
-    else if (count_doComm < _SYSTEM_TASK_COUNT_DOCOMM)
-        result = _SYSTEM_TASK_LOST_ITEM_DOCOMM;
-    else if (count_produceComm < _SYSTEM_TASK_COUNT_PRODUCEUTILS)
-        result = _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS;
-
-	return result;
-}

+ 0 - 60
EVSE/Projects/DD360ComBox/Apps/CSU/CheckSystemTask.h

@@ -1,60 +0,0 @@
-/*
- * CheckTask.h
- *
- *  Created on: 2021年9月2日
- *      Author: 7564
- */
-
-#ifndef CHECKTASK_H_
-#define CHECKTASK_H_
-
-#include 	<sys/timeb.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 	<stdint.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include 	<math.h>
-#include 	<stdbool.h>
-#include 	<dirent.h>
-
-#define _SYSTEM_TASK_LOST_ITEM_MAIN         1
-#define _SYSTEM_TASK_LOST_ITEM_EVCOMM       2
-#define _SYSTEM_TASK_LOST_ITEM_EVENTLOG     3
-#define _SYSTEM_TASK_LOST_ITEM_PRIMARYCOMM  4
-#define _SYSTEM_TASK_LOST_ITEM_LCMCONTROL   5
-#define _SYSTEM_TASK_LOST_ITEM_INTERCOMM    6
-#define _SYSTEM_TASK_LOST_ITEM_DOCOMM       7
-#define _SYSTEM_TASK_LOST_ITEM_PRODUCTUTILS 8
-
-#define _SYSTEM_TASK_COUNT_MAIN             5
-#define _SYSTEM_TASK_COUNT_EVCOMM           2
-#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_DOCOMM           1
-#define _SYSTEM_TASK_COUNT_PRODUCEUTILS     1
-
-
-unsigned char CheckSystemTask(unsigned char systemPage);
-
-#endif /* CHECKSYSTEMTASK_H_ */

+ 2 - 1
EVSE/Projects/DD360ComBox/Apps/CSU/Ethernet.c

@@ -169,7 +169,7 @@ void InitEthernet(void)
             pSysConfig->Eth0Interface.EthSubmaskAddress);
             pSysConfig->Eth0Interface.EthSubmaskAddress);
     //sprintf(tmpbuf,"/sbin/ifconfig eth0 192.168.100.10 netmask 255.255.255.0 up");
     //sprintf(tmpbuf,"/sbin/ifconfig eth0 192.168.100.10 netmask 255.255.255.0 up");
     system(tmpbuf);
     system(tmpbuf);
-
+    log_info("%s",tmpbuf);
     memset(tmpbuf, 0, 256);
     memset(tmpbuf, 0, 256);
     sprintf(tmpbuf, "route add default gw %s eth0 ",
     sprintf(tmpbuf, "route add default gw %s eth0 ",
             pSysConfig->Eth0Interface.EthGatewayAddress);
             pSysConfig->Eth0Interface.EthGatewayAddress);
@@ -183,6 +183,7 @@ void InitEthernet(void)
     sprintf(tmpbuf, "/sbin/ifconfig eth1 %s netmask %s up",
     sprintf(tmpbuf, "/sbin/ifconfig eth1 %s netmask %s up",
             pSysConfig->Eth1Interface.EthIpAddress,
             pSysConfig->Eth1Interface.EthIpAddress,
             pSysConfig->Eth1Interface.EthSubmaskAddress);
             pSysConfig->Eth1Interface.EthSubmaskAddress);
+    log_info("%s",tmpbuf);
     system(tmpbuf);
     system(tmpbuf);
 
 
     //Run DHCP client if enabled
     //Run DHCP client if enabled

+ 12 - 12
EVSE/Projects/DD360ComBox/Apps/CSU/Primary.c

@@ -85,8 +85,8 @@ void PrimaryLedIndicatorCtrlFork(void)
                     continue;
                     continue;
                 }
                 }
 
 
-                //printf("led indicator status = %d\r\n", chargingInfo[gunIndex]->SystemStatus);
-                //printf("level = %d\r\n", pSysWarning->Level);
+                //printf("led indicator status = %d", chargingInfo[gunIndex]->SystemStatus);
+                //printf("level = %d", pSysWarning->Level);
                 switch (pDcChargingInfo->SystemStatus) {
                 switch (pDcChargingInfo->SystemStatus) {
                 case S_BOOTING:
                 case S_BOOTING:
                     if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) {
                     if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) {
@@ -226,11 +226,11 @@ static void checkChargingInfoByDC(uint8_t systemStatus)
 #endif //!defined DD360Audi
 #endif //!defined DD360Audi
 
 
             if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
             if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
-                //printf("destroy gun = %d\r\n", pSysInfo->CurGunSelected);
+                //printf("destroy gun = %d", pSysInfo->CurGunSelected);
                 destroySelGun(pSysInfo->CurGunSelected);
                 destroySelGun(pSysInfo->CurGunSelected);
             } else {
             } else {
                 confirmSelGun(pSysInfo->CurGunSelected);
                 confirmSelGun(pSysInfo->CurGunSelected);
-                log_info("confirm select gun ............................... %d \n",
+                log_info("confirm select gun ............................... %d ",
                          pSysInfo->CurGunSelected);
                          pSysInfo->CurGunSelected);
             }
             }
         }
         }
@@ -433,7 +433,7 @@ void ChkPrimaryStatus(void)
 
 
         if (!leftBtnPush) {
         if (!leftBtnPush) {
             leftBtnPush = true;
             leftBtnPush = true;
-            log_info("left btn down...............................%x\n",
+            log_info("left btn down...............................%x",
                      pDcChargingInfo->SystemStatus);
                      pDcChargingInfo->SystemStatus);
             checkChargingInfoByAC();
             checkChargingInfoByAC();
             checkChargingInfoByDC(pDcChargingInfo->SystemStatus);
             checkChargingInfoByDC(pDcChargingInfo->SystemStatus);
@@ -480,11 +480,11 @@ void ChkPrimaryStatus(void)
                 }             else {
                 }             else {
 #if defined DD360Audi
 #if defined DD360Audi
                     if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
                     if (getConfirmSelectedGun(pSysInfo->CurGunSelected) == PASS) {
-                        //printf("destroy gun = %d\r\n", pSysInfo->CurGunSelected);
+                        //printf("destroy gun = %d", pSysInfo->CurGunSelected);
                         destroySelGun(pSysInfo->CurGunSelected);
                         destroySelGun(pSysInfo->CurGunSelected);
                     } else {
                     } else {
                         confirmSelGun(pSysInfo->CurGunSelected);
                         confirmSelGun(pSysInfo->CurGunSelected);
-                        log_info("confirm select gun ............................... %d \n",
+                        log_info("confirm select gun ............................... %d ",
                                  pSysInfo->CurGunSelected);
                                  pSysInfo->CurGunSelected);
                     }
                     }
 
 
@@ -517,7 +517,7 @@ void ChkPrimaryStatus(void)
 
 
             case S_COMPLETE:
             case S_COMPLETE:
                 // 回 IDLE
                 // 回 IDLE
-                //log_info("right btn down.................S_COMPLETE \n");
+                //log_info("right btn down.................S_COMPLETE ");
                 //pDcChargingInfo->SystemStatus = S_IDLE;
                 //pDcChargingInfo->SystemStatus = S_IDLE;
                 break;
                 break;
             }
             }
@@ -526,7 +526,7 @@ void ChkPrimaryStatus(void)
     } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
     } else if (ShmPrimaryMcuData->InputDet.bits.Button1 == BTN_RELEASE) {
         if (leftBtnPush) {
         if (leftBtnPush) {
             leftBtnPush = false;
             leftBtnPush = false;
-            //log_info("left btn up............................... \n");
+            //log_info("left btn up............................... ");
         }
         }
     }
     }
 
 
@@ -543,7 +543,7 @@ void ChkPrimaryStatus(void)
        ) {
        ) {
         if (!rightBtnPush) {
         if (!rightBtnPush) {
             rightBtnPush = true;
             rightBtnPush = true;
-            //log_info("right btn down............................... %d \n", pSysInfo->CurGunSelected);
+            //log_info("right btn down............................... %d ", pSysInfo->CurGunSelected);
             if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount &&
             if (pSysInfo->CurGunSelected + 1 < pSysConfig->TotalConnectorCount &&
                     pSysInfo->IsAlternatvieConf == NO) {
                     pSysInfo->IsAlternatvieConf == NO) {
                 pSysInfo->CurGunSelected++;
                 pSysInfo->CurGunSelected++;
@@ -570,12 +570,12 @@ void ChkPrimaryStatus(void)
                 ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
                 ChangeGunSelectByIndex(pSysInfo->CurGunSelected);
             }
             }
         }
         }
-        log_info("current select gun ............................... %d \n",
+        log_info("current select gun ............................... %d ",
                  pSysInfo->CurGunSelected);
                  pSysInfo->CurGunSelected);
     } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
     } else if (ShmPrimaryMcuData->InputDet.bits.Button2 == BTN_RELEASE) {
         if (rightBtnPush) {
         if (rightBtnPush) {
             rightBtnPush = false;
             rightBtnPush = false;
-            //log_info("right btn up............................... \n");
+            //log_info("right btn up............................... ");
         }
         }
     }
     }
 }
 }

+ 30 - 24
EVSE/Projects/DD360ComBox/Apps/CSU/RFID.c

@@ -119,7 +119,11 @@ static void UserScanFunction(void)
         strcpy((char *)pSysConfig->UserId, "");
         strcpy((char *)pSysConfig->UserId, "");
         return;
         return;
     }
     }
-
+    if (pSysConfig->EVCCID_Authorize) {
+        pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
+        if (strcmp( (char *)pSysConfig->UserId, (char *) pDcChargingInfo->EVCCID) != EQUAL )
+            return;
+    }
     // 先判斷現在是否可以提供刷卡
     // 先判斷現在是否可以提供刷卡
     // 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能
     // 1. 如果當前沒有槍是閒置狀態,則無提供刷卡功能
     // 2. 停止充電
     // 2. 停止充電
@@ -160,8 +164,8 @@ static void UserScanFunction(void)
     if (pGunIndexInfo->AcGunIndex > 0 &&
     if (pGunIndexInfo->AcGunIndex > 0 &&
             stopReq == DEFAULT_AC_INDEX &&
             stopReq == DEFAULT_AC_INDEX &&
             pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
             pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) {
-        log_info("ac stop charging \n");
-        log_info("index = %d, card number = %s, UserId = %s \n",
+        log_info("ac stop charging ");
+        log_info("index = %d, card number = %s, UserId = %s ",
                  pSysInfo->CurGunSelectedByAc,
                  pSysInfo->CurGunSelectedByAc,
                  pAcChargingInfo->StartUserId,
                  pAcChargingInfo->StartUserId,
                  pSysConfig->UserId);
                  pSysConfig->UserId);
@@ -180,8 +184,8 @@ static void UserScanFunction(void)
                 (pGunIndexInfo->AcGunIndex > 0 &&
                 (pGunIndexInfo->AcGunIndex > 0 &&
                  pSysInfo->CurGunSelectedByAc == NO_DEFINE))
                  pSysInfo->CurGunSelectedByAc == NO_DEFINE))
               ) {
               ) {
-        log_info("stop charging \n");
-        log_info("index = %d, card number = %s, UserId = %s \n",
+        log_info("stop charging ");
+        log_info("index = %d, card number = %s, UserId = %s ",
                  pSysInfo->CurGunSelected,
                  pSysInfo->CurGunSelected,
                  pDcChargingInfo->StartUserId,
                  pDcChargingInfo->StartUserId,
                  pSysConfig->UserId);
                  pSysConfig->UserId);
@@ -225,7 +229,7 @@ static void UserScanFunction(void)
         } else if ((pGunIndexInfo->AcGunIndex > 0 &&
         } else if ((pGunIndexInfo->AcGunIndex > 0 &&
                     pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) ||
                     pSysInfo->CurGunSelectedByAc == DEFAULT_AC_INDEX) ||
                    pDcChargingInfo->SystemStatus == S_IDLE) {
                    pDcChargingInfo->SystemStatus == S_IDLE) {
-            log_info("// LCM => Authorizing\r\n");
+            log_info("// LCM => Authorizing");
 
 
             setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
             setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
 
 
@@ -272,29 +276,31 @@ void ScannerCardProcess(void)
     }
     }
 
 
     if (pSysInfo->PageIndex == _LCM_AUTHORIZING) {
     if (pSysInfo->PageIndex == _LCM_AUTHORIZING) {
-        StartSystemTimeoutDet(Timeout_Authorizing);
+        if(!isAuthorizedComplete())
+            StartSystemTimeoutDet(Timeout_Authorizing);
 
 
-        //printf("isAuthorizedComplete = %d, %f\r\n", isAuthorizedComplete(), ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
+        //printf("isAuthorizedComplete = %d, %f", isAuthorizedComplete(), ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
         // 確認驗證卡號完成沒
         // 確認驗證卡號完成沒
         if (isAuthorizedComplete()
         if (isAuthorizedComplete()
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
 #if !defined DD360 && !defined DD360Audi && !defined DD360ComBox
                 || pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING
                 || pSysConfig->OfflinePolicy == _OFFLINE_POLICY_FREE_CHARGING
 #endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
 #endif //!defined DD360 && !defined DD360Audi && !defined DD360ComBox
-                && 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, "");
-            }
+                //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();
+            } ClearAuthorizedFlag();
         } else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
         } else if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_LOCAL_LIST) {
             // 白名單驗證
             // 白名單驗證
             for (i = 0; i < 10; i++) {
             for (i = 0; i < 10; i++) {
@@ -360,7 +366,7 @@ void CreateRfidFork(void)
         fd = InitialRfidPort();
         fd = InitialRfidPort();
         struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
         struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
 
 
-        log_info("RFID fork Child's PID is %d\r\n", getpid());
+        log_info("RFID fork Child's PID is %d", getpid());
 
 
         while (isContinue) {
         while (isContinue) {
             usleep(500000);
             usleep(500000);
@@ -375,7 +381,7 @@ void CreateRfidFork(void)
                 continue;
                 continue;
             }
             }
 
 
-            //log_info("Get Card..-%s- \n", pSysConfig->UserId);
+            //log_info("Get Card..-%s- ", pSysConfig->UserId);
             if (strlen((char *)pSysConfig->UserId) != 0) {
             if (strlen((char *)pSysConfig->UserId) != 0) {
                 continue;
                 continue;
             }
             }
@@ -447,7 +453,7 @@ void CreateRfidFork(void)
                     break;
                     break;
                 }
                 }
             }
             }
-            log_info("card number = %s\n", pSysConfig->UserId);
+            log_info("card number = %s", pSysConfig->UserId);
         }
         }
     }
     }
 }
 }

+ 1 - 1
EVSE/Projects/DD360ComBox/Apps/CSU/SelfTest.c

@@ -51,7 +51,7 @@ void SelfTestRun(void)
         if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) { //自檢完成
         if (pSysInfo->SelfTestSeq == _STEST_COMPLETE) { //自檢完成
             return;
             return;
         }
         }
-
+        
         ChkPrimaryStatus(); //確認硬體有無錯誤,如急停按鈕或門有打開
         ChkPrimaryStatus(); //確認硬體有無錯誤,如急停按鈕或門有打開
 
 
         if (pSysWarning->Level == WARN_LV_ER) {
         if (pSysWarning->Level == WARN_LV_ER) {

+ 0 - 403
EVSE/Projects/DD360ComBox/Apps/CSU/UpgradeFW.c

@@ -1,403 +0,0 @@
-#include <stdio.h>      /*標準輸入輸出定義*/
-#include <stdlib.h>     /*標準函數庫定義*/
-#include <string.h>
-#include <stdint.h>
-
-#include <sys/types.h>
-#include <dirent.h>
-
-#include "../Config.h"
-#include "../Log/log.h"
-#include "../Define/define.h"
-#include "../ShareMemory/shmMem.h"
-
-#include "main.h"
-//WatchDog.c
-extern void CreateWatchdog(void);
-extern void TryCloseWatchdog(void);
-extern void TryFeedWatchdog(void);
-
-
-//------------------------------------------------------------------------------
-static char *_priPortName = "/dev/ttyS1";
-static char *_485PortName = "/dev/ttyS5";
-
-//------------------------------------------------------------------------------
-static int InitComPort(uint8_t target)
-{
-    int fd;
-    struct termios tios;
-
-    if (target == UPGRADE_PRI) {
-        fd = open(_priPortName, O_RDWR);
-    } else if (target == UPGRADE_FAN ||
-               target == UPGRADE_RB ||
-               target == UPGRADE_AC ||
-               target == UPGRADE_LED
-              ) {
-        fd = open(_485PortName, O_RDWR);
-    }
-
-    if (fd <= 0) {
-        log_error("open 407 Communication port NG \n");
-        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)1;
-    tios.c_lflag = 0;
-    tcflush(fd, TCIFLUSH);
-    ioctl (fd, TCSETS, &tios);
-
-    return fd;
-}
-
-static int InitCanBus(void)
-{
-    int fd = -1;
-    int nbytes;
-    struct timeval tv;
-    struct ifreq ifr0;
-    struct sockaddr_can addr0;
-
-    system("/sbin/ip link set can0 down");
-    system("/sbin/ip link set can0 type can bitrate 500000 restart-ms 100");
-    system("/sbin/ip link set can0 up");
-
-    fd = socket(PF_CAN, SOCK_RAW, CAN_RAW);
-
-    tv.tv_sec = 0;
-    tv.tv_usec = 10000;
-    if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct  timeval)) < 0) {
-        log_error("Set SO_RCVTIMEO NG");
-    }
-    nbytes = 40960;
-    if (setsockopt(fd, SOL_SOCKET,  SO_RCVBUF, &nbytes, sizeof(int)) < 0) {
-        log_error("Set SO_RCVBUF NG");
-    }
-    nbytes = 40960;
-    if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &nbytes, sizeof(int)) < 0) {
-        log_error("Set SO_SNDBUF NG");
-    }
-
-    strcpy(ifr0.ifr_name, "can0");
-    ioctl(fd, SIOCGIFINDEX, &ifr0); /* ifr.ifr_ifindex gets filled with that device's index */
-    addr0.can_family = AF_CAN;
-    addr0.can_ifindex = ifr0.ifr_ifindex;
-    bind(fd, (struct sockaddr *)&addr0, sizeof(addr0));
-
-    return fd;
-}
-
-static int CheckUpdateProcess(void)
-{
-    //bool isPass = true;
-    uint8_t retSucc = 0;
-    uint8_t retFail = 0;
-    uint8_t index = 0;
-    uint8_t target = 0;
-    char Buf[256];
-    char *new_str = NULL;
-    uint8_t *ptr = NULL;
-    int fd = 0;
-    int CanFd = 0;
-    int uartFd = 0;
-    unsigned int Type = 0;
-    long int MaxLen = 48 * 1024 * 1024, ImageLen = 0;
-    DIR *d;
-    struct dirent *dir;
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    DcCommonInfo *ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
-    struct ChargingInfoData *pDcChargingInfo = NULL;
-
-    d = opendir("/mnt/");
-    if (d) {
-        while ((dir = readdir(d)) != NULL) {
-            if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0) {
-                continue;
-            }
-
-            new_str = calloc(strlen("/mnt/") + strlen(dir->d_name) + 1, sizeof(char));
-            //new_str[0] = '\0';
-            strcat(new_str, "/mnt/");
-            strcat(new_str, dir->d_name);
-            log_info("%s%s\r\n", "/mnt/", dir->d_name);
-            fd = open(new_str, O_RDONLY);
-            if (fd < 0) {
-                return FAIL;
-            }
-
-            ptr = calloc(MaxLen, sizeof(char)); //-48 is take out the header
-            //memset(ptr, 0xFF, MaxLen);  //-48 is take out the header
-
-            //get the image length
-            ImageLen = read(fd, ptr, MaxLen);
-            for (uint8_t i = 0; i < 16; i++) {
-                if (pSysConfig->ModelName[i] != ptr[i]) {
-                    return FAIL;
-                }
-            }
-
-            log_info("model name check pass. \n");
-            if (ImageLen > 20) {
-                Type = (((unsigned int)ptr[16]) << 24 |
-                        ((unsigned int)ptr[17]) << 16 |
-                        ((unsigned int)ptr[18]) << 8  |
-                        ((unsigned int)ptr[19]));
-                log_info("Typed...%x \r\n", Type);
-
-                switch (Type) {
-                case 0x10000001:
-                case 0x10000002:
-                case 0x10000003:
-                case 0x10000004:
-                case 0x10000005:
-                    if (Upgrade_Flash(Type, new_str, (char *)pSysConfig->ModelName) == PASS) {
-                        //return PASS;
-                        retSucc++;
-                    } else {
-                        log_info("Upgrade %x Failed\r\n", Type);
-                        //return FAIL;
-                        retFail++;
-                    }
-                    break;
-
-                case 0x10000007:
-                case 0x10000008:
-                case 0x10000009:
-                case 0x1000000A:
-                    CanFd = InitCanBus();
-                    if (CanFd > 0) {
-                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
-                            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
-
-                            if (pDcChargingInfo->Type == _Type_CCS_2) {
-                                uint8_t targetID = pDcChargingInfo->Evboard_id;
-
-                                if (pSysConfig->TotalConnectorCount == 1 &&
-                                        ShmDcCommonData->CcsVersion == _CCS_VERSION_CHECK_TAG_V015S0) {
-                                    //targetID += 1;
-                                }
-
-                                system("echo 3 > /proc/sys/vm/drop_caches");
-                                sleep(2);
-                                log_info("Upgrade CCS Processing..target id = %d \n", targetID);
-                                if (Upgrade_CCS(CanFd,
-                                                Type,
-                                                targetID,
-                                                new_str,
-                                                (char *)pSysConfig->ModelName) == FAIL) {
-                                    log_info("Upgrade CCS Failed \n");
-                                    retFail++;
-                                } else {
-                                    retSucc++;
-                                }
-                            }
-                        }
-                        close(CanFd);
-                    }
-                    memset(Buf, 0, sizeof(Buf));
-                    sprintf(Buf, "rm -rvf /mnt/%s", new_str);
-                    system(Buf);
-                    //isPass = true;
-#if 0
-                    CanFd = InitCanBus();
-                    if (CanFd > 0) {
-                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
-                            //if (!isPass) {
-                            //    break;
-                            //}
-                            if (chargingInfo[index]->Type == _Type_CCS_2) {
-                                if (Upgrade_CCS(CanFd, Type, chargingInfo[index]->Evboard_id, new_str, (char *)pSysConfig->ModelName) == FAIL) {
-                                    //isPass = false;
-                                    log_info("Upgrade %x Failed\r\n", Type);
-                                    retFail++;
-                                }
-                            }
-                        }
-                    } else {
-                        log_error("Upgrade CCS open CAN FD fail.\n");
-                        //isPass = false;
-                        return FAIL;
-                    }
-
-                    if (retFail != 0) {
-                        break;
-                    } else {
-                        retSucc++;
-                    }
-                    //return isPass;
-#endif //0
-                    break;
-
-                case 0x10000006:
-                case 0x1000000D:
-                case 0x1000000E:
-                case 0x20000002:
-                case 0x10000014:
-                    // CSU_PRIMARY_CONTROLLER : 0x10000006
-                    target = 0x00;
-
-                    if (Type == 0x10000006) {
-                        target = UPGRADE_PRI;
-                    } else if (Type == 0x1000000D) {
-                        target = UPGRADE_RB;
-                    } else if (Type == 0x1000000E) {
-                        target = UPGRADE_FAN;
-                    } else if (Type == 0x20000002) {
-                        target = UPGRADE_AC;
-                    } else if (Type == 0x10000014) {
-                        target = UPGRADE_LED;
-                    }
-
-                    uartFd = InitComPort(target);
-
-                    if (Upgrade_UART(uartFd, Type, target, new_str, (char *)pSysConfig->ModelName) == PASS) {
-                        //return PASS;
-                        retSucc++;
-                    } else {
-                        log_info("Upgrade %x Failed\r\n", Type);
-                        //return FAIL;
-                        return FAIL;
-                    }
-
-                    if (uartFd > 0) {
-                        close(uartFd);
-                    }
-                    break;
-
-                case 0x1000000B:
-                case 0x1000000C:
-                    // CHAdeMO_BOARD : 0x1000000B, GBT : 0x1000000C
-                    //bool isPass = true;
-                    CanFd = InitCanBus();
-                    if (CanFd > 0) {
-                        for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
-                            pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
-
-                            //if (!isPass) {
-                            //    break;
-                            //}
-
-                            if ((Type == 0x1000000B && pDcChargingInfo->Type == _Type_Chademo) ||
-                                    (Type == 0x1000000C && pDcChargingInfo->Type == _Type_GB)) {
-                                if (Upgrade_CAN(CanFd, Type, pDcChargingInfo->Evboard_id, new_str, (char *)pSysConfig->ModelName) == PASS) {
-                                    //isPass = PASS;
-                                    retSucc++;
-                                } else {
-                                    log_info("Upgrade %x Failed\r\n", Type);
-                                    //isPass = FAIL;
-                                    retFail++;
-                                }
-                            }
-                        }
-                    } else {
-                        log_info("Upgrad FD fail. \n");
-                        //isPass = false;
-                        return FAIL;
-                    }
-
-                    //return isPass;
-                    break;
-                }
-            }
-            free(new_str);
-            free(ptr);
-        }
-    }
-    free(dir);
-    closedir(d);
-
-    if (retFail != 0) {
-        return FAIL;
-    }
-
-    return PASS;
-}
-
-void CheckFwUpdateFunction(void)
-{
-    struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
-    struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
-    struct OCPP16Data *ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
-    struct ChargingInfoData *pAcChargingInfo = NULL;
-
-    //log_info("pSysInfo->FirmwareUpdate = %d \n", pSysInfo->FirmwareUpdate);
-    if (pSysInfo->FirmwareUpdate == YES) {
-        log_info("ftp : update start. \n");
-        TryCloseWatchdog();
-
-        for (uint8_t gun_index = 0; gun_index < pSysConfig->TotalConnectorCount; gun_index++) {
-            setChargerMode(gun_index, MODE_UPDATE);
-        }
-        sleep(1);
-        uint8_t updateResult = CheckUpdateProcess();
-
-        if (updateResult == PASS) {
-            log_info("ftp : update complete. \n");
-        } else if (updateResult == MODELNAME_FAIL) {
-            log_info("ftp : model name is none match. \n");
-            KillAllTask();
-            pSysInfo->FirmwareUpdate = NO;
-            sleep(5);
-            system("/usr/bin/run_evse_restart.sh");
-            return;
-        } else {
-            log_info("ftp : update fail. \n");
-        }
-
-        pSysInfo->FirmwareUpdate = NO;
-        sleep(5);
-        system("reboot -f");
-    } else if (ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq == YES) {
-        ShmOCPP16Data->MsMsg.bits.UpdateFirmwareReq = NO;
-
-        if (strcmp((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Downloaded") == EQUAL) {
-            log_info("Backend : update start. \n");
-            TryCloseWatchdog();
-            strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "");
-            strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installing");
-            ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
-            KillTask();
-
-            for (uint8_t _index = 0; _index < pSysConfig->TotalConnectorCount; _index++) {
-                setChargerMode(_index, MODE_UPDATE);
-            }
-
-            for (uint8_t _index = 0; _index < pSysConfig->AcConnectorCount; _index++) {
-                pAcChargingInfo = (struct ChargingInfoData *)GetAcChargingInfoData(_index);
-
-                pAcChargingInfo->SystemStatus = MODE_UPDATE;
-            }
-            sleep(1);
-
-            uint8_t updateResult = CheckUpdateProcess();
-
-            if (updateResult == PASS) {
-                log_info("Backend : update complete. \n");
-                strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
-            } else if (updateResult == MODELNAME_FAIL) {
-                log_info("Backend : model name is none match. \n");
-                KillAllTask();
-                strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
-                ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
-                sleep(5);
-                system("/usr/bin/run_evse_restart.sh");
-                return;
-            } else {
-                log_info("Backend : update fail. \n");
-                strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
-            }
-
-            strcpy((char *)ShmOCPP16Data->FirmwareStatusNotification.Status, "Installed");
-            ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = YES;
-            sleep(5);
-            system("reboot -f");
-        }
-    }
-}

+ 3 - 2
EVSE/Projects/DD360ComBox/Apps/CSU/WatchDog.c

@@ -28,7 +28,8 @@ int InitWatchDog()
 
 
     if(fd<=0)
     if(fd<=0)
     {
     {
-        log_error("System watch dog initial fail.\r\n");
+        log_info("Open watchdog fd:%d",fd);
+        log_error("System watch dog initial fail.\n");
     }
     }
     ioctl(fd, _IOWR('W', 6, int), &timeout);
     ioctl(fd, _IOWR('W', 6, int), &timeout);
 
 
@@ -47,7 +48,7 @@ void CreateWatchdog(void)
     }
     }
     else
     else
     {
     {
-        log_info("Watchdog Initial Success");
+        log_info("Watchdog Initial Success (%d)",wtdFd);
     }
     }
 }
 }
 
 

File diff suppressed because it is too large
+ 186 - 156
EVSE/Projects/DD360ComBox/Apps/CSU/main.c


+ 2 - 2
EVSE/Projects/DD360ComBox/Apps/CSU/main.h

@@ -31,7 +31,8 @@
 
 
 #define uSEC_VAL                                (1000000)
 #define uSEC_VAL                                (1000000)
 #define SELFTEST_TIMEOUT                        (60)//45
 #define SELFTEST_TIMEOUT                        (60)//45
-#define AUTHORIZE_TIMEOUT                       (15)//30
+#define AUTHORIZE_TIMEOUT                       (30)//30
+#define BALANCE_TIMEOUT                         (15)//15
 #define AUTHORIZE_COMP_TIMEOUT                  (3)
 #define AUTHORIZE_COMP_TIMEOUT                  (3)
 #define AUTHORIZE_FAIL_TIMEOUT                  (3)
 #define AUTHORIZE_FAIL_TIMEOUT                  (3)
 #define AUTHORIZE_STOP_TIMEOUT                  (30)
 #define AUTHORIZE_STOP_TIMEOUT                  (30)
@@ -43,7 +44,6 @@
 #define GUN_PRECHARGING_TIMEOUT                 (60)
 #define GUN_PRECHARGING_TIMEOUT                 (60)
 
 
 #define WHILE_LOOP_TIME                         (10000)
 #define WHILE_LOOP_TIME                         (10000)
-#define VERIFY_EVCCID                           0   // 0:Not verify 1:for verify
 
 
 //#define log_info(format, args...) StoreLogMsg_1("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
 //#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)
 //#define log_warn(format, args...) StoreLogMsg_1("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)

+ 42 - 42
EVSE/Projects/DD360ComBox/Apps/DataBase/DataBase.c

@@ -61,38 +61,38 @@ int DB_Open(void)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\r\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local charging record database open successfully.\r\n");
+        log_info( "Local charging record database open successfully.");
 
 
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Create local charging record table error message: %s\n", errMsg);
+            log_info( "Create local charging record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local charging record table successfully\n");
+            log_info( "Opened local charging record table successfully");
         }
         }
 
 
         if (sqlite3_exec(localDb, createCfgSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createCfgSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Create local config table error message: %s\n", errMsg);
+            log_info( "Create local config table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local config table successfully\n");
+            log_info( "Opened local config table successfully");
         }
         }
 
 
         //DS60-120
         //DS60-120
         if (sqlite3_exec(localDb, createrecordSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createrecordSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Create local record table error message: %s\n", errMsg);
+            log_info( "Create local record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local record table successfully\n");
+            log_info( "Opened local record table successfully");
         }
         }
 
 
         if (sqlite3_exec(localDb, createrebootSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createrebootSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Create reboot record table error message: %s\n", errMsg);
+            log_info( "Create reboot record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened reboot record table successfully\n");
+            log_info( "Opened reboot record table successfully");
         }
         }
         //-----
         //-----
 
 
@@ -126,24 +126,24 @@ int DB_Insert_Record(int gunIndex)
     //if (sqlite3_open("/Storage/ChargeLog/localCgargingRecord.db", &db)) {
     //if (sqlite3_open("/Storage/ChargeLog/localCgargingRecord.db", &db)) {
     if (sqlite3_open(DB_FILE, &localDb)) { //DS60-120 add
     if (sqlite3_open(DB_FILE, &localDb)) { //DS60-120 add
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\r\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local charging record database open successfully.\r\n");
+        log_info( "Local charging record database open successfully.");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Insert local charging record error message: %s\n", errMsg);
+            log_info( "Insert local charging record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Insert local charging record successfully\n");
+            log_info( "Insert local charging record successfully");
         }
         }
 
 
         //DS60-120 add
         //DS60-120 add
         sprintf(insertSql, "delete from charging_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
         sprintf(insertSql, "delete from charging_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "delete local charging error message: %s\n", errMsg);
+            log_info( "delete local charging error message: %s", errMsg);
         } else {
         } else {
-            log_info( "delete local charging record successfully\n");
+            log_info( "delete local charging record successfully");
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);
@@ -161,22 +161,22 @@ int DB_Update_Operactive(uint8_t gunIndex, uint8_t IsAvailable)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\r\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local charging record database open successfully (%d).\r\n", IsAvailable);
+        log_info( "Local charging record database open successfully (%d).", IsAvailable);
 
 
         //sprintf(sqlStr, "insert or replace into config (IsAvailable, connector, val) values('IsAvailable', %d, %d);", gunIndex, IsAvailable);
         //sprintf(sqlStr, "insert or replace into config (IsAvailable, connector, val) values('IsAvailable', %d, %d);", gunIndex, IsAvailable);
         sprintf(sqlStr,
         sprintf(sqlStr,
                 "insert or replace into config (item, connector, val) values('IsAvailable', %d, %d);",
                 "insert or replace into config (item, connector, val) values('IsAvailable', %d, %d);",
                 gunIndex,
                 gunIndex,
                 IsAvailable); //DS60-120 add
                 IsAvailable); //DS60-120 add
-        log_info("sqlStr= %s\r\n", sqlStr);
+        log_info("sqlStr= %s", sqlStr);
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "update config error message: %s\n", errMsg);
+            log_info( "update config error message: %s", errMsg);
         } else {
         } else {
-            log_info("update connector-%d config item isOperactive to %d\r\n", gunIndex, IsAvailable);
+            log_info("update connector-%d config item isOperactive to %d", gunIndex, IsAvailable);
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);
@@ -195,24 +195,24 @@ int DB_Get_Operactive(uint8_t gunIndex)
 
 
     //sprintf(sqlStr, "select * from config where IsAvailable='IsAvailable' and connector=%d;", gunIndex);
     //sprintf(sqlStr, "select * from config where IsAvailable='IsAvailable' and connector=%d;", gunIndex);
     sprintf(sqlStr, "select * from config where item='IsAvailable' and connector=%d;", gunIndex); //DS60-120 add
     sprintf(sqlStr, "select * from config where item='IsAvailable' and connector=%d;", gunIndex); //DS60-120 add
-    //DEBUG_INFO("sqlStr= %s\r\n", sqlStr);
+    //DEBUG_INFO("sqlStr= %s", sqlStr);
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\r\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local config query database open successfully.\r\n");
+        log_info( "Local config query database open successfully.");
         sqlite3_get_table(localDb, sqlStr, &rs, &rows, &cols, &errMsg);
         sqlite3_get_table(localDb, sqlStr, &rs, &rows, &cols, &errMsg);
         if (rows > 0) {
         if (rows > 0) {
             for (int idxRow = 1; idxRow <= rows; idxRow++) {
             for (int idxRow = 1; idxRow <= rows; idxRow++) {
                 if (strcmp(rs[(idxRow * cols) + 3], "0") == 0) {
                 if (strcmp(rs[(idxRow * cols) + 3], "0") == 0) {
                     result = false;
                     result = false;
                 }
                 }
-                log_info("Query connector-%d isOperactive: %s\r\n", gunIndex, rs[(idxRow * cols) + 3]);
+                log_info("Query connector-%d isOperactive: %s", gunIndex, rs[(idxRow * cols) + 3]);
             }
             }
         } else {
         } else {
-            log_info("Query connector-%d fail, set default value to operactive.\r\n", gunIndex);
+            log_info("Query connector-%d fail, set default value to operactive.", gunIndex);
         }
         }
 
 
         sqlite3_free_table(rs);
         sqlite3_free_table(rs);
@@ -232,23 +232,23 @@ int DB_Reboot_Record(void)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local charging record database open successfully.\n");
+        log_info( "Local charging record database open successfully.");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Insert reboot record error message: %s\n", errMsg);
+            log_info( "Insert reboot record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Insert reboot record successfully\n");
+            log_info( "Insert reboot record successfully");
         }
         }
 
 
         sprintf(insertSql, "delete from reboot_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
         sprintf(insertSql, "delete from reboot_record where idx < (select idx from charging_record order by idx desc limit 1)-2000;");
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, insertSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "delete reboot record error message: %s\n", errMsg);
+            log_info( "delete reboot record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "delete reboot record successfully\n");
+            log_info( "delete reboot record successfully");
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);
@@ -272,16 +272,16 @@ int CreateEventRecord(void)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_error( "Can't open database: %s\n", sqlite3_errmsg(localDb));
+        log_error( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local event record database open successfully.\n");
+        log_info( "Local event record database open successfully.");
 
 
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, createRecordSql, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_error( "Create local event record table error message: %s\n", errMsg);
+            log_error( "Create local event record table error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Opened local event record table successfully\n");
+            log_info( "Opened local event record table successfully");
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);
@@ -300,23 +300,23 @@ int InsertEventRecord(uint8_t *statusCode)
 
 
     if (sqlite3_open(DB_FILE, &localDb)) {
     if (sqlite3_open(DB_FILE, &localDb)) {
         result = FAIL;
         result = FAIL;
-        log_info( "Can't open database: %s\n", sqlite3_errmsg(localDb));
+        log_info( "Can't open database: %s", sqlite3_errmsg(localDb));
         sqlite3_close(localDb);
         sqlite3_close(localDb);
     } else {
     } else {
-        log_info( "Local event record database open successfully.\n");
+        log_info( "Local event record database open successfully.");
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "Insert local event record error message: %s\n", errMsg);
+            log_info( "Insert local event record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "Insert local event record successfully\n");
+            log_info( "Insert local event record successfully");
         }
         }
 
 
         sprintf(sqlStr, "delete from event_record where idx < (select idx from event_record order by idx desc limit 1)-2000;");
         sprintf(sqlStr, "delete from event_record where idx < (select idx from event_record order by idx desc limit 1)-2000;");
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
         if (sqlite3_exec(localDb, sqlStr, 0, 0, &errMsg) != SQLITE_OK) {
             result = FAIL;
             result = FAIL;
-            log_info( "delete local event_record error message: %s\n", errMsg);
+            log_info( "delete local event_record error message: %s", errMsg);
         } else {
         } else {
-            log_info( "delete local event record successfully\n");
+            log_info( "delete local event record successfully");
         }
         }
 
 
         sqlite3_close(localDb);
         sqlite3_close(localDb);

Some files were not shown because too many files changed in this diff