mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-31 06:15:15 +00:00
Add support for current sensors.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5379 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -3,8 +3,10 @@ lm-sensors CHANGES file
|
||||
|
||||
SVN-HEAD
|
||||
libsensors: Add support for instantaneous power sensors
|
||||
Add support for current sensors
|
||||
maxilife scripts: Delete (driver never ported to Linux 2.6)
|
||||
sensors: Add support for instantaneous power sensors
|
||||
Add support for current sensors
|
||||
sensors-detect: Fix detection of ADT7463 and LM96000
|
||||
Add VIA VX800/VX820 support
|
||||
Fix detection of Intel 5000 series FB-DIMM AMB
|
||||
|
@@ -11,6 +11,15 @@ given new feature.
|
||||
enum sensors_subfeature_type SENSORS_SUBFEATURE_POWER_INPUT
|
||||
enum sensors_subfeature_type SENSORS_SUBFEATURE_POWER_INPUT_HIGHEST
|
||||
enum sensors_subfeature_type SENSORS_SUBFEATURE_POWER_INPUT_LOWEST
|
||||
* Added support for current sensors
|
||||
enum sensors_feature_type SENSORS_FEATURE_CURR
|
||||
enum sensors_subfeature_type SENSORS_SUBFEATURE_CURR_INPUT
|
||||
enum sensors_subfeature_type SENSORS_SUBFEATURE_CURR_MIN
|
||||
enum sensors_subfeature_type SENSORS_SUBFEATURE_CURR_MAX
|
||||
enum sensors_subfeature_type SENSORS_SUBFEATURE_CURR_ALARM
|
||||
enum sensors_subfeature_type SENSORS_SUBFEATURE_CURR_MIN_ALARM
|
||||
enum sensors_subfeature_type SENSORS_SUBFEATURE_CURR_MAX_ALARM
|
||||
enum sensors_subfeature_type SENSORS_SUBFEATURE_CURR_BEEP
|
||||
|
||||
0x401 lm-sensors 3.0.2 to 3.0.3
|
||||
* Added bus type "virtual":
|
||||
|
@@ -134,6 +134,7 @@ typedef enum sensors_feature_type {
|
||||
SENSORS_FEATURE_TEMP = 0x02,
|
||||
SENSORS_FEATURE_POWER = 0x03,
|
||||
SENSORS_FEATURE_ENERGY = 0x04,
|
||||
SENSORS_FEATURE_CURR = 0x05,
|
||||
SENSORS_FEATURE_VID = 0x10,
|
||||
SENSORS_FEATURE_BEEP_ENABLE = 0x18,
|
||||
SENSORS_FEATURE_UNKNOWN = INT_MAX,
|
||||
@@ -182,6 +183,14 @@ typedef enum sensors_subfeature_type {
|
||||
|
||||
SENSORS_SUBFEATURE_ENERGY_INPUT = SENSORS_FEATURE_ENERGY << 8,
|
||||
|
||||
SENSORS_SUBFEATURE_CURR_INPUT = SENSORS_FEATURE_CURR << 8,
|
||||
SENSORS_SUBFEATURE_CURR_MIN,
|
||||
SENSORS_SUBFEATURE_CURR_MAX,
|
||||
SENSORS_SUBFEATURE_CURR_ALARM = (SENSORS_FEATURE_CURR << 8) | 0x80,
|
||||
SENSORS_SUBFEATURE_CURR_MIN_ALARM,
|
||||
SENSORS_SUBFEATURE_CURR_MAX_ALARM,
|
||||
SENSORS_SUBFEATURE_CURR_BEEP,
|
||||
|
||||
SENSORS_SUBFEATURE_VID = SENSORS_FEATURE_VID << 8,
|
||||
|
||||
SENSORS_SUBFEATURE_BEEP_ENABLE = SENSORS_FEATURE_BEEP_ENABLE << 8,
|
||||
|
16
lib/sysfs.c
16
lib/sysfs.c
@@ -138,7 +138,7 @@ char sensors_sysfs_mount[NAME_MAX];
|
||||
|
||||
#define MAX_SENSORS_PER_TYPE 20
|
||||
#define MAX_SUBFEATURES 8
|
||||
#define MAX_SENSOR_TYPES 5
|
||||
#define MAX_SENSOR_TYPES 6
|
||||
/* Room for all 5 types (in, fan, temp, power, energy) with all their
|
||||
subfeatures + VID + misc features */
|
||||
#define ALL_POSSIBLE_SUBFEATURES \
|
||||
@@ -153,6 +153,7 @@ int get_type_scaling(sensors_subfeature_type type)
|
||||
switch (type & 0xFF80) {
|
||||
case SENSORS_SUBFEATURE_IN_INPUT:
|
||||
case SENSORS_SUBFEATURE_TEMP_INPUT:
|
||||
case SENSORS_SUBFEATURE_CURR_INPUT:
|
||||
return 1000;
|
||||
case SENSORS_SUBFEATURE_FAN_INPUT:
|
||||
return 1;
|
||||
@@ -184,6 +185,7 @@ char *get_feature_name(sensors_feature_type ftype, char *sfname)
|
||||
case SENSORS_FEATURE_TEMP:
|
||||
case SENSORS_FEATURE_POWER:
|
||||
case SENSORS_FEATURE_ENERGY:
|
||||
case SENSORS_FEATURE_CURR:
|
||||
underscore = strchr(sfname, '_');
|
||||
name = strndup(sfname, underscore - sfname);
|
||||
break;
|
||||
@@ -259,6 +261,16 @@ static const struct subfeature_type_match energy_matches[] = {
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static const struct subfeature_type_match curr_matches[] = {
|
||||
{ "input", SENSORS_SUBFEATURE_CURR_INPUT },
|
||||
{ "min", SENSORS_SUBFEATURE_CURR_MIN },
|
||||
{ "max", SENSORS_SUBFEATURE_CURR_MAX },
|
||||
{ "alarm", SENSORS_SUBFEATURE_CURR_ALARM },
|
||||
{ "min_alarm", SENSORS_SUBFEATURE_CURR_MIN_ALARM },
|
||||
{ "max_alarm", SENSORS_SUBFEATURE_CURR_MAX_ALARM },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static const struct subfeature_type_match cpu_matches[] = {
|
||||
{ "vid", SENSORS_SUBFEATURE_VID },
|
||||
{ NULL, 0 }
|
||||
@@ -270,6 +282,7 @@ static struct feature_type_match matches[] = {
|
||||
{ "fan%d%c", fan_matches },
|
||||
{ "cpu%d%c", cpu_matches },
|
||||
{ "power%d%c", power_matches },
|
||||
{ "curr%d%c", curr_matches },
|
||||
{ "energy%d%c", energy_matches },
|
||||
};
|
||||
|
||||
@@ -360,6 +373,7 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
|
||||
case SENSORS_SUBFEATURE_TEMP_INPUT:
|
||||
case SENSORS_SUBFEATURE_POWER_AVERAGE:
|
||||
case SENSORS_SUBFEATURE_ENERGY_INPUT:
|
||||
case SENSORS_SUBFEATURE_CURR_INPUT:
|
||||
nr--;
|
||||
break;
|
||||
}
|
||||
|
@@ -578,6 +578,72 @@ static void print_chip_beep_enable(const sensors_chip_name *name,
|
||||
free(label);
|
||||
}
|
||||
|
||||
static void print_chip_curr(const sensors_chip_name *name,
|
||||
const sensors_feature *feature,
|
||||
int label_size)
|
||||
{
|
||||
const sensors_subfeature *sf, *sfmin, *sfmax;
|
||||
double alarm_max, alarm_min;
|
||||
char *label;
|
||||
|
||||
if (!(label = sensors_get_label(name, feature))) {
|
||||
fprintf(stderr, "ERROR: Can't get label of feature %s!\n",
|
||||
feature->name);
|
||||
return;
|
||||
}
|
||||
print_label(label, label_size);
|
||||
free(label);
|
||||
|
||||
sf = sensors_get_subfeature(name, feature,
|
||||
SENSORS_SUBFEATURE_CURR_INPUT);
|
||||
if (sf)
|
||||
printf("%+6.2f A", get_value(name, sf));
|
||||
else
|
||||
printf(" N/A");
|
||||
|
||||
sfmin = sensors_get_subfeature(name, feature,
|
||||
SENSORS_SUBFEATURE_CURR_MIN);
|
||||
sfmax = sensors_get_subfeature(name, feature,
|
||||
SENSORS_SUBFEATURE_CURR_MAX);
|
||||
if (sfmin && sfmax)
|
||||
printf(" (min = %+6.2f A, max = %+6.2f A)",
|
||||
get_value(name, sfmin),
|
||||
get_value(name, sfmax));
|
||||
else if (sfmin)
|
||||
printf(" (min = %+6.2f A)",
|
||||
get_value(name, sfmin));
|
||||
else if (sfmax)
|
||||
printf(" (max = %+6.2f A)",
|
||||
get_value(name, sfmax));
|
||||
|
||||
sf = sensors_get_subfeature(name, feature,
|
||||
SENSORS_SUBFEATURE_CURR_ALARM);
|
||||
sfmin = sensors_get_subfeature(name, feature,
|
||||
SENSORS_SUBFEATURE_CURR_MIN_ALARM);
|
||||
sfmax = sensors_get_subfeature(name, feature,
|
||||
SENSORS_SUBFEATURE_CURR_MAX_ALARM);
|
||||
if (sfmin || sfmax) {
|
||||
alarm_max = sfmax ? get_value(name, sfmax) : 0;
|
||||
alarm_min = sfmin ? get_value(name, sfmin) : 0;
|
||||
|
||||
if (alarm_min || alarm_max) {
|
||||
printf(" ALARM (");
|
||||
|
||||
if (alarm_min)
|
||||
printf("MIN");
|
||||
if (alarm_max)
|
||||
printf("%sMAX", (alarm_min) ? ", " : "");
|
||||
|
||||
printf(")");
|
||||
}
|
||||
} else if (sf) {
|
||||
printf(" %s",
|
||||
get_value(name, sf) ? "ALARM" : "");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_chip(const sensors_chip_name *name)
|
||||
{
|
||||
const sensors_feature *feature;
|
||||
@@ -609,6 +675,9 @@ void print_chip(const sensors_chip_name *name)
|
||||
case SENSORS_FEATURE_ENERGY:
|
||||
print_chip_energy(name, feature, label_size);
|
||||
break;
|
||||
case SENSORS_FEATURE_CURR:
|
||||
print_chip_curr(name, feature, label_size);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user