Selaa lähdekoodia

2020-07-13 / Eason Yang
1.Change : Module_4g.c
Reason :
a) Added : ShmOCPP16Date.
b) Added : If OcppConnStatus == PASS isReachableInternet is pass.
c) Rename : Version D0.03.
2.Change : Module_Wifi.c
Reason :
a) Added : if OcppConnStauts == PASS isReachableInternet is pass.
b) Rename : Version D0.06.

8009 4 vuotta sitten
vanhempi
commit
ddf3179c49
2 muutettua tiedostoa jossa 69 lisäystä ja 36 poistoa
  1. 44 18
      EVSE/Modularization/Module_4g.c
  2. 25 18
      EVSE/Modularization/Module_Wifi.c

+ 44 - 18
EVSE/Modularization/Module_4g.c

@@ -2,9 +2,9 @@
  *  Module_4g.c
  *
  *  Created on: 2019-11-29
- *  Update on: 2020-06-18
+ *  Update on: 2020-07-13
  *  Author: Eason Yang
- *  Version: D0.02
+ *  Version: D0.03
  */
 
 #include    <sys/types.h>
@@ -99,6 +99,7 @@ struct dongle_info
 struct SysConfigAndInfo			*ShmSysConfigAndInfo;
 struct StatusCodeData 			*ShmStatusCodeData;
 struct FanModuleData			*ShmFanModuleData;
+struct OCPP16Data				*ShmOCPP16Data;
 
 int StoreLogMsg(const char *fmt, ...)
 {
@@ -184,6 +185,24 @@ int InitShareMemory()
     else
     {}
 
+   	//creat ShmOCPP16Data
+	if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data),  0777)) < 0)
+	{
+		#ifdef SystemLogMessage
+		DEBUG_ERROR("shmget ShmOCPP16Data NG");
+		#endif
+		result = FAIL;
+	}
+	else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
+	{
+		#ifdef SystemLogMessage
+		DEBUG_ERROR("shmat ShmOCPP16Data NG");
+		#endif
+		result = FAIL;
+	}
+	else
+	{}
+
     return result;
 }
 
@@ -792,32 +811,39 @@ int isReachableInternet(void)
 	char buf[512];
 	//char tmp[512];
 
-	for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
+	if(ShmOCPP16Data->OcppConnStatus == PASS)
+	{
+		result = PASS;
+	}
+	else
 	{
-		sprintf(cmd, "ping -c 1 -w 3 -I ppp0 %s", valid_Internet[idx]);
-		fp = popen(cmd, "r");
-		if(fp != NULL)
+		for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
 		{
-			while(fgets(buf, sizeof(buf), fp) != NULL)
+			sprintf(cmd, "ping -c 1 -w 3 -I ppp0 %s", valid_Internet[idx]);
+			fp = popen(cmd, "r");
+			if(fp != NULL)
 			{
-				if(strstr(buf, "transmitted") > 0)
+				while(fgets(buf, sizeof(buf), fp) != NULL)
 				{
-					//sscanf(buf, "%*s%*s%*s%*s%*s%s", tmp);
-
-					if(strstr(buf,"100%") != NULL)
+					if(strstr(buf, "transmitted") > 0)
 					{
+						//sscanf(buf, "%*s%*s%*s%*s%*s%s", tmp);
 
+						if(strstr(buf,"100%") != NULL)
+						{
+
+						}
+						else
+						{
+							result = PASS;
+						}
+						//DEBUG_INFO("%s",buf);
+						//DEBUG_INFO("%s\n",tmp);
 					}
-					else
-					{
-						result = PASS;
-					}
-					//DEBUG_INFO("%s",buf);
-					//DEBUG_INFO("%s\n",tmp);
 				}
 			}
+			pclose(fp);
 		}
-		pclose(fp);
 	}
 
 	return result;

+ 25 - 18
EVSE/Modularization/Module_Wifi.c

@@ -2,9 +2,9 @@
  *  Module_Wifi.c
  *
  *  Created on: 2020-01-14
- *  Update on: 2020-06-29
+ *  Update on: 2020-07-13
  *  Author: Jerry Wang, Eason Yang, Folus Wen
- *  Version: D0.05
+ *  Version: D0.06
  */
 
 #include 	<sys/time.h>
@@ -590,32 +590,39 @@ int isReachableInternet()
 	char buf[512];
 	//char tmp[512];
 
-	for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
+	if(ShmOCPP16Data->OcppConnStatus == PASS)
 	{
-		sprintf(cmd, "ping -c 1 -w 3 -I %s %s", Wifi.currentInterface, valid_Internet[idx]);
-		fp = popen(cmd, "r");
-		if(fp != NULL)
+		result = PASS;
+	}
+	else
+	{
+		for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
 		{
-			while(fgets(buf, sizeof(buf), fp) != NULL)
+			sprintf(cmd, "ping -c 1 -w 3 -I %s %s", Wifi.currentInterface, valid_Internet[idx]);
+			fp = popen(cmd, "r");
+			if(fp != NULL)
 			{
-				if(strstr(buf, "transmitted") > 0)
+				while(fgets(buf, sizeof(buf), fp) != NULL)
 				{
-					//sscanf(buf, "%*s%*s%*s%*s%*s%*s%s", tmp);
-
-					if(strstr(buf,"100%") != NULL)
+					if(strstr(buf, "transmitted") > 0)
 					{
+						//sscanf(buf, "%*s%*s%*s%*s%*s%*s%s", tmp);
 
+						if(strstr(buf,"100%") != NULL)
+						{
+
+						}
+						else
+						{
+							result = PASS;
+						}
+						//DEBUG_INFO("%s",buf);
+						//DEBUG_INFO("%s\n",tmp);
 					}
-					else
-					{
-						result = PASS;
-					}
-					//DEBUG_INFO("%s",buf);
-					//DEBUG_INFO("%s\n",tmp);
 				}
 			}
+			pclose(fp);
 		}
-		pclose(fp);
 	}
 
 	return result;