Changeset 4559

Show
Ignore:
Timestamp:
07/05/07 23:03:06 (6 years ago)
Author:
jwrdegoede
Message:

Better generic print fault handling

Location:
lm-sensors/branches/lm-sensors-3.0.0/prog/sensors
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/branches/lm-sensors-3.0.0/prog/sensors/chips.c

    r4543 r4559  
    2323#include <stdlib.h> 
    2424#include <string.h> 
     25#include <math.h> 
    2526 
    2627#include "chips.h" 
     
    4243                     int minmax, int curprec, int limitprec) 
    4344{ 
     45   /* note: deg_ctof() will preserve HUGEVAL */ 
    4446   if (fahrenheit) { 
    4547      n_cur  = deg_ctof(n_cur); 
     
    4850   } 
    4951 
    50 /* use %* to pass precision as an argument */ 
     52   /* use %* to pass precision as an argument */ 
     53   if (n_cur != HUGE_VAL) 
     54      printf("%+6.*f%s  ", curprec, n_cur, degstr); 
     55   else 
     56      printf("FAULT     "); 
     57 
    5158   if(minmax == MINMAX) 
    52         printf("%+6.*f%s  (low  = %+5.*f%s, high = %+5.*f%s)  ", 
    53             curprec, n_cur, degstr, 
     59        printf("(low  = %+5.*f%s, high = %+5.*f%s)  ", 
    5460            limitprec, n_hyst, degstr, 
    5561            limitprec, n_over, degstr); 
    5662   else if(minmax == MAXONLY) 
    57         printf("%+6.*f%s  (high = %+5.*f%s)                  ", 
    58             curprec, n_cur, degstr, 
     63        printf("(high = %+5.*f%s)                  ", 
    5964            limitprec, n_over, degstr); 
    6065   else if(minmax == CRIT) 
    61         printf("%+6.*f%s  (high = %+5.*f%s, crit = %+5.*f%s)  ", 
    62             curprec, n_cur, degstr, 
     66        printf("(high = %+5.*f%s, crit = %+5.*f%s)  ", 
    6367            limitprec, n_over, degstr, 
    6468            limitprec, n_hyst, degstr); 
    6569   else if(minmax == HYST) 
    66         printf("%+6.*f%s  (high = %+5.*f%s, hyst = %+5.*f%s)  ", 
    67             curprec, n_cur, degstr, 
     70        printf("(high = %+5.*f%s, hyst = %+5.*f%s)  ", 
    6871            limitprec, n_over, degstr, 
    6972            limitprec, n_hyst, degstr); 
    70    else if(minmax == SINGLE) 
    71         printf("%+6.*f%s", 
    72             curprec, n_cur, degstr); 
    7373   else if(minmax == HYSTONLY) 
    74         printf("%+6.*f%s  (hyst = %+5.*f%s)                  ", 
    75             curprec, n_cur, degstr, 
     74        printf("(hyst = %+5.*f%s)                  ", 
    7675            limitprec, n_over, degstr); 
    77    else 
     76   else if(minmax != SINGLE) 
    7877        printf("Unknown temperature mode!"); 
    7978} 
  • lm-sensors/branches/lm-sensors-3.0.0/prog/sensors/chips_generic.c

    r4556 r4559  
    2222#include <stdlib.h> 
    2323#include <string.h> 
     24#include <math.h> 
    2425 
    2526#include "chips_generic.h" 
     
    152153  } 
    153154   
     155  if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_FAULT) && 
     156      TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_FAULT)) 
     157    val = HUGE_VAL; 
     158   
    154159  print_label(label, label_size); 
    155160  free(label); 
     
    170175  } 
    171176   
    172   /* ALARM and FAULT features */ 
    173   if (TEMP_FEATURE(SENSORS_FEATURE_TEMP_FAULT) && 
    174       TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_FAULT) > 0.5) { 
    175     printf(" FAULT"); 
    176   } else 
     177  /* ALARM features */ 
    177178  if ((TEMP_FEATURE(SENSORS_FEATURE_TEMP_ALARM) &&  
    178179       TEMP_FEATURE_VAL(SENSORS_FEATURE_TEMP_ALARM) > 0.5) 
     
    315316  print_label(label, label_size); 
    316317  free(label); 
    317   printf("%4.0f RPM", val); 
     318 
     319  if (FAN_FEATURE(SENSORS_FEATURE_FAN_FAULT) && 
     320      FAN_FEATURE_VAL(SENSORS_FEATURE_FAN_FAULT)) 
     321    printf("FAULT   "); 
     322  else 
     323    printf("%4.0f RPM", val); 
    318324   
    319325  sensors_get_available_features(name, feature, i, j, has_features, feature_vals, 
     
    330336    printf("  (div = %1.0f)", FAN_FEATURE_VAL(SENSORS_FEATURE_FAN_DIV)); 
    331337   
    332   /* ALARM and FAULT features */ 
    333   if (FAN_FEATURE(SENSORS_FEATURE_FAN_FAULT) && 
    334       FAN_FEATURE_VAL(SENSORS_FEATURE_FAN_FAULT)) { 
    335     printf(" FAULT"); 
    336   } else 
    337338  if (FAN_FEATURE(SENSORS_FEATURE_FAN_ALARM) &&  
    338339      FAN_FEATURE_VAL(SENSORS_FEATURE_FAN_ALARM)) {