mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-30 05:48:07 +00:00
Restore support for alarms.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4825 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
parent
071e4a8008
commit
36ded1b5fc
@ -191,6 +191,19 @@ static void fillChipVoltage (FeatureDescriptor *voltage,
|
||||
|
||||
/* terminate the list */
|
||||
voltage->dataNumbers[pos] = -1;
|
||||
|
||||
/* alarm if applicable */
|
||||
if (IN_FEATURE(SENSORS_FEATURE_IN_ALARM)) {
|
||||
voltage->alarmNumber = IN_FEATURE_NR(SENSORS_FEATURE_IN_ALARM);
|
||||
} else if (IN_FEATURE(SENSORS_FEATURE_IN_MIN_ALARM)) {
|
||||
voltage->alarmNumber = IN_FEATURE_NR(SENSORS_FEATURE_IN_MIN_ALARM);
|
||||
} else if (IN_FEATURE(SENSORS_FEATURE_IN_MAX_ALARM)) {
|
||||
voltage->alarmNumber = IN_FEATURE_NR(SENSORS_FEATURE_IN_MAX_ALARM);
|
||||
} else {
|
||||
voltage->alarmNumber = -1;
|
||||
}
|
||||
/* beep support missing for now */
|
||||
voltage->beepNumber = -1;
|
||||
}
|
||||
|
||||
#define TEMP_FEATURE(x) has_features[x - SENSORS_FEATURE_TEMP - 1]
|
||||
@ -227,6 +240,17 @@ static void fillChipTemperature (FeatureDescriptor *temperature,
|
||||
|
||||
/* terminate the list */
|
||||
temperature->dataNumbers[pos] = -1;
|
||||
|
||||
/* alarm if applicable */
|
||||
if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_ALARM)) {
|
||||
temperature->alarmNumber = TEMP_FEATURE_NR(SENSORS_FEATURE_TEMP_ALARM);
|
||||
} else if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_MAX_ALARM)) {
|
||||
temperature->alarmNumber = TEMP_FEATURE_NR(SENSORS_FEATURE_TEMP_MAX_ALARM);
|
||||
} else {
|
||||
temperature->alarmNumber = -1;
|
||||
}
|
||||
/* beep support missing for now */
|
||||
temperature->beepNumber = -1;
|
||||
}
|
||||
|
||||
#define FAN_FEATURE(x) has_features[x - SENSORS_FEATURE_FAN - 1]
|
||||
@ -261,6 +285,15 @@ static void fillChipFan (FeatureDescriptor *fan,
|
||||
|
||||
/* terminate the list */
|
||||
fan->dataNumbers[pos] = -1;
|
||||
|
||||
/* alarm if applicable */
|
||||
if (FAN_FEATURE(SENSORS_FEATURE_FAN_ALARM)) {
|
||||
fan->alarmNumber = FAN_FEATURE_NR(SENSORS_FEATURE_FAN_ALARM);
|
||||
} else {
|
||||
fan->alarmNumber = -1;
|
||||
}
|
||||
/* beep support missing for now */
|
||||
fan->beepNumber = -1;
|
||||
}
|
||||
|
||||
static void fillChipVid (FeatureDescriptor *vid,
|
||||
@ -269,6 +302,8 @@ static void fillChipVid (FeatureDescriptor *vid,
|
||||
vid->format = fmtVolt_3;
|
||||
vid->rrd = rrdF3;
|
||||
vid->type = DataType_voltage;
|
||||
vid->alarmNumber = -1;
|
||||
vid->beepNumber = -1;
|
||||
vid->dataNumbers[0] = feature->number;
|
||||
vid->dataNumbers[1] = -1;
|
||||
}
|
||||
@ -279,6 +314,8 @@ static void fillChipBeepEnable (FeatureDescriptor *beepen,
|
||||
beepen->format = fmtSoundAlarm;
|
||||
beepen->rrd = rrdF0;
|
||||
beepen->type = DataType_other;
|
||||
beepen->alarmNumber = -1;
|
||||
beepen->beepNumber = -1;
|
||||
beepen->dataNumbers[0] = feature->number;
|
||||
beepen->dataNumbers[1] = -1;
|
||||
}
|
||||
|
@ -76,44 +76,46 @@ static int
|
||||
doKnownChip
|
||||
(const sensors_chip_name *chip, const ChipDescriptor *descriptor, int action) {
|
||||
const FeatureDescriptor *features = descriptor->features;
|
||||
int alarms = 0, beeps = 0;
|
||||
int index0, subindex;
|
||||
int ret = 0;
|
||||
double tmp;
|
||||
|
||||
if (action == DO_READ)
|
||||
ret = idChip (chip);
|
||||
if (!ret && descriptor->alarmNumber) {
|
||||
if ((ret = sensors_get_value (chip, descriptor->alarmNumber, &tmp))) {
|
||||
sensorLog (LOG_ERR, "Error getting sensor data: %s/#%d: %s", chip->prefix, descriptor->alarmNumber, sensors_strerror (ret));
|
||||
ret = 20;
|
||||
} else {
|
||||
alarms = (int) (tmp + 0.5);
|
||||
}
|
||||
}
|
||||
if (!ret && descriptor->beepNumber) {
|
||||
if ((ret = sensors_get_value (chip, descriptor->beepNumber, &tmp))) {
|
||||
sensorLog (LOG_ERR, "Error getting sensor data: %s/#%d: %s", chip->prefix, descriptor->beepNumber, sensors_strerror (ret));
|
||||
ret = 21;
|
||||
} else {
|
||||
beeps = (int) (tmp + 0.5);
|
||||
}
|
||||
}
|
||||
for (index0 = 0; (ret == 0) && features[index0].format; ++ index0) {
|
||||
const FeatureDescriptor *feature = features + index0;
|
||||
int labelNumber = feature->dataNumbers[0];
|
||||
int alarm = alarms & feature->alarmMask;
|
||||
int beep = beeps & feature->beepMask;
|
||||
int alarm, beep;
|
||||
char *label = NULL;
|
||||
|
||||
if ((action == DO_SCAN) && !alarm) {
|
||||
continue;
|
||||
} else if (!(label = sensors_get_label (chip, labelNumber))) {
|
||||
if (!(label = sensors_get_label (chip, labelNumber))) {
|
||||
sensorLog (LOG_ERR, "Error getting sensor label: %s/#%d", chip->prefix, labelNumber);
|
||||
ret = 22;
|
||||
} else {
|
||||
double values[MAX_DATA];
|
||||
|
||||
alarm = 0;
|
||||
if (!ret && feature->alarmNumber != -1) {
|
||||
if ((ret = sensors_get_value (chip, feature->alarmNumber, &tmp))) {
|
||||
sensorLog (LOG_ERR, "Error getting sensor data: %s/#%d: %s", chip->prefix, feature->alarmNumber, sensors_strerror (ret));
|
||||
ret = 20;
|
||||
} else {
|
||||
alarm = (int) (tmp + 0.5);
|
||||
}
|
||||
}
|
||||
if ((action == DO_SCAN) && !alarm)
|
||||
continue;
|
||||
|
||||
beep = 0;
|
||||
if (!ret && feature->beepNumber != -1) {
|
||||
if ((ret = sensors_get_value (chip, feature->beepNumber, &tmp))) {
|
||||
sensorLog (LOG_ERR, "Error getting sensor data: %s/#%d: %s", chip->prefix, feature->beepNumber, sensors_strerror (ret));
|
||||
ret = 21;
|
||||
} else {
|
||||
beep = (int) (tmp + 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
for (subindex = 0; !ret && (feature->dataNumbers[subindex] >= 0); ++ subindex) {
|
||||
if ((ret = sensors_get_value (chip, feature->dataNumbers[subindex], values + subindex))) {
|
||||
sensorLog (LOG_ERR, "Error getting sensor data: %s/#%d: %s", chip->prefix, feature->dataNumbers[subindex], sensors_strerror (ret));
|
||||
|
@ -89,15 +89,13 @@ typedef struct {
|
||||
FormatterFN format;
|
||||
RRDFN rrd;
|
||||
DataType type;
|
||||
int alarmMask;
|
||||
int beepMask;
|
||||
int alarmNumber;
|
||||
int beepNumber;
|
||||
int dataNumbers[MAX_DATA + 1]; /* First entry is used for the label */
|
||||
} FeatureDescriptor;
|
||||
|
||||
typedef struct {
|
||||
FeatureDescriptor *features;
|
||||
int alarmNumber;
|
||||
int beepNumber;
|
||||
} ChipDescriptor;
|
||||
|
||||
extern ChipDescriptor * generateChipDescriptor (const sensors_chip_name *chip);
|
||||
|
Loading…
x
Reference in New Issue
Block a user