# HG changeset patch # User Michiel Broek # Date 1426888162 -3600 # Node ID cfc952a68d4a99b45b71cfc87aa4061d66fa6126 # Parent 5b49416eb11628e08b2bd7d552479f5ad91e8c69 Possible part of DS2408 code added. diff -r 5b49416eb116 -r cfc952a68d4a thermferm/devices.c --- a/thermferm/devices.c Fri Mar 20 22:22:18 2015 +0100 +++ b/thermferm/devices.c Fri Mar 20 22:49:22 2015 +0100 @@ -603,6 +603,46 @@ } free(addr); addr = NULL; + } /* if temperature sensor */ + /* + * DS2408 8 Channel addressable switch + */ + if (strncmp(device->address, (char *)"29", 2) == 0) { + /* + * Always read current state and set these bits + * in the subdevices value. We do this even with + * the output bits, they should match. + */ + addr = xstrcpy((char *)"/sys/bus/w1/devices/"); + addr = xstrcat(addr, device->address); + addr = xstrcat(addr, (char *)"/state"); + if ((fp = fopen(addr, "r"))) { + if (device->present != DEVPRESENT_YES) { + syslog(LOG_NOTICE, "DS2408 %s is back", device->address); +#ifdef HAVE_WIRINGPI_H + piLock(LOCK_DEVICES); +#endif + device->present = DEVPRESENT_YES; +#ifdef HAVE_WIRINGPI_H + piUnlock(LOCK_DEVICES); +#endif + } + + fclose(fp); + } else { + if (device->present != DEVPRESENT_NO) { + syslog(LOG_NOTICE, "DS2408 %s is missing", device->address); +#ifdef HAVE_WIRINGPI_H + piLock(LOCK_DEVICES); +#endif + device->present = DEVPRESENT_NO; +#ifdef HAVE_WIRINGPI_H + piUnlock(LOCK_DEVICES); +#endif + } + } + free(addr); + addr = NULL; } break;