Only log temperature error once. Only log temperature Ok again once. Do not log changed temperature.

Thu, 11 Apr 2024 14:57:32 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 11 Apr 2024 14:57:32 +0200
changeset 672
0c2c66920d79
parent 671
b2e2cbb13cb3
child 673
0c084b876a2c

Only log temperature error once. Only log temperature Ok again once. Do not log changed temperature.

thermferm/devices.c file | annotate | diff | comparison | revisions
thermferm/one-wire.c file | annotate | diff | comparison | revisions
--- a/thermferm/devices.c	Thu Apr 11 13:18:20 2024 +0200
+++ b/thermferm/devices.c	Thu Apr 11 14:57:32 2024 +0200
@@ -238,7 +238,7 @@
     time_t		now, my_timestamp;
     int			my_value, test_value;
 #ifdef HAVE_WIRINGPI_H
-    int			i;
+    int			rc, i;
     char		buf[40];
 #endif
 
@@ -792,9 +792,12 @@
 //				    syslog(LOG_NOTICE, "sensor %s value %d", dev_w1->address, dev_w1->value);
 				    found = TRUE;
 				    if ((dev_w1->value == -1) || (dev_w1->value < -55000)) {
-					syslog(LOG_NOTICE, "sensor %s value error %d", device->address, dev_w1->value);
+					if (device->present != DEVPRESENT_ERROR)
+					    syslog(LOG_NOTICE, "sensor %s value error %d, keep %d", device->address, dev_w1->value, device->value);
 					device->present = DEVPRESENT_ERROR;
 				    } else {
+					if (device->present != DEVPRESENT_YES)
+					    syslog(LOG_NOTICE, "sensor %s value ok %d", device->address, dev_w1->value);
 					device->value = dev_w1->value;
 					device->timestamp = time(NULL);
 					device->present = DEVPRESENT_YES;
--- a/thermferm/one-wire.c	Thu Apr 11 13:18:20 2024 +0200
+++ b/thermferm/one-wire.c	Thu Apr 11 14:57:32 2024 +0200
@@ -340,8 +340,8 @@
 		    mDelay(conv_time);
 		    if ((fgets(buffer, 25, fp))) {
 			sscanf(buffer, "%d", &value);
-			if (cur_w1->value != value)
-			    syslog(LOG_NOTICE, "One-wire device %s temperature read %d => %d", cur_w1->address, cur_w1->value, value);
+//			if (cur_w1->value != value)
+//			    syslog(LOG_NOTICE, "One-wire device %s temperature read %d => %d", cur_w1->address, cur_w1->value, value);
 			cur_w1->value = value;		/* devices.c will pick this up */
 		    } else {
 			syslog(LOG_NOTICE, "One-wire device %s temperature read error", cur_w1->address);

mercurial