thermferm/devices.c

changeset 588
322a29000fd7
parent 587
b8580eedfcc7
child 589
230a502b75ec
equal deleted inserted replaced
587:b8580eedfcc7 588:322a29000fd7
732 if ((rc = piHiPri(50))) 732 if ((rc = piHiPri(50)))
733 syslog(LOG_NOTICE, "my_devices_loop: piHiPri(50) rc=%d", rc); 733 syslog(LOG_NOTICE, "my_devices_loop: piHiPri(50) rc=%d", rc);
734 #endif 734 #endif
735 735
736 /* 736 /*
737 * Set the temperature sensors to 12 bits resolution. 737 * Set the temperature sensors to 12 bits resolution and write it in EEPROM
738 */ 738 */
739 for (device = Config.devices; device; device = device->next) { 739 for (device = Config.devices; device; device = device->next) {
740 if ((device->type == DEVTYPE_W1) && 740 if ((device->type == DEVTYPE_W1) &&
741 ((strncmp(device->address, (char *)"10", 2) == 0) || 741 ((strncmp(device->address, (char *)"10", 2) == 0) ||
742 (strncmp(device->address, (char *)"22", 2) == 0) || 742 (strncmp(device->address, (char *)"22", 2) == 0) ||
745 (strncmp(device->address, (char *)"42", 2) == 0))) { 745 (strncmp(device->address, (char *)"42", 2) == 0))) {
746 addr = xstrcpy((char *)"/sys/bus/w1/devices/"); 746 addr = xstrcpy((char *)"/sys/bus/w1/devices/");
747 addr = xstrcat(addr, device->address); 747 addr = xstrcat(addr, device->address);
748 addr = xstrcat(addr, (char *)"/w1_slave"); 748 addr = xstrcat(addr, (char *)"/w1_slave");
749 if ((fp = fopen(addr, "w"))) { 749 if ((fp = fopen(addr, "w"))) {
750 rc = fprintf(fp, "12\n0\n"); 750 rc = fprintf(fp, "12\n0\n"); // According to the kernel documentation. Seems to work.
751 fclose(fp); 751 fclose(fp);
752 if (rc == 5) { 752 if (rc != 5) {
753 syslog(LOG_NOTICE, "written 12 bits setting to %s", addr); 753 syslog(LOG_NOTICE, "Program 12 bits resolution error rc=%d for %s", rc, addr);
754 } else {
755 syslog(LOG_NOTICE, "error rc=%d for %s", rc, addr);
756 } 754 }
757 } 755 }
758 free(addr); 756 free(addr);
759 addr = NULL; 757 addr = NULL;
760 } 758 }

mercurial