Эх сурвалжийг харах

2020.07.09 / Folus Wen

Actions:
1. EVSE/Modularization/ocppfiles/MessageHandler.c GetConfigurationMaxKeys fixed to constant GetConfigurationMaxKeysNUM.
2. EVSE/Modularization/ocppfiles/Module_OcppBackend.c call lws_service() when SendBufLen > 0 to solve sometime lost out meesage.

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 жил өмнө
parent
commit
d5a87da562

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

@@ -11929,7 +11929,7 @@ int initialConfigurationTable(void)
 			if(strcmp(keystr, "GetConfigurationMaxKeys") == 0)
 			{
 				ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemAccessibility = (strcmp(readonlystr, "true")==0) ? 0 : 1;
-				sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemData, "%d", atoi(valuestr));
+				sprintf((char *)ShmOCPP16Data->ConfigurationTable.CoreProfile[GetConfigurationMaxKeys].ItemData, "%d", (atoi(valuestr)!=GetConfigurationMaxKeysNUM?GetConfigurationMaxKeysNUM:atoi(valuestr)));
 			}
 
 			if(strcmp(keystr, "HeartbeatInterval") == 0)
@@ -16314,8 +16314,9 @@ void LWS_Send(char * str)
 	}
 
 	pthread_mutex_lock(&lock_send);
-	memset(SendBuffer, 0, SendBufLen);
+	memset(SendBuffer, 0, ARRAY_SIZE(SendBuffer));
 	sprintf((char *)SendBuffer, "%s", str);
+	SendBufLen = strlen(str);
 	pthread_mutex_unlock(&lock_send);
 
 	lws_callback_on_writable(wsi_client);

+ 6 - 4
EVSE/Modularization/ocppfiles/Module_OcppBackend.c

@@ -19,7 +19,7 @@ struct StartTime
 // Function prototype
 //==========================================
 void ReceivedMessage(void *in, size_t len);
-int SendBufLen=(1024*4);//(1024*3);
+int SendBufLen=0;//(1024*4);//(1024*3);
 unsigned char SendBuffer[1024*4]={0};
 static int ConnectionEstablished=0;
 static int TransactionMessageResend = 1;  // the number of retry to submit a transaction-related message when the Central System fails to process it.
@@ -128,6 +128,7 @@ int SendData(struct lws *wsi)
 
     n = lws_write(wsi, out + LWS_SEND_BUFFER_PRE_PADDING, len, LWS_WRITE_TEXT);
     memset(SendBuffer, 0, len);
+    SendBufLen = 0;
 
     return n;
 }
@@ -1434,12 +1435,10 @@ int main(void)
 				{
 					queue_operation(QUEUE_OPERATION_SENT, "", "");
 					req_SendQueue = 0;
-					lws_service(context, 0);//timeout_ms
 				}
 
 				// Check System Value
 				CheckSystemValue();
-				lws_service(context, 0);//timeout_ms
 
 				if(GetHeartBeatWithNOResponse() >= 3)
 				{
@@ -1459,8 +1458,11 @@ int main(void)
 				}
 			}
 		}
-		lws_service(context, 0);//timeout_ms
 
+		do
+		{
+			lws_service(context, 0);//timeout_ms
+		}while((SendBufLen>0) && (context!=NULL) && GetInternetConn());
 		usleep(100000);
 	}
 	pthread_join(tid_ProcQueue, NULL);