Browse Source

2020.06.07 / Folus Wen

Actions:
1. EVSE/rootfs/usr/bin/run_evse_restart.sh & EVSE/rootfs/usr/bin/run_evse_stop.sh command fix.
2. EVSE/Modularization/ocppfiles/Module_OcppBackend.c move common routin to common.c
3. EVSE/Modularization/ocppfiles/Module_OcppBackend.c add process operation watch dog timer to cover websocket no resopnse issue.
4. EVSE/Modularization/ocppfiles/Module_OcppBackend.c implement only one meesgae could be send out to reduce websocket no response issue.
5. EVSE/Modularization/ocppfiles/Module_OcppBackend.c processTransactionQueue() fix logic to query queue when websocket is free or resend interval over time.
6. EVSE/Modularization/ocppfiles/MessageHandler.c implement query firmware version by DataTransfer.
7. EVSE/Modularization/ocppfiles/MessageHandler.c implement startTransaction, stopTransaction and meterValue only put message to queue pool.
8. EVSE/Modularization/ocppfiles/MessageHandler.c implement send MeterValue message by ClockAlignedDataInterval > 0.
9. All source code fix sizeof to ARRAY_SIZE with array type variable.

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 years ago
parent
commit
d4e2f43b2c

File diff suppressed because it is too large
+ 229 - 163
EVSE/Modularization/ocppfiles/MessageHandler.c


File diff suppressed because it is too large
+ 342 - 443
EVSE/Modularization/ocppfiles/Module_OcppBackend.c


+ 8 - 2
EVSE/Modularization/ocppfiles/Module_OcppBackend.h

@@ -1,7 +1,7 @@
 /*
  * Sample_OCPP_Task.h
  *
- *  Created on: 2020�~5��26��
+ *  Created on: 2020¦~5¤ë26¤é
  *      Author: foluswen
  */
 
@@ -100,6 +100,7 @@ extern char* strchr(const char *p, int ch);
 extern void splitstring(char *src, const char *separator, char **dest,int *num);
 extern char* stringtrim( char * s );
 extern char* stringtrimspace( char * s );
+extern char * strtrim( char * s );
 
 
 extern struct lws 					*wsi_client;
@@ -111,5 +112,10 @@ extern char 						OcppProtocol[10];
 extern char 						OcppHost[50];
 extern char 						OcppTempPath[50];
 extern int 							OcppPort;
-extern unsigned char 		StartTransactionIdTagTemp[20];
+extern unsigned char 				StartTransactionIdTagTemp[20];
+extern pthread_mutex_t 				lock_send;
+extern uint32_t						startTimeDog;
+extern uint32_t						startTimeQueue;
+extern uint8_t						isWebsocketSendable;
+extern uint8_t						counterLwsRestart;
 #endif /* HEADER_MODULE_OCPPBACKEND_H_ */

+ 134 - 0
EVSE/Modularization/ocppfiles/common.c

@@ -106,3 +106,137 @@ char* stringtrimspace( char * s )
 	*p2 = '\0';
 	return (s);
 }
+
+int DiffTimeb(struct timeb ST, struct timeb ET)
+{
+	//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;
+}
+
+void trim(char *s)
+{
+    int i=0, j, k, l=0;
+
+    while((s[i]==' ')||(s[i]=='\t')||(s[i]=='\n'))
+        i++;
+
+    j = strlen(s)-1;
+    while((s[j]==' ')||(s[j]=='\t')||(s[j]=='\n'))
+        j--;
+
+    if(i==0 && j==strlen(s)-1) { }
+    else if(i==0) s[j+1] = '\0';
+    else {
+        for(k=i; k<=j; k++) s[l++] = s[k];
+        s[l] = '\0';
+    }
+}
+
+int mystrcmp(char *p1,char *p2)
+{
+    while(*p1==*p2)
+    {
+        if(*p1=='\0' || *p2=='\0')
+            break;
+        p1++;
+        p2++;
+    }
+    if(*p1=='\0' && *p2=='\0')
+        return(PASS);
+    else
+        return(FAIL);
+}
+
+void substr(char *dest, const char* src, unsigned int start, unsigned int cnt)
+{
+	strncpy(dest, src + start, cnt);
+	dest[cnt] = 0;
+}
+
+int strposs(char *source, char *substr, int idx)
+{
+   char stack[strlen(source)];
+   int result=0;
+   int count=0;
+
+   while(count<=idx)
+   {
+	   memset(stack,0,sizeof stack);
+	   strncpy(stack, source+result, strlen(source)-result);
+
+	   int loc = strcspn(stack, substr);
+
+	   if(loc>0)
+		   result += (loc+1);
+	   else
+		   result = -1;
+
+	   count++;
+   }
+
+   return result;
+}
+
+void getSubStr(char *dest, char* src, char *split, int idx)
+{
+
+	int start = (strposs(src,",",idx)+1);
+	int cnt = (strposs(src,",",idx+1)-2)-(strposs(src,",",idx)+1);
+
+	strncpy(dest, src + start, cnt);
+	dest[cnt] = 0;
+}
+
+void split(char **arr, char *str, const char *del)
+{
+	char *s = strtok(str, del);
+
+	while(s != NULL)
+	{
+		*arr++ = s;
+		s = strtok(NULL, del);
+	}
+}
+
+int strpos(char *source, char *substr, int skip)
+{
+   char stack[strlen(source)];
+   strncpy(stack, source+skip, strlen(source)-skip);
+   char *p = strstr(stack, substr);
+   if (p)
+      return p - stack+skip;
+   return -1;
+}
+
+char * strtrim( char * s )
+{
+    char * p1 = s;
+	char * p2 = s;
+	while(*p1 != '\0')
+	{
+		while(*p1 == '\t' || *p1 == '\n' || *p1 == '\r') //while(*p1 == ' ' || *p1 == '\t' || *p1 == '\n' || *p1 == '\r')
+		{
+			p1 ++;
+
+		}
+
+		* p2 ++ = *p1 ++;
+		//printf("p2=%s\n",p2);
+	}
+	*p2 = '\0';
+	return (s);
+}
+
+char *random_uuid(char* buf)
+{
+	uuid_t uuid;
+
+	uuid_generate(uuid);
+	uuid_unparse(uuid, buf);
+
+	return 0;
+}

+ 1 - 1
EVSE/rootfs/usr/bin/run_evse_restart.sh

@@ -1,6 +1,6 @@
 #!/bin/sh
 pkill main
-pkill Module*
+pkill Module_
 pkill OcppBackend
 /root/main &
 

+ 1 - 1
EVSE/rootfs/usr/bin/run_evse_stop.sh

@@ -1,5 +1,5 @@
 #!/bin/sh
 pkill main
-pkill Module*
+pkill Module_
 pkill OcppBackend
 

Some files were not shown because too many files changed in this diff