39 struct dirent *de; |
39 struct dirent *de; |
40 // FILE *fp; |
40 // FILE *fp; |
41 DIR *fd; |
41 DIR *fd; |
42 devices_list *device, *ndev; |
42 devices_list *device, *ndev; |
43 int found, subdevices, i, rc = 0; |
43 int found, subdevices, i, rc = 0; |
44 char *family; |
44 char family[3]; |
45 uuid_t uu; |
45 uuid_t uu; |
46 |
46 |
47 /* |
47 /* |
48 * Scan for 1-wire devices |
48 * Scan for 1-wire devices |
49 */ |
49 */ |
50 if ((fd = opendir((char *)"/sys/bus/w1/devices"))) { |
50 if ((fd = opendir((char *)"/sys/bus/w1/devices"))) { |
51 while ((de = readdir(fd))) { |
51 while ((de = readdir(fd))) { |
52 if (de->d_name[0] != '.') { |
52 if (de->d_name[0] != '.') { |
53 found = FALSE; |
53 found = FALSE; |
54 for (device = Config.devices; device; device = device->next) { |
54 for (device = Config.devices; device; device = device->next) { |
55 if (strcmp(device->address ,de->d_name) == 0) { |
55 if (strcmp(device->address,de->d_name) == 0) { |
56 found = TRUE; |
56 found = TRUE; |
57 break; |
57 break; |
58 } |
58 } |
59 } |
59 } |
60 |
60 |
61 if (found == FALSE) { |
61 if (found == FALSE) { |
62 family = malloc(3); |
|
63 strncpy(family, de->d_name, 2); |
62 strncpy(family, de->d_name, 2); |
|
63 family[2] = '\0'; |
64 subdevices = 1; |
64 subdevices = 1; |
65 if (strcmp(family, (char *)"29") == 0) |
65 if (strcmp(family, (char *)"29") == 0) |
66 subdevices = 8; |
66 subdevices = 8; |
67 if (strcmp(family, (char *)"3a") == 0) |
67 if (strcmp(family, (char *)"3a") == 0) |
68 subdevices = 2; |
68 subdevices = 2; |