mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-30 13:57:41 +00:00
Better generic print fault handling
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4559 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
parent
83fe82736d
commit
4d2fa4eadd
@ -22,6 +22,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chips.h"
|
||||
#include "lib/sensors.h"
|
||||
@ -41,40 +42,38 @@ static inline float deg_ctof(float cel)
|
||||
void print_temp_info(float n_cur, float n_over, float n_hyst,
|
||||
int minmax, int curprec, int limitprec)
|
||||
{
|
||||
/* note: deg_ctof() will preserve HUGEVAL */
|
||||
if (fahrenheit) {
|
||||
n_cur = deg_ctof(n_cur);
|
||||
n_over = deg_ctof(n_over);
|
||||
n_hyst = deg_ctof(n_hyst);
|
||||
}
|
||||
|
||||
/* use %* to pass precision as an argument */
|
||||
/* use %* to pass precision as an argument */
|
||||
if (n_cur != HUGE_VAL)
|
||||
printf("%+6.*f%s ", curprec, n_cur, degstr);
|
||||
else
|
||||
printf("FAULT ");
|
||||
|
||||
if(minmax == MINMAX)
|
||||
printf("%+6.*f%s (low = %+5.*f%s, high = %+5.*f%s) ",
|
||||
curprec, n_cur, degstr,
|
||||
printf("(low = %+5.*f%s, high = %+5.*f%s) ",
|
||||
limitprec, n_hyst, degstr,
|
||||
limitprec, n_over, degstr);
|
||||
else if(minmax == MAXONLY)
|
||||
printf("%+6.*f%s (high = %+5.*f%s) ",
|
||||
curprec, n_cur, degstr,
|
||||
printf("(high = %+5.*f%s) ",
|
||||
limitprec, n_over, degstr);
|
||||
else if(minmax == CRIT)
|
||||
printf("%+6.*f%s (high = %+5.*f%s, crit = %+5.*f%s) ",
|
||||
curprec, n_cur, degstr,
|
||||
printf("(high = %+5.*f%s, crit = %+5.*f%s) ",
|
||||
limitprec, n_over, degstr,
|
||||
limitprec, n_hyst, degstr);
|
||||
else if(minmax == HYST)
|
||||
printf("%+6.*f%s (high = %+5.*f%s, hyst = %+5.*f%s) ",
|
||||
curprec, n_cur, degstr,
|
||||
printf("(high = %+5.*f%s, hyst = %+5.*f%s) ",
|
||||
limitprec, n_over, degstr,
|
||||
limitprec, n_hyst, degstr);
|
||||
else if(minmax == SINGLE)
|
||||
printf("%+6.*f%s",
|
||||
curprec, n_cur, degstr);
|
||||
else if(minmax == HYSTONLY)
|
||||
printf("%+6.*f%s (hyst = %+5.*f%s) ",
|
||||
curprec, n_cur, degstr,
|
||||
printf("(hyst = %+5.*f%s) ",
|
||||
limitprec, n_over, degstr);
|
||||
else
|
||||
else if(minmax != SINGLE)
|
||||
printf("Unknown temperature mode!");
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chips_generic.h"
|
||||
#include "chips.h"
|
||||
@ -151,6 +152,10 @@ static void print_generic_chip_temp(const sensors_chip_name *name,
|
||||
type = SINGLE;
|
||||
}
|
||||
|
||||
if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_FAULT) &&
|
||||
TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_FAULT))
|
||||
val = HUGE_VAL;
|
||||
|
||||
print_label(label, label_size);
|
||||
free(label);
|
||||
|
||||
@ -169,11 +174,7 @@ static void print_generic_chip_temp(const sensors_chip_name *name,
|
||||
"unknown");
|
||||
}
|
||||
|
||||
/* ALARM and FAULT features */
|
||||
if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_FAULT) &&
|
||||
TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_FAULT) > 0.5) {
|
||||
printf(" FAULT");
|
||||
} else
|
||||
/* ALARM features */
|
||||
if ((TEMP_FEATURE(SENSORS_FEATURE_TEMP_ALARM) &&
|
||||
TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_ALARM) > 0.5)
|
||||
|| (type == MINMAX &&
|
||||
@ -314,7 +315,12 @@ static void print_generic_chip_fan(const sensors_chip_name *name,
|
||||
|
||||
print_label(label, label_size);
|
||||
free(label);
|
||||
printf("%4.0f RPM", val);
|
||||
|
||||
if (FAN_FEATURE(SENSORS_FEATURE_FAN_FAULT) &&
|
||||
FAN_FEATURE_VAL(SENSORS_FEATURE_FAN_FAULT))
|
||||
printf("FAULT ");
|
||||
else
|
||||
printf("%4.0f RPM", val);
|
||||
|
||||
sensors_get_available_features(name, feature, i, j, has_features, feature_vals,
|
||||
size, SENSORS_FEATURE_FAN);
|
||||
@ -329,11 +335,6 @@ static void print_generic_chip_fan(const sensors_chip_name *name,
|
||||
else if (FAN_FEATURE(SENSORS_FEATURE_FAN_DIV))
|
||||
printf(" (div = %1.0f)", FAN_FEATURE_VAL(SENSORS_FEATURE_FAN_DIV));
|
||||
|
||||
/* ALARM and FAULT features */
|
||||
if (FAN_FEATURE(SENSORS_FEATURE_FAN_FAULT) &&
|
||||
FAN_FEATURE_VAL(SENSORS_FEATURE_FAN_FAULT)) {
|
||||
printf(" FAULT");
|
||||
} else
|
||||
if (FAN_FEATURE(SENSORS_FEATURE_FAN_ALARM) &&
|
||||
FAN_FEATURE_VAL(SENSORS_FEATURE_FAN_ALARM)) {
|
||||
printf(" ALARM");
|
||||
|
Loading…
x
Reference in New Issue
Block a user