فهرست منبع

fix merge conflict

Merge branch 'master' into DO360
Wendell 4 سال پیش
والد
کامیت
740f9fed03

+ 110 - 84
EVSE/Modularization/Module_Upgrade.c

@@ -484,7 +484,7 @@ int uart_tranceive(int fd, unsigned char* cmd, unsigned char* rx, int len, unsig
     return rxLen;
 }
 
-unsigned char uart_update_start(unsigned char fd, unsigned char targetAddr, unsigned int crc32)
+unsigned char uart_update_start(int fd, unsigned char targetAddr, unsigned int crc32)
 {
     unsigned char result = FAIL;
     unsigned char tx[11] = {0xaa, 0x00, targetAddr, UART_CMD_UPDATE_START, 0x04, 0x00, (crc32>>0)&0xff, (crc32>>8)&0xff, (crc32>>16)&0xff, (crc32>>24)&0xff, 0x00};
@@ -525,7 +525,7 @@ unsigned char uart_update_start(unsigned char fd, unsigned char targetAddr, unsi
     return result;
 }
 
-unsigned char uart_update_abord(unsigned char fd, unsigned char targetAddr)
+unsigned char uart_update_abord(int fd, unsigned char targetAddr)
 {
     unsigned char result = FAIL;
     unsigned char tx[7] = {0xaa, 0x00, targetAddr, UART_CMD_UPDATE_ABORD, 0x00, 0x00, 0x00};
@@ -562,7 +562,7 @@ unsigned char uart_update_abord(unsigned char fd, unsigned char targetAddr)
     return result;
 }
 
-unsigned char uart_update_transfer(unsigned char fd, unsigned char targetAddr, unsigned int startAddr, unsigned char *data, unsigned short int length)
+unsigned char uart_update_transfer(int fd, unsigned char targetAddr, unsigned int startAddr, unsigned char *data, unsigned short int length)
 {
     unsigned char result = FAIL;
     unsigned char tx[11 + length];
@@ -610,7 +610,7 @@ unsigned char uart_update_transfer(unsigned char fd, unsigned char targetAddr, u
     return result;
 }
 
-unsigned char uart_update_finish(unsigned char fd, unsigned char targetAddr)
+unsigned char uart_update_finish(int fd, unsigned char targetAddr)
 {
     unsigned char result = FAIL;
     unsigned char tx[7] = {0xaa, 0x00, targetAddr, UART_CMD_UPDATE_FINISH, 0x00, 0x00, 0x00};
@@ -647,7 +647,7 @@ unsigned char uart_update_finish(unsigned char fd, unsigned char targetAddr)
     return result;
 }
 
-unsigned char uart_config_timeout(unsigned char uartfd)
+unsigned char uart_config_timeout(int uartfd)
 {
 	struct termios tios;
 
@@ -712,52 +712,70 @@ int Upgrade_UART(int uartfdOrd,unsigned int Type,unsigned char TargetAddr,char *
                 DEBUG_INFO("CRC32 by calculation: 0x%08X\n",crc32(ptr,ImageLen));
                 if(crc32(ptr,ImageLen) == ImageCRC)
                 {
-                    if(uart_update_start(uartfd, TargetAddr, crc32(ptr+48,DataLength))==PASS)
+                    if(YES)
                     {
                         int CNT_Fail = 0;
                         int CNT_Trans = 0;
+
                         do
                         {
-                            if(uart_update_transfer(uartfd, TargetAddr, CNT_Trans*1024, ptr+48+(CNT_Trans*1024), 1024)==PASS)
-                            {
-                                CNT_Fail = 0;
-                                CNT_Trans++;
-                                DEBUG_INFO("Upgrade progress:%.2f%%\n", ((float)(CNT_Trans*1024))/(DataLength)*100);
-                            }
-                            else
-                            {
-                                DEBUG_WARN("Data transfer fail, retry %d \n", ++CNT_Fail);
-                                sleep(1);
-                            }
-                        }while(DataLength-(CNT_Trans*1024)>0 && CNT_Fail<10);
+                        	if(uart_update_start(uartfd, TargetAddr, crc32(ptr+48,DataLength))==PASS)
+                        		break;
+							else
+								DEBUG_WARN("Upgrade start fail, retry %d \n", ++CNT_Fail);
+                        }while(CNT_Fail<10);
 
                         if(CNT_Fail>=10)
-                        {
-                            uart_update_abord(uartfd, TargetAddr);
-                            DEBUG_ERROR("UART upgrade transfer retry > limits, aboard upgrade.\n");
-                        }
-                        else
-                        {
-                        	do
-                        	{
-                        		if(uart_update_finish(uartfd, TargetAddr)==PASS)
-                        			break;
-                        		else
-                        			DEBUG_WARN("Upgrade finish fail, retry %d \n", ++CNT_Fail);
-                        	}while(CNT_Fail<10);
-
-                        	if(CNT_Fail>=10)
-                        	{
-                        		uart_update_abord(uartfd, TargetAddr);
-                        		DEBUG_ERROR("UART upgrade finish retry > limits, aboard upgrade.\n");
-                        	}
-                        	else
-                        	{
-                        		result = PASS;
-                        		printf("UART upgrade success.\n");
-                        	}
-
-                        }
+						{
+							uart_update_abord(uartfd, TargetAddr);
+							DEBUG_ERROR("UART upgrade start retry > limits, aboard upgrade.\n");
+						}
+						else
+						{
+							CNT_Fail = 0;
+							do
+							{
+								if(uart_update_transfer(uartfd, TargetAddr, CNT_Trans*1024, ptr+48+(CNT_Trans*1024), 1024)==PASS)
+								{
+									CNT_Fail = 0;
+									CNT_Trans++;
+									DEBUG_INFO("Upgrade progress:%.2f%%\n", ((float)(CNT_Trans*1024))/(DataLength)*100);
+								}
+								else
+								{
+									DEBUG_WARN("Data transfer fail, retry %d \n", ++CNT_Fail);
+									sleep(1);
+								}
+							}while(DataLength-(CNT_Trans*1024)>0 && CNT_Fail<10);
+
+							if(CNT_Fail>=10)
+							{
+								uart_update_abord(uartfd, TargetAddr);
+								DEBUG_ERROR("UART upgrade transfer retry > limits, aboard upgrade.\n");
+							}
+							else
+							{
+								CNT_Fail = 0;
+								do
+								{
+									if(uart_update_finish(uartfd, TargetAddr)==PASS)
+										break;
+									else
+										DEBUG_WARN("Upgrade finish fail, retry %d \n", ++CNT_Fail);
+								}while(CNT_Fail<10);
+
+								if(CNT_Fail>=10)
+								{
+									uart_update_abord(uartfd, TargetAddr);
+									DEBUG_ERROR("UART upgrade finish retry > limits, aboard upgrade.\n");
+								}
+								else
+								{
+									result = PASS;
+									printf("UART upgrade success.\n");
+								}
+							}
+						}
                     }
                     else
                         DEBUG_ERROR("UART upgrade request failed.\n");
@@ -1034,6 +1052,7 @@ int Upgrade_CAN(int canfd,unsigned int Type,unsigned char TargetAddr,char *Sourc
 //================================================
 int Check_CCS_image_header(unsigned int Type,char *SourcePath,char *ModelName)
 {
+	int result = FAIL;
     long int MaxLen=48*1024*1024, ImageLen=0;
     unsigned int ImageCRC=0;
     int fd;
@@ -1078,47 +1097,54 @@ int Check_CCS_image_header(unsigned int Type,char *SourcePath,char *ModelName)
     close(fd);
     //read out the header
     int i;
-    for(i=0;i<16;i++)
-    {
-        if(ModelName[i] != ptr[i])
-        {
-            DEBUG_ERROR("Model name mismatch.\n");
-            return FAIL;
-        }
-    }
+    int isModelNameOK = PASS;
+	for(i=0;i<16;i++)
+	{
+		if(ModelName[i] != ptr[i])
+		{
+			isModelNameOK = FAIL;
+		}
+	}
 
-    // check if the firmware type is correct
-    if(Type == (((unsigned int)ptr[16])<<24 | ((unsigned int)ptr[17])<<16 | ((unsigned int)ptr[18])<<8 | ((unsigned int)ptr[19])))
-    {
-        if((ImageLen-48) == (((unsigned int)ptr[20])<<24 | ((unsigned int)ptr[21])<<16 | ((unsigned int)ptr[22])<<8 | ((unsigned int)ptr[23])))
-        {
-            // get CRC in the header
-            ImageCRC = ((unsigned int)ptr[34])<<24 | ((unsigned int)ptr[35])<<16 | ((unsigned int)ptr[36])<<8 | ((unsigned int)ptr[37]);
+	if(isModelNameOK == FAIL)
+	{
+		DEBUG_ERROR("Model name mismatch.\n");
+	}
+	else
+	{
+	    // check if the firmware type is correct
+	    if(Type == (((unsigned int)ptr[16])<<24 | ((unsigned int)ptr[17])<<16 | ((unsigned int)ptr[18])<<8 | ((unsigned int)ptr[19])))
+	    {
+	        if((ImageLen-48) == (((unsigned int)ptr[20])<<24 | ((unsigned int)ptr[21])<<16 | ((unsigned int)ptr[22])<<8 | ((unsigned int)ptr[23])))
+	        {
+	            // get CRC in the header
+	            ImageCRC = ((unsigned int)ptr[34])<<24 | ((unsigned int)ptr[35])<<16 | ((unsigned int)ptr[36])<<8 | ((unsigned int)ptr[37]);
+
+	            // calculate the image CRC
+	            DEBUG_INFO("CRC32 in CCS image: 0x%08X\n",ImageCRC);
+	            DEBUG_INFO("CRC32 by calculation: 0x%08X\n",crc32(ptr,ImageLen));
+	            if(crc32(ptr,ImageLen) == ImageCRC)
+	            {
+	                result = PASS;
+	            }
+	            else
+	            {
+	                DEBUG_ERROR("Firmware image CRC32 mismatch.\n");
+	            }
+	        }
+	        else
+	        {
+	            DEBUG_ERROR("Firmware image length mismatch.\n");
+	        }
+	    }
+	    else
+	    {
+	        DEBUG_ERROR("Firmware image type mismatch.\n");
+	    }
+	}
+    free(ptr);
 
-            // calculate the image CRC
-            DEBUG_INFO("CRC32 in CCS image: 0x%08X\n",ImageCRC);
-            DEBUG_INFO("CRC32 by calculation: 0x%08X\n",crc32(ptr,ImageLen));
-            if(crc32(ptr,ImageLen) == ImageCRC)
-            {
-                return PASS;
-            }
-            else
-            {
-                DEBUG_ERROR("Firmware image CRC32 mismatch.\n");
-                return FAIL;
-            }
-        }
-        else
-        {
-            DEBUG_ERROR("Firmware image length mismatch.\n");
-            return FAIL;
-        }
-    }
-    else
-    {
-        DEBUG_ERROR("Firmware image type mismatch.\n");
-        return FAIL;
-    }
+    return result;
 }
 
 int Put_CCS_image(char *SourcePath, unsigned char TargetAddr)
@@ -1162,7 +1188,7 @@ int Send_CCS_download_finish(int canfd,unsigned int Slave_Addr)
 
         struct timeval timer;
         gettimeofday(&timer, NULL);
-        unsigned long ack_timeout = 30 * 60 * 1000 * 1000;  //30 minutes
+        unsigned long ack_timeout = 5 * 60 * 1000 * 1000;  //5 minutes
 
         while (getTimeoutValue(timer) < ack_timeout)
         {

+ 23 - 16
EVSE/Modularization/Module_Wifi.c

@@ -238,7 +238,6 @@ int isFindInterface();
 int getInterfaceInfo();
 int isReachableInternet();
 int getLinkQuality();
-char* getTimeString(void);
 int setWPAconf();
 int restartWPA();
 void refreshUSB();
@@ -471,8 +470,6 @@ int isFindInterface()
 
 	struct ifaddrs *ifaddr, *ifa;
 
-	//refreshUSB();
-
 	if(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == WIFI_MODE_AP)
 	{
 		if (getifaddrs(&ifaddr) != FAIL)
@@ -4216,19 +4213,6 @@ int tcpSocketServerStart(void)
 //==========================================
 // Common routine
 //==========================================
-char* getTimeString(void)
-{
-	char *result=malloc(21);
-	time_t timep;
-	struct tm *p;
-	time(&timep);
-	p=gmtime(&timep);
-
-	sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]", (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, p->tm_hour, p->tm_sec);
-
-	return result;
-}
-
 void trim(char *s)
 {
     int i=0, j, k, l=0;
@@ -4413,6 +4397,27 @@ int restartWPA(void)
 	return result;
 }
 
+int resetModule(void)
+{
+	//refreshUSB();
+
+	#ifdef UBLOX
+		system("ifconfig mlan0 down");
+		sleep(1);
+		system("ifconfig mlan0 up");
+	#endif
+
+	#ifdef MT7601U
+		system("ifconfig wlan0 down");
+		sleep(1);
+		system("ifconfig wlan0 up");
+	#endif
+
+	DEBUG_WARN("Wifi interface restart.\n");
+
+	return PASS;
+}
+
 void proc_sta()
 {
 	switch(Wifi_module_sts)
@@ -4460,6 +4465,7 @@ void proc_sta()
 				DEBUG_INFO("Fail to connect to the AP %d times...\n",cnt_getAP_Fail);
 				if(cnt_getAP_Fail>=3)
 				{
+					resetModule();
 					Wifi_module_sts = STA_STATE_INIT;
 					cnt_getAP_Fail = 0;
 
@@ -4505,6 +4511,7 @@ void proc_sta()
 				memset(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress, 0, sizeof ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress);
 				memset(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMacAddress, 0, sizeof ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMacAddress);
 
+				resetModule();
 				if(isFindInterface() == PASS)
 				{
 					DEBUG_INFO("Wifi interface: %s\n", Wifi.currentInterface);

+ 4 - 0
EVSE/Modularization/ocpp20/MessageHandler.c

@@ -14978,6 +14978,7 @@ int httpDownLoadFile(char *location, char *path, char *filename,char *url)
 	//DEBUG_INFO("filename=%s\n",filename);
 	//DEBUG_INFO("url=%s\n",url);
 	sprintf(FilePath,"/mnt/%s",filename);
+	system("ping 8.8.8.8 &");
 
 	if((access(FilePath,F_OK))!=-1)
 	{
@@ -14997,6 +14998,7 @@ int httpDownLoadFile(char *location, char *path, char *filename,char *url)
 		return FALSE;
 	}
 
+	system("pkill ping");
 	return TRUE;
 }
 
@@ -15008,6 +15010,7 @@ int ftpDownLoadFile(char *location, char *user, char *password, int port, char *
 	int systemresult;
 	//char temp[100];
 	sprintf(FilePath,"/mnt/%s",filename);
+	system("ping 8.8.8.8 &");
 
 	if((access(FilePath,F_OK))!=-1)
 	{
@@ -15031,6 +15034,7 @@ int ftpDownLoadFile(char *location, char *user, char *password, int port, char *
 		return FALSE;
 	}
 
+	system("pkill ping");
 	return TRUE;
 
 }

+ 8 - 0
EVSE/Modularization/ocpp20/Module_OcppBackend20.c

@@ -358,6 +358,14 @@ void* ConnectWsServer(void* data)  //int ConnectWsServer()
 	struct lws_client_connect_info ConnInfo;
 	int use_ssl=0;
 
+	// If internet available synchronize datetime with ntp server
+	if(GetInternetConn() == 1)
+	{
+		DEBUG_INFO("NTP synchronize with Microsoft\n", system("/usr/sbin/ntpd -nqp time.windows.com &"));
+		DEBUG_INFO("NTP synchronize with China\n", system("/usr/sbin/ntpd -nqp cn.ntp.org.cn &"));
+		DEBUG_INFO("NTP synchronize with Taiwan\n", system("/usr/sbin/ntpd -nqp tock.stdtime.gov.tw &"));
+	}
+
 	if(context!=NULL)
 	{
 		pthread_detach(pthread_self());

+ 14 - 5
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -9967,7 +9967,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
 				{
-					if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+					if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+					   (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -9993,7 +9994,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
 				{
-					if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+					if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+					   (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -10020,7 +10022,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
 				{
-					if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+					if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+					   (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -10039,7 +10042,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
 				{
-					if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+					if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) ||
+					   (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -10066,7 +10070,8 @@ int handleSetChargingProfileRequest(char *uuid, char *payload)
 			{
 				if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
 				{
-					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) // S_CHARGING
+					if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) ||
+					   (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING)) // S_CHARGING
 					{
 						if(transactionIdInt == ShmOCPP16Data->StartTransaction[connectorIdInt -1].ResponseTransactionId)
 						{
@@ -14609,6 +14614,7 @@ int httpDownLoadFile(char *location, char *path, char *filename,char *url)
 	//DEBUG_INFO("filename=%s\n",filename);
 	//DEBUG_INFO("url=%s\n",url);
 	sprintf(FilePath,"/mnt/%s",filename);
+	system("ping 8.8.8.8 &");
 
 	if((access(FilePath,F_OK))!=-1)
 	{
@@ -14627,6 +14633,7 @@ int httpDownLoadFile(char *location, char *path, char *filename,char *url)
 		DEBUG_INFO("http DownLoad error!\n");
 		return FALSE;
 	}
+	system("pkill ping");
 
 	return TRUE;
 }
@@ -14639,6 +14646,7 @@ int ftpDownLoadFile(char *location, char *user, char *password, int port, char *
 	int systemresult;
 	//char temp[100];
 	sprintf(FilePath,"/mnt/%s",filename);
+	system("ping 8.8.8.8 &");
 
 	if((access(FilePath,F_OK))!=-1)
 	{
@@ -14662,6 +14670,7 @@ int ftpDownLoadFile(char *location, char *user, char *password, int port, char *
 		return FALSE;
 	}
 
+	system("pkill ping");
 	return TRUE;
 
 }

+ 8 - 1
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -410,11 +410,18 @@ static struct lws_protocols protocols[] =
 
 void* ConnectWsServer(void* data)  //int ConnectWsServer()
 {
-
 	struct lws_context_creation_info ContextInfo;
 	struct lws_client_connect_info ConnInfo;
 	int use_ssl=0;
 
+	// If internet available synchronize datetime with ntp server
+	if(GetInternetConn() == 1)
+	{
+		DEBUG_INFO("NTP synchronize with Microsoft\n", system("/usr/sbin/ntpd -nqp time.windows.com &"));
+		DEBUG_INFO("NTP synchronize with China\n", system("/usr/sbin/ntpd -nqp cn.ntp.org.cn &"));
+		DEBUG_INFO("NTP synchronize with Taiwan\n", system("/usr/sbin/ntpd -nqp tock.stdtime.gov.tw &"));
+	}
+
 	if(context!=NULL)
 	{
 		pthread_detach(pthread_self());

+ 21 - 44
EVSE/Projects/AW-CCS/Apps/CCS/Module_CCS.c

@@ -701,49 +701,6 @@ double DiffTimeb_fork2_Error_Monitor(struct timeb ST, struct timeb ET)
     return t_diff;
 }
 
-int CreateShareMemory()
-{
-    int MeterSMId;
-
-    //create ShmSysConfigAndInfo
-    if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), IPC_CREAT | 0777)) < 0)
-    {
-        SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[main]CreateShareMemory:shmget ShmSysConfigAndInfo NG");
-        return 0;
-    }
-    else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-        SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[main]CreateShareMemory:shmat ShmSysConfigAndInfo NG");
-        return 0;
-    }
-    memset(ShmSysConfigAndInfo,0,sizeof(struct SysConfigAndInfo));
-    //create ShmStatusCodeData
-    if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), IPC_CREAT | 0777)) < 0)
-    {
-        SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[main]CreateShareMemory:shmget ShmStatusCodeData NG");
-        return 0;
-    }
-    else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-        SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[main]CreateShareMemory:shmat ShmStatusCodeData NG");
-        return 0;
-    }
-    memset(ShmStatusCodeData,0,sizeof(struct StatusCodeData));
-    //create ShmCcsData
-    if ((MeterSMId = shmget(ShmCcsCommKey, sizeof(struct CcsData), IPC_CREAT | 0777)) < 0)
-    {
-        SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[main]CreateShareMemory:shmget ShmCcsData NG");
-        return 0;
-    }
-    else if ((ShmCcsData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
-    {
-        SAVE_SYS_LOG_MSG_EVCOMM("%s\n", "[main]CreateShareMemory:shmat ShmCcsData NG");
-        return 0;
-    }
-    memset(ShmCcsData,0,sizeof(struct CcsData));
-    return 1;
-}
-
 /*===========================================================================
 FUNCTION: ShareMemory_Init
 DESCRIPTION:
@@ -1028,7 +985,7 @@ GLOBAL VARIABLES:
 =============================================================================*/
 void Qca7kPowerReset()
 {
-    printf("\n[CCS Board]Reset QCA7000...\n");
+    //printf("\n[CCS Board]Reset QCA7000...\n");
     system("echo 1 > /sys/class/gpio/gpio88/value");
     usleep(500000);
     system("echo 0 > /sys/class/gpio/gpio88/value");
@@ -3900,6 +3857,26 @@ int MmeProcess(unsigned char *Buffer, int DataLength)
             break;
 		}
 
+	    case MMTYPE_VENDOR_VS_PL_LNK_STATUS_CNF:
+		{
+			struct QcaVendorMmeHeader *RecvPacket;
+			RecvPacket = (struct QcaVendorMmeHeader *)Buffer;
+
+			if(RecvPacket->MBODY[1]==0)
+			{
+				//PLC disconnected
+				sprintf((char*)buf_log_evcomm,
+					"[QCA7K][Rx][MMTYPE_VENDOR_VS_PL_LNK_STATUS_CNF]Got PLC Link Status:%d",
+					RecvPacket->MBODY[1]);
+				SAVE_SYS_LOG_MSG_EVCOMM("%s\n", buf_log_evcomm);
+				Update_V2G_Flow_Status(Other_Fault);
+			}
+			else
+				Update_V2G_Flow_Status(CM_SET_KEY_REQ);
+		ftime(&SeqStartTime);
+			break;
+		}
+
 	    default:
 		{
 	        break;

+ 19 - 17
EVSE/Projects/AW-CCS/Apps/CCS/Module_CCS.h

@@ -67,24 +67,26 @@
 /***********************************************/
 /*** MMTYPE (Management Message Type) **/
 /**********************************************/
-#define MMTYPE_CM_SET_KEY_REQ				0x6008
-#define MMTYPE_CM_SET_KEY_CNF				0x6009
-#define MMTYPE_CM_SLAC_PARM_REQ				0x6064
-#define MMTYPE_CM_SLAC_PARM_CNF				0x6065
-#define MMTYPE_CM_START_ATTEN_CHAR_IND		0x606A
-#define MMTYPE_CM_MNBC_SOUND_IND			0x6076
-#define MMTYPE_CM_ATTEN_CHAR_IND			0x606E
-#define MMTYPE_CM_ATTEN_CHAR_RSP			0x606F
-#define MMTYPE_CM_VALIDATE_REQ				0x6078
-#define MMTYPE_CM_VALIDATE_CNF				0x6079
-#define MMTYPE_CM_SLAC_MATCH_REQ			0x607C
-#define MMTYPE_CM_SLAC_MATCH_CNF			0x607D
-#define MMTYPE_CM_ATTEN_PROFILE_IND			0x6086
+#define MMTYPE_CM_SET_KEY_REQ					0x6008
+#define MMTYPE_CM_SET_KEY_CNF					0x6009
+#define MMTYPE_CM_SLAC_PARM_REQ					0x6064
+#define MMTYPE_CM_SLAC_PARM_CNF					0x6065
+#define MMTYPE_CM_START_ATTEN_CHAR_IND			0x606A
+#define MMTYPE_CM_MNBC_SOUND_IND				0x6076
+#define MMTYPE_CM_ATTEN_CHAR_IND				0x606E
+#define MMTYPE_CM_ATTEN_CHAR_RSP				0x606F
+#define MMTYPE_CM_VALIDATE_REQ					0x6078
+#define MMTYPE_CM_VALIDATE_CNF					0x6079
+#define MMTYPE_CM_SLAC_MATCH_REQ				0x607C
+#define MMTYPE_CM_SLAC_MATCH_CNF				0x607D
+#define MMTYPE_CM_ATTEN_PROFILE_IND				0x6086
 //following are the vendor specific type
-#define MMTYPE_VENDOR_VS_HOST_ACTION	 	0xA062		//Embedded Host Action Requested Indication MME
-#define MMTYPE_VENDOR_ATTEN_CHAR			0xA14E		//Attenuation Characteristics MME (VS_ATTEN_CHAR)
-#define MMTYPE_VENDOR_VS_NW_INFO			0xA038		//Network Info MME
-#define MMTYPE_VENDOR_VS_NW_INFO_CNF		0xA039		//Network Info MME
+#define MMTYPE_VENDOR_VS_HOST_ACTION	 		0xA062		//Embedded Host Action Requested Indication MME
+#define MMTYPE_VENDOR_ATTEN_CHAR				0xA14E		//Attenuation Characteristics MME (VS_ATTEN_CHAR)
+#define MMTYPE_VENDOR_VS_NW_INFO				0xA038		//Network Info MME
+#define MMTYPE_VENDOR_VS_NW_INFO_CNF			0xA039		//Network Info MME
+#define MMTYPE_VENDOR_VS_PL_LNK_STATUS       	0xA0B8      //Powerline Link Status /*+++ 20200808, vern, for PLC connection monitoring ---*/
+#define MMTYPE_VENDOR_VS_PL_LNK_STATUS_CNF    	0xA0B9      //Powerline Link Status /*+++ 20200808, vern, for PLC connection monitoring ---*/
 
 /***********************************************/
 /************** V2GTP Payload Type ************/

+ 4 - 1
EVSE/Projects/AW-Regular/Apps/main.c

@@ -1270,7 +1270,7 @@ void get_firmware_version(unsigned char gun_index)
 	strcpy((char*)ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, ShmCharger->gun_info[gun_index].ver.Version_FW);
 
 	// Get CSU root file system version
-	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "V0.62.00.0000.00");
+	sprintf((char*)ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "V0.63.00.0000.00");
 
 	// Get AC connector type from model name
 	for(uint8_t idx=0;idx<3;idx++)
@@ -3472,6 +3472,9 @@ int main(void)
 								sprintf((char*)ShmOCPP16Data->FirmwareStatusNotification.Status, "InstallationFailed");
 								ShmOCPP16Data->SpMsg.bits.FirmwareStatusNotificationReq = ON;
 								DEBUG_WARN("Firmware upgrade fail.\n");
+								
+								sleep(1);
+								system("rm -rvf /mnt/* ");
 								close(wtdFd);
 								system("/usr/bin/run_evse_restart.sh");
 							}

BIN
EVSE/Projects/AW-Regular/Images/ramdisk.gz


+ 59 - 13
EVSE/Projects/CCS/Apps/FWUpdate.c

@@ -388,14 +388,22 @@ unsigned char Update_uboot()
 
         // Write image to flash
         SAVE_SYS_LOG_MSG_FWUPDATE("[uboot]Writing image to mtdblock1...");
-        fread(ptr, sizeof(unsigned char), file_length, file);
-        wrd = write(fd, ptr, file_length);
+     //   fread(ptr, sizeof(unsigned char), file_length, file);
+      
+        //wrd = write(fd, ptr, file_length);
 
         close(fd);
         fclose(file);
+                
+        system("/bin/flash_erase /dev/mtd1 0 2");
+	system("/usr/sbin/nandwrite -p /dev/mtd1 /root/u-boot.img");
+	system("/bin/flash_erase /dev/mtd3 0 2");
+	system("/usr/sbin/nandwrite -p /dev/mtd3 /root/u-boot.img");
+
+        
         sprintf(buf_log_fwupdate, "[uboot]mtdblock1 - written length: %d bytes\n", wrd);
         SAVE_SYS_LOG_MSG_FWUPDATE(buf_log_fwupdate);
-
+#if 0
         if(wrd != file_length)
         {
             free(ptr);
@@ -434,6 +442,7 @@ unsigned char Update_uboot()
                 }
             }
         }
+#endif    
     }
     return result;
 }
@@ -489,14 +498,22 @@ unsigned char Update_DTB()
 
         // Write image to flash
         SAVE_SYS_LOG_MSG_FWUPDATE("[DTB]Writing image to mtdblock4...");
-        fread(ptr, sizeof(unsigned char), file_length, file);
-        wrd = write(fd, ptr, file_length);
+      //  fread(ptr, sizeof(unsigned char), file_length, file);
+      //  wrd = write(fd, ptr, file_length);
 
         close(fd);
         fclose(file);
+        
+        system("/bin/flash_erase /dev/mtd4 0 1");
+	system("/usr/sbin/nandwrite -p /dev/mtd4 /root/am335x-evm.dtb");
+
+	system("/bin/flash_erase /dev/mtd5 0 1");
+	system("/usr/sbin/nandwrite -p /dev/mtd5 /root/am335x-evm.dtb");
+        
+        
         sprintf(buf_log_fwupdate, "[DTB]mtdblock4 - written length: %d bytes\n", wrd);
         SAVE_SYS_LOG_MSG_FWUPDATE(buf_log_fwupdate);
-
+#if 0
         if(wrd != file_length)
         {
             free(ptr);
@@ -527,6 +544,7 @@ unsigned char Update_DTB()
                 }
             }
         }
+#endif        
     }
     return result;
 }
@@ -582,14 +600,22 @@ unsigned char Update_zImage()
 
         // Write image to flash
         SAVE_SYS_LOG_MSG_FWUPDATE("[zImage]Writing image to mtdblock6...");
-        fread(ptr, sizeof(unsigned char), file_length, file);
-        wrd = write(fd, ptr, file_length);
+      //  fread(ptr, sizeof(unsigned char), file_length, file);
+       // wrd = write(fd, ptr, file_length);
 
         close(fd);
         fclose(file);
+        
+	
+	system("/bin/flash_erase /dev/mtd6 0 20");
+	system("/usr/sbin/nandwrite -p /dev/mtd6 /root/zImage");
+
+	system("/bin/flash_erase /dev/mtd7 0 20");
+	system("/usr/sbin/nandwrite -p /dev/mtd7 /root/zImage");
+        
         sprintf(buf_log_fwupdate, "[zImage]mtdblock6 - written length: %d bytes\n", wrd);
         SAVE_SYS_LOG_MSG_FWUPDATE(buf_log_fwupdate);
-
+#if 0
         if(wrd != file_length)
         {
             free(ptr);
@@ -620,6 +646,7 @@ unsigned char Update_zImage()
                 }
             }
         }
+#endif        
     }
     return result;
 }
@@ -672,12 +699,22 @@ unsigned char Update_ramdisk()
         system("killall SeccComm");
 
         SAVE_SYS_LOG_MSG_FWUPDATE("[ramdisk]Writing image to mtdblock8...");
-        fread(ptr, sizeof(unsigned char), file_length, file);
-        wrd = write(fd, ptr, file_length);
+        //fread(ptr, sizeof(unsigned char), file_length, file);
+        //wrd = write(fd, ptr, file_length);
         close(fd);
         fclose(file);
+        
+
+       system("/bin/flash_erase /dev/mtd8 0 96");
+       system("/usr/sbin/nandwrite -p /dev/mtd8 /root/ramdisk.gz");
+
+       system("/bin/flash_erase /dev/mtd9 0 96");
+       system("/usr/sbin/nandwrite -p /dev/mtd9 /root/ramdisk.gz");
+                                	
+                                	
         sprintf(buf_log_fwupdate, "[ramdisk]mtdblock8 - written length: %d bytes\n", wrd);
         SAVE_SYS_LOG_MSG_FWUPDATE(buf_log_fwupdate);
+#if 0      
         if(wrd != file_length)
         {
             free(ptr);
@@ -719,6 +756,7 @@ unsigned char Update_ramdisk()
                 #endif
             }
         }
+#endif        
     }
     return result;
 }
@@ -776,14 +814,21 @@ unsigned char Update_user_config()
 
         // Write image to flash
         SAVE_SYS_LOG_MSG_FWUPDATE("[user_config]Writing image to mtdblock10...");
-        fread(ptr, sizeof(unsigned char), file_length, file);
-        wrd = write(fd, ptr, file_length);
+      //  fread(ptr, sizeof(unsigned char), file_length, file);
+        //wrd = write(fd, ptr, file_length);
         close(fd);
         fclose(file);
+        system("/bin/flash_erase /dev/mtd10 0 12");
+	system("/usr/sbin/nandwrite -p /dev/mtd10 /root/FactoryConfig.bin");
+
+	system("/bin/flash_erase /dev/mtd11 0 12");
+	system("/usr/sbin/nandwrite -p /dev/mtd11 /root/FactoryConfig.bin");
+									
         sprintf(buf_log_fwupdate,
                 "[user_config]mtdblock10 - written length: %d bytes\n",
                 wrd);
         SAVE_SYS_LOG_MSG_FWUPDATE(buf_log_fwupdate);
+#if 0      
         if(wrd != file_length)
         {
             free(ptr);
@@ -816,6 +861,7 @@ unsigned char Update_user_config()
                 }
             }
         }
+#endif        
     }
     return result;
 }

BIN
EVSE/Projects/CCS/Apps/SeccComm


+ 1 - 1
EVSE/Projects/CCS/Apps/version.h

@@ -5,7 +5,7 @@
                      initiated by Joseph D. Anderson
                            (since 2019/12/03)
 =============================================================================*/
-#define FIRMWARE_VERSION            "D0.16.S0"   //8-Byte(ASCII Code), “tx.yz.ab.cd”
+#define FIRMWARE_VERSION            "D0.17.S0"   //8-Byte(ASCII Code), “tx.yz.ab.cd”
 #define HARDWARE_VERSION            "CCS_8.0x"      //8-Byte(ASCII Code): CSU-03-RW, CCS_Board, REV:5.0
 #define LINUX_IMAGE_VERSION         "dd2da761d59f2cdd4064c9d95f8c302a442d33f3 (2019-01-04)"
 #define RTC_DEFAULT_TIME            1595486300      //Epoch time (decimal)

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