Changeset 4831
- Timestamp:
- 09/23/07 14:00:59 (1 year ago)
- Files:
-
- lm-sensors/branches/lm-sensors-3.0.0/lib/access.c (modified) (2 diffs)
- lm-sensors/branches/lm-sensors-3.0.0/lib/libsensors.3 (modified) (2 diffs)
- lm-sensors/branches/lm-sensors-3.0.0/lib/sensors.h (modified) (1 diff)
- lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/chips.c (modified) (9 diffs)
- lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/sense.c (modified) (1 diff)
- lm-sensors/branches/lm-sensors-3.0.0/prog/sensors/chips.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lm-sensors/branches/lm-sensors-3.0.0/lib/access.c
r4830 r4831 344 344 } 345 345 346 /* nr-1 is the last feature returned */ 347 const sensors_feature_data *sensors_get_all_features(const sensors_chip_name *name, 348 int *nr) 346 static const sensors_feature_data * 347 sensors_get_all_features(const sensors_chip_name *name, int *nr) 349 348 { 350 349 sensors_feature_data *feature_list; … … 362 361 } 363 362 return NULL; 363 } 364 365 const sensors_feature_data * 366 sensors_get_features(const sensors_chip_name *name, int *nr) 367 { 368 const sensors_feature_data *feature; 369 370 while ((feature = sensors_get_all_features(name, nr))) { 371 if (feature->mapping == SENSORS_NO_MAPPING) 372 return feature; 373 } 374 return NULL; /* end of list */ 375 } 376 377 const sensors_feature_data * 378 sensors_get_all_subfeatures(const sensors_chip_name *name, int feature, int *nr) 379 { 380 const sensors_feature_data *subfeature; 381 382 /* Seek directly to the first subfeature */ 383 if (*nr < feature) 384 *nr = feature; 385 386 subfeature = sensors_get_all_features(name, nr); 387 if (!subfeature) 388 return NULL; /* end of list */ 389 if (subfeature->number == feature || 390 subfeature->mapping == feature) 391 return subfeature; 392 return NULL; /* end of subfeature list */ 364 393 } 365 394 lm-sensors/branches/lm-sensors-3.0.0/lib/libsensors.3
r4758 r4831 45 45 .B const sensors_chip_name *sensors_get_detected_chips(const sensors_chip_name 46 46 \fB*match, int *nr);\fP 47 .B const sensors_feature_data *sensors_get_ all_features47 .B const sensors_feature_data *sensors_get_features 48 48 \fB(const sensors_chip_name *name, int *nr);\fP 49 .B const sensors_feature_data *sensors_get_all_subfeatures 50 \fB(const sensors_chip_name *name, int feature, int *nr);\fP 49 51 .B const char *libsensors_version; 50 52 .fi … … 122 124 (affected by the computation rules of the main feature). 123 125 124 \fBconst sensors_feature_data *sensors_get_all_features 125 (const sensors_chip_name *name, int *nr);\fP 126 \fBconst sensors_feature_data *sensors_get_features(const sensors_chip_name *name, int *nr);\fP 126 127 .br 127 This returns all features of a specific chip. They are returned in bunches: 128 everything with the same mapping is returned just after each other, with 129 the master feature in front (that feature does not map to itself, but 130 has SENSORS_NO_MAPPING as mapping field). nr is an internally used variable. 131 Set it to zero to start again at the begin of the list. If no more features 132 are found NULL is returned. Do not try to change the returned structure; you 133 will corrupt internal data structures. 128 This returns all main features of a specific chip. nr is an internally 129 used variable. Set it to zero to start at the begin of the list. If no 130 more features are found NULL is returned. 131 Do not try to change the returned structure; you will corrupt internal 132 data structures. 133 134 \fBconst sensors_feature_data *sensors_get_all_subfeatures(const sensors_chip_name *name, int feature, int *nr);\fP 135 .br 136 This returns all subfeatures of a given main feature (including that 137 main feature itself, in first position.) nr is an internally used 138 variable. Set it to zero to start at the begin of the list. If no more 139 features are found NULL is returned. 140 Do not try to change the returned structure; you will corrupt internal 141 data structures. 134 142 135 143 \fBconst char *libsensors_version;\fP lm-sensors/branches/lm-sensors-3.0.0/lib/sensors.h
r4830 r4831 184 184 } sensors_feature_data; 185 185 186 /* This returns all features of a specific chip. They are returned in 187 bunches: everything with the same mapping is returned just after each 188 other, with the master feature in front (that feature does not map to 189 itself, but has SENSORS_NO_MAPPING as mapping field). nr is 190 an internally used variable. Set it to zero to start again at the 191 begin of the list. If no more features are found NULL is returned. 186 /* This returns all main features of a specific chip. nr is an internally 187 used variable. Set it to zero to start at the begin of the list. If no 188 more features are found NULL is returned. 192 189 Do not try to change the returned structure; you will corrupt internal 193 190 data structures. */ 194 const sensors_feature_data *sensors_get_all_features 195 (const sensors_chip_name *name, int *nr); 191 const sensors_feature_data * 192 sensors_get_features(const sensors_chip_name *name, int *nr); 193 194 /* This returns all subfeatures of a given main feature (including that 195 main feature itself, in first position.) nr is an internally used 196 variable. Set it to zero to start at the begin of the list. If no more 197 features are found NULL is returned. 198 Do not try to change the returned structure; you will corrupt internal 199 data structures. */ 200 const sensors_feature_data * 201 sensors_get_all_subfeatures(const sensors_chip_name *name, int feature, int *nr); 196 202 197 203 #ifdef __cplusplus lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/chips.c
r4828 r4831 143 143 static void getAvailableFeatures (const sensors_chip_name *name, 144 144 const sensors_feature_data *feature, 145 int i,short *has_features,145 short *has_features, 146 146 int *feature_nrs, int size, 147 147 int first_val) 148 148 { 149 149 const sensors_feature_data *iter; 150 151 while ((iter = sensors_get_all_features (name, &i)) && 152 iter->mapping == feature->number) {150 int i = 0; 151 152 while ((iter = sensors_get_all_subfeatures(name, feature->number, &i))) { 153 153 int index0; 154 154 … … 167 167 static void fillChipVoltage (FeatureDescriptor *voltage, 168 168 const sensors_chip_name *name, 169 const sensors_feature_data *feature , int i)169 const sensors_feature_data *feature) 170 170 { 171 171 const int size = SENSORS_FEATURE_IN_BEEP - SENSORS_FEATURE_IN; … … 178 178 voltage->dataNumbers[pos++] = feature->number; 179 179 180 getAvailableFeatures (name, feature, i,has_features,180 getAvailableFeatures (name, feature, has_features, 181 181 feature_nrs, size, SENSORS_FEATURE_IN); 182 182 … … 215 215 static void fillChipTemperature (FeatureDescriptor *temperature, 216 216 const sensors_chip_name *name, 217 const sensors_feature_data *feature , int i)217 const sensors_feature_data *feature) 218 218 { 219 219 const int size = SENSORS_FEATURE_TEMP_BEEP - SENSORS_FEATURE_TEMP; … … 226 226 temperature->dataNumbers[pos++] = feature->number; 227 227 228 getAvailableFeatures (name, feature, i,has_features,228 getAvailableFeatures (name, feature, has_features, 229 229 feature_nrs, size, SENSORS_FEATURE_TEMP); 230 230 … … 266 266 static void fillChipFan (FeatureDescriptor *fan, 267 267 const sensors_chip_name *name, 268 const sensors_feature_data *feature , int i)268 const sensors_feature_data *feature) 269 269 { 270 270 const int size = SENSORS_FEATURE_FAN_BEEP - SENSORS_FEATURE_FAN; … … 277 277 fan->dataNumbers[pos++] = feature->number; 278 278 279 getAvailableFeatures (name, feature, i,has_features,279 getAvailableFeatures (name, feature, has_features, 280 280 feature_nrs, size, SENSORS_FEATURE_FAN); 281 281 … … 342 342 /* How many main features do we have? */ 343 343 nr = 0; 344 while ((sensor = sensors_get_all_features(chip, &nr))) { 345 if (sensor->mapping == SENSORS_NO_MAPPING) 346 count++; 347 } 344 while ((sensor = sensors_get_features(chip, &nr))) 345 count++; 348 346 349 347 /* Allocate the memory we need */ … … 355 353 count = 0; 356 354 nr = 0; 357 while ((sensor = sensors_get_all_features(chip, &nr))) { 358 if (sensor->mapping != SENSORS_NO_MAPPING) 359 continue; 360 355 while ((sensor = sensors_get_features(chip, &nr))) { 361 356 switch (sensor->type) { 362 357 case SENSORS_FEATURE_TEMP: 363 fillChipTemperature(&features[count], chip, sensor , nr);358 fillChipTemperature(&features[count], chip, sensor); 364 359 break; 365 360 case SENSORS_FEATURE_IN: 366 fillChipVoltage(&features[count], chip, sensor , nr);361 fillChipVoltage(&features[count], chip, sensor); 367 362 break; 368 363 case SENSORS_FEATURE_FAN: 369 fillChipFan(&features[count], chip, sensor , nr);364 fillChipFan(&features[count], chip, sensor); 370 365 break; 371 366 case SENSORS_FEATURE_VID: lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/sense.c
r4828 r4831 37 37 getRawLabel 38 38 (const sensors_chip_name *name, int feature, const char **label) { 39 const sensors_feature_data *rawFeature; 40 int nr = 0, err = 0; 41 do { 42 rawFeature = sensors_get_all_features (name, &nr); 43 } while (rawFeature && (rawFeature->number != feature)); 39 const sensors_feature_data *mainfeat, *sub; 40 int a, b; 41 42 a = 0; 43 while ((mainfeat = sensors_get_features(name, &a))) { 44 b = 0; 45 while ((sub = sensors_get_all_subfeatures(name, mainfeat->number, &b))) { 46 if (sub->number == feature) { 47 *label = sub->name; 48 return 0; 49 } 50 } 51 } 44 52 /* TODO: Ensure labels match RRD construct and are not repeated! */ 45 if (!rawFeature) { 46 err = -1; 47 } else { 48 *label = rawFeature->name; 49 } 50 return err; 53 return -1; 51 54 } 52 55 lm-sensors/branches/lm-sensors-3.0.0/prog/sensors/chips.c
r4822 r4831 31 31 void print_chip_raw(const sensors_chip_name *name) 32 32 { 33 int a ;34 const sensors_feature_data * data;33 int a, b; 34 const sensors_feature_data *feature, *sub; 35 35 char *label; 36 36 double val; 37 37 38 38 a = 0; 39 while ((data = sensors_get_all_features(name, &a))) { 40 if (!(label = sensors_get_label(name, data->number))) { 41 printf("ERROR: Can't get feature `%s' label!\n", 42 data->name); 43 continue; 44 } 45 if (data->flags & SENSORS_MODE_R) { 46 if (sensors_get_value(name, data->number, &val)) 47 printf("ERROR: Can't get feature `%s' data!\n", 48 data->name); 49 else if (data->mapping != SENSORS_NO_MAPPING) 50 printf(" %s: %.2f\n", label, val); 51 else 52 printf("%s: %.2f (%s)\n", label, val, 53 data->name); 54 } else 55 printf("(%s)\n", label); 56 free(label); 39 while ((feature = sensors_get_features(name, &a))) { 40 b = 0; 41 while ((sub = sensors_get_all_subfeatures(name, feature->number, 42 &b))) { 43 if (!(label = sensors_get_label(name, sub->number))) { 44 printf("ERROR: Can't get feature `%s' label!\n", 45 sub->name); 46 continue; 47 } 48 if (sub->flags & SENSORS_MODE_R) { 49 if (sensors_get_value(name, sub->number, &val)) 50 printf("ERROR: Can't get feature `%s' " 51 "data!\n", sub->name); 52 else if (sub->mapping != SENSORS_NO_MAPPING) 53 printf(" %s: %.2f\n", label, val); 54 else 55 printf("%s: %.2f (%s)\n", label, val, 56 sub->name); 57 } else 58 printf("(%s)\n", label); 59 free(label); 60 } 57 61 } 58 62 } … … 71 75 static void sensors_get_available_features(const sensors_chip_name *name, 72 76 const sensors_feature_data *feature, 73 int i,short *has_features,77 short *has_features, 74 78 double *feature_vals, int size, 75 79 int first_val) 76 80 { 77 81 const sensors_feature_data *iter; 78 79 while ((iter = sensors_get_all_features(name, &i)) && 80 iter->mapping == feature->number) {82 int i = 0; 83 84 while ((iter = sensors_get_all_subfeatures(name, feature->number, &i))) { 81 85 int indx, err; 82 86 … … 105 109 106 110 i = 0; 107 while ((iter = sensors_get_all_features(name, &i))) { 108 if (iter->mapping != SENSORS_NO_MAPPING) 109 continue; 111 while ((iter = sensors_get_features(name, &i))) { 110 112 if ((label = sensors_get_label(name, iter->number)) && 111 113 strlen(label) > max_size) … … 142 144 #define TEMP_FEATURE_VAL(x) feature_vals[x - SENSORS_FEATURE_TEMP - 1] 143 145 static void print_chip_temp(const sensors_chip_name *name, 144 const sensors_feature_data *feature, int i,146 const sensors_feature_data *feature, 145 147 int label_size) 146 148 { … … 164 166 } 165 167 166 sensors_get_available_features(name, feature, i,has_features,168 sensors_get_available_features(name, feature, has_features, 167 169 feature_vals, size, 168 170 SENSORS_FEATURE_TEMP); … … 280 282 #define IN_FEATURE_VAL(x) feature_vals[x - SENSORS_FEATURE_IN - 1] 281 283 static void print_chip_in(const sensors_chip_name *name, 282 const sensors_feature_data *feature, int i,284 const sensors_feature_data *feature, 283 285 int label_size) 284 286 { … … 300 302 } 301 303 302 sensors_get_available_features(name, feature, i,has_features,304 sensors_get_available_features(name, feature, has_features, 303 305 feature_vals, size, SENSORS_FEATURE_IN); 304 306 … … 345 347 #define FAN_FEATURE_VAL(x) feature_vals[x - SENSORS_FEATURE_FAN - 1] 346 348 static void print_chip_fan(const sensors_chip_name *name, 347 const sensors_feature_data *feature, int i,349 const sensors_feature_data *feature, 348 350 int label_size) 349 351 { … … 368 370 free(label); 369 371 370 sensors_get_available_features(name, feature, i,has_features,372 sensors_get_available_features(name, feature, has_features, 371 373 feature_vals, size, SENSORS_FEATURE_FAN); 372 374 … … 433 435 434 436 i = 0; 435 while ((feature = sensors_get_all_features(name, &i))) { 436 if (feature->mapping != SENSORS_NO_MAPPING) 437 continue; 438 437 while ((feature = sensors_get_features(name, &i))) { 439 438 switch (feature->type) { 440 439 case SENSORS_FEATURE_TEMP: 441 print_chip_temp(name, feature, i,label_size);440 print_chip_temp(name, feature, label_size); 442 441 break; 443 442 case SENSORS_FEATURE_IN: 444 print_chip_in(name, feature, i,label_size);443 print_chip_in(name, feature, label_size); 445 444 break; 446 445 case SENSORS_FEATURE_FAN: 447 print_chip_fan(name, feature, i,label_size);446 print_chip_fan(name, feature, label_size); 448 447 break; 449 448 case SENSORS_FEATURE_VID:
