thermferm/devices.c

changeset 235
885ad8d52126
parent 220
382938c5fce2
child 239
793c09ece542
equal deleted inserted replaced
234:b69438db19ec 235:885ad8d52126
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_NOTICE, "dht11 sensor disappeared"); 127 syslog(LOG_WARNING, "dht11 sensor disappeared");
128 } else { 128 } else {
129 syslog(LOG_NOTICE, "dht11 sensor not present"); 129 syslog(LOG_WARNING, "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_INFO, "dht11 data checksum was wrong 5 times"); 156 syslog(LOG_WARNING, "dht11 data checksum was wrong 5 times");
157 usleep(100000); 157 usleep(100000);
158 } 158 }
159 } 159 }
160 } 160 }
161 161
430 addr = xstrcpy((char *)"/sys/bus/w1/devices/"); 430 addr = xstrcpy((char *)"/sys/bus/w1/devices/");
431 addr = xstrcat(addr, device->address); 431 addr = xstrcat(addr, device->address);
432 addr = xstrcat(addr, (char *)"/w1_slave"); 432 addr = xstrcat(addr, (char *)"/w1_slave");
433 if ((fp = fopen(addr, "r"))) { 433 if ((fp = fopen(addr, "r"))) {
434 if (device->present != DEVPRESENT_YES) { 434 if (device->present != DEVPRESENT_YES) {
435 syslog(LOG_NOTICE, "sensor %s is back", device->address); 435 syslog(LOG_WARNING, "sensor %s is back", device->address);
436 device->present = DEVPRESENT_YES; 436 device->present = DEVPRESENT_YES;
437 } 437 }
438 /* 438 /*
439 * The output looks like: 439 * The output looks like:
440 * 72 01 4b 46 7f ff 0e 10 57 : crc=57 YES 440 * 72 01 4b 46 7f ff 0e 10 57 : crc=57 YES
452 if ((rc == 1) && (device->value != temp)) { 452 if ((rc == 1) && (device->value != temp)) {
453 device->value = temp; 453 device->value = temp;
454 device->timestamp = time(NULL); 454 device->timestamp = time(NULL);
455 } 455 }
456 } else { 456 } else {
457 syslog(LOG_NOTICE, "sensor %s CRC error", device->address); 457 syslog(LOG_WARNING, "sensor %s CRC error", device->address);
458 device->present = DEVPRESENT_ERROR; 458 device->present = DEVPRESENT_ERROR;
459 } 459 }
460 fclose(fp); 460 fclose(fp);
461 } else { 461 } else {
462 if (device->present != DEVPRESENT_NO) { 462 if (device->present != DEVPRESENT_NO) {
463 syslog(LOG_NOTICE, "sensor %s is missing", device->address); 463 syslog(LOG_WARNING, "sensor %s is missing", device->address);
464 device->present = DEVPRESENT_NO; 464 device->present = DEVPRESENT_NO;
465 } 465 }
466 } 466 }
467 free(addr); 467 free(addr);
468 addr = NULL; 468 addr = NULL;

mercurial