thermferm/devices.c

changeset 672
0c2c66920d79
parent 671
b2e2cbb13cb3
child 674
6cabc02f4c8d
equal deleted inserted replaced
671:b2e2cbb13cb3 672:0c2c66920d79
236 { 236 {
237 devices_list *device; 237 devices_list *device;
238 time_t now, my_timestamp; 238 time_t now, my_timestamp;
239 int my_value, test_value; 239 int my_value, test_value;
240 #ifdef HAVE_WIRINGPI_H 240 #ifdef HAVE_WIRINGPI_H
241 int i; 241 int rc, i;
242 char buf[40]; 242 char buf[40];
243 #endif 243 #endif
244 244
245 if (uuid == NULL) 245 if (uuid == NULL)
246 return 0; 246 return 0;
790 for (dev_w1 = w1_devices; dev_w1; dev_w1 = dev_w1->next) { 790 for (dev_w1 = w1_devices; dev_w1; dev_w1 = dev_w1->next) {
791 if (strcmp(device->address, dev_w1->address) == 0) { 791 if (strcmp(device->address, dev_w1->address) == 0) {
792 // syslog(LOG_NOTICE, "sensor %s value %d", dev_w1->address, dev_w1->value); 792 // syslog(LOG_NOTICE, "sensor %s value %d", dev_w1->address, dev_w1->value);
793 found = TRUE; 793 found = TRUE;
794 if ((dev_w1->value == -1) || (dev_w1->value < -55000)) { 794 if ((dev_w1->value == -1) || (dev_w1->value < -55000)) {
795 syslog(LOG_NOTICE, "sensor %s value error %d", device->address, dev_w1->value); 795 if (device->present != DEVPRESENT_ERROR)
796 syslog(LOG_NOTICE, "sensor %s value error %d, keep %d", device->address, dev_w1->value, device->value);
796 device->present = DEVPRESENT_ERROR; 797 device->present = DEVPRESENT_ERROR;
797 } else { 798 } else {
799 if (device->present != DEVPRESENT_YES)
800 syslog(LOG_NOTICE, "sensor %s value ok %d", device->address, dev_w1->value);
798 device->value = dev_w1->value; 801 device->value = dev_w1->value;
799 device->timestamp = time(NULL); 802 device->timestamp = time(NULL);
800 device->present = DEVPRESENT_YES; 803 device->present = DEVPRESENT_YES;
801 } 804 }
802 } 805 }

mercurial