Changeset 103

Show
Ignore:
Timestamp:
12/22/98 18:41:43 (14 years ago)
Author:
frodo
Message:

Yet more library and prog/sensors stuff. LM75 data is now printed!

* Added sensors_get_algorithm_name and sensors_get_adapter_name to the

library.

* First application of sensors_get_value is very encouraging; LM75 data is

now printed.

Location:
lm-sensors/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/lib/access.c

    r102 r103  
    141141    for (i = 0; i < chip->labels_count; i++) 
    142142      if (!strcmp(featureptr->name, chip->labels[i].name)) { 
    143         if (! (*result = strdup(chip->labels[i].name))) 
     143        if (! (*result = strdup(chip->labels[i].value))) 
    144144          sensors_fatal_error("sensors_get_label","Allocating label text"); 
    145145        return 0; 
     
    183183   contain wildcard values! This function will return 0 on success, and <0 
    184184   on failure.  */ 
    185 int sensors_set_value(sensors_chip_name name, int feature, double value) 
     185int sensors_set_feature(sensors_chip_name name, int feature, double value) 
    186186{ 
    187187  sensors_chip_feature *featureptr; 
     
    215215  return res; 
    216216} 
     217 
     218const char *sensors_get_adapter_name(int bus_nr) 
     219{ 
     220  int i; 
     221  if (bus_nr == SENSORS_CHIP_NAME_BUS_ISA) 
     222    return "ISA adapter"; 
     223  for (i=0; i < sensors_proc_bus_count; i++) 
     224    if (sensors_proc_bus[i].number == bus_nr) 
     225      return sensors_proc_bus[i].adapter; 
     226  return NULL; 
     227} 
     228 
     229const char *sensors_get_algorithm_name(int bus_nr) 
     230{ 
     231  int i; 
     232  if (bus_nr == SENSORS_CHIP_NAME_BUS_ISA) 
     233    return "ISA algorithm"; 
     234  for (i=0; i < sensors_proc_bus_count; i++) 
     235    if (sensors_proc_bus[i].number == bus_nr) 
     236      return sensors_proc_bus[i].algorithm; 
     237  return NULL; 
     238} 
  • lm-sensors/trunk/lib/sensors.h

    r102 r103  
    6161extern int sensors_chip_name_has_wildcards(sensors_chip_name chip); 
    6262 
     63/* These functions return the adapter and algorithm names of a bus number, 
     64   as used within the sensors_chip_name structure. If it could not be found,  
     65   it returns NULL */ 
     66extern const char *sensors_get_adapter_name(int bus_nr); 
     67extern const char *sensors_get_algorithm_name(int bus_nr); 
     68 
    6369/* Look up the label which belongs to this chip. Note that chip should not 
    6470   contain wildcard values! *result is newly allocated (free it yourself). 
     
    7682   contain wildcard values! This function will return 0 on success, and <0 
    7783   on failure.  */ 
    78 extern int sensors_set_value(sensors_chip_name name, int feature, 
    79                              double value); 
     84extern int sensors_set_feature(sensors_chip_name name, int feature, 
     85                               double value); 
    8086 
    8187/* This function returns all detected chips, one by one. To start at the 
  • lm-sensors/trunk/prog/sensors/Module.mk

    r99 r103  
    2424# defined value verbatim into the command-list of rules... 
    2525PROGSENSORSTARGETS := $(MODULE_DIR)/sensors 
    26 PROGSENSORSSOURCES := $(MODULE_DIR)/main.c 
     26PROGSENSORSSOURCES := $(MODULE_DIR)/main.c $(MODULE_DIR)/chips.c 
    2727 
    2828# Include all dependency files. We use '.rd' to indicate this will create 
     
    3131 
    3232$(PROGSENSORSTARGETS): $(PROGSENSORSSOURCES:.c=.ro) lib/$(LIBSHBASENAME) 
    33         $(CC) -o $@ $^ -Llib -lsensors 
     33        $(CC) -o $@ $(PROGSENSORSSOURCES:.c=.ro) -Llib -lsensors 
    3434 
    3535all-prog-sensors: $(PROGSENSORSTARGETS) 
  • lm-sensors/trunk/prog/sensors/main.c

    r102 r103  
    2626#include "lib/sensors.h"  
    2727#include "lib/error.h" 
     28#include "chips.h" 
    2829 
    2930#define PROGRAM "sensors" 
     
    122123  int chip_nr; 
    123124  const sensors_chip_name *chip; 
     125  const char *algo,*adap; 
    124126 
    125127  struct option long_opts[] =  { 
     
    164166 
    165167  /* Here comes the real code... */ 
    166   printf("Detected chips:\n"); 
    167   for (chip_nr = 0; (chip = sensors_get_detected_chips(&chip_nr));) 
     168  for (chip_nr = 0; (chip = sensors_get_detected_chips(&chip_nr));) { 
    168169    if (chip->bus == SENSORS_CHIP_NAME_BUS_ISA) 
    169       printf("  %s-isa-%04x\n",chip->prefix,chip->addr); 
     170      printf("%s-isa-%04x\n",chip->prefix,chip->addr); 
    170171    else 
    171       printf("  %s-i2c-%d-%02x\n",chip->prefix,chip->bus,chip->addr); 
     172      printf("%s-i2c-%d-%02x\n",chip->prefix,chip->bus,chip->addr); 
     173    adap = sensors_get_adapter_name(chip->bus); 
     174    if (adap) 
     175      printf("Adapter: %s\n",adap); 
     176    algo = sensors_get_algorithm_name(chip->bus); 
     177    if (algo) 
     178      printf("Algorithm: %s\n",algo); 
     179    if (!algo || !adap) 
     180      printf(" ERROR: Can't get adapter or algorithm?!?\n"); 
     181    if (!strcmp(chip->prefix,"lm75")) 
     182      print_lm75(chip); 
     183     printf("\n"); 
     184  } 
    172185  exit(0); 
    173186}