2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-30 13:57:41 +00:00

(mds) modify the print_temp_info() routine that was added in the

Fahrenheit patch so that it will print either limit/hysteresis
      or min/max. Add a flag to each call to select the right one.
      Change temp output to be %3.1f. Some chips are 1 degree accuracy,
      some are .5, the 686a is less. For now since it is a common
      routine use one decimal point. In future maybe add another
      parameter to the routine to specify accuracy.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@939 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Mark D. Studebaker
2000-11-30 02:42:53 +00:00
parent 6dadf068b2
commit a1952c601f

View File

@@ -28,7 +28,7 @@
static char *spacestr(int n); static char *spacestr(int n);
static void print_label(const char *label, int space); static void print_label(const char *label, int space);
static void free_the_label(char **label); static void free_the_label(char **label);
static void print_temp_info( float, float, float ); static void print_temp_info( float, float, float, int );
static inline float deg_ctof( float ); static inline float deg_ctof( float );
extern int fahrenheit; extern int fahrenheit;
@@ -48,7 +48,10 @@ inline float deg_ctof( float cel )
return ( cel * ( 9.0F / 5.0F ) + 32.0F ); return ( cel * ( 9.0F / 5.0F ) + 32.0F );
} }
void print_temp_info( float cur, float over, float hyst ) #define HYST 0
#define MINMAX 1
/* minmax = 0 for limit/hysteresis, 1 for max/min */
void print_temp_info( float cur, float over, float hyst, int minmax )
{ {
char degv[5]; char degv[5];
@@ -71,7 +74,11 @@ void print_temp_info( float cur, float over, float hyst )
n_hyst = hyst; n_hyst = hyst;
} }
printf( "%+3.0f%s (limit = %+3.0f%s, hysteresis = %+3.0f%s)", if(minmax == MINMAX)
printf( "%+3.1f%s (min = %+3.0f%s, max = %+3.0f%s)",
n_cur, degv, n_hyst, degv, n_over, degv );
else
printf( "%+3.1f%s (limit = %+3.0f%s, hysteresis = %+3.0f%s)",
n_cur, degv, n_over, degv, n_hyst, degv ); n_cur, degv, n_over, degv, n_hyst, degv );
} }
@@ -154,7 +161,7 @@ void print_lm75(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_LM75_TEMP_OVER,&over)) { !sensors_get_feature(*name,SENSORS_LM75_TEMP_OVER,&over)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, over, hyst ); print_temp_info( cur, over, hyst, HYST );
printf( "\n" ); printf( "\n" );
} }
} else } else
@@ -181,7 +188,7 @@ void print_adm1021(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_ADM1021_TEMP_OVER,&over)) { !sensors_get_feature(*name,SENSORS_ADM1021_TEMP_OVER,&over)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, over, hyst ); print_temp_info( cur, over, hyst, MINMAX );
if (alarms & (ADM1021_ALARM_TEMP_HIGH | ADM1021_ALARM_TEMP_LOW)) { if (alarms & (ADM1021_ALARM_TEMP_HIGH | ADM1021_ALARM_TEMP_LOW)) {
printf("ALARM ("); printf("ALARM (");
i = 0; i = 0;
@@ -206,7 +213,7 @@ void print_adm1021(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_ADM1021_REMOTE_TEMP_OVER,&over)) { !sensors_get_feature(*name,SENSORS_ADM1021_REMOTE_TEMP_OVER,&over)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, over, hyst ); print_temp_info( cur, over, hyst, MINMAX );
if (alarms & (ADM1021_ALARM_RTEMP_HIGH | ADM1021_ALARM_RTEMP_LOW | if (alarms & (ADM1021_ALARM_RTEMP_HIGH | ADM1021_ALARM_RTEMP_LOW |
ADM1021_ALARM_RTEMP_NA)) { ADM1021_ALARM_RTEMP_NA)) {
printf("ALARM ("); printf("ALARM (");
@@ -360,7 +367,7 @@ void print_adm9240(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_ADM9240_TEMP_OVER,&max)) { !sensors_get_feature(*name,SENSORS_ADM9240_TEMP_OVER,&max)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, min, max ); print_temp_info( cur, min, max, HYST );
printf( " %s\n", alarms & ADM9240_ALARM_TEMP ? "ALARM" : "" ); printf( " %s\n", alarms & ADM9240_ALARM_TEMP ? "ALARM" : "" );
} }
} else } else
@@ -479,7 +486,7 @@ void print_sis5595(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_SIS5595_TEMP_OVER,&max)) { !sensors_get_feature(*name,SENSORS_SIS5595_TEMP_OVER,&max)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, min, max ); print_temp_info( cur, min, max, HYST );
printf( " %s\n", alarms & SIS5595_ALARM_TEMP ? "ALARM" : "" ); printf( " %s\n", alarms & SIS5595_ALARM_TEMP ? "ALARM" : "" );
} }
} else } else
@@ -601,7 +608,7 @@ void print_via686a(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_VIA686A_TEMP_OVER,&max)) { !sensors_get_feature(*name,SENSORS_VIA686A_TEMP_OVER,&max)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, min, max ); print_temp_info( cur, min, max, HYST );
printf(" %s\n", alarms & VIA686A_ALARM_TEMP ? "ALARM" : "" ); printf(" %s\n", alarms & VIA686A_ALARM_TEMP ? "ALARM" : "" );
} }
} else } else
@@ -613,7 +620,7 @@ void print_via686a(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_VIA686A_TEMP2_OVER,&max)) { !sensors_get_feature(*name,SENSORS_VIA686A_TEMP2_OVER,&max)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, min, max ); print_temp_info( cur, min, max, HYST );
printf(" %s\n", alarms & VIA686A_ALARM_TEMP2 ? "ALARM" : "" ); printf(" %s\n", alarms & VIA686A_ALARM_TEMP2 ? "ALARM" : "" );
} }
} else } else
@@ -625,7 +632,7 @@ void print_via686a(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_VIA686A_TEMP3_OVER,&max)) { !sensors_get_feature(*name,SENSORS_VIA686A_TEMP3_OVER,&max)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, min, max ); print_temp_info( cur, min, max, HYST );
printf(" %s\n", alarms & VIA686A_ALARM_TEMP3 ? "ALARM" : "" ); printf(" %s\n", alarms & VIA686A_ALARM_TEMP3 ? "ALARM" : "" );
} }
} else } else
@@ -776,7 +783,7 @@ void print_lm78(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_LM78_TEMP_OVER,&max)) { !sensors_get_feature(*name,SENSORS_LM78_TEMP_OVER,&max)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf( " %s\n", alarms & LM78_ALARM_TEMP ? "ALARM" : "" ); printf( " %s\n", alarms & LM78_ALARM_TEMP ? "ALARM" : "" );
} }
} else } else
@@ -969,7 +976,7 @@ void print_gl518(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_GL518_TEMP_HYST,&min)) { !sensors_get_feature(*name,SENSORS_GL518_TEMP_HYST,&min)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf("%s %s\n", alarms&GL518_ALARM_TEMP?"ALARM":" ", printf("%s %s\n", alarms&GL518_ALARM_TEMP?"ALARM":" ",
beeps&GL518_ALARM_TEMP?"(beep)":""); beeps&GL518_ALARM_TEMP?"(beep)":"");
} }
@@ -1083,11 +1090,24 @@ void print_adm1025(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_ADM1025_TEMP1_OVER,&max)) { !sensors_get_feature(*name,SENSORS_ADM1025_TEMP1_OVER,&max)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, MINMAX );
printf(" %s\n", alarms&ADM1025_ALARM_TEMP?"ALARM":""); printf(" %s\n", alarms&ADM1025_ALARM_TEMP?"ALARM":"");
} }
} else } else
printf("ERROR: Can't get TEMP data!\n"); printf("ERROR: Can't get TEMP1 data!\n");
free_the_label(&label);
if (!sensors_get_label_and_valid(*name,SENSORS_ADM1025_TEMP2,&label,&valid) &&
!sensors_get_feature(*name,SENSORS_ADM1025_TEMP2,&cur) &&
!sensors_get_feature(*name,SENSORS_ADM1025_TEMP2_HYST,&min) &&
!sensors_get_feature(*name,SENSORS_ADM1025_TEMP2_OVER,&max)) {
if (valid) {
print_label(label,10);
print_temp_info( cur, max, min, MINMAX );
printf(" %s\n", alarms&ADM1025_ALARM_RTEMP ? "ALARM":"");
}
} else
printf("ERROR: Can't get TEMP2 data!\n");
free_the_label(&label); free_the_label(&label);
} }
@@ -1399,7 +1419,7 @@ void print_mtp008(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_MTP008_TEMP1_OVER,&max)) { !sensors_get_feature(*name,SENSORS_MTP008_TEMP1_OVER,&max)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, MINMAX );
printf(" %s\n", alarms&MTP008_ALARM_TEMP1?"ALARM":""); printf(" %s\n", alarms&MTP008_ALARM_TEMP1?"ALARM":"");
} }
} else } else
@@ -1412,7 +1432,7 @@ void print_mtp008(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_MTP008_TEMP2_OVER,&max)) { !sensors_get_feature(*name,SENSORS_MTP008_TEMP2_OVER,&max)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, MINMAX );
printf(" %s\n", alarms&MTP008_ALARM_TEMP2?"ALARM":""); printf(" %s\n", alarms&MTP008_ALARM_TEMP2?"ALARM":"");
} }
} else } else
@@ -1425,7 +1445,7 @@ void print_mtp008(const sensors_chip_name *name)
!sensors_get_feature(*name,SENSORS_MTP008_TEMP3_OVER,&max)) { !sensors_get_feature(*name,SENSORS_MTP008_TEMP3_OVER,&max)) {
if (valid) { if (valid) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, MINMAX );
printf(" %s\n", alarms&MTP008_ALARM_TEMP3?"ALARM":""); printf(" %s\n", alarms&MTP008_ALARM_TEMP3?"ALARM":"");
} }
} else } else
@@ -1640,13 +1660,13 @@ void print_w83781d(const sensors_chip_name *name)
if (valid) { if (valid) {
if((!is82d) && (!is83s)) { if((!is82d) && (!is83s)) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf(" %s %s\n", alarms&W83781D_ALARM_TEMP1 ?"ALARM":" ", printf(" %s %s\n", alarms&W83781D_ALARM_TEMP1 ?"ALARM":" ",
beeps&W83781D_ALARM_TEMP1?"(beep)":""); beeps&W83781D_ALARM_TEMP1?"(beep)":"");
} else { } else {
if(!sensors_get_feature(*name,SENSORS_W83781D_SENS1,&sens)) { if(!sensors_get_feature(*name,SENSORS_W83781D_SENS1,&sens)) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf( " sensor = %s %s %s\n", printf( " sensor = %s %s %s\n",
(((int)sens)==1)?"PII/Celeron diode":(((int)sens)==2)? (((int)sens)==1)?"PII/Celeron diode":(((int)sens)==2)?
"3904 transistor":"thermistor", "3904 transistor":"thermistor",
@@ -1668,13 +1688,13 @@ void print_w83781d(const sensors_chip_name *name)
if (valid) { if (valid) {
if((!is82d) && (!is83s)) { if((!is82d) && (!is83s)) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf(" %s %s\n", alarms&W83781D_ALARM_TEMP2 ?"ALARM":" ", printf(" %s %s\n", alarms&W83781D_ALARM_TEMP2 ?"ALARM":" ",
beeps&W83781D_ALARM_TEMP2?"(beep)":""); beeps&W83781D_ALARM_TEMP2?"(beep)":"");
} else { } else {
if(!sensors_get_feature(*name,SENSORS_W83781D_SENS2,&sens)) { if(!sensors_get_feature(*name,SENSORS_W83781D_SENS2,&sens)) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf( " sensor = %s %s %s\n", printf( " sensor = %s %s %s\n",
(((int)sens)==1)?"PII/Celeron diode":(((int)sens)==2)? (((int)sens)==1)?"PII/Celeron diode":(((int)sens)==2)?
"3904 transistor":"thermistor", "3904 transistor":"thermistor",
@@ -1697,13 +1717,13 @@ void print_w83781d(const sensors_chip_name *name)
if (valid) { if (valid) {
if(!is82d) { if(!is82d) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf(" %s %s\n", alarms&W83781D_ALARM_TEMP2 ?"ALARM":" ", printf(" %s %s\n", alarms&W83781D_ALARM_TEMP2 ?"ALARM":" ",
beeps&W83781D_ALARM_TEMP3?"(beep)":""); beeps&W83781D_ALARM_TEMP3?"(beep)":"");
} else { } else {
if(!sensors_get_feature(*name,SENSORS_W83781D_SENS3,&sens)) { if(!sensors_get_feature(*name,SENSORS_W83781D_SENS3,&sens)) {
print_label(label,10); print_label(label,10);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf( " sensor = %s %s %s\n", printf( " sensor = %s %s %s\n",
(((int)sens)==1)?"PII/Celeron diode":(((int)sens)==2)? (((int)sens)==1)?"PII/Celeron diode":(((int)sens)==2)?
"3904 transistor":"thermistor", "3904 transistor":"thermistor",
@@ -1770,7 +1790,7 @@ void print_maxilife(const sensors_chip_name *name)
!sensors_get_feature(*name, SENSORS_MAXI_CG_TEMP1_HYST, &min)) { !sensors_get_feature(*name, SENSORS_MAXI_CG_TEMP1_HYST, &min)) {
if (valid && (cur || max || min)) { if (valid && (cur || max || min)) {
print_label(label, 12); print_label(label, 12);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf("\n"); printf("\n");
} }
} else } else
@@ -1783,7 +1803,7 @@ void print_maxilife(const sensors_chip_name *name)
!sensors_get_feature(*name, SENSORS_MAXI_CG_TEMP2_HYST, &min)) { !sensors_get_feature(*name, SENSORS_MAXI_CG_TEMP2_HYST, &min)) {
if (valid && (cur || max || min)) { if (valid && (cur || max || min)) {
print_label(label, 12); print_label(label, 12);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf(" %s\n", alarms&MAXI_ALARM_TEMP2 ? "ALARM" : ""); printf(" %s\n", alarms&MAXI_ALARM_TEMP2 ? "ALARM" : "");
} }
} else } else
@@ -1796,7 +1816,7 @@ void print_maxilife(const sensors_chip_name *name)
!sensors_get_feature(*name, SENSORS_MAXI_CG_TEMP3_HYST, &min)) { !sensors_get_feature(*name, SENSORS_MAXI_CG_TEMP3_HYST, &min)) {
if (valid && (cur || max || min)) { if (valid && (cur || max || min)) {
print_label(label, 12); print_label(label, 12);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf("\n"); printf("\n");
} }
} else } else
@@ -1809,7 +1829,7 @@ void print_maxilife(const sensors_chip_name *name)
!sensors_get_feature(*name, SENSORS_MAXI_CG_TEMP4_HYST, &min)) { !sensors_get_feature(*name, SENSORS_MAXI_CG_TEMP4_HYST, &min)) {
if (valid && (cur || max || min)) { if (valid && (cur || max || min)) {
print_label(label, 12); print_label(label, 12);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf(" %s\n", alarms&MAXI_ALARM_TEMP4 ? "ALARM" : ""); printf(" %s\n", alarms&MAXI_ALARM_TEMP4 ? "ALARM" : "");
} }
} else } else
@@ -1822,7 +1842,7 @@ void print_maxilife(const sensors_chip_name *name)
!sensors_get_feature(*name, SENSORS_MAXI_CG_TEMP5_HYST, &min)) { !sensors_get_feature(*name, SENSORS_MAXI_CG_TEMP5_HYST, &min)) {
if (valid && (cur || max || min)) { if (valid && (cur || max || min)) {
print_label(label, 12); print_label(label, 12);
print_temp_info( cur, max, min ); print_temp_info( cur, max, min, HYST );
printf(" %s\n", alarms&MAXI_ALARM_TEMP5 ? "ALARM" : ""); printf(" %s\n", alarms&MAXI_ALARM_TEMP5 ? "ALARM" : "");
} }
} else } else