293 /* |
293 /* |
294 * cur_w1 points to the next not handled device. |
294 * cur_w1 points to the next not handled device. |
295 */ |
295 */ |
296 if (cur_w1 != NULL) { |
296 if (cur_w1 != NULL) { |
297 |
297 |
298 if ((strcmp(cur_w1->family, (char *)"10") == 0) || (strcmp(cur_w1->family, (char *)"22") == 0) || (strcmp(cur_w1->family, (char *)"28") == 0) || |
298 if (((strcmp(cur_w1->family, (char *)"10") == 0) || (strcmp(cur_w1->family, (char *)"22") == 0) || (strcmp(cur_w1->family, (char *)"28") == 0) || |
299 (strcmp(cur_w1->family, (char *)"3b") == 0) || (strcmp(cur_w1->family, (char *)"42") == 0)) { |
299 (strcmp(cur_w1->family, (char *)"3b") == 0) || (strcmp(cur_w1->family, (char *)"42") == 0)) && |
|
300 (cur_w1->present == DEVPRESENT_YES)) { |
300 devfile = xstrcpy((char *)"/sys/bus/w1/devices/"); |
301 devfile = xstrcpy((char *)"/sys/bus/w1/devices/"); |
301 devfile = xstrcat(devfile, cur_w1->address); |
302 devfile = xstrcat(devfile, cur_w1->address); |
302 devfile = xstrcat(devfile, (char *)"/resolution"); |
303 devfile = xstrcat(devfile, (char *)"/resolution"); |
303 if ((fp = fopen(devfile, "r+"))) { |
304 if ((fp = fopen(devfile, "r+"))) { |
304 if ((fgets(buffer, 25, fp))) { |
305 if ((fgets(buffer, 25, fp))) { |
305 sscanf(buffer, "%d", &value); |
306 sscanf(buffer, "%d", &value); |
306 if (value != W1_TEMP_RESOLUTION) { |
307 /* If device is removed, value is negative (errno?) */ |
|
308 if ((value > 0) && (value != W1_TEMP_RESOLUTION)) { |
307 syslog(LOG_NOTICE, "One-wire device %s set resolution from %d to %d", cur_w1->address, value, W1_TEMP_RESOLUTION); |
309 syslog(LOG_NOTICE, "One-wire device %s set resolution from %d to %d", cur_w1->address, value, W1_TEMP_RESOLUTION); |
308 fseek(fp, 0L, SEEK_SET); |
310 fseek(fp, 0L, SEEK_SET); |
309 sprintf(buffer, "%d", W1_TEMP_RESOLUTION); |
311 sprintf(buffer, "%d", W1_TEMP_RESOLUTION); |
310 fputs(buffer, fp); |
312 fputs(buffer, fp); |
311 } |
313 } |