mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-31 06:15:15 +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:
@@ -22,6 +22,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "chips.h"
|
#include "chips.h"
|
||||||
#include "lib/sensors.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,
|
void print_temp_info(float n_cur, float n_over, float n_hyst,
|
||||||
int minmax, int curprec, int limitprec)
|
int minmax, int curprec, int limitprec)
|
||||||
{
|
{
|
||||||
|
/* note: deg_ctof() will preserve HUGEVAL */
|
||||||
if (fahrenheit) {
|
if (fahrenheit) {
|
||||||
n_cur = deg_ctof(n_cur);
|
n_cur = deg_ctof(n_cur);
|
||||||
n_over = deg_ctof(n_over);
|
n_over = deg_ctof(n_over);
|
||||||
n_hyst = deg_ctof(n_hyst);
|
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)
|
if(minmax == MINMAX)
|
||||||
printf("%+6.*f%s (low = %+5.*f%s, high = %+5.*f%s) ",
|
printf("(low = %+5.*f%s, high = %+5.*f%s) ",
|
||||||
curprec, n_cur, degstr,
|
|
||||||
limitprec, n_hyst, degstr,
|
limitprec, n_hyst, degstr,
|
||||||
limitprec, n_over, degstr);
|
limitprec, n_over, degstr);
|
||||||
else if(minmax == MAXONLY)
|
else if(minmax == MAXONLY)
|
||||||
printf("%+6.*f%s (high = %+5.*f%s) ",
|
printf("(high = %+5.*f%s) ",
|
||||||
curprec, n_cur, degstr,
|
|
||||||
limitprec, n_over, degstr);
|
limitprec, n_over, degstr);
|
||||||
else if(minmax == CRIT)
|
else if(minmax == CRIT)
|
||||||
printf("%+6.*f%s (high = %+5.*f%s, crit = %+5.*f%s) ",
|
printf("(high = %+5.*f%s, crit = %+5.*f%s) ",
|
||||||
curprec, n_cur, degstr,
|
|
||||||
limitprec, n_over, degstr,
|
limitprec, n_over, degstr,
|
||||||
limitprec, n_hyst, degstr);
|
limitprec, n_hyst, degstr);
|
||||||
else if(minmax == HYST)
|
else if(minmax == HYST)
|
||||||
printf("%+6.*f%s (high = %+5.*f%s, hyst = %+5.*f%s) ",
|
printf("(high = %+5.*f%s, hyst = %+5.*f%s) ",
|
||||||
curprec, n_cur, degstr,
|
|
||||||
limitprec, n_over, degstr,
|
limitprec, n_over, degstr,
|
||||||
limitprec, n_hyst, degstr);
|
limitprec, n_hyst, degstr);
|
||||||
else if(minmax == SINGLE)
|
|
||||||
printf("%+6.*f%s",
|
|
||||||
curprec, n_cur, degstr);
|
|
||||||
else if(minmax == HYSTONLY)
|
else if(minmax == HYSTONLY)
|
||||||
printf("%+6.*f%s (hyst = %+5.*f%s) ",
|
printf("(hyst = %+5.*f%s) ",
|
||||||
curprec, n_cur, degstr,
|
|
||||||
limitprec, n_over, degstr);
|
limitprec, n_over, degstr);
|
||||||
else
|
else if(minmax != SINGLE)
|
||||||
printf("Unknown temperature mode!");
|
printf("Unknown temperature mode!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "chips_generic.h"
|
#include "chips_generic.h"
|
||||||
#include "chips.h"
|
#include "chips.h"
|
||||||
@@ -151,6 +152,10 @@ static void print_generic_chip_temp(const sensors_chip_name *name,
|
|||||||
type = SINGLE;
|
type = SINGLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_FAULT) &&
|
||||||
|
TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_FAULT))
|
||||||
|
val = HUGE_VAL;
|
||||||
|
|
||||||
print_label(label, label_size);
|
print_label(label, label_size);
|
||||||
free(label);
|
free(label);
|
||||||
|
|
||||||
@@ -169,11 +174,7 @@ static void print_generic_chip_temp(const sensors_chip_name *name,
|
|||||||
"unknown");
|
"unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ALARM and FAULT features */
|
/* ALARM features */
|
||||||
if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_FAULT) &&
|
|
||||||
TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_FAULT) > 0.5) {
|
|
||||||
printf(" FAULT");
|
|
||||||
} else
|
|
||||||
if ((TEMP_FEATURE(SENSORS_FEATURE_TEMP_ALARM) &&
|
if ((TEMP_FEATURE(SENSORS_FEATURE_TEMP_ALARM) &&
|
||||||
TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_ALARM) > 0.5)
|
TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_ALARM) > 0.5)
|
||||||
|| (type == MINMAX &&
|
|| (type == MINMAX &&
|
||||||
@@ -314,7 +315,12 @@ static void print_generic_chip_fan(const sensors_chip_name *name,
|
|||||||
|
|
||||||
print_label(label, label_size);
|
print_label(label, label_size);
|
||||||
free(label);
|
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,
|
sensors_get_available_features(name, feature, i, j, has_features, feature_vals,
|
||||||
size, SENSORS_FEATURE_FAN);
|
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))
|
else if (FAN_FEATURE(SENSORS_FEATURE_FAN_DIV))
|
||||||
printf(" (div = %1.0f)", FAN_FEATURE_VAL(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) &&
|
if (FAN_FEATURE(SENSORS_FEATURE_FAN_ALARM) &&
|
||||||
FAN_FEATURE_VAL(SENSORS_FEATURE_FAN_ALARM)) {
|
FAN_FEATURE_VAL(SENSORS_FEATURE_FAN_ALARM)) {
|
||||||
printf(" ALARM");
|
printf(" ALARM");
|
||||||
|
Reference in New Issue
Block a user