# HG changeset patch # User Michiel Broek # Date 1556461674 -7200 # Node ID b8580eedfcc722b93df30eac8c212f36c131aa2d # Parent 504463dad07deb727e136844d4e89ace80b182d6 Experimental 12 bits resolution init diff -r 504463dad07d -r b8580eedfcc7 thermferm/devices.c --- a/thermferm/devices.c Sun Apr 28 11:38:30 2019 +0200 +++ b/thermferm/devices.c Sun Apr 28 16:27:54 2019 +0200 @@ -734,6 +734,33 @@ #endif /* + * Set the temperature sensors to 12 bits resolution. + */ + for (device = Config.devices; device; device = device->next) { + if ((device->type == DEVTYPE_W1) && + ((strncmp(device->address, (char *)"10", 2) == 0) || + (strncmp(device->address, (char *)"22", 2) == 0) || + (strncmp(device->address, (char *)"28", 2) == 0) || + (strncmp(device->address, (char *)"3b", 2) == 0) || + (strncmp(device->address, (char *)"42", 2) == 0))) { + addr = xstrcpy((char *)"/sys/bus/w1/devices/"); + addr = xstrcat(addr, device->address); + addr = xstrcat(addr, (char *)"/w1_slave"); + if ((fp = fopen(addr, "w"))) { + rc = fprintf(fp, "12\n0\n"); + fclose(fp); + if (rc == 5) { + syslog(LOG_NOTICE, "written 12 bits setting to %s", addr); + } else { + syslog(LOG_NOTICE, "error rc=%d for %s", rc, addr); + } + } + free(addr); + addr = NULL; + } + } + + /* * Loop forever until the external shutdown variable is set. */ for (;;) {