# HG changeset patch # User Michiel Broek # Date 1403185636 -7200 # Node ID 2431965e8a8c58a8aeed2165c871323f61cb1e04 # Parent 07802719f63dedf89e553e97017b7a2a784505d9 Write loglines only every 60 seconds diff -r 07802719f63d -r 2431965e8a8c thermferm/thermferm.c --- a/thermferm/thermferm.c Thu Jun 19 14:32:33 2014 +0200 +++ b/thermferm/thermferm.c Thu Jun 19 15:47:16 2014 +0200 @@ -263,8 +263,9 @@ int server(void) { char buf[1024]; - w1_therm *tmp1, *old1; - rc_switch *tmp2, *old2; + time_t now, last = (time_t)0; + w1_therm *tmp1; + rc_switch *tmp2; int rc, run = 1, temp; if (lockprog((char *)"thermferm")) { @@ -311,10 +312,8 @@ tmp1->update = FALSE; lcdupdate = TRUE; } - old1 = tmp1->next; - tmp1 = old1; - old2 = tmp2->next; - tmp2 = old2; + tmp1 = tmp1->next; + tmp2 = tmp2->next; if (((tmp1->lastval / 100) < (tempB - 5)) && (coolerB == 1)) { coolerB = 0; syslog(LOG_NOTICE, "Temperature B is %.1f, switched cooler off", (tmp1->lastval / 1000.0)); @@ -338,14 +337,23 @@ snprintf(buf, 16, "%5.2f %cC %c %s ", tmp1->lastval / 1000.0, 0xdf, coolerA ? '-' : ' ', tmp1->alias); mb_lcdPuts(lcdHandle, buf); temp = tmp1->lastval; - old1 = tmp1->next; - tmp1 = old1; + tmp1 = tmp1->next; lcdPosition(lcdHandle, 0, 1); snprintf(buf, 16, "%5.2f %cC %c %s ", tmp1->lastval / 1000.0, 0xdf, coolerB ? '-' : ' ', tmp1->alias); mb_lcdPuts(lcdHandle, buf); - snprintf(buf, 1023, "%.2f,%s,%.2f,%s", temp / 1000.0, coolerA ? (char *)"on" : (char *)"off", + } + + now = time(NULL); + if (((int)now - (int)last) > 60) { + last = now; + tmp1 = Config.w1therms; + temp = tmp1->lastval; + tmp1 = tmp1->next; + if (temp && tmp1->lastval && run) { + snprintf(buf, 1023, "%.2f,%s,%.2f,%s", temp / 1000.0, coolerA ? (char *)"on" : (char *)"off", tmp1->lastval / 1000.0, coolerB ? (char *)"on" : (char *)"off"); - logger((char *)"thermferm.log", (char *)"thermferm", buf); + logger((char *)"thermferm.log", (char *)"thermferm", buf); + } } usleep(100000);