thermferm/devices.c

changeset 268
dda91dfa4aa8
parent 262
d0014ccec615
child 323
608592f74b10
equal deleted inserted replaced
267:a84792cab21c 268:dda91dfa4aa8
122 /* 122 /*
123 * If there is no sensor, j = 0 123 * If there is no sensor, j = 0
124 */ 124 */
125 if ((counter == 255) && (j == 0)) { 125 if ((counter == 255) && (j == 0)) {
126 if (dht11_temperature != -1) { 126 if (dht11_temperature != -1) {
127 syslog(LOG_WARNING, "dht11 sensor disappeared"); 127 syslog(LOG_NOTICE, "dht11 sensor disappeared");
128 } else { 128 } else {
129 syslog(LOG_WARNING, "dht11 sensor not present"); 129 syslog(LOG_NOTICE, "dht11 sensor not present");
130 } 130 }
131 dht11_temperature = -1; 131 dht11_temperature = -1;
132 dht11_humidity = -1; 132 dht11_humidity = -1;
133 dht11_valid = FALSE; 133 dht11_valid = FALSE;
134 return; 134 return;
151 dht11_humidity = h; 151 dht11_humidity = h;
152 dht11_valid = TRUE; 152 dht11_valid = TRUE;
153 } else { 153 } else {
154 tries--; 154 tries--;
155 if (tries == 0) 155 if (tries == 0)
156 syslog(LOG_WARNING, "dht11 data checksum was wrong 5 times"); 156 syslog(LOG_NOTICE, "dht11 data checksum was wrong 5 times");
157 usleep(100000); 157 usleep(100000);
158 } 158 }
159 } 159 }
160 } 160 }
161 161
511 addr = xstrcpy((char *)"/sys/bus/w1/devices/"); 511 addr = xstrcpy((char *)"/sys/bus/w1/devices/");
512 addr = xstrcat(addr, device->address); 512 addr = xstrcat(addr, device->address);
513 addr = xstrcat(addr, (char *)"/w1_slave"); 513 addr = xstrcat(addr, (char *)"/w1_slave");
514 if ((fp = fopen(addr, "r"))) { 514 if ((fp = fopen(addr, "r"))) {
515 if (device->present != DEVPRESENT_YES) { 515 if (device->present != DEVPRESENT_YES) {
516 syslog(LOG_WARNING, "sensor %s is back", device->address); 516 syslog(LOG_NOTICE, "sensor %s is back", device->address);
517 #ifdef HAVE_WIRINGPI_H 517 #ifdef HAVE_WIRINGPI_H
518 piLock(LOCK_DEVICES); 518 piLock(LOCK_DEVICES);
519 #endif 519 #endif
520 device->present = DEVPRESENT_YES; 520 device->present = DEVPRESENT_YES;
521 #ifdef HAVE_WIRINGPI_H 521 #ifdef HAVE_WIRINGPI_H
545 } 545 }
546 #ifdef HAVE_WIRINGPI_H 546 #ifdef HAVE_WIRINGPI_H
547 piUnlock(LOCK_DEVICES); 547 piUnlock(LOCK_DEVICES);
548 #endif 548 #endif
549 } else { 549 } else {
550 syslog(LOG_WARNING, "sensor %s CRC error", device->address); 550 syslog(LOG_NOTICE, "sensor %s CRC error", device->address);
551 #ifdef HAVE_WIRINGPI_H 551 #ifdef HAVE_WIRINGPI_H
552 piLock(LOCK_DEVICES); 552 piLock(LOCK_DEVICES);
553 #endif 553 #endif
554 device->present = DEVPRESENT_ERROR; 554 device->present = DEVPRESENT_ERROR;
555 #ifdef HAVE_WIRINGPI_H 555 #ifdef HAVE_WIRINGPI_H
557 #endif 557 #endif
558 } 558 }
559 fclose(fp); 559 fclose(fp);
560 } else { 560 } else {
561 if (device->present != DEVPRESENT_NO) { 561 if (device->present != DEVPRESENT_NO) {
562 syslog(LOG_WARNING, "sensor %s is missing", device->address); 562 syslog(LOG_NOTICE, "sensor %s is missing", device->address);
563 #ifdef HAVE_WIRINGPI_H 563 #ifdef HAVE_WIRINGPI_H
564 piLock(LOCK_DEVICES); 564 piLock(LOCK_DEVICES);
565 #endif 565 #endif
566 device->present = DEVPRESENT_NO; 566 device->present = DEVPRESENT_NO;
567 #ifdef HAVE_WIRINGPI_H 567 #ifdef HAVE_WIRINGPI_H

mercurial