diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c index c949456d..7ec0f448 100644 --- a/prog/sensors/chips.c +++ b/prog/sensors/chips.c @@ -22,6 +22,7 @@ #include #include #include +#include #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!"); } diff --git a/prog/sensors/chips_generic.c b/prog/sensors/chips_generic.c index 3bc9f8e9..28bd2a56 100644 --- a/prog/sensors/chips_generic.c +++ b/prog/sensors/chips_generic.c @@ -21,6 +21,7 @@ #include #include +#include #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");