mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-09-05 00:35:35 +00:00
Unknown chip support
Some basic support, in the form of sensors_get_all_features(), for chips that are known to the library, but unknown to the application. prog/sensors has a demo of how to use this, in function print_unknown_chip in chips.c. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@110 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
@@ -218,3 +218,30 @@ void print_lm78(const sensors_chip_name *name)
|
||||
free_the_label(&label);
|
||||
}
|
||||
|
||||
void print_unknown_chip(const sensors_chip_name *name)
|
||||
{
|
||||
int a,b;
|
||||
const sensors_feature_data *data;
|
||||
char *label;
|
||||
double val;
|
||||
|
||||
a=b=0;
|
||||
while((data=sensors_get_all_features(*name,&a,&b))) {
|
||||
if (sensors_get_label(*name,data->number,&label)) {
|
||||
printf("ERROR: Can't get feature `%s' data!",data->name);
|
||||
continue;
|
||||
}
|
||||
if (data->mode & SENSORS_MODE_R) {
|
||||
if(sensors_get_feature(*name,data->number,&val)) {
|
||||
printf("ERROR: Can't get feature `%s' data!",data->name);
|
||||
continue;
|
||||
}
|
||||
if (data->mapping != SENSORS_NO_MAPPING)
|
||||
printf(" %s: %.2f (%s)\n",label,val,data->name);
|
||||
else
|
||||
printf("%s: %.2f (%s)\n",label,val,data->name);
|
||||
} else
|
||||
printf("(%s)",label);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "lib/sensors.h"
|
||||
|
||||
extern void print_unknown_chip(const sensors_chip_name *name);
|
||||
|
||||
extern void print_lm75(const sensors_chip_name *name);
|
||||
extern void print_lm78(const sensors_chip_name *name);
|
||||
|
||||
|
@@ -165,6 +165,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Here comes the real code... */
|
||||
|
||||
for (chip_nr = 0; (chip = sensors_get_detected_chips(&chip_nr));) {
|
||||
if (chip->bus == SENSORS_CHIP_NAME_BUS_ISA)
|
||||
printf("%s-isa-%04x\n",chip->prefix,chip->addr);
|
||||
@@ -183,7 +184,11 @@ int main (int argc, char *argv[])
|
||||
else if (!strcmp(chip->prefix,"lm78") || !strcmp(chip->prefix,"lm78-j") ||
|
||||
!strcmp(chip->prefix,"lm79"))
|
||||
print_lm78(chip);
|
||||
else
|
||||
print_unknown_chip(chip);
|
||||
printf("\n");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user