Преглед на файлове

Merge branch 'DD360Audi'

FolusWen преди 4 години
родител
ревизия
0d8ecc1e22
променени са 37 файла, в които са добавени 1709 реда и са изтрити 1302 реда
  1. 266 282
      EVSE/Projects/DD360Audi/Apps/FactoryConfig.c
  2. 27 4
      EVSE/Projects/DD360Audi/Apps/Module_EvComm.c
  3. 208 251
      EVSE/Projects/DD360Audi/Apps/Module_EventLogging.c
  4. 42 108
      EVSE/Projects/DD360Audi/Apps/Module_InternalComm.c
  5. 3 0
      EVSE/Projects/DD360Audi/Apps/Module_LcmContro.h
  6. 41 18
      EVSE/Projects/DD360Audi/Apps/Module_LcmControl.c
  7. BIN
      EVSE/Projects/DD360Audi/Apps/Module_PsuComm
  8. 251 283
      EVSE/Projects/DD360Audi/Apps/OutputTask.c
  9. 369 106
      EVSE/Projects/DD360Audi/Apps/ReDoComm.c
  10. 12 6
      EVSE/Projects/DD360Audi/Apps/ReDoComm.h
  11. BIN
      EVSE/Projects/DD360Audi/Apps/UnsafetyOutputTask
  12. 1 1
      EVSE/Projects/DD360Audi/Apps/init.sh
  13. 409 172
      EVSE/Projects/DD360Audi/Apps/main.c
  14. 1 1
      EVSE/Projects/DD360Audi/Apps/web.sh
  15. BIN
      EVSE/Projects/DD360Audi/AudiUI/DWIN_SET_AudiUI_Emergence_20210113.7z
  16. BIN
      EVSE/Projects/DD360Audi/Images/DDYC182V0UE2AD_ramdisk.gz
  17. BIN
      EVSE/Projects/DD360Audi/Images/ramdisk.gz
  18. BIN
      EVSE/Projects/DD360Audi/Images/root/DoComm
  19. BIN
      EVSE/Projects/DD360Audi/Images/root/Module_EvComm
  20. BIN
      EVSE/Projects/DD360Audi/Images/root/Module_EventLogging
  21. BIN
      EVSE/Projects/DD360Audi/Images/root/Module_InternalComm
  22. BIN
      EVSE/Projects/DD360Audi/Images/root/main
  23. BIN
      EVSE/Projects/DD360Audi/output/DoComm
  24. BIN
      EVSE/Projects/DD360Audi/output/FactoryConfig
  25. BIN
      EVSE/Projects/DD360Audi/output/Module_EvComm
  26. BIN
      EVSE/Projects/DD360Audi/output/Module_EventLogging
  27. BIN
      EVSE/Projects/DD360Audi/output/Module_InternalComm
  28. BIN
      EVSE/Projects/DD360Audi/output/Module_LcmControl
  29. BIN
      EVSE/Projects/DD360Audi/output/Module_PrimaryComm
  30. BIN
      EVSE/Projects/DD360Audi/output/ReadCmdline
  31. BIN
      EVSE/Projects/DD360Audi/output/UnsafetyOutputTask
  32. 1 1
      EVSE/Projects/DD360Audi/output/init.sh
  33. BIN
      EVSE/Projects/DD360Audi/output/main
  34. 1 1
      EVSE/Projects/DD360Audi/output/web.sh
  35. 68 68
      EVSE/Projects/DS60-120/Apps/Module_InternalComm.c
  36. 9 0
      EVSE/Projects/define.h
  37. BIN
      EVSE/rootfs/root/OcppBackend20

+ 266 - 282
EVSE/Projects/DD360Audi/Apps/FactoryConfig.c

@@ -1,323 +1,307 @@
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
+#include    <sys/time.h>
+#include    <sys/timeb.h>
 #include    <sys/types.h>
 #include    <sys/stat.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/can.h>
-#include 	<linux/can/raw.h>
-#include 	<linux/wireless.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
+#include    <sys/types.h>
+#include    <sys/ioctl.h>
+#include    <sys/socket.h>
+#include    <sys/ipc.h>
+#include    <sys/shm.h>
+#include    <sys/shm.h>
+#include    <sys/mman.h>
+#include    <linux/can.h>
+#include    <linux/can/raw.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 	<errno.h>
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include	"../../define.h"
-#include 	"Config.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    <errno.h>
+#include    <string.h>
+#include    <time.h>
+#include    <ctype.h>
+#include    <ifaddrs.h>
+#include    "../../define.h"
+#include    "Config.h"
 
 #define Debug
-#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
-#define PASS				1
-#define FAIL				-1
-#define OUTPUT_FLASH		0x01
-#define OUTPUT_FILE			0x02
+#define ARRAY_SIZE(A)       (sizeof(A) / sizeof(A[0]))
+#define PASS                1
+#define FAIL                -1
+#define OUTPUT_FLASH        0x01
+#define OUTPUT_FILE         0x02
 
-struct SysConfigData 			SysConfig;
+struct SysConfigData            SysConfig;
 
 int StoreLogMsg(const char *fmt, ...);
 
 int StoreLogMsg(const char *fmt, ...)
 {
-	char Buf[4096+256];
-	char buffer[4096];
-	va_list args;
-	struct timeb  SeqEndTime;
-	struct tm *tm;
+    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);
+    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);
+    memset(Buf, 0, sizeof(Buf));
+    ftime(&SeqEndTime);
+    SeqEndTime.time = time(NULL);
+    tm = localtime(&SeqEndTime.time);
 
-	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);
+    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;
+    return rc;
 }
 
 void helpOutput(void)
 {
-	printf("Usage: Module_FactoryConfig [OPTION]...\r\n\r\n");
-	printf("Generate factory default configuration value\r\n\r\n");
-	printf("OPTION:\r\n");
-	printf("	-a Write to file(/mnt) & flash\r\n");
-	printf("	-f Write to file(/mnt)\r\n");
-	printf("	-m Write to flash\r\n");
+    printf("Usage: Module_FactoryConfig [OPTION]...\r\n\r\n");
+    printf("Generate factory default configuration value\r\n\r\n");
+    printf("OPTION:\r\n");
+    printf("	-a Write to file(/mnt) & flash\r\n");
+    printf("	-f Write to file(/mnt)\r\n");
+    printf("	-m Write to flash\r\n");
 }
 
 /**************************************************************************************/
 /************This task will create Factory default confgiuration file *****************/
- /***********and store it into mtdblock 10,11,12                               ****************/
+/***********and store it into mtdblock 10,11,12                               ****************/
 /**************************************************************************************/
-int main(int argc,char *argv[])
+int main(int argc, char *argv[])
 {
-	unsigned char outType=0;
-	unsigned int i,Chk, MtdBlockSize=0x600000;
-	unsigned char *ptr;
-	int fd,wrd;
+    unsigned char outType = 0;
+    unsigned int i, Chk, MtdBlockSize = 0x600000;
+    unsigned char *ptr;
+    int fd, wrd;
 
-	ptr=malloc(MtdBlockSize);
-	if(ptr==NULL)
-	{
-		#ifdef SystemLogMessage
-		StoreLogMsg("[FactoryConfig]main: malloc for SysConfigData NG");
-		#endif
-		return 0;
-	}
-	memset(ptr, 0, MtdBlockSize);
-	memset(&SysConfig, 0, sizeof(struct SysConfigData));
+    ptr = malloc(MtdBlockSize);
+    if (ptr == NULL) {
+#ifdef SystemLogMessage
+        StoreLogMsg("[FactoryConfig]main: malloc for SysConfigData NG");
+#endif
+        return 0;
+    }
+    memset(ptr, 0, MtdBlockSize);
+    memset(&SysConfig, 0, sizeof(struct SysConfigData));
 
-	/*
-	 * TODO: Set factory default configuration
-	*/
-	//********** System **********// udhcpc -i eth1 -s ./dhcp_script/eth1.script
-	//
-	strcpy((char *)SysConfig.ModelName, "DDYE182V0UD2AU");
-	strcpy((char *)SysConfig.SerialNumber, "SERIALFORRD");
+    /*
+     * TODO: Set factory default configuration
+    */
+    //********** System **********// udhcpc -i eth1 -s ./dhcp_script/eth1.script
+    //
+    strcpy((char *)SysConfig.ModelName, "DDYC182V0UE2AD");
+    strcpy((char *)SysConfig.SerialNumber, "SERIALFORRD");
 
-	memset(SysConfig.SystemId, 0x00, sizeof(SysConfig.SystemId));
-	char Dash = '-';
+    memset(SysConfig.SystemId, 0x00, sizeof(SysConfig.SystemId));
+    char Dash = '-';
 
-	strcat((char *)SysConfig.SystemId, (char *)SysConfig.ModelName);
-	strncat((char *)SysConfig.SystemId, &Dash, 1);
-	strcat((char *)SysConfig.SystemId, (char *)SysConfig.SerialNumber);
+    strcat((char *)SysConfig.SystemId, (char *)SysConfig.ModelName);
+    strncat((char *)SysConfig.SystemId, &Dash, 1);
+    strcat((char *)SysConfig.SystemId, (char *)SysConfig.SerialNumber);
 
-	strcpy((char *)SysConfig.SystemDateTime, "");
-	SysConfig.AuthorisationMode = AUTH_MODE_ENABLE;
-	SysConfig.DefaultLanguage = 0;
-	SysConfig.RfidCardNumEndian = 0;
-	SysConfig.AcPlugInTimes = 0;
-	SysConfig.GbPlugInTimes = 0;
-	SysConfig.Ccs1PlugInTime = 0;
-	SysConfig.Ccs2PlugInTimes = 0;
-	SysConfig.ChademoPlugInTimes = 0;
-	SysConfig.BillingData.isBilling = 0;
-	SysConfig.isAPP = 1;
-	SysConfig.isQRCode = 1;
-	SysConfig.isRFID = 1;
-	//********** Charging **********//
-	SysConfig.MaxChargingEnergy = 0;
-	SysConfig.MaxChargingCurrent = 500;		// 最大可輸出電流 (整樁)
-	SysConfig.MaxChargingDuration = 0;
-	SysConfig.AcMaxChargingCurrent = 0;
-	SysConfig.PhaseLossPolicy = 0;
-	/*+++ 20200908, vern, modify it +++*/
-	/*for(unsigned char i = 0; i < 10; i++)
-		strcpy((char *)SysConfig.LocalWhiteCard, "");*/
-	memset(SysConfig.LocalWhiteCard,0,sizeof(SysConfig.LocalWhiteCard));	
-	/*--- 20200908, vern, modify it ---*/
-	strcpy((char *)SysConfig.UserId, "");
-	//********** Network **********//
-	strcpy((char *)SysConfig.FtpServer, "");
-	SysConfig.Eth0Interface.EthDhcpClient = 0;
-	strcpy((char *) SysConfig.Eth0Interface.EthIpAddress, "192.168.1.10");
-	strcpy((char *) SysConfig.Eth0Interface.EthSubmaskAddress, "255.255.255.0");
-	strcpy((char *) SysConfig.Eth0Interface.EthGatewayAddress, "192.168.1.254");
-	SysConfig.Eth1Interface.EthDhcpClient = 0;
-	strcpy((char *) SysConfig.Eth1Interface.EthIpAddress, "192.168.0.10");
-	strcpy((char *) SysConfig.Eth1Interface.EthSubmaskAddress, "255.255.255.0");
-	strcpy((char *) SysConfig.Eth1Interface.EthGatewayAddress, "192.168.0.254");
-	if(SysConfig.ModelName[10] == 'W')
-		SysConfig.AthInterface.WifiMode = 2;
-	else
-		SysConfig.AthInterface.WifiMode = 0;
-	strcpy((char *) SysConfig.AthInterface.WifiSsid, "");
-	strcpy((char *) SysConfig.AthInterface.WifiPassword, "");
-	SysConfig.AthInterface.WifiRssi = 0;
-	SysConfig.AthInterface.WifiDhcpServer = 0;
-	SysConfig.AthInterface.WifiDhcpClient = 0;
-	strcpy((char *) SysConfig.AthInterface.WifiMacAddress, "");
-	strcpy((char *) SysConfig.AthInterface.WifiIpAddress, "");
-	strcpy((char *) SysConfig.AthInterface.WifiSubmaskAddress, "");
-	strcpy((char *) SysConfig.AthInterface.WifiGatewayAddress, "");
-	SysConfig.AthInterface.WifiNetworkConn = 0;
-	strcpy((char *) SysConfig.TelecomInterface.TelcomModelName, "");
-	strcpy((char *) SysConfig.TelecomInterface.TelcomSoftwareVer, "");
-	//strcpy((char *) SysConfig.TelecomInterface.TelcomApn, "Internet");
-	strcpy((char *) SysConfig.TelecomInterface.TelcomApn, "");
-	SysConfig.TelecomInterface.TelcomRssi = 0;
-	strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapId, " ");
-	strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapPwd, " ");
-	strcpy((char *) SysConfig.TelecomInterface.TelcomModemImei, "");
-	strcpy((char *) SysConfig.TelecomInterface.TelcomSimImsi, "");
-	strcpy((char *) SysConfig.TelecomInterface.TelcomSimIccid, "");
-	SysConfig.TelecomInterface.TelcomSimStatus = 0;
-	SysConfig.TelecomInterface.TelcomModemMode = 0;
-	strcpy((char *) SysConfig.TelecomInterface.TelcomIpAddress, "");
-	SysConfig.TelecomInterface.TelcomNetworkConn = 0;
-	strcpy((char *)SysConfig.chargePointVendor, "Phihong Technology");
-	//********** Backend **********//
-	SysConfig.BackendConnTimeout = 300; //300 seconds
-	SysConfig.OfflinePolicy = 2;
-	SysConfig.OfflineMaxChargeEnergy = 0;
-	SysConfig.OfflineMaxChargeDuration = 0;
-	strcpy((char *) SysConfig.OcppServerURL, "");
-	strcpy((char *) SysConfig.ChargeBoxId, "");
-	SysConfig.LedInfo.Intensity = 2;
+    strcpy((char *)SysConfig.SystemDateTime, "");
+    SysConfig.AuthorisationMode = AUTH_MODE_ENABLE;
+    SysConfig.DefaultLanguage = 0;
+    SysConfig.RfidCardNumEndian = 0;
+    SysConfig.AcPlugInTimes = 0;
+    SysConfig.GbPlugInTimes = 0;
+    SysConfig.Ccs1PlugInTime = 0;
+    SysConfig.Ccs2PlugInTimes = 0;
+    SysConfig.ChademoPlugInTimes = 0;
+    SysConfig.BillingData.isBilling = 0;
+    SysConfig.isAPP = 1;
+    SysConfig.isQRCode = 1;
+    SysConfig.isRFID = 1;
+    //********** Charging **********//
+    SysConfig.MaxChargingEnergy = 0;
+    SysConfig.MaxChargingCurrent = 500;     // ��憭批虾頛詨枂�餅� (�湔�)
+    SysConfig.MaxChargingDuration = 0;
+    SysConfig.AcMaxChargingCurrent = 0;
+    SysConfig.PhaseLossPolicy = 0;
+    /*+++ 20200908, vern, modify it +++*/
+    /*for(unsigned char i = 0; i < 10; i++)
+        strcpy((char *)SysConfig.LocalWhiteCard, "");*/
+    memset(SysConfig.LocalWhiteCard, 0, sizeof(SysConfig.LocalWhiteCard));
+    /*--- 20200908, vern, modify it ---*/
+    strcpy((char *)SysConfig.UserId, "");
+    //********** Network **********//
+    strcpy((char *)SysConfig.FtpServer, "");
+    SysConfig.Eth0Interface.EthDhcpClient = 0;
+    strcpy((char *) SysConfig.Eth0Interface.EthIpAddress, "192.168.1.10");
+    strcpy((char *) SysConfig.Eth0Interface.EthSubmaskAddress, "255.255.255.0");
+    strcpy((char *) SysConfig.Eth0Interface.EthGatewayAddress, "192.168.1.254");
+    SysConfig.Eth1Interface.EthDhcpClient = 0;
+    strcpy((char *) SysConfig.Eth1Interface.EthIpAddress, "192.168.0.10");
+    strcpy((char *) SysConfig.Eth1Interface.EthSubmaskAddress, "255.255.255.0");
+    strcpy((char *) SysConfig.Eth1Interface.EthGatewayAddress, "192.168.0.254");
+    if (SysConfig.ModelName[10] == 'W') {
+        SysConfig.AthInterface.WifiMode = 2;
+    } else {
+        SysConfig.AthInterface.WifiMode = 0;
+    }
+    strcpy((char *) SysConfig.AthInterface.WifiSsid, "");
+    strcpy((char *) SysConfig.AthInterface.WifiPassword, "");
+    SysConfig.AthInterface.WifiRssi = 0;
+    SysConfig.AthInterface.WifiDhcpServer = 0;
+    SysConfig.AthInterface.WifiDhcpClient = 0;
+    strcpy((char *) SysConfig.AthInterface.WifiMacAddress, "");
+    strcpy((char *) SysConfig.AthInterface.WifiIpAddress, "");
+    strcpy((char *) SysConfig.AthInterface.WifiSubmaskAddress, "");
+    strcpy((char *) SysConfig.AthInterface.WifiGatewayAddress, "");
+    SysConfig.AthInterface.WifiNetworkConn = 0;
+    strcpy((char *) SysConfig.TelecomInterface.TelcomModelName, "");
+    strcpy((char *) SysConfig.TelecomInterface.TelcomSoftwareVer, "");
+    //strcpy((char *) SysConfig.TelecomInterface.TelcomApn, "Internet");
+    strcpy((char *) SysConfig.TelecomInterface.TelcomApn, "");
+    SysConfig.TelecomInterface.TelcomRssi = 0;
+    strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapId, " ");
+    strcpy((char *) SysConfig.TelecomInterface.TelcomChapPapPwd, " ");
+    strcpy((char *) SysConfig.TelecomInterface.TelcomModemImei, "");
+    strcpy((char *) SysConfig.TelecomInterface.TelcomSimImsi, "");
+    strcpy((char *) SysConfig.TelecomInterface.TelcomSimIccid, "");
+    SysConfig.TelecomInterface.TelcomSimStatus = 0;
+    SysConfig.TelecomInterface.TelcomModemMode = 0;
+    strcpy((char *) SysConfig.TelecomInterface.TelcomIpAddress, "");
+    SysConfig.TelecomInterface.TelcomNetworkConn = 0;
+    strcpy((char *)SysConfig.chargePointVendor, "Phihong Technology");
+    //********** Backend **********//
+    SysConfig.BackendConnTimeout = 300; //300 seconds
+    SysConfig.OfflinePolicy = 2;
+    SysConfig.OfflineMaxChargeEnergy = 0;
+    SysConfig.OfflineMaxChargeDuration = 0;
+    strcpy((char *) SysConfig.OcppServerURL, "");
+    strcpy((char *) SysConfig.ChargeBoxId, "");
+    SysConfig.LedInfo.Intensity = 2;
 
-	//copy default configuration to pointer
-	memcpy(ptr,&SysConfig,sizeof(struct SysConfigData));
+    //copy default configuration to pointer
+    memcpy(ptr, &SysConfig, sizeof(struct SysConfigData));
 
-	//calculate CRC
-	Chk=0;
-	for(i=0;i<(MtdBlockSize-4);i++)
-	{
-		Chk+=*(ptr+i);
-	}
-	memcpy(	ptr+MtdBlockSize-4,&Chk,4);
+    //calculate CRC
+    Chk = 0;
+    for (i = 0; i < (MtdBlockSize - 4); i++) {
+        Chk += *(ptr + i);
+    }
+    memcpy( ptr + MtdBlockSize - 4, &Chk, 4);
 
-	/*
-	* Parameter process
-	*/
-	if (argc > 1)
-	{
-		char *arg = argv[1];
-		switch (arg[0])
-		{
-		case '-':
-			switch (arg[1])
-			{
-				case 'a':
-					outType |= OUTPUT_FILE;
-					outType |= OUTPUT_FLASH;
-					break;
-				case 'f':
-					outType |= OUTPUT_FILE;
-					break;
-				case 'm':
-					outType |= OUTPUT_FLASH;
-					break;
-				default:
-					helpOutput();
-					break;
-			}
-				break;
-			default:
-				helpOutput();
-				break;
-		}
-	}
-	else
-	{
-		helpOutput();
-	}
+    /*
+    * Parameter process
+    */
+    if (argc > 1) {
+        char *arg = argv[1];
+        switch (arg[0]) {
+        case '-':
+            switch (arg[1]) {
+            case 'a':
+                outType |= OUTPUT_FILE;
+                outType |= OUTPUT_FLASH;
+                break;
+            case 'f':
+                outType |= OUTPUT_FILE;
+                break;
+            case 'm':
+                outType |= OUTPUT_FLASH;
+                break;
+            default:
+                helpOutput();
+                break;
+            }
+            break;
+        default:
+            helpOutput();
+            break;
+        }
+    } else {
+        helpOutput();
+    }
 
-	/*
-	 * Configuration bin file generate
-	*/
-	if((outType&OUTPUT_FILE)>0)
-	{
-		fd = open("/mnt/FactoryDefaultConfig.bin", O_RDWR | O_CREAT);
-		if (fd < 0)
-		{
-			StoreLogMsg("[FactoryConfig]main: open /mnt/FactoryDefaultConfig.bin NG");
-			free(ptr);
-			return 0;
-		}
-		wrd=write(fd, ptr, MtdBlockSize);
-		close(fd);
-		if(wrd<MtdBlockSize)
-		{
-			StoreLogMsg("write /mnt/FactoryDefaultConfig.bin NG\r\n");
-			free(ptr);
-			return 0;
-		}
-		StoreLogMsg("FactoryConfig write to file in /mnt OK.\r\n");
-	}
+    /*
+     * Configuration bin file generate
+    */
+    if ((outType & OUTPUT_FILE) > 0) {
+        fd = open("/mnt/FactoryDefaultConfig.bin", O_RDWR | O_CREAT);
+        if (fd < 0) {
+            StoreLogMsg("[FactoryConfig]main: open /mnt/FactoryDefaultConfig.bin NG");
+            free(ptr);
+            return 0;
+        }
+        wrd = write(fd, ptr, MtdBlockSize);
+        close(fd);
+        if (wrd < MtdBlockSize) {
+            StoreLogMsg("write /mnt/FactoryDefaultConfig.bin NG\r\n");
+            free(ptr);
+            return 0;
+        }
+        StoreLogMsg("FactoryConfig write to file in /mnt OK.\r\n");
+    }
 
-	/*
-	* Flash memory write
-	*/
-	if((outType&OUTPUT_FLASH)>0)
-	{
-		// Save factory default setting value to flash factory default setting block
-		fd = open("/dev/mtdblock12", O_RDWR);
-		if (fd < 0)
-		{
-			StoreLogMsg("open /dev/mtdblock12 NG\r\n");
-			free(ptr);
-			return 0;
-		}
-		wrd=write(fd, ptr, MtdBlockSize);
-		close(fd);
-		if(wrd<MtdBlockSize)
-		{
-			StoreLogMsg("write /dev/mtdblock12 NG\r\n");
-			free(ptr);
-			return 0;
-		}
+    /*
+    * Flash memory write
+    */
+    if ((outType & OUTPUT_FLASH) > 0) {
+        // Save factory default setting value to flash factory default setting block
+        fd = open("/dev/mtdblock12", O_RDWR);
+        if (fd < 0) {
+            StoreLogMsg("open /dev/mtdblock12 NG\r\n");
+            free(ptr);
+            return 0;
+        }
+        wrd = write(fd, ptr, MtdBlockSize);
+        close(fd);
+        if (wrd < MtdBlockSize) {
+            StoreLogMsg("write /dev/mtdblock12 NG\r\n");
+            free(ptr);
+            return 0;
+        }
 
-		// Save factory default setting value to flash backup setting block
-		fd = open("/dev/mtdblock11", O_RDWR);
-		if (fd < 0)
-		{
-			StoreLogMsg("open /dev/mtdblock11 NG\r\n");
-			free(ptr);
-			return 0;
-		}
-		wrd=write(fd, ptr, MtdBlockSize);
-		close(fd);
-		if(wrd<MtdBlockSize)
-		{
-			StoreLogMsg("write /dev/mtdblock11 NG\r\n");
-			free(ptr);
-			return 0;
-		}
+        // Save factory default setting value to flash backup setting block
+        fd = open("/dev/mtdblock11", O_RDWR);
+        if (fd < 0) {
+            StoreLogMsg("open /dev/mtdblock11 NG\r\n");
+            free(ptr);
+            return 0;
+        }
+        wrd = write(fd, ptr, MtdBlockSize);
+        close(fd);
+        if (wrd < MtdBlockSize) {
+            StoreLogMsg("write /dev/mtdblock11 NG\r\n");
+            free(ptr);
+            return 0;
+        }
 
-		// Save factory default setting value to flash setting block
-		fd = open("/dev/mtdblock10", O_RDWR);
-		if (fd < 0)
-		{
-			StoreLogMsg("open /dev/mtdblock10 NG\r\n");
-			free(ptr);
-			return 0;
-		}
-		wrd=write(fd, ptr, MtdBlockSize);
-		close(fd);
-		if(wrd<MtdBlockSize)
-		{
-			StoreLogMsg("write /dev/mtdblock10 NG\r\n");
-			free(ptr);
-			return 0;
-		}
-		StoreLogMsg("FactoryConfig write to flash OK\r\n");
-	}
+        // Save factory default setting value to flash setting block
+        fd = open("/dev/mtdblock10", O_RDWR);
+        if (fd < 0) {
+            StoreLogMsg("open /dev/mtdblock10 NG\r\n");
+            free(ptr);
+            return 0;
+        }
+        wrd = write(fd, ptr, MtdBlockSize);
+        close(fd);
+        if (wrd < MtdBlockSize) {
+            StoreLogMsg("write /dev/mtdblock10 NG\r\n");
+            free(ptr);
+            return 0;
+        }
+        StoreLogMsg("FactoryConfig write to flash OK\r\n");
+    }
 
-	free(ptr);
+    free(ptr);
 
-	return FAIL;
+    return FAIL;
 }
 

+ 27 - 4
EVSE/Projects/DD360Audi/Apps/Module_EvComm.c

@@ -67,9 +67,9 @@ float _outCur_2 = 0;
 // Chademo : 500V, 125A,
 // GB : 750, 120A
 // CCS : 950V, 120A
-float maxChargingVol[2] = { 5000, 9500 };           // 限制最大充電電壓,如依照模塊則填上 0
+float maxChargingVol[2] = { 9500, 9500 };           // 限制最大充電電壓,如依照模塊則填上 0
 // 限制最大充電電流與能量透過 Web
-float maxChargingCur[2] = { 5000, 1200 };           // 限制最大充電電流,如依照模塊則填上 0
+float maxChargingCur[2] = { 5000, 2000 };           // 限制最大充電電流,如依照模塊則填上 0
 float maxChargingPow = 0;                           // 限制最大充電能量,如依照模塊則填上 0
 
 // 槍資訊
@@ -1016,8 +1016,13 @@ void ClearAbnormalStatus_CCS(byte gun_index)
         return;
     }
 
-    if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023701", 6) == EQUAL &&
-            ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail == YES) {
+    if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "012219", 6) == EQUAL &&
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP == YES) {
+        memcpy(code, "012219", 6);
+        memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
+        isCleanCheck = true;
+    } else if (strncmp((char *)_chargingData[gun_index]->EvConnAlarmCode, "023701", 6) == EQUAL &&
+               ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail == YES) {
         memcpy(code, "023701", 6);
         memcpy(_chargingData[gun_index]->EvConnAlarmCode, "", 6);
         isCleanCheck = true;
@@ -1731,6 +1736,7 @@ void ClearAbnormalStatus_CCS(byte gun_index)
             if (index != gun_index || ShmSysConfigAndInfo->SysConfig.TotalConnectorCount == 1) {
                 PRINTF_FUNC("CCS clean error : index = %d, EvConnAlarmCode = %s, code = %s \n", index, _chargingData[index]->EvConnAlarmCode, code);
                 if (strncmp((char *)_chargingData[index]->EvConnAlarmCode, code, 6) != EQUAL) {
+                    if (strncmp(code, "012219", 6) == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP = NO; }
                     if (strncmp(code, "023701", 6) == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEvCommFail = NO; }
                     if (strncmp(code, "023737", 6) == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsRESTemperatureInhibit = NO; }
                     if (strncmp(code, "023738", 6) == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.CcsEVShiftPosition = NO; }
@@ -1891,6 +1897,10 @@ void AbnormalStopAnalysis(byte gun_index, byte *errCode)
 
     memcpy(_chargingData[gun_index]->EvConnAlarmCode, string, 6);
     PRINTF_FUNC("NOTIFICATION_EV_STOP : EvConnAlarmCode = %s \n", _chargingData[gun_index]->EvConnAlarmCode);
+    //OVP error
+    if (strcmp(string, "012217") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChademoOutputOVP = YES; }
+    if (strcmp(string, "012219") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP = YES; }
+    if (strcmp(string, "012221") == EQUAL) { ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemGbOutputOVP = YES; }
 
     if (strcmp(string, "023700") == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoEvCommFail = YES; }
     if (strcmp(string, "023704") == EQUAL) { ShmStatusCodeData->InfoCode.InfoEvents.bits.ChademoBatteryMalfun = YES; }
@@ -2267,9 +2277,22 @@ void CANReceiver()
                 break;
                 case ACK_GET_OUTPUT_REQ: {
                     _chargingData[targetGun]->EvBatterySoc = frame.data[1];
+
+                    //Jerry add set voltage limit
                     _chargingData[targetGun]->EvBatterytargetVoltage = (float)((frame.data[3] << 8) + frame.data[2]) / 10;
+                    if (_chargingData[targetGun]->EvBatterytargetVoltage > maxChargingVol[targetGun] * 0.1) {
+                        _chargingData[targetGun]->EvBatterytargetVoltage = maxChargingVol[targetGun] * 0.1;
+                    }
+                    //printf("id = %d, EvBatterytargetVoltage = %.2f\r\n", targetGun, _chargingData[targetGun]->EvBatterytargetVoltage);
+                    //Jerry add set currency limit
                     _chargingData[targetGun]->EvBatterytargetCurrent = (float)((frame.data[5] << 8) + frame.data[4]) / 10;
+                    if (_chargingData[targetGun]->EvBatterytargetCurrent > maxChargingCur[targetGun] * 0.1) {
+                        _chargingData[targetGun]->EvBatterytargetCurrent = maxChargingCur[targetGun] * 0.1;
+                    }
+                    //printf("id = %d, EvBatterytargetCurrent = %.2f\r\n", targetGun, _chargingData[targetGun]->EvBatterytargetCurrent);
+
                     _chargingData[targetGun]->RemainChargingDuration = ((short) frame.data[7] << 8) + (short) frame.data[6];
+                    //printf("RemainChargingDuration = %d\r\n",  _chargingData[targetGun]->RemainChargingDuration);
 
                     if (_chargingData[targetGun]->Type == _Type_Chademo) {
                         //if (ShmCHAdeMOData->ev[_chargingData[targetGun]->type_index].EvDetection != frame.data[0])

+ 208 - 251
EVSE/Projects/DD360Audi/Apps/Module_EventLogging.c

@@ -1,41 +1,41 @@
-#include 	<sys/time.h>
-#include 	<sys/timeb.h>
+#include    <sys/time.h>
+#include    <sys/timeb.h>
 #include    <sys/types.h>
 #include    <sys/stat.h>
-#include 	<sys/types.h>
-#include 	<sys/ioctl.h>
-#include 	<sys/socket.h>
-#include 	<sys/ipc.h>
-#include 	<sys/shm.h>
-#include 	<sys/shm.h>
-#include 	<sys/mman.h>
-#include 	<linux/wireless.h>
-#include 	<arpa/inet.h>
-#include 	<netinet/in.h>
+#include    <sys/types.h>
+#include    <sys/ioctl.h>
+#include    <sys/socket.h>
+#include    <sys/ipc.h>
+#include    <sys/shm.h>
+#include    <sys/shm.h>
+#include    <sys/mman.h>
+#include    <linux/wireless.h>
+#include    <arpa/inet.h>
+#include    <netinet/in.h>
 
-#include 	<unistd.h>
-#include 	<stdarg.h>
-#include    <stdio.h>      /*標準輸入輸出定義*/
-#include    <stdlib.h>     /*標準函數庫定義*/
-#include    <unistd.h>     /*Unix 標準函數定義*/
-#include    <fcntl.h>      /*檔控制定義*/
-#include    <termios.h>    /*PPSIX 終端控制定義*/
-#include    <errno.h>      /*錯誤號定義*/
-#include 	<errno.h>
-#include 	<string.h>
-#include	<time.h>
-#include	<ctype.h>
-#include 	<ifaddrs.h>
-#include	"../../define.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    <errno.h>
+#include    <string.h>
+#include    <time.h>
+#include    <ctype.h>
+#include    <ifaddrs.h>
+#include    "../../define.h"
 
-#define ARRAY_SIZE(A)		(sizeof(A) / sizeof(A[0]))
-#define PASS				1
-#define FAIL				-1
-#define YES					1
-#define NO					0
+#define ARRAY_SIZE(A)       (sizeof(A) / sizeof(A[0]))
+#define PASS                1
+#define FAIL                -1
+#define YES                 1
+#define NO                  0
 
-struct SysConfigAndInfo			*ShmSysConfigAndInfo;
-struct StatusCodeData 			*ShmStatusCodeData;
+struct SysConfigAndInfo         *ShmSysConfigAndInfo;
+struct StatusCodeData           *ShmStatusCodeData;
 
 void PRINTF_FUNC(char *string, ...);
 
@@ -46,74 +46,71 @@ int StoreLogMsg(const char *fmt, ...);
 
 int StoreLogMsg(const char *fmt, ...)
 {
-	char Buf[4096+256];
-	char buffer[4096];
-	va_list args;
-	struct timeb  SeqEndTime;
-	struct tm *tm;
+    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);
+    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);
+    memset(Buf, 0, sizeof(Buf));
+    ftime(&SeqEndTime);
+    SeqEndTime.time = time(NULL);
+    tm = localtime(&SeqEndTime.time);
 
-	if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
-	{
-		sprintf(Buf,"%02d:%02d:%02d:%03d - %s",
-			tm->tm_hour,tm->tm_min,tm->tm_sec,SeqEndTime.millitm, buffer);
-		printf("%s \n", Buf);
-	}
-	else
-	{
-		sprintf(Buf,"echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
-			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);
-	}
+    if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES) {
+        sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
+                tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
+        printf("%s \n", Buf);
+    } else {
+        sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
+                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;
+    return rc;
 }
 
 int DiffTimeb(struct timeb ST, struct timeb ET)
 {
-	//return milli-second
-	unsigned int StartTime,StopTime;
+    //return milli-second
+    unsigned int StartTime, StopTime;
 
-	StartTime=(unsigned int)ST.time;
-	StopTime=(unsigned int)ET.time;
-	return (StopTime-StartTime)*1000+ET.millitm-ST.millitm;
+    StartTime = (unsigned int)ST.time;
+    StopTime = (unsigned int)ET.time;
+    return (StopTime - StartTime) * 1000 + ET.millitm - ST.millitm;
 }
 
 void PRINTF_FUNC(char *string, ...)
 {
-	va_list args;
-	char buffer[4096];
-	va_start(args, string);
-	vsnprintf(buffer, sizeof(buffer), string, args);
-	va_end(args);
+    va_list args;
+    char buffer[4096];
+    va_start(args, string);
+    vsnprintf(buffer, sizeof(buffer), string, args);
+    va_end(args);
 
-	DEBUG_INFO("%s \n", buffer);
+    DEBUG_INFO("%s \n", buffer);
 }
 
 //=================================
 // Common routine
 //=================================
-char* getTimeString(void)
+char *getTimeString(void)
 {
-	char *result=malloc(21);
-	time_t timep;
-	struct tm *p;
-	time(&timep);
-	p=gmtime(&timep);
+    char *result = malloc(21);
+    time_t timep;
+    struct tm *p;
+    time(&timep);
+    p = gmtime(&timep);
 
-	sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
+    sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900 + p->tm_year), (1 + p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
 
-	return result;
+    return result;
 }
 
 //==========================================
@@ -121,43 +118,35 @@ char* getTimeString(void)
 //==========================================
 int InitShareMemory()
 {
-	int result = PASS;
-	int MeterSMId;
+    int result = PASS;
+    int MeterSMId;
 
-	//creat ShmSysConfigAndInfo
-	if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0)
-    {
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
-		#endif
-		result = FAIL;
-	}
-    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
-		#endif
-    	result = FAIL;
-   	 }
-    else
+    //creat ShmSysConfigAndInfo
+    if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo),  0777)) < 0) {
+#ifdef SystemLogMessage
+        DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
+#endif
+        result = FAIL;
+    } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
+#ifdef SystemLogMessage
+        DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
+#endif
+        result = FAIL;
+    } else
     {}
 
-   	 //creat ShmStatusCodeData
-   	 if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0)
-    {
-		#ifdef SystemLogMessage
-   		DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
-		#endif
-   		result = FAIL;
-	}
-    else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-    	#ifdef SystemLogMessage
-    	DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
-		#endif
-    	result = FAIL;
-   	}
-    else
+    //creat ShmStatusCodeData
+    if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),  0777)) < 0) {
+#ifdef SystemLogMessage
+        DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
+#endif
+        result = FAIL;
+    } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
+#ifdef SystemLogMessage
+        DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
+#endif
+        result = FAIL;
+    } else
     {}
 
     return result;
@@ -168,157 +157,125 @@ int InitShareMemory()
 //================================================
 void AddFaultCodeToBuf(unsigned char *Code)
 {
-	if(ShmSysConfigAndInfo->SysWarningInfo.WarningCount < 10)
-	{
-		memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[ShmSysConfigAndInfo->SysWarningInfo.WarningCount][0], Code, 7);
-		ShmSysConfigAndInfo->SysWarningInfo.WarningCount++;
-	}
+    if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount < 10) {
+        memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[ShmSysConfigAndInfo->SysWarningInfo.WarningCount][0], Code, 7);
+        ShmSysConfigAndInfo->SysWarningInfo.WarningCount++;
+    }
 }
 
 void RemoveFaultCodeToBuf(unsigned char *Code)
 {
-	unsigned char find = 0x01;
-	char _code[7];
-	sprintf(_code,"%s", Code);
+    unsigned char find = 0x01;
+    char _code[7];
+    sprintf(_code, "%s", Code);
 
-	// 把相關的錯誤碼一次移除,避免重複顯示
-	while(find)
-	{
-		find = 0x00;
-		for(unsigned char i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++)
-		{
-			if (find == 0x00)
-			{
-				if(memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], _code, 7) == 0)
-				{
-					find = 0x01;
-				}
-			}
-			else
-			{
-				memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i - 1][0],
-					&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], 7);
-			}
-		}
+    // �羓㮾�𦦵��航炊蝣潔�甈∠宏�歹��踹��滩�憿舐內
+    while (find) {
+        find = 0x00;
+        for (unsigned char i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+            if (find == 0x00) {
+                if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], _code, 7) == 0) {
+                    find = 0x01;
+                }
+            } else {
+                memcpy(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i - 1][0],
+                       &ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], 7);
+            }
+        }
 
-		if (find)
-		{
-			ShmSysConfigAndInfo->SysWarningInfo.WarningCount--;
-		}
-	}
+        if (find) {
+            ShmSysConfigAndInfo->SysWarningInfo.WarningCount--;
+        }
+    }
 }
 
 int main(void)
 {
-	int ByteCount,BitCount;
-	unsigned char tmp, EventCodeTmp[7];
+    int ByteCount, BitCount;
+    unsigned char tmp, EventCodeTmp[7];
 
-	if(InitShareMemory() == FAIL)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("InitShareMemory NG\n");
-		#endif
-		if(ShmStatusCodeData!=NULL)
-		{
-			ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=1;
-		}
-		sleep(5);
-		return 0;
-	}
+    if (InitShareMemory() == FAIL) {
+#ifdef SystemLogMessage
+        DEBUG_ERROR("InitShareMemory NG\n");
+#endif
+        if (ShmStatusCodeData != NULL) {
+            ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
+        }
+        sleep(5);
+        return 0;
+    }
 
-	for(;;)
-	{
-		//check Fault Status
-		for(ByteCount=0;ByteCount<sizeof(ShmStatusCodeData->FaultCode.PreviousFaultVal);ByteCount++)
-		{
-			if(ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[ByteCount] != ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount])
-			{
-				tmp=ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[ByteCount]; //prevent be modified during following process
-				for(BitCount=0;BitCount<8;BitCount++)
-				{
-					if(((tmp>>BitCount)&0x01) != ((ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount]>>BitCount)&0x01))
-					{
-						memset(EventCodeTmp,0,sizeof(EventCodeTmp));
-						memcpy(EventCodeTmp,FaultStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
-						if(((tmp>>BitCount)&0x01)==0)//Recovered
-						{
-							//EventCodeTmp[0]=1;
-							DEBUG_INFO("Recovery Fault Code = %s\n", EventCodeTmp);
-							ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] &= ~(1<<BitCount);
-							RemoveFaultCodeToBuf(EventCodeTmp);
-						}
-						else
-						{
-							DEBUG_INFO("Fault Code = %s\n", EventCodeTmp);
-							ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] |= (1<<BitCount);
-							AddFaultCodeToBuf(EventCodeTmp);
-						}
-					}
-				}
-			}
-		}
+    for (;;) {
+        //check Fault Status
+        for (ByteCount = 0; ByteCount < sizeof(ShmStatusCodeData->FaultCode.PreviousFaultVal); ByteCount++) {
+            if (ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[ByteCount] != ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount]) {
+                tmp = ShmStatusCodeData->FaultCode.FaultEvents.FaultVal[ByteCount]; //prevent be modified during following process
+                for (BitCount = 0; BitCount < 8; BitCount++) {
+                    if (((tmp >> BitCount) & 0x01) != ((ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] >> BitCount) & 0x01)) {
+                        memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
+                        memcpy(EventCodeTmp, FaultStatusCode[ByteCount * 8 + BitCount], sizeof(EventCodeTmp) - 1);
+                        if (((tmp >> BitCount) & 0x01) == 0) { //Recovered
+                            //EventCodeTmp[0]=1;
+                            DEBUG_INFO("Recovery Fault Code = %s\n", EventCodeTmp);
+                            ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] &= ~(1 << BitCount);
+                            RemoveFaultCodeToBuf(EventCodeTmp);
+                        } else {
+                            DEBUG_INFO("Fault Code = %s\n", EventCodeTmp);
+                            ShmStatusCodeData->FaultCode.PreviousFaultVal[ByteCount] |= (1 << BitCount);
+                            AddFaultCodeToBuf(EventCodeTmp);
+                        }
+                    }
+                }
+            }
+        }
 
-		//check Alarm Status
-		for(ByteCount=0;ByteCount<sizeof(ShmStatusCodeData->AlarmCode.PreviousAlarmVal);ByteCount++)
-		{
-			if(ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[ByteCount] != ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount])
-			{
-				tmp=ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[ByteCount]; //prevent be modified during following process
-				for(BitCount=0;BitCount<8;BitCount++)
-				{
-					if(((tmp>>BitCount)&0x01) != ((ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount]>>BitCount)&0x01))
-					{
-						memset(EventCodeTmp,0,sizeof(EventCodeTmp));
-						memcpy(EventCodeTmp,AlarmStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
-						if(((tmp>>BitCount)&0x01)==0)//Recovered
-						{
-							//EventCodeTmp[0]=1;
-							DEBUG_INFO("Recovery Alarm Code = %s\n", EventCodeTmp);
-							ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] &= ~(1<<BitCount);
-							RemoveFaultCodeToBuf(EventCodeTmp);
-						}
-						else
-						{
-							DEBUG_INFO("Alarm Code = %s\n", EventCodeTmp);
-							ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] |= (1<<BitCount);
-							AddFaultCodeToBuf(EventCodeTmp);
-						}
-					}
-				}
-			}
-		}
+        //check Alarm Status
+        for (ByteCount = 0; ByteCount < sizeof(ShmStatusCodeData->AlarmCode.PreviousAlarmVal); ByteCount++) {
+            if (ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[ByteCount] != ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount]) {
+                tmp = ShmStatusCodeData->AlarmCode.AlarmEvents.AlarmVal[ByteCount]; //prevent be modified during following process
+                for (BitCount = 0; BitCount < 8; BitCount++) {
+                    if (((tmp >> BitCount) & 0x01) != ((ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] >> BitCount) & 0x01)) {
+                        memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
+                        memcpy(EventCodeTmp, AlarmStatusCode[ByteCount * 8 + BitCount], sizeof(EventCodeTmp) - 1);
+                        if (((tmp >> BitCount) & 0x01) == 0) { //Recovered
+                            //EventCodeTmp[0]=1;
+                            DEBUG_INFO("Recovery Alarm Code = %s\n", EventCodeTmp);
+                            ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] &= ~(1 << BitCount);
+                            RemoveFaultCodeToBuf(EventCodeTmp);
+                        } else {
+                            DEBUG_INFO("Alarm Code = %s\n", EventCodeTmp);
+                            ShmStatusCodeData->AlarmCode.PreviousAlarmVal[ByteCount] |= (1 << BitCount);
+                            AddFaultCodeToBuf(EventCodeTmp);
+                        }
+                    }
+                }
+            }
+        }
 
-		//check Info Status
-		for(ByteCount=0;ByteCount<sizeof(ShmStatusCodeData->InfoCode.PreviousInfoVal);ByteCount++)
-		{
-			if(ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[ByteCount] != ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount])
-			{
-				tmp=ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[ByteCount]; //prevent be modified during following process
-				for(BitCount=0;BitCount<8;BitCount++)
-				{
-					if(((tmp>>BitCount)&0x01) != ((ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount]>>BitCount)&0x01))
-					{
-						memset(EventCodeTmp,0,sizeof(EventCodeTmp));
-						memcpy(EventCodeTmp,InfoStatusCode[ByteCount*8+BitCount],sizeof(EventCodeTmp)-1);
-						if(((tmp>>BitCount)&0x01)==0)//Recovered
-						{
-							//EventCodeTmp[0]=1;
-							DEBUG_INFO("Recovery Info Code = %s\n", EventCodeTmp);
-							ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] &= ~(1<<BitCount);
-							RemoveFaultCodeToBuf(EventCodeTmp);
-						}
-						else
-						{
-							DEBUG_INFO("Info Code = %s\n", EventCodeTmp);
-							ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] |= (1<<BitCount);
-							AddFaultCodeToBuf(EventCodeTmp);
-						}
-					}
-				}
-			}
-		}
-		usleep(500000);
-	}
+        //check Info Status
+        for (ByteCount = 0; ByteCount < sizeof(ShmStatusCodeData->InfoCode.PreviousInfoVal); ByteCount++) {
+            if (ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[ByteCount] != ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount]) {
+                tmp = ShmStatusCodeData->InfoCode.InfoEvents.InfoVal[ByteCount]; //prevent be modified during following process
+                for (BitCount = 0; BitCount < 8; BitCount++) {
+                    if (((tmp >> BitCount) & 0x01) != ((ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] >> BitCount) & 0x01)) {
+                        memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
+                        memcpy(EventCodeTmp, InfoStatusCode[ByteCount * 8 + BitCount], sizeof(EventCodeTmp) - 1);
+                        if (((tmp >> BitCount) & 0x01) == 0) { //Recovered
+                            //EventCodeTmp[0]=1;
+                            DEBUG_INFO("Recovery Info Code = %s\n", EventCodeTmp);
+                            ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] &= ~(1 << BitCount);
+                            RemoveFaultCodeToBuf(EventCodeTmp);
+                        } else {
+                            DEBUG_INFO("Info Code = %s\n", EventCodeTmp);
+                            ShmStatusCodeData->InfoCode.PreviousInfoVal[ByteCount] |= (1 << BitCount);
+                            AddFaultCodeToBuf(EventCodeTmp);
+                        }
+                    }
+                }
+            }
+        }
+        usleep(500000);
+    }
 
-	return FAIL;
+    return FAIL;
 }

+ 42 - 108
EVSE/Projects/DD360Audi/Apps/Module_InternalComm.c

@@ -39,6 +39,7 @@
 #define FAIL                -1
 #define YES                 1
 #define NO                  0
+#define OUTPUT_VOL_CHK_TIME    200     // ms
 #define TEN_MINUTES         600
 #define ENV_TEMP_MIN        45
 #define ENV_TEMP_MAX        50
@@ -129,6 +130,8 @@ struct timeval  _ac_charging_comp;
 struct timeval  _ac_preparing;
 struct timeb    _ac_startChargingTime;
 struct timeb    _ac_endChargingTime;
+bool _isOvpChkTimeFlag[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
+struct timeval _checkOutputVolProtectTimer[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 
 unsigned short _setFanSpeed = 0;
 float _beforeChargingTotalEnergy = 0.0;
@@ -466,6 +469,7 @@ void GetPresentInputVol()
                 ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputUVP = NO;
             }
         }
+#endif //!defined DD360 && !defined DD360Audi
         //********************************************************************************************************//
         // Vin (OVP)
         if (ShmSysConfigAndInfo->SysInfo.ChargerType == _CHARGER_TYPE_IEC) {
@@ -511,7 +515,6 @@ void GetPresentInputVol()
                 ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemL3InputOVP = NO;
             }
         }
-#endif //!defined DD360 && !defined DD360Audi
     }
 }
 
@@ -1629,18 +1632,38 @@ void CableCheckDetected(byte index)
 void CheckOutputPowerOverCarReq(byte index)
 {
     float fireV = _chargingData[index]->FireChargingVoltage;
-    float carV = _chargingData[index]->EvBatterytargetVoltage * 10;
+    float carV = _chargingData[index]->EvBatteryMaxVoltage * 10;
 
     if ((_chargingData[index]->EvBatterytargetVoltage * 10) > 1500 &&
             (_chargingData[index]->Type == _Type_Chademo ||
              _chargingData[index]->Type == _Type_CCS_2 ||
              _chargingData[index]->Type == _Type_GB)) {
-        if (fireV >= (carV + (carV * 0.1))) {
-            PRINTF_FUNC("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
-                        _chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10));
-            DEBUG_ERROR("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
-                        _chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10));
-            _chargingData[index]->StopChargeFlag = YES;
+        if (fireV >= (carV + (carV * 0.02))) {
+            if (!_isOvpChkTimeFlag[index]) {
+                if ((_chargingData[index]->PresentChargingVoltage * 10) >= VOUT_MIN_VOLTAGE * 10) {
+                    gettimeofday(&_checkOutputVolProtectTimer[index], NULL);
+                    _isOvpChkTimeFlag[index] = YES;
+                }
+            } else {
+                PRINTF_FUNC("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
+                            _chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10));
+                DEBUG_ERROR("[Module_InternalComm]CheckOutputPowerOverCarReq NG : fire = %f, battery = %f \n",
+                            _chargingData[index]->FireChargingVoltage, (_chargingData[index]->EvBatterytargetVoltage * 10));
+                if ((GetTimeoutValue(_checkOutputVolProtectTimer[index]) / 1000) >= OUTPUT_VOL_CHK_TIME) {
+                    if (_chargingData[index]->Type == _Type_Chademo) {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemChademoOutputOVP = YES;
+                    } else if (_chargingData[index]->Type == _Type_CCS_2) {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemCcsOutputOVP = YES;
+                    } else if (_chargingData[index]->Type == _Type_GB) {
+                        ShmStatusCodeData->AlarmCode.AlarmEvents.bits.SystemGbOutputOVP = YES;
+                    }
+                    _chargingData[index]->StopChargeFlag = YES;
+                }
+            }
+        } else {
+            if (_isOvpChkTimeFlag[index] == YES) {
+                _isOvpChkTimeFlag[index] = NO;
+            }
         }
     }
 }
@@ -2156,12 +2179,14 @@ int main(void)
     //bool printRelayStatus = true;
     for (;;) {
         bool isCharging = false;
+
         // 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
         if (ShmRelayModuleData->SelfTest_Comp == NO) {
             GetFwAndHwVersion_Relay();
             SetRtcData_Relay();
             sleep(1);
         }
+
 #ifndef NO_FAN_BOARD
         if (ShmFanModuleData->SelfTest_Comp == NO) {
             GetFwAndHwVersion_Fan();
@@ -2170,7 +2195,8 @@ int main(void)
             sleep(1);
             gettimeofday(&_priority_time, NULL);
         }
-#endif
+#endif //NO_FAN_BOARD
+
         // 自檢階段處理,自檢階段如果讀不到版號則代表該系統沒有掛燈板
         if (ShmLedModuleData->SelfTest_Comp == NO) {
             // 自檢階段
@@ -2201,6 +2227,7 @@ int main(void)
             // 讀取當前 AC relay 狀態
             regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
 #endif //!defined DD360 && !defined DD360Audi
+
             //GetRelayOutputStatus();
 
             for (int i = 0; i < gunCount; i++) {
@@ -2219,11 +2246,12 @@ int main(void)
                 }
 
                 CheckAcInputOvpStatus(i);
-
 #endif //!defined DD360 && !defined DD360Audi
+
                 if (_chargingData[i]->SystemStatus == S_IDLE) {
                     _chargingData[i]->RelayWeldingCheck = NO;
                     _isRelayWelding[i] = NO;
+                    _isOvpChkTimeFlag[i] = NO;
                 }
 
                 if (_chargingData[i]->SystemStatus == S_BOOTING ||
@@ -2246,7 +2274,7 @@ int main(void)
 
                     if (_chargingData[i]->SystemStatus == S_CHARGING) {
                         CheckOutputPowerOverCarReq(i);
-                        CheckOutputVolNoneMatchFire(i);
+                        //CheckOutputVolNoneMatchFire(i);
                     } else {
                         _isOutputNoneMatch[i] = NO;
                     }
@@ -2309,53 +2337,8 @@ int main(void)
 
                 }
             }
-
-
-//          if(IsNoneMatchRelayStatus())
-//          {
-//              if (printRelayStatus)
-//              {
-////                    PRINTF_FUNC("Match Relay Target, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x \n",
-////                            outputRelay.relay_event.bits.AC_Contactor,
-////                            outputRelay.relay_event.bits.Gun1_P,
-////                            outputRelay.relay_event.bits.Gun1_N,
-////                            outputRelay.relay_event.bits.Gun2_P,
-////                            outputRelay.relay_event.bits.Gun2_N,
-////                            outputRelay.relay_event.bits.CCS_Precharge,
-////                            outputRelay.relay_event.bits.Gun1_Parallel_P,
-////                            outputRelay.relay_event.bits.Gun1_Parallel_N);
-//              }
-//              printRelayStatus = false;
-//              if (Config_Relay_Output(Uart5Fd, Addr.Relay, &outputRelay))
-//              {
-//                  PRINTF_FUNC("Match Relay Target, AC = %x, g1_p = %x, g1_n = %x, g2_p = %x, g2_n = %x, pre = %x, bri_p = %x, bri_n = %x \n",
-//                          outputRelay.relay_event.bits.AC_Contactor,
-//                          outputRelay.relay_event.bits.Gun1_P,
-//                          outputRelay.relay_event.bits.Gun1_N,
-//                          outputRelay.relay_event.bits.Gun2_P,
-//                          outputRelay.relay_event.bits.Gun2_N,
-//                          outputRelay.relay_event.bits.CCS_Precharge,
-//                          outputRelay.relay_event.bits.Gun1_Parallel_P,
-//                          outputRelay.relay_event.bits.Gun1_Parallel_N);
-//              }
-//          }
-//          else
-//          {
-//              if (!printRelayStatus)
-//              {
-//                  PRINTF_FUNC("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",
-//                          regRelay.relay_event.bits.AC_Contactor,
-//                          regRelay.relay_event.bits.Gun1_P,
-//                          regRelay.relay_event.bits.Gun1_N,
-//                          regRelay.relay_event.bits.Gun2_P,
-//                          regRelay.relay_event.bits.Gun2_N,
-//                          regRelay.relay_event.bits.CCS_Precharge,
-//                          regRelay.relay_event.bits.Gun1_Parallel_P,
-//                          regRelay.relay_event.bits.Gun1_Parallel_N);
-//              }
-//              printRelayStatus = true;
-//          }
         }
+
 #ifndef NO_FAN_BOARD
         if (ShmFanModuleData->SelfTest_Comp == YES) {
             if (GetTimeoutValue(_priority_time) / 1000 >= 1000) {
@@ -2370,61 +2353,12 @@ int main(void)
                 ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
                 ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
 
-//              if (isCharging)
-//              {
-////                    if (ShmFanModuleData->PresentFan1Speed < MAX_FAN_SPEED ||
-////                        ShmFanModuleData->PresentFan2Speed < MAX_FAN_SPEED ||
-////                        ShmFanModuleData->PresentFan3Speed < MAX_FAN_SPEED ||
-////                        ShmFanModuleData->PresentFan4Speed < MAX_FAN_SPEED)
-////                    {
-////                        ShmFanModuleData->SetFan1Speed = MAX_FAN_SPEED;
-////                        ShmFanModuleData->SetFan2Speed = MAX_FAN_SPEED;
-////                        ShmFanModuleData->SetFan3Speed = MAX_FAN_SPEED;
-////                        ShmFanModuleData->SetFan4Speed = MAX_FAN_SPEED;
-////                    }
-//
-//                  // 在還沒問到 PSU 溫度~ 還是要有個最小轉速
-//                  ShmFanModuleData->SetFan1Speed = MIN_FAN_SPEED;
-//                  ShmFanModuleData->SetFan2Speed = MIN_FAN_SPEED;
-//                  ShmFanModuleData->SetFan3Speed = MIN_FAN_SPEED;
-//                  ShmFanModuleData->SetFan4Speed = MIN_FAN_SPEED;
-//
-//                  if (ShmFanModuleData->TestFanSpeed > 0)
-//                  {
-//                      ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
-//                      ShmFanModuleData->SetFan2Speed = ShmFanModuleData->TestFanSpeed;
-//                      ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
-//                      ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
-//                  }
-//              }
-//              else
-//              {
-////                    if (ShmFanModuleData->PresentFan1Speed > MIN_FAN_SPEED ||
-////                        ShmFanModuleData->PresentFan2Speed > MIN_FAN_SPEED ||
-////                        ShmFanModuleData->PresentFan3Speed > MIN_FAN_SPEED ||
-////                        ShmFanModuleData->PresentFan4Speed > MIN_FAN_SPEED)
-////                    {
-//                      ShmFanModuleData->SetFan1Speed = MIN_FAN_SPEED;
-//                      ShmFanModuleData->SetFan2Speed = MIN_FAN_SPEED;
-//                      ShmFanModuleData->SetFan3Speed = MIN_FAN_SPEED;
-//                      ShmFanModuleData->SetFan4Speed = MIN_FAN_SPEED;
-////                    }
-//
-//                  // 停止時,如溫度還是很高,則需要維持該轉速直到溫度降低
-//                  if (ShmFanModuleData->TestFanSpeed >= MAX_FAN_SPEED)
-//                  {
-//                      ShmFanModuleData->SetFan1Speed = ShmFanModuleData->TestFanSpeed;
-//                      ShmFanModuleData->SetFan2Speed = ShmFanModuleData->TestFanSpeed;
-//                      ShmFanModuleData->SetFan3Speed = ShmFanModuleData->TestFanSpeed;
-//                      ShmFanModuleData->SetFan4Speed = ShmFanModuleData->TestFanSpeed;
-//                  }
-//              }
-
                 //PRINTF_FUNC("set fan = %d \n", ShmFanModuleData->SetFan1Speed);
                 SetFanModuleSpeed();
             }
         }
-#endif
+#endif //NO_FAN_BOARD
+
         if (ShmLedModuleData->SelfTest_Comp == YES) {
             if (GetTimeoutValue(_led_priority_time) / 1000 >= 1000) {
                 if (gunCount == 1) {

+ 3 - 0
EVSE/Projects/DD360Audi/Apps/Module_LcmContro.h

@@ -41,6 +41,7 @@ typedef unsigned char           byte;
 struct SysConfigAndInfo         *ShmSysConfigAndInfo;
 struct StatusCodeData           *ShmStatusCodeData;
 struct FanModuleData            *ShmFanModuleData;
+struct PrimaryMcuData           *ShmPrimaryMcuData;
 
 #define NO_DEFINE               255
 #define DEFAULT_AC_INDEX        2
@@ -149,6 +150,7 @@ short __balance              = 0x0270;
 short __remain_balance       = 0x0280;
 short __custStationIdL1      = 0x0450;
 //short __custStationIdL2      = 0x0470;
+short _emergency_map         = 0x011C;
 
 // ICON ID
 byte _disappear              = 0;
@@ -227,3 +229,4 @@ byte _left_gun_enable_map    = 67;
 byte _right_gun_disable_map  = 68;
 byte _right_gun_enable_map   = 69;
 byte _select_gun_btn         = 70;
+byte _emergency_disable_map  = 72;

+ 41 - 18
EVSE/Projects/DD360Audi/Apps/Module_LcmControl.c

@@ -118,6 +118,19 @@ int InitShareMemory()
         return 0;
     }
 
+    //creat ShmStatusCodeData
+    if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0) {
+#ifdef SystemLogMessage
+        DEBUG_ERROR("shmget ShmPrimaryMcuData NG\n");
+#endif
+        result = FAIL;
+    } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
+#ifdef ShmPrimaryMcuData
+        DEBUG_ERROR("shmat ShmPrimaryMcuData NG\n");
+#endif
+        result = FAIL;
+    }
+
     return result;
 }
 
@@ -352,19 +365,20 @@ void ChangeWarningFunc()
         if ((i - j) >= 5) {
             break;
         }
-        if ((memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033900", 6) == 0) ||
-                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033901", 6) == 0) ||
-                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033902", 6) == 0) ||
-                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043627", 6) == 0) ||
-                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043628", 6) == 0) ||
-                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043622", 6) == 0)  ||
-                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043623", 6) == 0) ||
-                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043624", 6) == 0) ||
-                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043625", 6) == 0) ||
-                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043626", 6) == 0)  ||
-                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042241", 6) == 0) ||
-                (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042242", 6) == 0)
-           ) {
+        if (
+            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033900", 6) == 0) ||
+            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033901", 6) == 0) ||
+            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "033902", 6) == 0) ||
+            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043627", 6) == 0) ||
+            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043628", 6) == 0) ||
+            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043622", 6) == 0) ||
+            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043623", 6) == 0) ||
+            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043624", 6) == 0) ||
+            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043625", 6) == 0) ||
+            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "043626", 6) == 0) ||
+            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042241", 6) == 0) ||
+            (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i + ShmSysConfigAndInfo->SysWarningInfo.PageIndex * 5][0], "042242", 6) == 0)
+        ) {
             j++;
             continue;
         }
@@ -401,7 +415,7 @@ void ChangeQrCode_Idle(char *input)
     uint16_t urlLen = 0;
     uint8_t cmd[len];
     uint8_t tmpBuf[15] = {0};
-    uint8_t tmpLen = sizeof(tmpBuf) - 1;
+    //uint8_t tmpLen = sizeof(tmpBuf) - 1;
 
     strncpy((char *)cmd, " ", len);
 
@@ -477,7 +491,7 @@ void ChangeQrCode_Charge(char *input)
     uint16_t urlLen = 0;
     uint8_t cmd[len];
     uint8_t tmpBuf[15] = {0};
-    uint8_t tmpLen = sizeof(tmpBuf) - 1;
+    //uint8_t tmpLen = sizeof(tmpBuf) - 1;
 
     strncpy((char *)cmd, " ", len);
 
@@ -1314,7 +1328,7 @@ void ProcessPageInfo()
                     } else {
                         ChangeChargingPowerValue(0);
                     }
-#if 0
+#if 1
                     if (_chargingInfoData[i]->PresentChargedEnergy >= 0.1 &&
                             _chargingInfoData[i]->PresentChargedEnergy <= ENERGY_MAX_KWH) {
                         ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
@@ -1331,7 +1345,7 @@ void ProcessPageInfo()
                             ChangeBalanceValue(__remain_balance, i);
                         }
                     }
-#endif // 0
+#else
                     ChangeChargingEnergyValue(_chargingInfoData[i]->PresentChargedEnergy);
 
                     if (ShmSysConfigAndInfo->SysConfig.BillingData.isBilling &&
@@ -1339,7 +1353,7 @@ void ProcessPageInfo()
                         ChangeChargingFeeValue(_chargingInfoData[i]->ChargingFee);
                         ChangeBalanceValue(__remain_balance, i);
                     }
-
+#endif // 0
                     if (!ShmSysConfigAndInfo->SysConfig.BillingData.isBilling) {
                         ChangeDisplay2Value(__charging_fee_map, _disappear);
                         ChangeDisplay2Value(__charging_fee_tx, _disappear);
@@ -1372,6 +1386,14 @@ void ProcessPageInfo()
         }
     }
     break;
+
+    case _LCM_FIX:
+        if (ShmPrimaryMcuData->InputDet.bits.EmergencyButton == 1) {
+            ChangeDisplay2Value(_emergency_map, _emergency_disable_map);
+        } else {
+            ChangeDisplay2Value(_emergency_map, _disappear);
+        }
+        break;
     }
 }
 
@@ -1520,5 +1542,6 @@ int main(void)
     }
 
     CloseCommunicationLcmPort();
+
     return FAIL;
 }

BIN
EVSE/Projects/DD360Audi/Apps/Module_PsuComm


+ 251 - 283
EVSE/Projects/DD360Audi/Apps/OutputTask.c

@@ -1,150 +1,134 @@
 /*
  * OutputTask.c
  *
- *  Created on: 2020¦~2¤ë25¤é
+ *  Created on: 2020年2月25日
  *      Author: 7564
  */
 
-#include 	"OutputTask.h"
+#include    "OutputTask.h"
 
 bool isOpen;
 
 int InitComPort()
 {
-	int fd;
-	struct termios tios;
-
-	fd = open(priPortName, O_RDWR);
-	if(fd<=0)
-	{
-		#ifdef SystemLogMessage
-		DEBUG_ERROR("open 407 Communication port NG \n");
-		#endif
-		return -1;
-	}
-	ioctl (fd, TCGETS, &tios);
-	tios.c_cflag = B115200| CS8 | CLOCAL | CREAD;
-	tios.c_lflag = 0;
-	tios.c_iflag = 0;
-	tios.c_oflag = 0;
-	tios.c_cc[VMIN]=0;
-	tios.c_cc[VTIME]=(unsigned char)1;
-	tios.c_lflag=0;
-	tcflush(fd, TCIFLUSH);
-	ioctl (fd, TCSETS, &tios);
-
-	return fd;
+    int fd;
+    struct termios tios;
+
+    fd = open(priPortName, O_RDWR);
+    if (fd <= 0) {
+#ifdef SystemLogMessage
+        DEBUG_ERROR("open 407 Communication port NG \n");
+#endif
+        return -1;
+    }
+    ioctl (fd, TCGETS, &tios);
+    tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD;
+    tios.c_lflag = 0;
+    tios.c_iflag = 0;
+    tios.c_oflag = 0;
+    tios.c_cc[VMIN] = 0;
+    tios.c_cc[VTIME] = (unsigned char)1;
+    tios.c_lflag = 0;
+    tcflush(fd, TCIFLUSH);
+    ioctl (fd, TCSETS, &tios);
+
+    return fd;
 }
 
 unsigned long GetTimeoutValue(struct timeval _sour_time)
 {
-	struct timeval _end_time;
-	gettimeofday(&_end_time, NULL);
+    struct timeval _end_time;
+    gettimeofday(&_end_time, NULL);
 
-	return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
+    return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
 }
 
 void ShowMainMsg()
 {
-	printf("Max Vol : %f, Max Cur : %d, POW : %d \n", UnSafeDataInfo->PSU_VOLTAGE,
-			UnSafeDataInfo->PSU_CURRENT, UnSafeDataInfo->PSU_POWER);
-	printf("=> ");
+    printf("Max Vol : %f, Max Cur : %d, POW : %d \n", UnSafeDataInfo->PSU_VOLTAGE,
+           UnSafeDataInfo->PSU_CURRENT, UnSafeDataInfo->PSU_POWER);
+    printf("=> ");
 }
 
 void ChkButtonStatus()
 {
-	if (Button1 == PRESS && !leftBtnPush)
-	{
-		if(!leftBtnPush)
-		{
-			leftBtnPush = true;
-			if (_charging_mode == CHARGING_MODE_STOP)
-			{
-				_charging_mode = CHARGING_MODE_START;
-				printf("****************** Switch to Charging Mode ******************\n");
-			}
-		}
-		else if (Button1 == RELEASE)
-		{
-			if(leftBtnPush)
-			{
-				leftBtnPush = false;
-			}
-		}
-	}
-
-	if (Button2 == PRESS && !rightBtnPush)
-	{
-		if(!rightBtnPush)
-		{
-			rightBtnPush = true;
-			if (_charging_mode == CHARGING_MODE_START)
-			{
-				_charging_mode = CHARGING_MODE_TERMINATING;
-				printf("****************** Switch to Stop Mode ******************\n");
-			}
-		}
-		else if (Button2 == RELEASE)
-		{
-			if(rightBtnPush)
-			{
-				rightBtnPush = false;
-			}
-		}
-	}
+    if (Button1 == PRESS && !leftBtnPush) {
+        if (!leftBtnPush) {
+            leftBtnPush = true;
+            if (_charging_mode == CHARGING_MODE_STOP) {
+                _charging_mode = CHARGING_MODE_START;
+                printf("****************** Switch to Charging Mode ******************\n");
+            }
+        } else if (Button1 == RELEASE) {
+            if (leftBtnPush) {
+                leftBtnPush = false;
+            }
+        }
+    }
+
+    if (Button2 == PRESS && !rightBtnPush) {
+        if (!rightBtnPush) {
+            rightBtnPush = true;
+            if (_charging_mode == CHARGING_MODE_START) {
+                _charging_mode = CHARGING_MODE_TERMINATING;
+                printf("****************** Switch to Stop Mode ******************\n");
+            }
+        } else if (Button2 == RELEASE) {
+            if (rightBtnPush) {
+                rightBtnPush = false;
+            }
+        }
+    }
 }
 
 void GetModuleCountCallback(byte group, byte count)
 {
-	printf("group = %d, count = %d \n", group, count);
-	if (group == SYSTEM_CMD)
-		UnSafeDataInfo->PSU_COUNT = count;
+    printf("group = %d, count = %d \n", group, count);
+    if (group == SYSTEM_CMD) {
+        UnSafeDataInfo->PSU_COUNT = count;
+    }
 }
 
 void GetAvailableCapCallback(byte address, short maxVol, short minVol, short maxCur, short totalPow)
 {
-	int _groupPower = 0, _groupCurrent = 0;
+    int _groupPower = 0, _groupCurrent = 0;
 
-	UnSafeDataInfo->PsuModule[address].PSU_VOLTAGE_INFO = maxVol;
-	UnSafeDataInfo->PsuModule[address].PSU_CURRENT_INFO = maxCur;
-	UnSafeDataInfo->PsuModule[address].PSU_POWER_INFO = totalPow;
+    UnSafeDataInfo->PsuModule[address].PSU_VOLTAGE_INFO = maxVol;
+    UnSafeDataInfo->PsuModule[address].PSU_CURRENT_INFO = maxCur;
+    UnSafeDataInfo->PsuModule[address].PSU_POWER_INFO = totalPow;
 
-	for (byte index = 0; index < UnSafeDataInfo->PSU_COUNT; index++)
-	{
-		_groupCurrent += UnSafeDataInfo->PsuModule[address].PSU_CURRENT_INFO;
-		_groupPower += UnSafeDataInfo->PsuModule[address].PSU_POWER_INFO;
-	}
+    for (byte index = 0; index < UnSafeDataInfo->PSU_COUNT; index++) {
+        _groupCurrent += UnSafeDataInfo->PsuModule[address].PSU_CURRENT_INFO;
+        _groupPower += UnSafeDataInfo->PsuModule[address].PSU_POWER_INFO;
+    }
 
-	UnSafeDataInfo->PSU_VOLTAGE = maxVol;
-	UnSafeDataInfo->PSU_CURRENT = _groupCurrent;
-	UnSafeDataInfo->PSU_POWER = _groupPower;
+    UnSafeDataInfo->PSU_VOLTAGE = maxVol;
+    UnSafeDataInfo->PSU_CURRENT = _groupCurrent;
+    UnSafeDataInfo->PSU_POWER = _groupPower;
 }
 
 void GetStatusCallback(byte group, byte address, byte temp, int alarm)
 {
-	printf("alarm = %d \n", alarm);
+    printf("alarm = %d \n", alarm);
 }
 
 void GetInputVoltageCallback(byte address, unsigned short vol1, unsigned short vol2, unsigned short vol3)
 {
-	printf("vol1 = %d, vol2 = %d, vol3 = %d \n", vol1, vol2, vol3);
+    printf("vol1 = %d, vol2 = %d, vol3 = %d \n", vol1, vol2, vol3);
 }
 
 int CreateShareMemory()
 {
-	int MeterSMId;
-
-	if ((MeterSMId = shmget(ShmTestKey,	sizeof(struct UnSafeData), IPC_CREAT | 0777)) < 0)
-	{
-		return 0;
-	}
-	else if ((UnSafeDataInfo = shmat(MeterSMId, NULL, 0))	== (void *) -1)
-	{
-		return 0;
-	}
-	memset(UnSafeDataInfo, 0, sizeof(struct UnSafeData));
-
-	return 1;
+    int MeterSMId;
+
+    if ((MeterSMId = shmget(ShmTestKey, sizeof(struct UnSafeData), IPC_CREAT | 0777)) < 0) {
+        return 0;
+    } else if ((UnSafeDataInfo = shmat(MeterSMId, NULL, 0))   == (void *) - 1) {
+        return 0;
+    }
+    memset(UnSafeDataInfo, 0, sizeof(struct UnSafeData));
+
+    return 1;
 }
 
 static void get_char(char *word)
@@ -158,216 +142,200 @@ static void get_char(char *word)
     tv.tv_usec = 10; //wait input timout time
 
     //if input
-    if (select(1, &rfds, NULL, NULL, &tv) > 0)
-    {
-    	fgets(word, 128, stdin);
+    if (select(1, &rfds, NULL, NULL, &tv) > 0) {
+        fgets(word, 128, stdin);
     }
 }
 
 void GetInputString()
 {
-	char word[128];
-	char newString[7][10];
-	int i, j, ctr;
-
-	get_char(word);
-
-	if (strlen(word) == 0)
-	    return;
-	//fgets(word, sizeof(word), stdin);
-
-	j = 0;
-	ctr = 0;
-	for (i = 0; i <= (strlen(word)); i++) {
-		if (word[i] == ' ' || word[i] == '\0' || word[i] == 10) {
-			newString[ctr][j] = '\0';
-			ctr++;
-			j = 0;
-		} else {
-			newString[ctr][j] = word[i];
-			j++;
-		}
-	}
-
-	VOLTAGE = atof(newString[0]);
-	CURRENT = atof(newString[1]);
-	if (VOLTAGE <= UnSafeDataInfo->PSU_VOLTAGE && CURRENT <= UnSafeDataInfo->PSU_CURRENT)
-	{
-		//printf("OutputVol = %f, OutputCur = %f \n", VOLTAGE, CURRENT);
-	}
-	else
-	{
-		ShowMainMsg();
-	}
+    char word[128];
+    char newString[7][10];
+    int i, j, ctr;
+
+    get_char(word);
+
+    if (strlen(word) == 0) {
+        return;
+    }
+    //fgets(word, sizeof(word), stdin);
+
+    j = 0;
+    ctr = 0;
+    for (i = 0; i <= (strlen(word)); i++) {
+        if (word[i] == ' ' || word[i] == '\0' || word[i] == 10) {
+            newString[ctr][j] = '\0';
+            ctr++;
+            j = 0;
+        } else {
+            newString[ctr][j] = word[i];
+            j++;
+        }
+    }
+
+    VOLTAGE = atof(newString[0]);
+    CURRENT = atof(newString[1]);
+    if (VOLTAGE <= UnSafeDataInfo->PSU_VOLTAGE && CURRENT <= UnSafeDataInfo->PSU_CURRENT) {
+        //printf("OutputVol = %f, OutputCur = %f \n", VOLTAGE, CURRENT);
+    } else {
+        ShowMainMsg();
+    }
 }
 
 void GetIavailableCallback(byte address, unsigned short Iavail, unsigned short Vext)
 {
-	//printf("address = %d, Iavail = %d, Vext = %d \n", address, Iavail, Vext);
+    //printf("address = %d, Iavail = %d, Vext = %d \n", address, Iavail, Vext);
 }
 
 void GetOutputAndTempCallback(byte address, unsigned short outputVol,
-		unsigned short outputCur, unsigned short outputPower, unsigned char Temperature)
+                              unsigned short outputCur, unsigned short outputPower, unsigned char Temperature)
 {
-	//printf("***Output Value and Temp*** address = %d, Vol = %d, Cur = %d, Pow = %d, Temp = %d \n",
-	//		address, outputVol, outputCur, outputPower, Temperature);
+    //printf("***Output Value and Temp*** address = %d, Vol = %d, Cur = %d, Pow = %d, Temp = %d \n",
+    //      address, outputVol, outputCur, outputPower, Temperature);
 }
 
 void GetModuleStatusCallback(byte address, unsigned char isErr, unsigned char status,
-		unsigned char err1, unsigned char err2, unsigned char err3, unsigned char err4)
+                             unsigned char err1, unsigned char err2, unsigned char err3, unsigned char err4)
 {
-	//int alarm = (err2 << 24) | (err3 << 16) | (err4 << 8);
-
-	// err2 == state 2
-	// err3 == state 1
-	// err4 == state 0
-	//printf("***Status*** address = %d, alarm = %d \n", address, alarm);
-//	printf("***Status*** address = %d, err1 = %d, err2 = %d, err3 = %d, err4 = %d \n",
-//			address, err1,err2,err3,err4);
+    //int alarm = (err2 << 24) | (err3 << 16) | (err4 << 8);
+
+    // err2 == state 2
+    // err3 == state 1
+    // err4 == state 0
+    //printf("***Status*** address = %d, alarm = %d \n", address, alarm);
+//  printf("***Status*** address = %d, err1 = %d, err2 = %d, err3 = %d, err4 = %d \n",
+//          address, err1,err2,err3,err4);
 }
 
 void GetModuleInputCallback(byte address, unsigned short inputR,
-		unsigned short inputS, unsigned short inputT)
+                            unsigned short inputS, unsigned short inputT)
 {
 
 }
 
 int main(void)
 {
-	isOpen =false;
-
-	if(CreateShareMemory() == 0)
-	{
-		printf("CreateShareMemory fail. \n");
-		return 0;
-	}
-	RefreshModuleCount(&GetModuleCountCallback);
-	RefreshAvailableCap(&GetAvailableCapCallback);
-
-	RefreshStatus(&GetStatusCallback);
-	RefreshInputVol(&GetInputVoltageCallback);
-
-	RefreshIavailable(&GetIavailableCallback);
-
-	AutoMode_RefreshOutputAndTemp(&GetOutputAndTempCallback);
-	AutoMode_RefreshModuleStatus(&GetModuleStatusCallback);
-	AutoMode_RefreshModuleInput(&GetModuleInputCallback);
-
-	Uart1Fd = InitComPort();
-	libInitialize = InitialCommunication();
-
-	if (Uart1Fd < 0 || !libInitialize)
-	{
-		printf("Initial port fail. \n");
-		return 0;
-	}
-
-	sleep(5);
-	gettimeofday(&_cmdSubPriority_time, NULL);
-	VOLTAGE = 0.0;
-	CURRENT = 0.0;
-
-	SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
-//	while (1)
-//	{
-//		printf("++++++++++++++2++++++++++++++++++++++++++++++++++++++\n");
-//		SetWalkInConfig(0, YES, 0);
-//		SetWalkInConfig(1, NO, 0);
-//		printf("++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
-//		sleep(1);
-//	}
+    isOpen = false;
+
+    if (CreateShareMemory() == 0) {
+        printf("CreateShareMemory fail. \n");
+        return 0;
+    }
+    RefreshModuleCount(&GetModuleCountCallback);
+    RefreshAvailableCap(&GetAvailableCapCallback);
+
+    RefreshStatus(&GetStatusCallback);
+    RefreshInputVol(&GetInputVoltageCallback);
+
+    RefreshIavailable(&GetIavailableCallback);
+
+    AutoMode_RefreshOutputAndTemp(&GetOutputAndTempCallback);
+    AutoMode_RefreshModuleStatus(&GetModuleStatusCallback);
+    AutoMode_RefreshModuleInput(&GetModuleInputCallback);
+
+    Uart1Fd = InitComPort();
+    libInitialize = InitialCommunication();
+
+    if (Uart1Fd < 0 || !libInitialize) {
+        printf("Initial port fail. \n");
+        return 0;
+    }
+
+    sleep(5);
+    gettimeofday(&_cmdSubPriority_time, NULL);
+    VOLTAGE = 0.0;
+    CURRENT = 0.0;
+
+    SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
+//  while (1)
+//  {
+//      printf("++++++++++++++2++++++++++++++++++++++++++++++++++++++\n");
+//      SetWalkInConfig(0, YES, 0);
+//      SetWalkInConfig(1, NO, 0);
+//      printf("++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+//      sleep(1);
+//  }
 //
-//	sleep(1);
-//		printf("++++++++++++++2++++++++++++++++++++++++++++++++++++++\n");
-//		SetWalkInConfig(SYSTEM_CMD, NO, 0);
-//		printf("++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
-//	return 0;
-	while (1)
-	{
-		GetInputGpioStatus();
-		//ChkButtonStatus();
-		// ¤Á´« Walk-in mode (default 5s -> 2s)
-		SetWalkInConfig(SYSTEM_CMD, NO, 0);
-
-		int time = GetTimeoutValue(_cmdSubPriority_time) / 1000;
-		while(isGetCount == YES)
-		{
-			if (_charging_mode == CHARGING_MODE_START)
-			{
-				// ¨ú±o¼Ò¶ô¿é¥XÃB©w¹q¬y¯à¤O
-				GetModuleIavailable(0);
-			}
-
-			GetInputString();
-			if (VOLTAGE > 150 && CURRENT >= 0)
-				_charging_mode = CHARGING_MODE_START;
-			else
-				_charging_mode = CHARGING_MODE_TERMINATING;
-			//printf("_charging_mode = %d \n", _charging_mode);
-			switch(_charging_mode)
-			{
-				case CHARGING_MODE_START:
-				{
-					//if (!isOpen)
-					{
-						//SwitchPower(SYSTEM_CMD, PSU_POWER_ON);
-						//FlashLed(SYSTEM_CMD, PSU_FLASH_ON);
-						SetDirModulePresentOutput(0,
-												VOLTAGE * 10,
-												CURRENT * 10,
-												0x01,
-												0x01);
-					}
-					//PresentOutputVol(SYSTEM_CMD, VOLTAGE * 10, CURRENT * 10);
-				}
-					break;
-				case CHARGING_MODE_TERMINATING:
-				{
-					//if (isOpen)
-					{
-						SetDirModulePresentOutput(0,
-							VOLTAGE * 10,
-							CURRENT * 10,
-							0x00,
-							0x01);
-						//SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
-						//FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
-					}
-				}
-					break;
-			}
-			//GetStatus(0);
-			//GetModuleInput(0);
-			sleep(1);
-		}
-
-		if (UnSafeDataInfo->PSU_COUNT <= 0)
-		{
-			if (time > 1000)
-			{
-				printf("Step 1 : GetModuleCount...... \n");
-				GetModuleCount(SYSTEM_CMD);
-				gettimeofday(&_cmdSubPriority_time, NULL);
-			}
-		}
-		else if (time < 5000)
-		{
-			printf("Step 2 : GetModuleCap...... \n");
-			GetModuleCap(0);
-
-			SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
-			FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
-		}
-		else
-		{
-			ShowMainMsg();
-			isGetCount = YES;
-		}
-
-		sleep(1);
-	}
-
-	return 0;
+//  sleep(1);
+//      printf("++++++++++++++2++++++++++++++++++++++++++++++++++++++\n");
+//      SetWalkInConfig(SYSTEM_CMD, NO, 0);
+//      printf("++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+//  return 0;
+    while (1) {
+        GetInputGpioStatus();
+        //ChkButtonStatus();
+        // 切� Walk-in mode (default 5s -> 2s)
+        SetWalkInConfig(SYSTEM_CMD, NO, 0);
+
+        int time = GetTimeoutValue(_cmdSubPriority_time) / 1000;
+        while (isGetCount == YES) {
+            if (_charging_mode == CHARGING_MODE_START) {
+                // �得模塊輸出�定電�能力
+                GetModuleIavailable(0);
+            }
+
+            GetInputString();
+            if (VOLTAGE > 150 && CURRENT >= 0) {
+                _charging_mode = CHARGING_MODE_START;
+            } else {
+                _charging_mode = CHARGING_MODE_TERMINATING;
+            }
+            //printf("_charging_mode = %d \n", _charging_mode);
+            switch (_charging_mode) {
+            case CHARGING_MODE_START: {
+                //if (!isOpen)
+                {
+                    //SwitchPower(SYSTEM_CMD, PSU_POWER_ON);
+                    //FlashLed(SYSTEM_CMD, PSU_FLASH_ON);
+                    SetDirModulePresentOutput(0,
+                                              VOLTAGE * 10,
+                                              CURRENT * 10,
+                                              0x01,
+                                              0x01);
+                }
+                //PresentOutputVol(SYSTEM_CMD, VOLTAGE * 10, CURRENT * 10);
+            }
+            break;
+            case CHARGING_MODE_TERMINATING: {
+                //if (isOpen)
+                {
+                    SetDirModulePresentOutput(0,
+                                              VOLTAGE * 10,
+                                              CURRENT * 10,
+                                              0x00,
+                                              0x01);
+                    //SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
+                    //FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
+                }
+            }
+            break;
+            }
+            //GetStatus(0);
+            //GetModuleInput(0);
+            sleep(1);
+        }
+
+        if (UnSafeDataInfo->PSU_COUNT <= 0) {
+            if (time > 1000) {
+                printf("Step 1 : GetModuleCount...... \n");
+                GetModuleCount(SYSTEM_CMD);
+                gettimeofday(&_cmdSubPriority_time, NULL);
+            }
+        } else if (time < 5000) {
+            printf("Step 2 : GetModuleCap...... \n");
+            GetModuleCap(0);
+
+            SwitchPower(SYSTEM_CMD, PSU_POWER_OFF);
+            FlashLed(SYSTEM_CMD, PSU_FLASH_NORMAL);
+        } else {
+            ShowMainMsg();
+            isGetCount = YES;
+        }
+
+        sleep(1);
+    }
+
+    return 0;
 }
 
 

+ 369 - 106
EVSE/Projects/DD360Audi/Apps/ReDoComm.c

@@ -25,6 +25,7 @@
 #include "Config.h"
 #include "ReDoComm.h"
 #include "AudiCust.h"
+#include "timeout.h"
 
 //------------------------------------------------------------------------------
 #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
@@ -43,7 +44,7 @@ static struct OCPP16Data        *ShmOCPP16Data;
 static struct PrimaryMcuData    *ShmPrimaryMcuData;
 static struct ChargingInfoData  *ChargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 static struct timeb             gRegTimeUp[2][MAX_REGISTER_NUM] = {0};
-static struct WARNING_CODE_INFO PreSysWarningInfo = {0};
+static struct WARNING_CODE_INFO gPreSysWarningInfo = {0};
 static AudiCustInfo             *gAudiCustInfo = NULL;
 
 //------------------------------------------------------------------------------
@@ -151,7 +152,7 @@ static void Hexdump(const void *p, size_t size)
 
     message_len += sprintf(&message[message_len], "\r\n");
 
-    printf("%s", message);
+    DEBUG_INFO("%s", message);
 }
 
 static int string2ByteArray(char *input, byte *output)
@@ -295,36 +296,67 @@ static int doCommConnToServer(void)
 }
 
 //------------------------------------------------------------------------------
-//--- DoComm function ---
+//--- Audi select gun ---
 //------------------------------------------------------------------------------
-static int compareOpcode(uint8_t opCode)
+static void clearPricesInfo(uint8_t id)
 {
-    if (opCode != OP_WAIT_RESPONSE) {
-        //DEBUG_ERROR("response operative code fail\r\n");
-        return FAIL;
-    }
+    memset(&gAudiCustInfo->PricesInfo[id], 0, sizeof(PricesInfo));
+    gAudiCustInfo->PricesInfo[id].Balance = FAIL_BALANCE_PRICES;
+}
 
-    return PASS;
+static void ClearAuthorizedFlag(void)
+{
+    ShmOCPP16Data->SpMsg.bits.AuthorizeConf = NO;
+    ShmSysConfigAndInfo->SysInfo.AuthorizeFlag = NO;
 }
 
-static int compareResult(uint8_t result)
+static void ClearDetectPluginFlag(void)
 {
-    if (result != COMMAND_RESULT_OK) {
-        //DEBUG_ERROR("response result fail\r\n");
-        return FAIL;
+    ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
+}
+
+static bool isDetectPlugin(void)
+{
+    if (ShmSysConfigAndInfo->SysInfo.WaitForPlugit == YES) {
+        return YES;
     }
 
-    return PASS;
+    return NO;
 }
 
-static int compareRegister(uint8_t srcReg, uint8_t destReg)
+static void destroySelectGun(uint8_t curGun)
 {
-    if (srcReg != destReg) {
-        //DEBUG_ERROR("response register fail\r\n");
-        return FAIL;
+    uint8_t i = 0;
+    uint8_t totalGun = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
+
+    if (curGun == DESTROY_ALL_SEL) {
+        gAudiCustInfo->SelGunInfo.RightGun = SEL_GUN_RELEASE;
+        gAudiCustInfo->SelGunInfo.LeftGun = SEL_GUN_RELEASE;
+
+        for (i = 0; i < totalGun; i++) {
+            ChargingData[i]->TimeoutFlag = Timeout_None;
+            clearPricesInfo(i);
+        }
+        ShmSysConfigAndInfo->SysInfo.CurGunSelected = 0;
+        strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
     }
 
-    return PASS;
+    //for charging timeout or complete
+    if ((curGun == LEFT_GUN_NUM) && (gAudiCustInfo->SelGunInfo.LeftGun != SEL_GUN_RELEASE)) {
+        gAudiCustInfo->SelGunInfo.LeftGun = SEL_GUN_RELEASE;
+        if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf != NO) {
+            ClearAuthorizedFlag();
+        }
+        clearPricesInfo(curGun);
+    }
+
+    if ((curGun == RIGHT_GUN_NUM) && (gAudiCustInfo->SelGunInfo.RightGun != SEL_GUN_RELEASE)) {
+        if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf != NO) {
+            ClearAuthorizedFlag();
+        }
+
+        clearPricesInfo(curGun);
+    }
 }
 
 static int getConfirmSelectedGun(uint8_t curSel)
@@ -354,11 +386,44 @@ static void setConfirmSelGun(uint8_t selGun)
 {
     if (selGun == LEFT_GUN_NUM && gAudiCustInfo->SelGunInfo.LeftGun == SEL_GUN_RELEASE) {
         gAudiCustInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
-        printf("confirmSelGun left\r\n");
+        //printf("confirmSelGun left\r\n");
     } else if (selGun == RIGHT_GUN_NUM && gAudiCustInfo->SelGunInfo.RightGun == SEL_GUN_RELEASE) {
         gAudiCustInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
-        printf("confirmSelGun right\r\n");
+        //printf("confirmSelGun right\r\n");
+    }
+}
+
+//------------------------------------------------------------------------------
+//--- DoComm function ---
+//------------------------------------------------------------------------------
+static int compareOpcode(uint8_t opCode)
+{
+    if (opCode != OP_WAIT_RESPONSE) {
+        //DEBUG_ERROR("response operative code fail\r\n");
+        return FAIL;
+    }
+
+    return PASS;
+}
+
+static int compareResult(uint8_t result)
+{
+    if (result != COMMAND_RESULT_OK) {
+        //DEBUG_ERROR("response result fail\r\n");
+        return FAIL;
     }
+
+    return PASS;
+}
+
+static int compareRegister(uint8_t srcReg, uint8_t destReg)
+{
+    if (srcReg != destReg) {
+        //DEBUG_ERROR("response register fail\r\n");
+        return FAIL;
+    }
+
+    return PASS;
 }
 
 static float transPricesUnit(int prices)
@@ -375,7 +440,7 @@ static void clearMiscCommand(void)
 static int qrCodeUrlInfoHandle(uint8_t *data)
 {
     int len = 0;
-    char cmdBuf[128] = {0};
+    //char cmdBuf[128] = {0};
     char localTime[128] = {0};
     uint16_t timeLen = 0;
     struct timeb SeqEndTime;
@@ -400,7 +465,6 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
     //copy QR code string
     if (strncmp((char *)localTime, (char *)&data[0], timeLen - 2) != 0) {
         memset(ShmSysConfigAndInfo->SysConfig.SystemId, '\0', sizeof(ShmSysConfigAndInfo->SysConfig.SystemId));
-        //strncpy(ShmSysConfigAndInfo->SysConfig.SystemId, '\0', sizeof(ShmSysConfigAndInfo->SysConfig.SystemId));
         //printf("data =  %s\r\n", data);
         len = string2ByteArray((char *)data, (uint8_t *)ShmSysConfigAndInfo->SysConfig.SystemId);
         //printf("SystemId =  %s\r\n", ShmSysConfigAndInfo->SysConfig.SystemId);
@@ -427,6 +491,20 @@ static int qrCodeUrlInfoHandle(uint8_t *data)
 
 static int updateFirmwareHandle(uint8_t *imgName)
 {
+    int ret = PASS;
+    char cmdBuf[1024] = {0};
+
+    sprintf(cmdBuf, "/mnt/%s", imgName);
+    DEBUG_INFO("Program ready to check file %s\n", cmdBuf);
+    if ( access(cmdBuf, F_OK) != -1) {
+        DEBUG_INFO("File '%s' exist.\n", cmdBuf);
+        ShmSysConfigAndInfo->SysInfo.FirmwareUpdate = YES;
+    } else {
+        DEBUG_INFO("File '%s' doesn't exist.\n", cmdBuf);
+        ret = FAIL;
+    }
+
+#if 0
     char cmdBuf[1024] = {0};
     int status = 0;
 
@@ -457,8 +535,9 @@ static int updateFirmwareHandle(uint8_t *imgName)
     }
 
     system("rm -rf ./tftpUpdate.sh"); //刪除shell
+#endif //0
 
-    return PASS;
+    return ret;
 }
 
 static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
@@ -585,27 +664,88 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
             }
             DEBUG_INFO("Remote start charging id = %d\r\n", id);
 
-            if (getConfirmSelectedGun(id - 1) == FAIL) {
-                DEBUG_INFO("Remote start not select gun\r\n");
+            //if (getConfirmSelectedGun(id - 1) == FAIL) {
+            //    DEBUG_INFO("Remote start not select gun\r\n");
+            //    break;
+            //}
+
+            if (getSelGunWaitToAuthor(id - 1) == FAIL) {
+                DEBUG_ERROR("Remote start gun already charging\r\n");
                 break;
             }
 
-            //if (getSelGunWaitToAuthor(id - 1) == FAIL) {
-            //    DEBUG_ERROR("Remote start gun already charging\r\n");
-            //    break;
-            //}
+            if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (id - 1)) {
+                if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == LEFT_GUN_NUM &&
+                        (gAudiCustInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM ||
+                         gAudiCustInfo->SelGunInfo.LeftGun == SEL_GUN_ATHOR)) {
+                    gAudiCustInfo->SelGunInfo.LeftGun = SEL_GUN_RELEASE;
+                    strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
+                    ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
+                    sleep(1); //Jerry add
+                    ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
+                    gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
+                    ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
+                }
 
-            //if (ShmSysConfigAndInfo->SysInfo.CurGunSelected != (id - 1)) {
-            //    ShmSysConfigAndInfo->SysInfo.CurGunSelected = (id - 1);
-            //    ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
-            //}
+                if (ShmSysConfigAndInfo->SysInfo.CurGunSelected == RIGHT_GUN_NUM &&
+                        (gAudiCustInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM ||
+                         gAudiCustInfo->SelGunInfo.RightGun == SEL_GUN_ATHOR)) {
+                    gAudiCustInfo->SelGunInfo.RightGun = SEL_GUN_RELEASE;
+                    strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
+                    ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
+                    sleep(1); //Jerry add
+                    ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
+                    gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
+                    ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
+                }
+
+                ShmSysConfigAndInfo->SysInfo.CurGunSelected = (id - 1);
+                ShmSysConfigAndInfo->SysInfo.CurGunSelectedByAc = NO_DEFINE;
+            }
 
-            //setConfirmSelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
+            setConfirmSelGun(ShmSysConfigAndInfo->SysInfo.CurGunSelected);
 
             ShmOCPP16Data->CsMsg.bits[id - 1].RemoteStartTransactionReq = YES;
             gAudiCustInfo->PricesInfo[id - 1].Balance = 0.00;
-            if (id == 2) {
-                clearMiscCommand();
+            clearMiscCommand();
+            break;
+
+        case MISC_CMD_REMOTE_STOP_CHARGING:
+            if (value != YES) {
+                if (id == 2) {
+                    clearMiscCommand();
+                }
+                break;
+            }
+
+            strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
+            ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
+            ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
+            gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
+            ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
+            destroySelectGun(id - 1);
+
+            clearMiscCommand();
+            break;
+
+        case MISC_CMD_REMOTE_UNLOCK:
+            if (value != YES) {
+                if (id == 2) {
+                    clearMiscCommand();
+                }
+                break;
+            }
+
+            if (isDetectPlugin() == YES) {
+                ClearDetectPluginFlag();
+                strcpy((char *)ShmSysConfigAndInfo->SysConfig.UserId, "");
+                ShmSysConfigAndInfo->SysInfo.WaitForPlugit = NO;
+                ShmSysConfigAndInfo->SysInfo.SystemPage = _LCM_SELECT_GUN;
+                gettimeofday(&ShmSysConfigAndInfo->SysInfo.SystemTimeoutTimer, NULL);
+                ShmSysConfigAndInfo->SysInfo.SystemTimeoutFlag = Timeout_None;
+                destroySelectGun(id - 1);
+            } else {
+                ChargingData[id - 1]->StopChargeFlag = YES;
             }
             break;
 
@@ -613,6 +753,7 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
             clearMiscCommand();
             break;
         }
+        usleep(128);
     }
 
     return ret;
@@ -620,24 +761,36 @@ static int miscCommandHandle(uint8_t dataLen, uint8_t id, uint8_t *data)
 
 static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
 {
+    uint8_t addr = 0;
     float MaxVolt, MaxCurrent, MaxPower;
+    static PricesInfo pricesInfo[2] = {0};
     CapabilityInfo *pCapabilityInfo = NULL;
     AccountInfo *pAccountInfo = NULL;
 
+    //--- charging capability information --------------------------------------
     pCapabilityInfo = (CapabilityInfo *)&data[0];
 
     MaxVolt = (float)(ntohs(pCapabilityInfo->OutputVoltage));
-    if ((MaxVolt >= 0) && (MaxVolt <= MAX_VOLTAGE)) {
+    if (MaxVolt >= 0) {
+        if (MaxVolt > MAX_VOLTAGE) {
+            MaxVolt = MAX_VOLTAGE;
+        }
         ChargingData[gunID]->MaximumChargingVoltage = MaxVolt;
     }
 
     MaxCurrent = (float)(ntohs(pCapabilityInfo->OutputCurrent));
-    if ((MaxCurrent >= 0) && (MaxCurrent <= MAX_CURRENCY)) {
+    if (MaxCurrent >= 0) {
+        if (MaxCurrent > MAX_CURRENCY) {
+            MaxCurrent = MAX_CURRENCY;
+        }
         ChargingData[gunID]->AvailableChargingCurrent = MaxCurrent;
     }
 
     MaxPower = (float)(ntohs(pCapabilityInfo->OutputPower));
-    if ((MaxPower >= 0) && (MaxPower <= MAX_POWER)) {
+    if (MaxPower >= 0) {
+        if (MaxPower > MAX_POWER) {
+            MaxPower = MAX_POWER;
+        }
         ChargingData[gunID]->AvailableChargingPower = MaxPower;
     }
     //MaxVolt = (float)(data[0] << 8 |data[1]);
@@ -645,19 +798,27 @@ static int chargingcapabilityHandle(uint8_t *data, uint8_t gunID)
     //MaxPower = (float)(data[4] << 8 | data[5]);
     //printf("MaxVolt=%f, MaxCurrent=%f, MaxPower=%f,\n", MaxVolt, MaxCurrent, MaxPower);
 
-    pAccountInfo = (AccountInfo *)&data[6];
+    //--- user prices information ----------------------------------------------
+    addr = (sizeof(CapabilityInfo) - 2); //2 byte reserved
+    pAccountInfo = (AccountInfo *)&data[addr];
 
     ShmSysConfigAndInfo->SysConfig.BillingData.Currency = pAccountInfo->Currency;
-    gAudiCustInfo->PricesInfo[gunID].UserPrices        = transPricesUnit(ntohl(pAccountInfo->UserPrices));
-    ChargingData[gunID]->ChargingFee                   = transPricesUnit(ntohl(pAccountInfo->TotalCost));
-    gAudiCustInfo->PricesInfo[gunID].Balance           = transPricesUnit(ntohl(pAccountInfo->Balance));
+    gAudiCustInfo->PricesInfo[gunID].UserPrices         = transPricesUnit(ntohl(pAccountInfo->UserPrices));
+    ChargingData[gunID]->ChargingFee                    = transPricesUnit(ntohl(pAccountInfo->TotalCost));
+    gAudiCustInfo->PricesInfo[gunID].Balance            = transPricesUnit(ntohl(pAccountInfo->Balance));
 
-    DEBUG_INFO("id = %d, user prices = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s\r\n",
-               gunID,
-               gAudiCustInfo->PricesInfo[gunID].UserPrices,
-               ChargingData[gunID]->ChargingFee,
-               gAudiCustInfo->PricesInfo[gunID].Balance,
-               (uint8_t *)Currency[ShmSysConfigAndInfo->SysConfig.BillingData.Currency]);
+    if ((pricesInfo[gunID].UserPrices != gAudiCustInfo->PricesInfo[gunID].UserPrices) ||
+            (pricesInfo[gunID].Balance != gAudiCustInfo->PricesInfo[gunID].Balance)) {
+        pricesInfo[gunID].UserPrices = gAudiCustInfo->PricesInfo[gunID].UserPrices;
+        pricesInfo[gunID].Balance = gAudiCustInfo->PricesInfo[gunID].Balance;
+
+        DEBUG_INFO("id = %d, user prices = %.2f, Total cost = %.2f, Account balances = %.2f, currency = %s\r\n",
+                   gunID,
+                   gAudiCustInfo->PricesInfo[gunID].UserPrices,
+                   ChargingData[gunID]->ChargingFee,
+                   gAudiCustInfo->PricesInfo[gunID].Balance,
+                   (uint8_t *)Currency[ShmSysConfigAndInfo->SysConfig.BillingData.Currency]);
+    }
 
     return PASS;
 }
@@ -684,8 +845,10 @@ static void removeFaultCodeToBuf(uint8_t *Code)
 
     // 把相關的錯誤碼一次移除,避免重複顯示
     while (find) {
+        usleep(128);
         find = 0x00;
         for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
+            usleep(128);
             if (find == 0x00) {
                 if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0], _code, 7) == 0) {
                     find = 0x01;
@@ -702,6 +865,20 @@ static void removeFaultCodeToBuf(uint8_t *Code)
     }
 }
 
+bool CompareArrayIsZero(uint8_t *array, unsigned int array_size)
+{
+    uint8_t i;
+
+    if (array != NULL) {
+        for (i = 0; i < array_size; i++) {
+            if (array[i] != 0) {
+                return false;
+            }
+        }
+    }
+
+    return true;
+}
 static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
 {
     uint8_t ret = 0;
@@ -709,12 +886,22 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     uint8_t count = 0;
     uint8_t EventCodeTmp[7] = {0};
     uint8_t StatusArray[MAX_REGISTER_NUM][WARNING_CODE_SIZE] = {0};
+    uint8_t remaindLen = dataLen % dataLen;
+    uint8_t statusCodeError = 0;
+
+    if (remaindLen != 0) {
+        dataLen -= remaindLen;
+    }
 
     if (dataLen < WARNING_CODE_SIZE) {
-        DEBUG_ERROR("raw data len < 6 = %d\r\n", dataLen);
+        DEBUG_ERROR("fail status code length = %d\r\n", dataLen);
+        Hexdump(data, dataLen);
         if (ShmSysConfigAndInfo->SysWarningInfo.WarningCount > 0) {
             for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
-                if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= 0x33) { //from backend or power cabinet
+                usleep(128);
+                if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '3' ||  //from backend or power cabinet
+                        (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0] >= 'B' &&
+                         ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '4')) {
                     memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
                     memcpy(EventCodeTmp,
                            ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i],
@@ -727,25 +914,34 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     }
 
     for (count = 0; count < dataLen; count += WARNING_CODE_SIZE) {
+        usleep(128);
         // misc command status code handle
-        if (strcmp((char *)&data[count], MISC_ST_MISC_CMD) == 0) {
-            if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
-                gDoCommGblData.MiscCmd = REG_MISC_CONTROL;
-            }
+        if (strncmp((char *)&data[count], MISC_ST_MISC_CMD, WARNING_CODE_SIZE) == 0) {
+            //if (gDoCommGblData.MiscCmd != REG_MISC_CONTROL) {
+            gDoCommGblData.MiscCmd = REG_MISC_CONTROL;
+            //}
             memset((char *)&data[count], 0, WARNING_CODE_SIZE);
             continue;
-        } else if (strcmp((char *)&data[count], MISC_ST_VERSION) == 0) {
-            if (gDoCommGblData.MiscCmd != REG_REPORT_CSU_VERSION) {
-                gDoCommGblData.MiscCmd = REG_REPORT_CSU_VERSION;
-            }
+        } else if (strncmp((char *)&data[count], MISC_ST_VERSION, WARNING_CODE_SIZE) == 0) {
+            //if (gDoCommGblData.MiscCmd != REG_REPORT_CSU_VERSION) {
+            gDoCommGblData.MiscCmd = REG_REPORT_CSU_VERSION;
+            //}
             memset((char *)&data[count], 0, WARNING_CODE_SIZE);
             continue;
         }
 
+        if (CompareArrayIsZero((uint8_t *)&data[count], WARNING_CODE_SIZE) == true) {
+            memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
+            memcpy(EventCodeTmp, (char *)&data[count], sizeof(EventCodeTmp));
+            DEBUG_ERROR("error status = %s\r\n", EventCodeTmp);
+            continue;
+        }
+
         strncpy((char *)&StatusArray[count / WARNING_CODE_SIZE], (char *)&data[count], WARNING_CODE_SIZE);
+
         ret = 0;
         for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
-
+            usleep(128);
             if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0],
                        StatusArray[count / WARNING_CODE_SIZE],
                        WARNING_CODE_SIZE) == 0) {
@@ -761,10 +957,23 @@ static int powerCabinetStatusProcess(uint8_t dataLen, uint8_t *data)
     }
 
     for (i = 0; i < ShmSysConfigAndInfo->SysWarningInfo.WarningCount; i++) {
-        if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '3') { //from backend or power cabinet 0x33
+        usleep(128);
+        //if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0] >= 'B' &&
+        //        ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '4') {
+        //    memset(EventCodeTmp, 0, sizeof(EventCodeTmp));
+        //    memcpy(EventCodeTmp,
+        //           ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i],
+        //           sizeof(EventCodeTmp));
+        //    removeFaultCodeToBuf(EventCodeTmp);
+        //}
+
+        if (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '3' || //from backend or power cabinet 0x33
+                (ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0] >= 'B' &&
+                 ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][1] >= '4')) {
             ret = 0;
 
             for (count = 0; count < (dataLen / WARNING_CODE_SIZE); count++) {
+                usleep(128);
                 if (memcmp(&ShmSysConfigAndInfo->SysWarningInfo.WarningCode[i][0],
                            StatusArray[count],
                            WARNING_CODE_SIZE) == 0) {
@@ -821,8 +1030,8 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t id, uint8_t reg
         break;
 
     case REG_DISPENSER_STATUS:
-        memset(&PreSysWarningInfo, 0, sizeof(struct WARNING_CODE_INFO));
-        memcpy(&PreSysWarningInfo,
+        memset(&gPreSysWarningInfo, 0, sizeof(struct WARNING_CODE_INFO));
+        memcpy(&gPreSysWarningInfo,
                &(ShmSysConfigAndInfo->SysWarningInfo),
                sizeof(struct WARNING_CODE_INFO));
         break;
@@ -837,12 +1046,15 @@ static int responsePackeHandle(int fd, uint8_t *pResult, uint8_t id, uint8_t reg
     case REG_SOFTWARE_UPDATE:
         pSoftwareUpd = (SoftwareUpdInfo *)&pCsuResult->Data.Data[0];
 
-        if ((pSoftwareUpd->ImgName == NULL) || (rawDataLen == 0)) {
+        if ((strcmp((char *)pSoftwareUpd->ImgName, "") == 0) ||
+                (rawDataLen == 0) ||
+                pSoftwareUpd->UpdateState != 1) {
             ret = FAIL;
             break;
         }
 
-        updateFirmwareHandle(pSoftwareUpd->ImgName);
+        ret = FAIL;
+        ret = updateFirmwareHandle(pSoftwareUpd->ImgName);
         break;
 
     case REG_PLUG_IN_STATE:
@@ -970,7 +1182,7 @@ static int writeWaitPlugItState(int fd, uint8_t id)
     return ret;
 }
 
-static int readPowerCabinetSystemID(int fd)
+static int readQRcodeURLAndSystemDate(int fd)
 {
     int ret = PASS;
 
@@ -989,10 +1201,10 @@ static int writePresentChargingInfo(int fd, uint8_t plugNum, uint8_t id)
     uint8_t dataBuf[16] = {0};
     PreChargingInfo *pPreChargingInfo = (PreChargingInfo *)dataBuf;
 
-    pPreChargingInfo->EvBatterySoc = htonl(ChargingData[plugNum]->EvBatterySoc);
+    pPreChargingInfo->PresentChargingVoltage = htons((uint16_t)ChargingData[plugNum]->PresentChargingVoltage * 10);
+    pPreChargingInfo->PresentChargingCurrent = htons((uint16_t)ChargingData[plugNum]->PresentChargingCurrent * 10);
     pPreChargingInfo->RemainChargingDuration = htonl(ChargingData[plugNum]->RemainChargingDuration);
-    pPreChargingInfo->PresentChargingVoltage = htonl(ChargingData[plugNum]->PresentChargingVoltage);
-    pPreChargingInfo->PresentChargingCurrent = htonl(ChargingData[plugNum]->PresentChargingCurrent);
+    pPreChargingInfo->EvBatterySoc = ChargingData[plugNum]->EvBatterySoc;
 
     ret = composeSocketData(fd,
                             id,
@@ -1149,13 +1361,14 @@ static int writePlugInStatus(int fd, uint8_t plugNum, uint8_t id)
 static int readSoftwareUpdate(int fd)
 {
     int ret = PASS;
+    uint8_t dataBuf[2] = {ShmSysConfigAndInfo->SysInfo.FirmwareUpdate, 0};
 
     ret = composeSocketData(fd,
-                            ID_REGISTER,
+                            0x01,
                             OP_READ_DATA,
                             REG_SOFTWARE_UPDATE,
-                            0,
-                            NULL);
+                            1,
+                            &dataBuf[0]);
 
     return ret;
 }
@@ -1209,7 +1422,7 @@ static int writeDispenserStatus(int fd)
     int ret = PASS;
 
     if ((ShmSysConfigAndInfo->SysWarningInfo.WarningCount <= 0) &&
-            (PreSysWarningInfo.WarningCount <= 0)) {
+            (gPreSysWarningInfo.WarningCount <= 0)) {
         return FAIL;
     }
 
@@ -1218,9 +1431,9 @@ static int writeDispenserStatus(int fd)
         memcpy(CurWarnCodeTmp[count], ShmSysConfigAndInfo->SysWarningInfo.WarningCode[count], WARNING_CODE_SIZE);
     }
 
-    warningCount = PreSysWarningInfo.WarningCount;
+    warningCount = gPreSysWarningInfo.WarningCount;
     for (count = 0; count < warningCount; count++) {
-        memcpy(PreWarnCodeTmp[count], PreSysWarningInfo.WarningCode[count], WARNING_CODE_SIZE);
+        memcpy(PreWarnCodeTmp[count], gPreSysWarningInfo.WarningCode[count], WARNING_CODE_SIZE);
     }
 
     if (strcmp((char *)&CurWarnCodeTmp[0], (char *)&PreWarnCodeTmp[0]) == 0) {
@@ -1401,6 +1614,46 @@ static int InitShareMemory(void)
     return result;
 }
 
+static void updateFirmwareProcess(int fd, uint8_t totalConnCount)
+{
+    bool canUpdateFirmware = true;
+    uint8_t plugNum = 0;
+    uint8_t ackCount = 5;
+    struct timeb updateTime;
+
+    if (ShmSysConfigAndInfo->SysWarningInfo.Level != 2) {
+        for (plugNum = 0; plugNum < totalConnCount; plugNum++) {
+            if (ChargingData[plugNum]->SystemStatus != S_IDLE &&
+                    ChargingData[plugNum]->SystemStatus != S_RESERVATION &&
+                    ChargingData[plugNum]->SystemStatus != S_MAINTAIN) {
+                canUpdateFirmware = false;
+            }
+        }
+    }
+
+    if (canUpdateFirmware) {
+        ftime(&updateTime);
+        if (DiffTimeb(gRegTimeUp[0][REG_SOFTWARE_UPDATE], updateTime) > LOOP_RETRY_TIME * 5) {
+            readSoftwareUpdate(fd);
+            ftime(&gRegTimeUp[0][REG_SOFTWARE_UPDATE]);
+        }
+
+        if (ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == YES) {
+            while (ackCount != 0) {
+                ftime(&updateTime);
+                if (DiffTimeb(gRegTimeUp[0][REG_SOFTWARE_UPDATE], updateTime) > LOOP_RETRY_TIME / 2) {
+                    readSoftwareUpdate(fd);
+                    ftime(&gRegTimeUp[0][REG_SOFTWARE_UPDATE]);
+                    if (ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == NO) {
+                        ackCount--;
+                    }
+                }
+                usleep(128);
+            }
+        }
+    }
+}
+
 static void checkAuthorProcess(int fd, uint8_t plugNum)
 {
     int ret = 0;
@@ -1446,6 +1699,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
     struct timeb NowTime;
 
     while (isContinue) {
+        usleep(128);
         ftime(&NowTime);
 
         switch (curReg) {
@@ -1488,11 +1742,20 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         //    break;
 
         //case REG_SOFTWARE_UPDATE:
-        //    if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME) {
-        //        readSoftwareUpdate(fd);
-        //        ftime(&gRegTimeUp[plugNum][curReg]);
+        //    if (ChargingData[plugNum]->SystemStatus == S_IDLE) {
+        //        if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME * 10) {
+        //            readSoftwareUpdate(fd);
+        //            ftime(&gRegTimeUp[plugNum][curReg]);
+        //        }
+        //        while (ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == YES) {
+        //            ftime(&NowTime);
+        //            if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > LOOP_RETRY_TIME) {
+        //                readSoftwareUpdate(fd);
+        //            }
+        //            usleep(128);
+        //        }
         //    }
-        //    curReg = REG_PLUG_IN_STATE;
+        //    isContinue = 0;
         //    break;
 
         case REG_PLUG_IN_STATE:
@@ -1541,7 +1804,7 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
                 //power up write dispenser version and get power cabinet system ID
                 if ((writeCsuModuleVersion(fd) == PASS) &&
                         (writeOtherModuleVersion(fd) == PASS) &&
-                        (readPowerCabinetSystemID(fd) == PASS)) {
+                        (readQRcodeURLAndSystemDate(fd) == PASS)) {
                     //gDoCommGblData.DisConnCount = 0;
                     isContinue = 0;
                 }
@@ -1554,12 +1817,12 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
         case REG_QRCODE_URL_INFO:
             if (gunID == 1) {
                 if (DiffTimeb(gRegTimeUp[plugNum][curReg], NowTime) > (LOOP_RETRY_TIME * 10)) {
-                    readPowerCabinetSystemID(fd);
+                    readQRcodeURLAndSystemDate(fd);
                     ftime(&gRegTimeUp[plugNum][curReg]);
                 }
             }
             isContinue = 0;
-            //curReg = REG_WAIT_PLUG_IT_STATE;
+            //curReg = REG_SOFTWARE_UPDATE;
             break;
 
         //case REG_WAIT_PLUG_IT_STATE:
@@ -1586,14 +1849,14 @@ static int messageTrigger(int fd, uint8_t plugNum, uint8_t gunID, uint8_t curReg
     return ret;
 }
 
-static bool isDetectPlugin()
-{
-    if (ShmSysConfigAndInfo->SysInfo.WaitForPlugit == YES) {
-        return YES;
-    }
-
-    return NO;
-}
+//static bool isDetectPlugin()
+//{
+//    if (ShmSysConfigAndInfo->SysInfo.WaitForPlugit == YES) {
+//        return YES;
+//    }
+//
+//    return NO;
+//}
 
 static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
 {
@@ -1621,15 +1884,6 @@ static void systemStatusProcess(int fd, uint8_t plugNum, uint8_t gunID)
                 ftime(&gRegTimeUp[plugNum][REG_CHARGING_CAP]);
             }
         }
-
-        //check update firmware
-        //if (ChargingData[plugNum]->SystemStatus == S_IDLE) {
-        //    ftime(&AuthNowTime);
-        //    if (DiffTimeb(gRegTimeUp[plugNum][REG_SOFTWARE_UPDATE], AuthNowTime) > LOOP_RETRY_TIME) {
-        //        readSoftwareUpdate(fd);
-        //        ftime(&gRegTimeUp[plugNum][REG_SOFTWARE_UPDATE]);
-        //    }
-        //}
         break;
 
     case S_PREPARNING: //get permission
@@ -1780,6 +2034,7 @@ static int networkCreatePorcess(void)
                ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
 
     gDoCommGblData.DisConnCount = 0;
+    destroySelectGun(DESTROY_ALL_SEL);
 
     sleep(3);
 
@@ -1811,14 +2066,14 @@ int main(int argc, char *argv[])
         return 0;
     }
 
-    totalConnCount =  ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
+    totalConnCount = ShmSysConfigAndInfo->SysConfig.TotalConnectorCount;
 
     for (index = 0; index < totalConnCount; index++) {
         if (!FindChargingInfoData(index, &ChargingData[0])) {
             DEBUG_ERROR("FindChargingInfoData false \n");
             break;
         }
-        gAudiCustInfo->PricesInfo[index].Balance = FAIL_BALANCE_PRICES;
+        clearPricesInfo(index);
     }
 
     //initial trigger message timer
@@ -1845,10 +2100,12 @@ int main(int argc, char *argv[])
                 gunID = (plugNum  + 1); //connector Id, 1 = left gun, 2 = right gun
                 systemStatusProcess(fd, plugNum, gunID);
 
-                if ((initDone = messageTrigger(fd,
-                                               plugNum,
-                                               gunID,
-                                               REG_POWER_CABINET_STATUS)) == DISPENSER_SOCKET_RECONN) {
+                initDone = messageTrigger(fd,
+                                          plugNum,
+                                          gunID,
+                                          REG_POWER_CABINET_STATUS);
+
+                if (initDone == DISPENSER_SOCKET_RECONN) {
                     break;
                 }
             }
@@ -1866,6 +2123,12 @@ int main(int argc, char *argv[])
 
             initDone = DISPENER_INIT_FAIL;
         }
+
+        //update dispenser firmware
+        if (initDone != DISPENER_INIT_FAIL) {
+            updateFirmwareProcess(fd, totalConnCount);
+        }
+
         usleep(1000);
     }
 }

+ 12 - 6
EVSE/Projects/DD360Audi/Apps/ReDoComm.h

@@ -83,7 +83,7 @@
 //--- dispenser result ---
 //------------------------------------------------------------------------------
 #define COMMAND_RESULT_OK                       0x01
-#define COMMAND_RESULT_NG                       0x02
+#define COMMAND_RESULT_NG                       0x02 //wait state
 
 //------------------------------------------------------------------------------
 //--- power cabinet misc status code ---
@@ -104,6 +104,11 @@
 #define MISC_CMD_HARDWARE_REBOOT                0x0101
 #define MISC_CMD_SOFTWARE_RESTART               0x0102
 #define MISC_CMD_REMOTE_START_CHARGING          0x0103
+#define MISC_CMD_REMOTE_STOP_CHARGING           0x0104
+#define MISC_CMD_REMOTE_UNLOCK                  0x0105
+
+#define ST_UPDATE_FIRMWARE                      0x01
+#define ST_NO_UPDATE_FIRMWARE                   0x02
 
 //------------------------------------------------------------------------------
 #pragma pack(push)
@@ -114,7 +119,7 @@ typedef struct StDoCommGlobalVar {
     uint8_t DisConnCount;
     uint8_t ConnectorID[2]; //keep from power cabinet
     uint8_t MiscCmd;
-    uint8_t Reserved[4];
+    uint8_t Reserved[3];
 } DoCommGblData;
 
 typedef struct StCommnadHead {
@@ -173,14 +178,15 @@ typedef struct StMiscCommand {
 } MiscCommand;
 
 typedef struct StPresentChargingInfo {
-    int EvBatterySoc;               // 0~100%
+    uint16_t PresentChargingVoltage;   //0~6553.5 volt
+    uint16_t PresentChargingCurrent;   //0~6553.5 amp
     int RemainChargingDuration;     // second
-    float PresentChargingVoltage;   //0~6553.5 volt
-    float PresentChargingCurrent;   //0~6553.5 amp
+    uint8_t EvBatterySoc;               // 0~100%
 } PreChargingInfo;
 
 typedef struct StSoftwareUpdInfo {
-    uint8_t ImgName[249];
+    uint8_t UpdateState;         //1:update , 2: not update
+    uint8_t ImgName[248];
 } SoftwareUpdInfo;
 
 typedef struct StCapabilityInfo {

BIN
EVSE/Projects/DD360Audi/Apps/UnsafetyOutputTask


+ 1 - 1
EVSE/Projects/DD360Audi/Apps/init.sh

@@ -4,7 +4,7 @@ chmod 777 Module_LcmControl
 chmod 777 Module_InternalComm
 chmod 777 Module_EventLogging
 chmod 777 Module_EvComm
-chmod 777 Module_PsuComm
+#chmod 777 Module_PsuComm
 chmod 777 OcppBackend
 chmod 777 kill.sh
 chmod 777 ReadCmdline

Файловите разлики са ограничени, защото са твърде много
+ 409 - 172
EVSE/Projects/DD360Audi/Apps/main.c


+ 1 - 1
EVSE/Projects/DD360Audi/Apps/web.sh

@@ -1 +1 @@
-/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf  -m /lib
+/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf  -m /lib

BIN
EVSE/Projects/DD360Audi/AudiUI/DWIN_SET_AudiUI_Emergence_20210113.7z


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


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


BIN
EVSE/Projects/DD360Audi/Images/root/DoComm


BIN
EVSE/Projects/DD360Audi/Images/root/Module_EvComm


BIN
EVSE/Projects/DD360Audi/Images/root/Module_EventLogging


BIN
EVSE/Projects/DD360Audi/Images/root/Module_InternalComm


BIN
EVSE/Projects/DD360Audi/Images/root/main


BIN
EVSE/Projects/DD360Audi/output/DoComm


BIN
EVSE/Projects/DD360Audi/output/FactoryConfig


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/ReadCmdline


BIN
EVSE/Projects/DD360Audi/output/UnsafetyOutputTask


+ 1 - 1
EVSE/Projects/DD360Audi/output/init.sh

@@ -4,7 +4,7 @@ chmod 777 Module_LcmControl
 chmod 777 Module_InternalComm
 chmod 777 Module_EventLogging
 chmod 777 Module_EvComm
-chmod 777 Module_PsuComm
+#chmod 777 Module_PsuComm
 chmod 777 OcppBackend
 chmod 777 kill.sh
 chmod 777 ReadCmdline

BIN
EVSE/Projects/DD360Audi/output/main


+ 1 - 1
EVSE/Projects/DD360Audi/output/web.sh

@@ -1 +1 @@
-/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf  -m /lib
+/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf  -m /lib

+ 68 - 68
EVSE/Projects/DS60-120/Apps/Module_InternalComm.c

@@ -15,12 +15,12 @@
 
 #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    <stdio.h>      /*璅蹱�頛詨�頛詨枂摰𡁶儔*/
+#include    <stdlib.h>     /*璅蹱��賣彍摨怠�蝢�*/
+#include    <unistd.h>     /*Unix 璅蹱��賣彍摰𡁶儔*/
+#include    <fcntl.h>      /*瑼娍綉�嗅�蝢�*/
+#include    <termios.h>    /*PPSIX 蝯�垢�批�摰𡁶儔*/
+#include    <errno.h>      /*�航炊�笔�蝢�*/
 #include 	<errno.h>
 #include 	<string.h>
 #include	<time.h>
@@ -65,17 +65,17 @@ struct PsuData 					*ShmPsuData;
 struct OCPP16Data				*ShmOCPP16Data;
 struct DcCommonInformation		*ShmDcCommonData;
 
-#define VIN_MAX_VOLTAGE_IEC			285	// 大於該值 : OVP
-#define VIN_MAX_REV_VOLTAGE_IEC		275	// 小於賦歸 OVP
-#define VIN_MIN_VOLTAGE_IEC			160	// 小於該值 : UVP
-#define VIN_MIN_REV_VOLTAGE_IEC		170	// 大於賦歸 UVP
+#define VIN_MAX_VOLTAGE_IEC			285	// 憭扳䲰閰脣�� : OVP
+#define VIN_MAX_REV_VOLTAGE_IEC		275	// 撠𤩺䲰鞈行飛 OVP
+#define VIN_MIN_VOLTAGE_IEC			160	// 撠𤩺䲰閰脣�� : UVP
+#define VIN_MIN_REV_VOLTAGE_IEC		170	// 憭扳䲰鞈行飛 UVP
 
-#define VIN_MAX_VOLTAGE_UL			315	// 大於該值 : OVP // 美規 (W)
-#define VIN_MAX_REV_VOLTAGE_UL		305	// 小於賦歸 OVP
-#define VIN_MIN_VOLTAGE_UL			210	// 小於該值 : UVP
-#define VIN_MIN_REV_VOLTAGE_UL 		220	// 大於賦歸 UVP
+#define VIN_MAX_VOLTAGE_UL			315	// 憭扳䲰閰脣�� : OVP // 蝢舘� (W)
+#define VIN_MAX_REV_VOLTAGE_UL		305	// 撠𤩺䲰鞈行飛 OVP
+#define VIN_MIN_VOLTAGE_UL			210	// 撠𤩺䲰閰脣�� : UVP
+#define VIN_MIN_REV_VOLTAGE_UL 		220	// 憭扳䲰鞈行飛 UVP
 
-#define VIN_DROP_VOLTAGE	150	// 小於該值 : ac drop
+#define VIN_DROP_VOLTAGE	150	// 撠𤩺䲰閰脣�� : ac drop
 
 #define VOUT_MAX_VOLTAGE	995
 #define VOUT_MIN_VOLTAGE	150
@@ -101,19 +101,19 @@ struct DcCommonInformation		*ShmDcCommonData;
 #define LED_BRIGHTNESS_LV_MID		0.5
 #define LED_BRIGHTNESS_LV_LOW		0.2
 
-// 最小切換 Relay 電壓
+// ��撠誩��� Relay �餃�
 #define SELF_TO_CHANGE_RELAY_STATUS			600
-// 透過電壓確認 Relay 是否搭上的依據電壓
+// �誯��餃�蝣箄� Relay �臬炏�凋�����𡁻𤓖憯�
 #define CHECK_RELAY_STATUS					300
 #define CHECK_RELAY_STATUS_GAP				100
-// 安全在停止充電程序中斷開 Relay 的電流
+// 摰匧��典�甇W��餌�摨譍葉�琿� Relay ��𤓖瘚�
 #define SEFETY_SWITCH_RELAY_CUR				50
-// 確認 Relay Welding 電壓
+// 蝣箄� Relay Welding �餃�
 #define RELAY_WELDING_DET					300
 
 byte gunCount;
 byte acgunCount;
-// 槍資訊
+// 瑽滩�閮�
 struct ChargingInfoData *_chargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
 struct ChargingInfoData *ac_chargingInfo[AC_QUANTITY];
 
@@ -452,7 +452,7 @@ void SetModelName_Fan()
 	}
 }
 
-// AC 三相輸入電壓
+// AC 銝厩㮾頛詨��餃�
 void GetPresentInputVol()
 {
 	if (Query_Present_InputVoltage(Uart5Fd, Addr.Relay, &inputVoltage) == PASS)
@@ -717,7 +717,7 @@ void GetPresentInputVol()
 	}
 }
 
-// 左右槍的 Relay 前後的輸出電壓
+// 撌血𢰧瑽滨� Relay �滚���撓�粹𤓖憯�
 void GetPersentOutputVol()
 {
 	if (Query_Present_OutputVoltage(Uart5Fd, Addr.Relay, &outputVoltage) == PASS)
@@ -758,8 +758,8 @@ void GetPersentOutputVol()
 
 			//unsigned short Ovp = 0;
 			//unsigned short Ocp = 0;
-			//Ovp = MIN [VOUT_MAX_VOLTAGE, EV_BATTERY_VOLTAGE] 	// 最大輸出電壓與電池電壓最大值
-			//Ocp = MIN [IOUT_MAX_CURRENT, EV_CURRENT_REQ]		// 最大輸出電流與需求電流最小值
+			//Ovp = MIN [VOUT_MAX_VOLTAGE, EV_BATTERY_VOLTAGE] 	// ��憭扯撓�粹𤓖憯栞��餅��餃���憭批��
+			//Ocp = MIN [IOUT_MAX_CURRENT, EV_CURRENT_REQ]		// ��憭扯撓�粹𤓖瘚����瘙�𤓖瘚��撠誩��
 			if (_chargingData[index]->Type == _Type_Chademo)
 			{
 				//Ovp = MaxValue(_chargingData[index]->MaximumChargingVoltage, _chargingData[index]->EvBatteryMaxVoltage);
@@ -773,7 +773,7 @@ void GetPersentOutputVol()
 	}
 }
 
-// 風扇速度
+// 憸冽��笔漲
 void GetFanSpeed()
 {
 	//PRINTF_FUNC("Get fan board speed \n");
@@ -792,7 +792,7 @@ void GetFanSpeed()
 	}
 }
 
-// 讀取 Relay 狀態
+// 霈��� Relay ����
 void GetRelayOutputStatus()
 {
 	if (Query_Relay_Output(Uart5Fd, Addr.Relay, &regRelay) == PASS)
@@ -801,7 +801,7 @@ void GetRelayOutputStatus()
 	}
 }
 
-// 確認 K1 K2 relay 的狀態
+// 蝣箄� K1 K2 relay �����
 void CheckK1K2RelayOutput(byte index)
 {
 	if (index == 0)
@@ -882,9 +882,9 @@ void CheckK1K2RelayOutput(byte index)
 
 void GetGfdAdc()
 {
-	// define : 每 0.2 ~ 1 秒一次
-	// occur : <= 75k 歐姆 @ 150 - 750 Vdc
-	// warning : >= 100 歐姆 && <= 500 歐姆 @ 150-750 Vdc
+	// define : 瘥� 0.2 ~ 1 蝘雴�甈�
+	// occur : <= 75k 甇𣂼� @ 150 - 750 Vdc
+	// warning : >= 100 甇𣂼� && <= 500 甇𣂼� @ 150-750 Vdc
 	if (Query_Gfd_Adc(Uart5Fd, Addr.Relay, &gfd_adc) == PASS)
 	{
 		for (int i = 0; i < gunCount; i++)
@@ -951,7 +951,7 @@ void GetGpioInput()
 
 		if (gpio_in.SPD == 1)
 		{
-			// SPD (雷擊保護) ON
+			// SPD (�瑟�靽肽風) ON
 			PRINTF_FUNC("RB SPD. \n");
 		}
 
@@ -1203,14 +1203,14 @@ void SetK1K2RelayStatus(byte index)
 
 void SetParalleRelayStatus()
 {
-	// 之後雙槍單模機種,橋接都會上
+	// 銋见��蹱��格芋璈毺車嚗峕��仿����
 	if (gunCount >= 2 && ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == NO)
 	{
 		if (_chargingData[0]->SystemStatus == S_BOOTING || _chargingData[1]->SystemStatus == S_BOOTING ||
 				((_chargingData[0]->SystemStatus == S_IDLE || _chargingData[0]->SystemStatus == S_MAINTAIN) &&
 				(_chargingData[1]->SystemStatus == S_IDLE || _chargingData[1]->SystemStatus == S_MAINTAIN)))
 		{
-			// 初始化~ 不搭橋接
+			// �嘥��𤦸 銝齿𨰹璈𧢲𦻖
 			if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
 				outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
 			else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
@@ -1221,12 +1221,12 @@ void SetParalleRelayStatus()
 			if (_chargingData[0]->IsReadyToCharging == YES ||
 					_chargingData[1]->IsReadyToCharging == YES)
 			{
-				// ************需考慮在切換中 - 切開 relay 與搭回 relay 的時機點************
+				// ************������典��𥕢葉 - ��� relay ��𨰹�� relay ���璈罸�************
 				if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX)
 				{
 					if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag < _REASSIGNED_RELAY_M_TO_A)
 					{
-						// 最大充 - 搭上橋接
+						// ��憭批� - �凋�璈𧢲𦻖
 						if (regRelay.relay_event.bits.Gun1_Parallel_N == NO)
 							outputRelay.relay_event.bits.Gun1_Parallel_N = YES;
 						else if (regRelay.relay_event.bits.Gun1_Parallel_P == NO)
@@ -1234,7 +1234,7 @@ void SetParalleRelayStatus()
 					}
 					else
 					{
-						// 平均充 - 不搭
+						// 撟喳��� - 銝齿𨰹
 						if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
 							outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
 						else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
@@ -1245,7 +1245,7 @@ void SetParalleRelayStatus()
 				{
 					if (ShmSysConfigAndInfo->SysInfo.ReAssignedFlag < _REASSIGNED_RELAY_A_TO_M)
 					{
-						// 平均充 - 不搭
+						// 撟喳��� - 銝齿𨰹
 						if (regRelay.relay_event.bits.Gun1_Parallel_P == YES)
 							outputRelay.relay_event.bits.Gun1_Parallel_P = NO;
 						else if (regRelay.relay_event.bits.Gun1_Parallel_N == YES)
@@ -1253,7 +1253,7 @@ void SetParalleRelayStatus()
 					}
 					else
 					{
-						// 最大充 - 搭上橋接
+						// ��憭批� - �凋�璈𧢲𦻖
 						if (regRelay.relay_event.bits.Gun1_Parallel_N == NO)
 							outputRelay.relay_event.bits.Gun1_Parallel_N = YES;
 						else if (regRelay.relay_event.bits.Gun1_Parallel_P == NO)
@@ -1817,7 +1817,7 @@ bool IsNoneMatchRelayStatus()
 
 void MatchRelayStatus()
 {
-	// 因為 AC Contactor 沒有 Feedback,所以暫時先這樣處理
+	// �删� AC Contactor 瘝埝� Feedback嚗峕�隞交麱����蹱見�閧�
 	//regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
 	ShmSysConfigAndInfo->SysInfo.AcContactorStatus  = regRelay.relay_event.bits.AC_Contactor = outputRelay.relay_event.bits.AC_Contactor;
 	regRelay.relay_event.bits.CCS_Precharge = outputRelay.relay_event.bits.CCS_Precharge;
@@ -1834,7 +1834,7 @@ void CheckRelayStatusByADC()
 	if (ShmRelayModuleData->Gun1FuseOutputVolt > 0 && ShmRelayModuleData->Gun1RelayOutputVolt > 0 &&
 			(ShmRelayModuleData->Gun1FuseOutputVolt == ShmRelayModuleData->Gun1RelayOutputVolt))
 	{
-		// Relay 前後電壓一致
+		// Relay �滚��餃�銝���
 		_chargingData[0]->RelayK1K2Status = 0x01;
 	}
 	else
@@ -1843,7 +1843,7 @@ void CheckRelayStatusByADC()
 	if (ShmRelayModuleData->Gun2FuseOutputVolt > 0 && ShmRelayModuleData->Gun2RelayOutputVolt > 0 &&
 				(ShmRelayModuleData->Gun2FuseOutputVolt == ShmRelayModuleData->Gun2RelayOutputVolt))
 	{
-		// Relay 前後電壓一致
+		// Relay �滚��餃�銝���
 		_chargingData[1]->RelayK1K2Status = 0x01;
 	}
 	else
@@ -1867,12 +1867,12 @@ void SetGfdConfig(byte index, byte resister)
 void CableCheckDetected(byte index)
 {
 	// Cable Check
-	// 當火線上的電壓 = 車端要求的電壓電流
+	// �嗥�蝺帋���𤓖憯� = 頠羓垢閬����𤓖憯㯄𤓖瘚�
 	// _chargingData[targetGun]->EvBatterytargetVoltage
-	// 才可以開始偵測 1s
-	// Warning : Rgfd <= 150 歐/V 假設電壓為 500V 則~ Rgfd <= 75000 歐
-	// Pre-Warning : 150 歐/V < Rgfd <= 500 歐/V 假設電壓為 500V 則 75000 歐 < Rgfd <= 250000
-	// SO Normal : Rgfd > 500 歐/V 假設電壓為 500 V 則 Rgfd > 250000 歐
+	// �滚虾隞仿�憪见�皜� 1s
+	// Warning : Rgfd <= 150 甇�/V ��身�餃��� 500V �㻬 Rgfd <= 75000 甇�
+	// Pre-Warning : 150 甇�/V < Rgfd <= 500 甇�/V ��身�餃��� 500V �� 75000 甇� < Rgfd <= 250000
+	// SO Normal : Rgfd > 500 甇�/V ��身�餃��� 500 V �� Rgfd > 250000 甇�
 	if ((_chargingData[index]->Type >= _Type_Chademo && _chargingData[index]->Type <= _Type_GB) ||
 			(_chargingData[index]->Type == 0x09 && ShmSysConfigAndInfo->SysConfig.AlwaysGfdFlag))
 	{
@@ -2058,18 +2058,18 @@ void GetPsuTempForFanSpeed()
 
 void GetFanSpeedByFunction()
 {
-	// 風控修改 :
+	// 憸冽綉靽格㺿 :
 	// ******************************************************* //
 	//
-	//       當前PSU輸出總 KW       PSU Temp
+	//       �嗅�PSU頛詨枂蝮� KW       PSU Temp
 	// 50 x -------------------- x ---------- + 0.5 x (PSU Temp - 70)
-	//       當前樁最大功率 KW         50
+	//       �嗅�璅��憭批��� KW         50
 	//
 	// ******************************************************* //
 
-	// 當前樁最大功率 KW : ShmPsuData->SystemAvailablePower
+	// �嗅�璅��憭批��� KW : ShmPsuData->SystemAvailablePower
 	unsigned int _maxPower = ShmPsuData->SystemAvailablePower;
-	// 當前PSU輸出總 KW & PSU Temp :
+	// �嗅�PSU頛詨枂蝮� KW & PSU Temp :
 	unsigned char temp = 0;
 	float power = 0;
 
@@ -2097,7 +2097,7 @@ void GetFanSpeedByFunction()
 	if (temp > 70)
 		_temp_diff = temp - 70;
 
-	// debug mode 直接印出資訊後離開
+	// debug mode �湔𦻖�啣枂鞈��敺屸𣪧��
 	if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES)
 	{
 //		printf("Fan Speed Information: power = %f, _maxPower = %d, temp = %d -- _pw_rate = %f, _temp_rate = %f, _temp_diff = %d \n",
@@ -2356,7 +2356,7 @@ void AcChargeTypeProcess()
 				ac_chargingInfo[0]->SystemStatus = _status;
 			}
 
-			// 設定限制最大充電電流 >= 6 ~ <= 32
+			// 閮剖��𣂼���憭批��駁𤓖瘚� >= 6 ~ <= 32
 			switch(ac_chargingInfo[0]->SystemStatus)
 			{
 				case S_IDLE:
@@ -2428,7 +2428,7 @@ void AcChargeTypeProcess()
 					ac_chargingInfo[0]->PresentChargingVoltage = AC_DEFAULT_VOL;
 					ac_chargingInfo[0]->PresentChargingCurrent = ((float)acChargingCurrent.OuputCurrentL1 / 10);
 
-					// 用以判斷是否有在輸出
+					// �其誑�斗𪃾�臬炏�匧銁頛詨枂
 					ac_chargingInfo[0]->IsCharging = acStatus.RelayStatus;
 
 					SetCpDuty(ShmSysConfigAndInfo->SysConfig.AcMaxChargingCurrent);
@@ -2456,7 +2456,7 @@ void AcChargeTypeProcess()
 						ftime(&_ac_endChargingTime);
 						if (strcmp((char *)ac_chargingInfo[0]->StartDateTime, "") != EQUAL)
 						{
-							// AC 固定為第2把槍
+							// AC �箏��箇洵2�𦠜�
 							OcppStopTransation(1);
 						}
 
@@ -2539,7 +2539,7 @@ int main(void)
 	for(;;)
 	{
 		bool isCharging = false;
-		// 程序開始之前~ 必須先確定 FW 版本與硬體版本,確認後!!~ 該模組才算是真正的 Initial Comp.
+		// 蝔见��见�銋见�~ 敹����Ⅱ摰� FW ��𧋦��′擃𠉛��穿�蝣箄�敺�!!~ 閰脫芋蝯��蝞埈糓��迤�� Initial Comp.
 		if (ShmRelayModuleData->SelfTest_Comp == NO)
 		{
 			GetFwAndHwVersion_Relay();
@@ -2557,10 +2557,10 @@ int main(void)
 			gettimeofday(&_priority_time, NULL);
 		}
 
-		// 自檢階段處理,自檢階段如果讀不到版號則代表該系統沒有掛燈板
+		// �芣炎�擧挾�閧�嚗諹䌊瑼a�畾萄��𡏭�銝滚������誨銵刻府蝟餌絞瘝埝��𤤿���
 		if (ShmLedModuleData->SelfTest_Comp == NO)
 		{
-			// 自檢階段
+			// �芣炎�擧挾
 			if (ShmSysConfigAndInfo->SysInfo.SelfTestSeq <= _STEST_PSU_CAP)
 			{
 				GetFwAndHwVersion_Led();
@@ -2569,7 +2569,7 @@ int main(void)
 			}
 			else
 			{
-				// 自檢階段沒有問到版號
+				// �芣炎�擧挾瘝埝��誩����
 				if (ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LedboardStestFail == NO)
 					ShmStatusCodeData->AlarmCode.AlarmEvents.bits.LedboardStestFail = YES;
 			}
@@ -2579,14 +2579,14 @@ int main(void)
 
 		if (ShmRelayModuleData->SelfTest_Comp == YES)
 		{
-			// ==============優先權最高 10 ms ==============
-			// 輸出電壓
+			// ==============�芸�甈𦠜�擃� 10 ms ==============
+			// 頛詨枂�餃�
 			GetPersentOutputVol();
 
-			// 三相輸入電壓
+			// 銝厩㮾頛詨��餃�
 			GetPresentInputVol();
 
-			// 讀取當前 AC relay 狀態
+			// 霈��𣇉訜�� AC relay ����
 			regRelay.relay_event.bits.AC_Contactor = ShmSysConfigAndInfo->SysInfo.AcContactorStatus;
 			GetRelayOutputStatus();
 
@@ -2595,10 +2595,10 @@ int main(void)
 				// Cable check (Set)
 				CableCheckDetected(i);
 
-				// check k1 k2 relay 狀態
+				// check k1 k2 relay ����
 				CheckK1K2RelayOutput(i);
 
-				// 依據當前各槍的狀態選擇 搭上/放開 Relay
+				// 靘脲��嗅��������钅��� �凋�/�暸� Relay
 				SetK1K2RelayStatus(i);
 
 				if (_chargingData[i]->SystemStatus == S_IDLE)
@@ -2631,10 +2631,10 @@ int main(void)
 			// Cable check (Get)
 			GetGfdAdc();
 
-			// 橋接 relay
+			// 璈𧢲𦻖 relay
 			SetParalleRelayStatus();
 
-			// 搭上 AC Contactor
+			// �凋� AC Contactor
 //			if (isCharging)
 //				outputRelay.relay_event.bits.AC_Contactor = YES;
 //			else
@@ -2663,7 +2663,7 @@ int main(void)
 			if (ShmPsuData->Work_Step >= _TEST_MODE && ShmPsuData->Work_Step <= _TEST_MODE)
 				outputRelay.relay_event.bits.Gun1_N = outputRelay.relay_event.bits.Gun1_P = YES;
 
-			// 搭上/鬆開 Relay
+			// �凋�/擛�� Relay
 			if(IsNoneMatchRelayStatus())
 			{
 				relayMatchFlag = NO;

+ 9 - 0
EVSE/Projects/define.h

@@ -108,6 +108,15 @@ Storage							0x0A200000-0x7FFFFFFF		1886 MB
     #define GENERAL_GUN_QUANTITY	0
     #define PSU_QUANTITY            2
     #define ONE_CONNECTOR_USE       0
+#elif DD360Audi
+    #define MAX_PSU_QUANTITY        62
+    #define CHAdeMO_QUANTITY        0
+    #define CCS_QUANTITY            2
+    #define GB_QUANTITY             0
+    #define AC_QUANTITY             0
+    #define GENERAL_GUN_QUANTITY	0
+    #define PSU_QUANTITY            2
+    #define ONE_CONNECTOR_USE       0
 #elif DO360
     #define MAX_PSU_QUANTITY        62
     #define CHAdeMO_QUANTITY        0

BIN
EVSE/rootfs/root/OcppBackend20


Някои файлове не бяха показани, защото твърде много файлове са промени