]> git.webhop.me Git - lcd4linux.git/commitdiff
plugin_huawei-fix-interval-check_V2.patch from Jar
authormichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 14 Feb 2010 02:46:43 +0000 (02:46 +0000)
committermichael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 14 Feb 2010 02:46:43 +0000 (02:46 +0000)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1111 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

plugin_huawei.c

index fbcf503a060d61d9b09c2b1ee0475a907e9ce5d5..69215fa92e95b0466bbc14fba98313205463c7dc 100644 (file)
@@ -840,16 +840,16 @@ static void huawei_read_flowreport(const char *cmd)
 static void my_quality(RESULT * result, RESULT * arg1)
 {
     int age;
-    struct timeval now;
     static struct timeval prev_age;
     static double value;
 
-    gettimeofday(&now, NULL);
     age = age_diff(prev_age);
 
-    if (age > MIN_INTERVAL && huawei_configured() == 1) {
-       prev_age = now;
-       huawei_read_quality(QUALITY);
+    if (age < 0 || age >= MIN_INTERVAL) {
+       gettimeofday(&prev_age, NULL);
+
+       if (huawei_configured() == 1)
+           huawei_read_quality(QUALITY);
     }
 
     /* Note: R2S stands for 'Result to String' */
@@ -888,17 +888,17 @@ static void my_quality(RESULT * result, RESULT * arg1)
 static void my_mode(RESULT * result, RESULT * arg1)
 {
     int age;
-    struct timeval now;
     static struct timeval prev_age;
     double value_num;
     char *value_str, *mode_str;
 
-    gettimeofday(&now, NULL);
     age = age_diff(prev_age);
 
-    if (age > MIN_INTERVAL && huawei_configured() == 1) {
-       prev_age = now;
-       huawei_read_sysinfo(SYSINFO);
+    if (age < 0 || age >= MIN_INTERVAL) {
+       gettimeofday(&prev_age, NULL);
+
+       if (huawei_configured() == 1)
+           huawei_read_sysinfo(SYSINFO);
     }
 
     if (strncmp(R2S(arg1), "text", 4) == 0) {
@@ -945,16 +945,16 @@ static void my_mode(RESULT * result, RESULT * arg1)
 static void my_manuf(RESULT * result)
 {
     int age;
-    struct timeval now;
     static struct timeval prev_age;
     char *value_str;
 
-    gettimeofday(&now, NULL);
     age = age_diff(prev_age);
 
-    if (age > MIN_INTERVAL && huawei_configured() == 1) {
-       prev_age = now;
-       huawei_read_manuf(MANUF);
+    if (age < 0 || age >= MIN_INTERVAL) {
+       gettimeofday(&prev_age, NULL);
+
+       if (huawei_configured() == 1)
+           huawei_read_manuf(MANUF);
     }
 
     /* start with an empty string */
@@ -978,16 +978,16 @@ static void my_manuf(RESULT * result)
 static void my_model(RESULT * result)
 {
     int age;
-    struct timeval now;
     static struct timeval prev_age;
     char *value_str;
 
-    gettimeofday(&now, NULL);
     age = age_diff(prev_age);
 
-    if (age > MIN_INTERVAL && huawei_configured() == 1) {
-       prev_age = now;
-       huawei_read_model(MODEL);
+    if (age < 0 || age >= MIN_INTERVAL) {
+       gettimeofday(&prev_age, NULL);
+
+       if (huawei_configured() == 1)
+           huawei_read_model(MODEL);
     }
 
     /* start with an empty string */
@@ -1011,16 +1011,16 @@ static void my_model(RESULT * result)
 static void my_fwver(RESULT * result)
 {
     int age;
-    struct timeval now;
     static struct timeval prev_age;
     char *value_str;
 
-    gettimeofday(&now, NULL);
     age = age_diff(prev_age);
 
-    if (age > MIN_INTERVAL && huawei_configured() == 1) {
-       prev_age = now;
-       huawei_read_fwver(FWVER);
+    if (age < 0 || age >= MIN_INTERVAL) {
+       gettimeofday(&prev_age, NULL);
+
+       if (huawei_configured() == 1)
+           huawei_read_fwver(FWVER);
     }
 
     /* start with an empty string */
@@ -1044,16 +1044,16 @@ static void my_fwver(RESULT * result)
 static void my_operator(RESULT * result)
 {
     int age;
-    struct timeval now;
     static struct timeval prev_age;
     char *value_str;
 
-    gettimeofday(&now, NULL);
     age = age_diff(prev_age);
 
-    if (age > MIN_INTERVAL && huawei_configured() == 1) {
-       prev_age = now;
-       huawei_read_operator(OPERATOR);
+    if (age < 0 || age >= MIN_INTERVAL) {
+       gettimeofday(&prev_age, NULL);
+
+       if (huawei_configured() == 1)
+           huawei_read_operator(OPERATOR);
     }
 
     /* start with an empty string */
@@ -1080,15 +1080,15 @@ static void my_flowreport(RESULT * result, RESULT * arg1)
     unsigned int days, hours, mins, secs;
     double value_num;
     char value_str[32];
-    struct timeval now;
     static struct timeval prev_age;
 
-    gettimeofday(&now, NULL);
     age = age_diff(prev_age);
 
-    if (age > MIN_INTERVAL && huawei_configured() == 1) {
-       prev_age = now;
-       huawei_read_flowreport(FLOWREPORT);
+    if (age < 0 || age >= MIN_INTERVAL) {
+       gettimeofday(&prev_age, NULL);
+
+       if (huawei_configured() == 1)
+           huawei_read_flowreport(FLOWREPORT);
     }
 
     if (strncmp(R2S(arg1), "uptime", 6) == 0) {