diff --git a/lib/access.c b/lib/access.c index a530469a..b8b6247d 100644 --- a/lib/access.c +++ b/lib/access.c @@ -140,7 +140,7 @@ int sensors_get_label(sensors_chip_name name, int feature, char **result) for (chip = NULL; (chip = sensors_for_all_config_chips(name,chip));) for (i = 0; i < chip->labels_count; i++) if (!strcmp(featureptr->name, chip->labels[i].name)) { - if (! (*result = strdup(chip->labels[i].name))) + if (! (*result = strdup(chip->labels[i].value))) sensors_fatal_error("sensors_get_label","Allocating label text"); return 0; } @@ -182,7 +182,7 @@ int sensors_get_feature(sensors_chip_name name, int feature, double *result) /* Set the value of a feature of a certain chip. Note that chip should not contain wildcard values! This function will return 0 on success, and <0 on failure. */ -int sensors_set_value(sensors_chip_name name, int feature, double value) +int sensors_set_feature(sensors_chip_name name, int feature, double value) { sensors_chip_feature *featureptr; sensors_chip *chip; @@ -214,3 +214,25 @@ const sensors_chip_name *sensors_get_detected_chips (int *nr) (*nr)++; return res; } + +const char *sensors_get_adapter_name(int bus_nr) +{ + int i; + if (bus_nr == SENSORS_CHIP_NAME_BUS_ISA) + return "ISA adapter"; + for (i=0; i < sensors_proc_bus_count; i++) + if (sensors_proc_bus[i].number == bus_nr) + return sensors_proc_bus[i].adapter; + return NULL; +} + +const char *sensors_get_algorithm_name(int bus_nr) +{ + int i; + if (bus_nr == SENSORS_CHIP_NAME_BUS_ISA) + return "ISA algorithm"; + for (i=0; i < sensors_proc_bus_count; i++) + if (sensors_proc_bus[i].number == bus_nr) + return sensors_proc_bus[i].algorithm; + return NULL; +} diff --git a/lib/sensors.h b/lib/sensors.h index 18f7bcf8..d8526607 100644 --- a/lib/sensors.h +++ b/lib/sensors.h @@ -60,6 +60,12 @@ extern int sensors_match_chip(sensors_chip_name chip1, if there are wildcards. */ extern int sensors_chip_name_has_wildcards(sensors_chip_name chip); +/* These functions return the adapter and algorithm names of a bus number, + as used within the sensors_chip_name structure. If it could not be found, + it returns NULL */ +extern const char *sensors_get_adapter_name(int bus_nr); +extern const char *sensors_get_algorithm_name(int bus_nr); + /* Look up the label which belongs to this chip. Note that chip should not contain wildcard values! *result is newly allocated (free it yourself). This function will return 0 on success, and <0 on failure. */ @@ -75,8 +81,8 @@ extern int sensors_get_feature(sensors_chip_name name, int feature, /* Set the value of a feature of a certain chip. Note that chip should not contain wildcard values! This function will return 0 on success, and <0 on failure. */ -extern int sensors_set_value(sensors_chip_name name, int feature, - double value); +extern int sensors_set_feature(sensors_chip_name name, int feature, + double value); /* This function returns all detected chips, one by one. To start at the beginning of the list, use 0 for nr; NULL is returned if we are diff --git a/prog/sensors/Module.mk b/prog/sensors/Module.mk index c7fc73e8..a45d81ef 100644 --- a/prog/sensors/Module.mk +++ b/prog/sensors/Module.mk @@ -23,14 +23,14 @@ MODULE_DIR := prog/sensors # Regrettably, even 'simply expanded variables' will not put their currently # defined value verbatim into the command-list of rules... PROGSENSORSTARGETS := $(MODULE_DIR)/sensors -PROGSENSORSSOURCES := $(MODULE_DIR)/main.c +PROGSENSORSSOURCES := $(MODULE_DIR)/main.c $(MODULE_DIR)/chips.c # Include all dependency files. We use '.rd' to indicate this will create # executables. INCLUDEFILES += $(PROGSENSORSSOURCES:.c=.rd) $(PROGSENSORSTARGETS): $(PROGSENSORSSOURCES:.c=.ro) lib/$(LIBSHBASENAME) - $(CC) -o $@ $^ -Llib -lsensors + $(CC) -o $@ $(PROGSENSORSSOURCES:.c=.ro) -Llib -lsensors all-prog-sensors: $(PROGSENSORSTARGETS) all :: all-prog-sensors diff --git a/prog/sensors/main.c b/prog/sensors/main.c index 07a64153..17f54aba 100644 --- a/prog/sensors/main.c +++ b/prog/sensors/main.c @@ -25,6 +25,7 @@ #include "lib/sensors.h" #include "lib/error.h" +#include "chips.h" #define PROGRAM "sensors" #define VERSION "0.0" @@ -121,6 +122,7 @@ int main (int argc, char *argv[]) int chip_nr; const sensors_chip_name *chip; + const char *algo,*adap; struct option long_opts[] = { { "help", no_argument, NULL, 'h' }, @@ -163,11 +165,22 @@ int main (int argc, char *argv[]) } /* Here comes the real code... */ - printf("Detected chips:\n"); - for (chip_nr = 0; (chip = sensors_get_detected_chips(&chip_nr));) + 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); + printf("%s-isa-%04x\n",chip->prefix,chip->addr); else - printf(" %s-i2c-%d-%02x\n",chip->prefix,chip->bus,chip->addr); + printf("%s-i2c-%d-%02x\n",chip->prefix,chip->bus,chip->addr); + adap = sensors_get_adapter_name(chip->bus); + if (adap) + printf("Adapter: %s\n",adap); + algo = sensors_get_algorithm_name(chip->bus); + if (algo) + printf("Algorithm: %s\n",algo); + if (!algo || !adap) + printf(" ERROR: Can't get adapter or algorithm?!?\n"); + if (!strcmp(chip->prefix,"lm75")) + print_lm75(chip); + printf("\n"); + } exit(0); }