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

2020-06-18 / Eason Yang
1.Change : Module_4g.c
Reason :
a) Fixed : isReachableInternet() , ping -c 1 -w 3 -I ppp0
b) Fixed : valid_Internet www.baidu.com -> 180.76.76.76
c) Remove : pkill Module_Wifi
d) Added : Version D0.01
2.Change : Module_Wifi.c
Reason :
a) Fixed : isReachableInternet() , ping -c 1 -w 3 -I Wifi.currentInterface valid_Internet
b) Rename : Version D0.04

8009 4 жил өмнө
parent
commit
6666131056

+ 15 - 9
EVSE/Modularization/Module_4g.c

@@ -1,8 +1,10 @@
 /*
- * Module_4g.c
+ *  Module_4g.c
  *
- *  Created on: 2019年11月29日
- *      Author: Eason Yang
+ *  Created on: 2019-11-29
+ *  Update on: 2020-06-18
+ *  Author: Eason Yang
+ *  Version: D0.01 
  */
 
 #include    <sys/types.h>
@@ -73,7 +75,7 @@ void trim_s(char *s, unsigned char len);
 void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
 
 char *portName[3] 			= {"/dev/ttyUSB2", "/dev/ttyUSB2", "/dev/ttyACM2"};
-char *valid_Internet[2] 	= {"8.8.8.8", "www.baidu.com"};
+char *valid_Internet[2] 	= {"8.8.8.8", "180.76.76.76"};
 pid_t	pid;
 
 struct dongle_info
@@ -792,8 +794,7 @@ int isReachableInternet(void)
 
 	for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
 	{
-		strcpy(cmd, "ping -c 1 -w 3 ");
-		strcat(cmd, valid_Internet[idx]);
+		sprintf(cmd, "ping -c 1 -w 3 -I ppp0 %s", valid_Internet[idx]);
 		fp = popen(cmd, "r");
 		if(fp != NULL)
 		{
@@ -801,12 +802,18 @@ int isReachableInternet(void)
 			{
 				if(strstr(buf, "transmitted") > 0)
 				{
-					sscanf(buf, "%*s%*s%*s%*s%*s%s", tmp);
+					//sscanf(buf, "%*s%*s%*s%*s%*s%s", tmp);
 
-					if(strcmp(tmp,"100%") != 0)
+					if(strstr(buf,"100%") != NULL)
+					{
+
+					}
+					else
 					{
 						result = PASS;
 					}
+					//DEBUG_INFO("%s",buf);
+					//DEBUG_INFO("%s\n",tmp);
 				}
 			}
 		}
@@ -1065,7 +1072,6 @@ int main(void)
 	{
 		if(((Dongle.Model = Check4GModem()) != FAIL))
 		{
-			system("pkill Module_Wifi");
 			ShmStatusCodeData->FaultCode.FaultEvents.bits.Telecom4GModuleBroken = 0;
 
 			Dongle.cnt_SearchModuleFail = 0;

+ 4 - 5
EVSE/Modularization/Module_Wifi.c

@@ -1,10 +1,10 @@
 /*
- * Module_Wifi.c
+ *  Module_Wifi.c
  *
  *  Created on: 2020-01-14
- *  Update on: 2020-05-27
+ *  Update on: 2020-06-18
  *  Author: Jerry Wang, Eason Yang, Folus Wen
- *  Version: D0.03
+ *  Version: D0.04
  */
 
 #include 	<sys/time.h>
@@ -592,8 +592,7 @@ int isReachableInternet()
 
 	for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
 	{
-		strcpy(cmd, "ping -c 1 -w 3 ");
-		strcat(cmd, valid_Internet[idx]);
+		sprintf(cmd, "ping -c 1 -w 3 -I %s %s", Wifi.currentInterface, valid_Internet[idx]);
 		fp = popen(cmd, "r");
 		if(fp != NULL)
 		{