Attempt to better check the temperature sensors and lower the cpu load.

Sat, 27 Apr 2019 20:47:26 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 27 Apr 2019 20:47:26 +0200
changeset 583
9795a16de807
parent 582
ba340e00aab2
child 584
ff7f038fae2f

Attempt to better check the temperature sensors and lower the cpu load.

thermferm/devices.c file | annotate | diff | comparison | revisions
thermferm/server.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
--- a/thermferm/devices.c	Sat Apr 27 15:36:16 2019 +0200
+++ b/thermferm/devices.c	Sat Apr 27 20:47:26 2019 +0200
@@ -386,9 +386,9 @@
 		piUnlock(LOCK_DEVICES);
 #endif
 		return 0;
-	    }
-	}
-    }
+	    } // if ((test_value != my_value) || (((int)now - (int)my_timestamp) >= 120))
+	} // if (! strcmp(uuid, device->uuid))
+    } // for (device = Config.devices; device; device = device->next)
 #ifdef HAVE_WIRINGPI_H
     piUnlock(LOCK_DEVICES);
 #endif
@@ -729,8 +729,8 @@
     syslog(LOG_NOTICE, "Thread my_devices_loop started");
 
 #ifdef HAVE_WIRINGPI_H
-    if ((rc = piHiPri(10)))
-    	syslog(LOG_NOTICE, "my_devices_loop: piHiPri(10) rc=%d", rc);
+    if ((rc = piHiPri(50)))
+    	syslog(LOG_NOTICE, "my_devices_loop: piHiPri(50) rc=%d", rc);
 #endif
 
     /*
@@ -798,6 +798,12 @@
 				    	piUnlock(LOCK_DEVICES);
 #endif
 				    }
+				    if ((temp == 85000) || (temp < -125000)) {
+					syslog(LOG_NOTICE, "sensor %s value error '%d`", device->address, temp);
+				    }
+				    if (temp & 0xf800) {
+					syslog(LOG_NOTICE, "sensor %s sign bits error", device->address);
+				    }
 				} else {
 				    syslog(LOG_NOTICE, "sensor %s CRC error '%s`", device->address, line1);
 #ifdef HAVE_WIRINGPI_H
--- a/thermferm/server.c	Sat Apr 27 15:36:16 2019 +0200
+++ b/thermferm/server.c	Sat Apr 27 20:47:26 2019 +0200
@@ -2562,7 +2562,7 @@
 		fprintf(stdout, "Thread my_server_loop stopped\n");
 	    return 0;
 	}
-
+	usleep(100000);
     }
 }
 
--- a/thermferm/thermferm.c	Sat Apr 27 15:36:16 2019 +0200
+++ b/thermferm/thermferm.c	Sat Apr 27 20:47:26 2019 +0200
@@ -1230,6 +1230,7 @@
 		} else {
 		    Config.temp_state = 2;
 		}
+		usleep(10000);
 	    }
 	    row++;
 
@@ -1260,6 +1261,7 @@
 		} else {
 		    Config.hum_state = 2;
 		}
+		usleep(10000);
 	    }
 	    row++;
 	    /*

mercurial