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

2020.01.31 / Folus Wen

Actions:
1. Module_OcppBackend debug output message fix.

Files:
1. As follow commit history

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

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 5 жил өмнө
parent
commit
898de358bc

+ 5 - 5
EVSE/Modularization/ocppfiles/JsonParser.c

@@ -5,7 +5,7 @@
 #include	<assert.h>
 #include	"hashmap.h"
 #include	"MessageHandler.h"
-
+#include        "SystemLogMessage.h"
 
 
 #define MESSAGE_TYPE_CALL			2
@@ -70,7 +70,7 @@ static FunCallErrorPtr funcallerror[] = {	handleError	};
 
 void ReceivedMessage(void *in, size_t len)
 {
-	printf("ReceivedMessage\n");
+	DEBUG_INFO("ReceivedMessage\n");
 	char tempin[1024*4];
 	int MsgType = 0;
 	char UniqueId[37],Action[33],Payload[10241],ErrorCode[129],ErrorDescription[513];
@@ -99,7 +99,7 @@ void ReceivedMessage(void *in, size_t len)
 	//char *str = "[ ]";
 	if(strcmp((const char *)tempin,"[ ]") == 0)
 	{
-		printf("Message is empty arrary. \n");
+	    DEBUG_INFO("Message is empty arrary. \n");
 	    return;
 	}
 
@@ -291,7 +291,7 @@ void ReceivedMessage(void *in, size_t len)
 	}
 	else
 	{
-		printf("Message is null. cant parse messgae. \n");
+		DEBUG_WARN("Message is null. cant parse messgae. \n");
 	}
 
 }
@@ -378,7 +378,7 @@ void CallErrorHandler(char *id, char *errorCode, char *errorDescription,char *pa
 
 	if(callErrorfptr == NULL)
 	{
-		printf("callErrorfptr is null\n");
+		DEBUG_ERROR("callErrorfptr is null\n");
 	}
 
 	if ( callErrorfptr )

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

@@ -358,7 +358,7 @@ int SendData(struct lws *wsi)
 
     memcpy (out + LWS_SEND_BUFFER_PRE_PADDING, SendBuffer, len );
 
-    DEBUG_OCPPMESSAGE_INFO(" SendData= %s\n", out + LWS_SEND_BUFFER_PRE_PADDING);
+    DEBUG_OCPPMESSAGE_INFO("\n===> %s\n", out + LWS_SEND_BUFFER_PRE_PADDING);
     n = lws_write(wsi, out + LWS_SEND_BUFFER_PRE_PADDING, len, LWS_WRITE_TEXT);
 
     memset(SendBuffer, 0, len);
@@ -465,7 +465,7 @@ static int OCPP16Callback(struct lws *wsi, enum lws_callback_reasons reason, voi
 			break;
 		case LWS_CALLBACK_CLIENT_RECEIVE://8
 			((char *)in)[len] = '\0';
-			DEBUG_OCPPMESSAGE_INFO("Original Receive %s\n", (char *)in);
+			DEBUG_OCPPMESSAGE_INFO("\n<=== %s\n", (char *)in);
 			char tempin[1024*4]={0};
 			int c = 0;
 			char *loc;

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

@@ -27,7 +27,7 @@ int StoreLogMsg(const char *fmt, ...)
 			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
 			buffer,
 			tm->tm_year+1900,tm->tm_mon+1);
-	printf("buffer: %s\n",Buf );
+	//printf("buffer: %s\n",Buf );
 	//execl("sh", "sh", "-c", Buf, NULL);//system((const char*)Buf);
 	system((const char*)Buf);
 	#ifdef Debug
@@ -54,7 +54,7 @@ int StoreOcppMsg(const char *fmt, ...)
 			tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,
 			buffer,
 			tm->tm_year+1900,tm->tm_mon+1);
-	printf("buffer: %s\n",Buf );
+	//printf("buffer: %s\n",Buf );
 	//execl("sh", "sh", "-c", Buf, NULL);//system((const char*)Buf);
 	system((const char*)Buf);
 	#ifdef Debug

+ 35 - 35
EVSE/Modularization/ocppfiles/hashmap.c

@@ -12,7 +12,7 @@
 #include <string.h>
 #include <pthread.h>
 #include <unistd.h>     /*Unix 標準函數定義*/
-
+#include "SystemLogMessage.h"
 
 typedef enum boolean { FALSE, TRUE } BOOL;
 static pthread_mutex_t m;
@@ -213,7 +213,7 @@ unsigned int hashmap_hash_int(hashmap_map * m, char* keystring){
 
 	/* Knuth's Multiplicative Method */
 	key = (key >> 3) * 2654435761;
-	printf("table_size=%d\n",hashMap[0].table_size);
+	DEBUG_INFO("table_size=%d\n",hashMap[0].table_size);
 
 	return key % hashMap[0].table_size;//key % m->table_size;
 }
@@ -227,7 +227,7 @@ int hashmap_hash(map_t in, char* key){
 	int i;
 
 	/* If full, return immediately */
-	printf("hashMap[0].table_size=%d\n",hashMap[0].table_size);
+	DEBUG_INFO("hashMap[0].table_size=%d\n",hashMap[0].table_size);
 	if(hashMap[0].size >= (hashMap[0].table_size/2)) return MAP_FULL;
 
 	/* Find the best index */
@@ -237,14 +237,14 @@ int hashmap_hash(map_t in, char* key){
 	for(i = 0; i< MAX_CHAIN_LENGTH; i++){
 		if(hashMap[0].data[curr].in_use == 0)
 		{
-			printf(" no in_use \n");
+			DEBUG_INFO(" no in_use \n");
 			return curr;
 		}
 
 
 		if(hashMap[0].data[curr].in_use == 1 && (strcmp(hashMap[0].data[curr].key,key)==0))
 		{
-			printf("key use, key exist!!!!\n");
+			DEBUG_INFO("key use, key exist!!!!\n");
 			return curr;
 		}
 
@@ -354,7 +354,7 @@ int hashmap_put(map_t in, char* key, any_t value){
 		index = hashmap_hash(in, key);
 	}
 
-	printf("hash index=%d\n",index);
+	DEBUG_INFO("hash index=%d\n",index);
 	/* Set the data */
 	strcpy(hashMap[0].data[index].data, value);
 	strcpy(hashMap[0].data[index].key, key);
@@ -363,9 +363,9 @@ int hashmap_put(map_t in, char* key, any_t value){
 	hashMap[0].data[index].in_use = 1;
 	hashMap[0].size++;
 
-	printf("hash m->data[index].data=%s\n",hashMap[0].data[index].data);
-	printf("hash m->data[index].key=%s\n",hashMap[0].data[index].key);
-	printf("hash m->data[index].in_use=%d\n",hashMap[0].data[index].in_use);
+	DEBUG_INFO("hash m->data[index].data=%s\n",hashMap[0].data[index].data);
+	DEBUG_INFO("hash m->data[index].key=%s\n",hashMap[0].data[index].key);
+	DEBUG_INFO("hash m->data[index].in_use=%d\n",hashMap[0].data[index].in_use);
 
 	return MAP_OK;
 
@@ -410,26 +410,26 @@ int hashmap_get(map_t in, char* key, any_t *arg){
 
 	/* Find data location */
 	curr = hashmap_hash_int(hashMap, key);
-	printf("MAP_get curr=%d\n",curr);
+	DEBUG_INFO("MAP_get curr=%d\n",curr);
 
 	/* Linear probing, if necessary */
 	for(i = 0; i<MAX_CHAIN_LENGTH; i++){
 
 	        int in_use = hashMap[0].data[curr].in_use;
-	        printf("MAP_get in use=%d\n",in_use);
+	        DEBUG_INFO("MAP_get in use=%d\n",in_use);
 	        if (in_use == 1){
-	        	printf("MAP_get hashMap.data[curr].key=%s\n", hashMap[0].data[curr].key);
-	        	printf("MAP_get hashMap.data[curr].data=%s\n", hashMap[0].data[curr].data);
+	        	DEBUG_INFO("MAP_get hashMap.data[curr].key=%s\n", hashMap[0].data[curr].key);
+	        	DEBUG_INFO("MAP_get hashMap.data[curr].data=%s\n", hashMap[0].data[curr].data);
 	            if (strcmp(hashMap[0].data[curr].key,key)==0){
 	            	strcpy(arg, hashMap[0].data[curr].data);
 	                //*arg = (m->data[curr].data);
-	                printf("MAP_OK curr=%d\n",curr);
+	                DEBUG_INFO("MAP_OK curr=%d\n",curr);
 	                return MAP_OK;
 	            }
 			}
 
 			curr = (curr + 1) % hashMap[0].table_size;
-			printf("MAP_MISSING curr=%d\n",curr);
+			DEBUG_INFO("MAP_MISSING curr=%d\n",curr);
 	}
 
 	memset(arg, 0, sizeof arg);
@@ -530,11 +530,11 @@ int hashmap_remove(map_t in, char* key){
 	               // m->data[curr].data = NULL;
 	               // m->data[curr].key = NULL;
 
-	                printf("remove m->size=%d \n",hashMap[0].size);
+	                DEBUG_INFO("remove m->size=%d \n",hashMap[0].size);
 	                /* Reduce the size */
 	                hashMap[0].size--;
 
-	                printf("remove ok!\n");
+	                DEBUG_INFO("remove ok!\n");
 	                return MAP_OK;
 	            }
 			}
@@ -618,11 +618,11 @@ stat("../Storage/OCPP", &stats);
 // Check for directory existence
 if (S_ISDIR(stats.st_mode) == 1)
 {
-	//printf("\n directory exist \n");
+	//printf("directory exist \n");
 }
 else
 {
-	printf("\n directory not exist, create dir \n");
+	DEBUG_INFO("directory not exist, create dir \n");
 	sprintf(rmFileCmd,"mkdir -p %s","../Storage/OCPP");
 	system(rmFileCmd);
 }
@@ -635,12 +635,12 @@ if((access("../Storage/OCPP/MessageSent",F_OK))!=-1)
 }
 else
 {
-	printf("MessageSent not exist\n");
+	DEBUG_INFO("MessageSent not exist\n");
 	FILE *log = fopen("../Storage/OCPP/MessageSent", "w+");
 
 	if(log == NULL)
 	{
-		printf("Can't Create File MessageSent \n");
+		DEBUG_ERROR("Can't Create File MessageSent \n");
 		return 0;
 	}
 	else
@@ -654,7 +654,7 @@ outfile = fopen ("../Storage/OCPP/MessageSent", "a");
 sprintf(tempstring,"%s,%s\n", uuid,data);
 fputs(tempstring, outfile);
 fclose (outfile);
-printf("MessageSent add\n");
+DEBUG_INFO("MessageSent add\n");
 return 1;
 }
 
@@ -674,11 +674,11 @@ int MessageSent_get(char *uuid, char *data)
 	// Check for directory existence
 	if (S_ISDIR(stats.st_mode) == 1)
 	{
-		//printf("\n directory exist \n");
+		//printf("directory exist \n");
 	}
 	else
 	{
-		printf("\n directory not exist, create dir \n");
+		DEBUG_INFO("directory not exist, create dir \n");
 		sprintf(rmFileCmd,"mkdir -p %s","../Storage/OCPP");
 		system(rmFileCmd);
 	}
@@ -691,12 +691,12 @@ int MessageSent_get(char *uuid, char *data)
 	}
 	else
 	{
-		printf("MessageSent not exist\n");
+		DEBUG_INFO("MessageSent not exist\n");
 		FILE *log = fopen("../Storage/OCPP/MessageSent", "w+");
 
 		if(log == NULL)
 		{
-			printf("Can't Create File MessageSent \n");
+			DEBUG_ERROR("Can't Create File MessageSent \n");
 			return 0;
 		}
 		else
@@ -709,7 +709,7 @@ int MessageSent_get(char *uuid, char *data)
 	/* opening file for reading */
 	fp = fopen("../Storage/OCPP/MessageSent" , "r");
 	if(fp == NULL) {
-		printf("Error opening file");
+		DEBUG_ERROR("Error opening file");
 		return FALSE;
 	}
 
@@ -719,7 +719,7 @@ int MessageSent_get(char *uuid, char *data)
 
 	if(c == EOF)
 	{
-		printf("MessageSent is null\n");
+		DEBUG_INFO("MessageSent is null\n");
 		//strcpy(uuid,"");
 		strcpy(data,"");
 		result = FALSE;
@@ -750,7 +750,7 @@ int MessageSent_get(char *uuid, char *data)
 
 			if(strcmp(sstr, uuid) == 0)
 			{
-				printf("\n uuid:%s compare all right!!! ", sstr);
+				DEBUG_INFO("uuid:%s compare all right!!!\n", sstr);
 
 				loc = strstr(str, ",");
 				memset(sstr ,0, sizeof(sstr) );
@@ -762,7 +762,7 @@ int MessageSent_get(char *uuid, char *data)
 				}
 				datastr[e] = '\0';
 
-				printf("\n data:%s", datastr);
+				DEBUG_INFO("data:%s\n", datastr);
 				//strcpy(uuid,sstr);
 				strcpy(data,datastr);
 				result = TRUE;
@@ -798,7 +798,7 @@ if (S_ISDIR(stats.st_mode) == 1)
 }
 else
 {
-	printf("\n directory not exist, create dir \n");
+	DEBUG_INFO("\n directory not exist, create dir \n");
 	sprintf(rmFileCmd,"mkdir -p %s","../Storage/OCPP");
 	system(rmFileCmd);
 }
@@ -811,12 +811,12 @@ if((access("../Storage/OCPP/MessageSent",F_OK))!=-1)
 }
 else
 {
-	printf("MessageSent not exist\n");
+	DEBUG_INFO("MessageSent not exist\n");
 	FILE *log = fopen("../Storage/OCPP/MessageSent", "w+");
 
 	if(log == NULL)
 	{
-		printf("log is NULL\n");
+		DEBUG_ERROR("log is NULL\n");
 		return 0;
 	}
 	else
@@ -842,7 +842,7 @@ rewind(infile);
 
 if(c == EOF)
 {
-	printf("MessageSent is  NULL\n");
+	DEBUG_INFO("MessageSent is  NULL\n");
 
 	fclose(infile);
 	fclose(outfile);
@@ -890,7 +890,7 @@ else
 	}
 	else
 	{
-		printf("Error: unable to rename the file");
+		DEBUG_ERROR("Error: unable to rename the file");
 	}
 }
 

BIN
EVSE/Projects/AW-Regular/Images/FactoryDefaultConfig.bin


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


BIN
EVSE/rootfs/root/Module_4g


BIN
EVSE/rootfs/root/Module_Wifi


BIN
EVSE/rootfs/root/OcppBackend


BIN
EVSE/rootfs/root/WebService


BIN
EVSE/rootfs/root/logPackTools