ソースを参照

[Improve][Modularization][Module_OcppBackend / Module_OcppBackend20]

2021.02.28 / Folus Wen

Actions:
1. Connect server timeout check logic implement.
2. Module_OcppBackend quene message mapping logic change find latest message.

Files:
1. As follow commit history

Image version: D0.00.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 4 年 前
コミット
ba241cafc0

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

@@ -37,6 +37,7 @@ uint32_t startTimeQueue;
 uint8_t	isWebsocketSendable = 1;
 uint8_t	counterLwsRestart = 0;;
 uint8_t counterQueueSent = 0;
+uint8_t	counterConnect = 0;
 
 //=================================
 // Common routine
@@ -359,6 +360,7 @@ void* ConnectWsServer(void* data)  //int ConnectWsServer()
 	struct lws_context_creation_info ContextInfo;
 	struct lws_client_connect_info ConnInfo;
 	int use_ssl=0;
+	counterConnect += 1;
 
 	// If internet available synchronize datetime with ntp server
 	if(GetInternetConn() == 1)
@@ -466,6 +468,9 @@ void* ConnectWsServer(void* data)  //int ConnectWsServer()
 		goto end;
 	}
 
+	counterConnect=0;
+	DEBUG_INFO("counterConnect: %d\n", counterConnect);
+
 end:
 	pthread_exit(NULL/*(void *) fname*/);
 }
@@ -991,6 +996,12 @@ void* processWatchdog()
 			startTimeDog = time((time_t*)NULL);
 		}
 		
+		if(counterConnect >= 2)
+		{
+			DEBUG_INFO("Connect OCPP server timeout over 3 count.\n");
+			system("pkill OcppBackend");
+		}
+
 		/*
 		if(system("pidof -s Module_PhBackend > /dev/null") != 0)
 		{

+ 2 - 2
EVSE/Modularization/ocppfiles/MessageHandler.c

@@ -15440,7 +15440,7 @@ int GetTransactionId(int gunindex, unsigned char idTag[], uint8_t isStopTransact
 					if((atoi(revbuf[0])==gunindex) && (strcmp(revbuf[1],(const char *)idTag)==0))
 					{
 						temptransactionId = atoi(revbuf[2]);
-						break;
+						//break;
 					}
 				}
 				else
@@ -15448,7 +15448,7 @@ int GetTransactionId(int gunindex, unsigned char idTag[], uint8_t isStopTransact
 					if((atoi(revbuf[0])==gunindex) || (strcmp(revbuf[1],(const char *)idTag)==0))
 					{
 						temptransactionId = atoi(revbuf[2]);
-						break;
+						//break;
 					}
 				}
 			}

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

@@ -36,8 +36,9 @@ unsigned char StartTransactionIdTagTemp[20]={0};
 uint32_t startTimeDog;
 uint32_t startTimeQueue;
 uint8_t	isWebsocketSendable = 1;
-uint8_t	counterLwsRestart = 0;;
+uint8_t	counterLwsRestart = 0;
 uint8_t counterQueueSent = 0;
+uint8_t	counterConnect = 0;
 
 sqlite3 *db;
 char *errMsg = NULL;
@@ -416,6 +417,7 @@ void* ConnectWsServer(void* data)  //int ConnectWsServer()
 	struct lws_context_creation_info ContextInfo;
 	struct lws_client_connect_info ConnInfo;
 	int use_ssl=0;
+	counterConnect += 1;
 
 	// If internet available synchronize datetime with ntp server
 	if(GetInternetConn() == 1)
@@ -523,6 +525,9 @@ void* ConnectWsServer(void* data)  //int ConnectWsServer()
 		goto end;
 	}
 
+	counterConnect=0;
+	DEBUG_INFO("counterConnect: %d\n", counterConnect);
+
 end:
 	pthread_exit(NULL/*(void *) fname*/);
 }
@@ -1264,6 +1269,12 @@ void* processWatchdog()
 
 			startTimeDog = time((time_t*)NULL);
 		}
+
+		if(counterConnect >= 2)
+		{
+			DEBUG_INFO("Connect OCPP server timeout over 3 count.\n");
+			system("pkill OcppBackend");
+		}
 		
 		/*
 		if(system("pidof -s Module_PhBackend > /dev/null") != 0)