Mon, 05 Oct 2015 15:21:46 +0200
Make sure that a DS2413 device used as input has the output latch turned off.
thermferm/devices.c | file | annotate | diff | comparison | revisions |
--- a/thermferm/devices.c Fri Sep 18 12:55:49 2015 +0200 +++ b/thermferm/devices.c Mon Oct 05 15:21:46 2015 +0200 @@ -820,6 +820,28 @@ piUnlock(LOCK_DEVICES); #endif } + /* + * First make sure that if this device is configured as input + * to drive the output high. + */ + if (device->direction == DEVDIR_IN_BIN) { + uint8_t state, output; + + if ((rc = read_w1(device->address, (char *)"state")) >= 0) { + state = (unsigned int)rc; + output = ((state & 0x02) >> 1) + ((state & 0x08) >> 2); /* Both latch states */ + if (device->subdevice == 0) { + output = (output & 0xfe); + output |= 0x01; + } else if (device->subdevice == 1) { + output = (output & 0xfd); + output |= 0x02; + } else { + output = 0xff; + } + write_w1(device->address, (char *)"output", output); + } + } if ((rc = read_w1(device->address, (char *)"state")) >= 0) { #ifdef HAVE_WIRINGPI_H piLock(LOCK_DEVICES);