Changeset 928
- Timestamp:
- 11/13/00 19:31:48 (13 years ago)
- Location:
- lm-sensors/trunk/prog/sensors
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/prog/sensors/chips.c
r909 r928 29 29 static void print_label(const char *label, int space); 30 30 static void free_the_label(char **label); 31 static void print_temp_info( float, float, float ); 32 static inline float deg_ctof( float ); 33 34 extern int fahrenheit; 31 35 32 36 char *spacestr(int n) … … 38 42 buf[n] = '\0'; 39 43 return buf; 44 } 45 46 inline float deg_ctof( float cel ) 47 { 48 return ( cel * ( 9.0F / 5.0F ) + 32.0F ); 49 } 50 51 void print_temp_info( float cur, float over, float hyst ) 52 { 53 char degv[5]; 54 55 float n_cur, 56 n_over, 57 n_hyst; 58 59 if ( fahrenheit ) 60 { 61 sprintf( degv, "%cF", 176 ); 62 n_cur = deg_ctof( cur ); 63 n_over = deg_ctof( over ); 64 n_hyst = deg_ctof( hyst ); 65 } 66 else 67 { 68 sprintf( degv, "%cC", 176 ); 69 n_cur = cur; 70 n_over = over; 71 n_hyst = hyst; 72 } 73 74 printf( "%+3.0f%s (limit = %+3.0f%s, hysteresis = %+3.0f%s)", 75 n_cur, degv, n_over, degv, n_hyst, degv ); 40 76 } 41 77 … … 82 118 if (valid) { 83 119 print_label(label,10); 84 print f("%6.1f C (limit: %6.1f C, hysteresis: %6.1f C)\n",85 cur,over,hyst);120 print_temp_info( cur, over, hyst ); 121 printf( "\n" ); 86 122 } 87 123 } else … … 109 145 if (valid) { 110 146 print_label(label,10); 111 printf("%4.0f C (limit: %4.0f C, hysteresis: %4.0f C) ", 112 cur,over,hyst); 147 print_temp_info( cur, over, hyst ); 113 148 if (alarms & (ADM1021_ALARM_TEMP_HIGH | ADM1021_ALARM_TEMP_LOW)) { 114 149 printf("ALARM ("); … … 135 170 if (valid) { 136 171 print_label(label,10); 137 printf("%4.0f C (limit: %4.0f C, hysteresis: %4.0f C) ", 138 cur,over,hyst); 172 print_temp_info( cur, over, hyst ); 139 173 if (alarms & (ADM1021_ALARM_RTEMP_HIGH | ADM1021_ALARM_RTEMP_LOW | 140 174 ADM1021_ALARM_RTEMP_NA)) { … … 192 226 if (valid) { 193 227 print_label(label,10); 194 printf( "%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n",228 printf( "%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", 195 229 cur,min,max,alarms&ADM9240_ALARM_IN0?"ALARM":""); 196 230 } … … 290 324 if (valid) { 291 325 print_label(label,10); 292 print f("%+3.0f C (limit = %+3.0f C, hysteresis = %+3.0f C) %s\n",293 cur,max,min, alarms&ADM9240_ALARM_TEMP?"ALARM":"");326 print_temp_info( cur, min, max ); 327 printf( " %s\n", alarms & ADM9240_ALARM_TEMP ? "ALARM" : "" ); 294 328 } 295 329 } else … … 409 443 if (valid) { 410 444 print_label(label,10); 411 print f("%+3.0f C (limit = %+3.0f C, hysteresis = %+3.0f C) %s\n",412 cur,max,min, alarms&SIS5595_ALARM_TEMP?"ALARM":"");445 print_temp_info( cur, min, max ); 446 printf( " %s\n", alarms & SIS5595_ALARM_TEMP ? "ALARM" : "" ); 413 447 } 414 448 } else … … 531 565 if (valid) { 532 566 print_label(label,10); 533 print f("%+3.1f C (limit = %+3.0f C, hysteresis = %+3.0f C) %s\n",534 cur,max,min, alarms&VIA686A_ALARM_TEMP?"ALARM":"");567 print_temp_info( cur, min, max ); 568 printf(" %s\n", alarms & VIA686A_ALARM_TEMP ? "ALARM" : "" ); 535 569 } 536 570 } else … … 543 577 if (valid) { 544 578 print_label(label,10); 545 print f("%+3.1f C (limit = %+3.0f C, hysteresis = %+3.0f C) %s\n",546 cur,max,min, alarms&VIA686A_ALARM_TEMP2?"ALARM":"");579 print_temp_info( cur, min, max ); 580 printf(" %s\n", alarms & VIA686A_ALARM_TEMP2 ? "ALARM" : "" ); 547 581 } 548 582 } else … … 555 589 if (valid) { 556 590 print_label(label,10); 557 print f("%+3.1f C (limit = %+3.0f C, hysteresis = %+3.0f C) %s\n",558 cur,max,min, alarms&VIA686A_ALARM_TEMP3?"ALARM":"");591 print_temp_info( cur, min, max ); 592 printf(" %s\n", alarms & VIA686A_ALARM_TEMP3 ? "ALARM" : "" ); 559 593 } 560 594 } else … … 706 740 if (valid) { 707 741 print_label(label,10); 708 print f("%+3.0f C (limit = %+3.0f C, hysteresis = %+3.0f C) %s\n",709 cur,max,min, alarms&LM78_ALARM_TEMP?"ALARM":"");742 print_temp_info( cur, max, min ); 743 printf( " %s\n", alarms & LM78_ALARM_TEMP ? "ALARM" : "" ); 710 744 } 711 745 } else … … 899 933 if (valid) { 900 934 print_label(label,10); 901 print f("%+3.0f C (limit = %+3.0f C, hysteresis = %+3.0f C) %s %s\n",902 cur,max,min, alarms&GL518_ALARM_TEMP?"ALARM":" ",935 print_temp_info( cur, max, min ); 936 printf("%s %s\n", alarms&GL518_ALARM_TEMP?"ALARM":" ", 903 937 beeps&GL518_ALARM_TEMP?"(beep)":""); 904 938 } … … 1013 1047 if (valid) { 1014 1048 print_label(label,10); 1015 print f("%+3.0f C (limit = %+3.0f C, hysteresis = %+3.0f C) %s\n",1016 cur,max,min, alarms&ADM1025_ALARM_TEMP?"ALARM":"");1049 print_temp_info( cur, max, min ); 1050 printf(" %s\n", alarms&ADM1025_ALARM_TEMP?"ALARM":""); 1017 1051 } 1018 1052 } else … … 1153 1187 if (valid) { 1154 1188 print_label(label,10); 1155 printf("%+3.2f C (hot:limit = %+3.0f C, hysteresis = %+3.0f C) %s\n", 1189 1190 if ( fahrenheit ) 1191 { 1192 printf("%+3.2f°C (hot:limit = %+3.0f°F, hysteresis = %+3.0f°F) %s\n", 1193 deg_ctof(cur),deg_ctof(max),deg_ctof(min), alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 1194 printf(" (os: limit = %+3.0f°F, hysteresis = %+3.0f°F) %s\n", 1195 deg_ctof(max2),deg_ctof(min2), alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 1196 } 1197 else 1198 { 1199 printf("%+3.2f °C (hot:limit = %+3.0f°C, hysteresis = %+3.0f°C) %s\n", 1156 1200 cur,max,min, alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 1157 printf(" (os: limit = %+3.0f C, hysteresis = %+3.0fC) %s\n",1201 printf(" (os: limit = %+3.0f°C, hysteresis = %+3.0f°C) %s\n", 1158 1202 max2,min2, alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 1203 } 1159 1204 } 1160 1205 } else … … 1318 1363 if (valid) { 1319 1364 print_label(label,10); 1320 print f("%+6.0f C (limit = %+3.0f C, hysteresis = %+3.0f C) %s\n",1321 cur,max,min, alarms&MTP008_ALARM_TEMP1?"ALARM":"");1365 print_temp_info( cur, max, min ); 1366 printf(" %s\n", alarms&MTP008_ALARM_TEMP1?"ALARM":""); 1322 1367 } 1323 1368 } else … … 1331 1376 if (valid) { 1332 1377 print_label(label,10); 1333 print f("%+6.0f C (limit = %+3.0f C, hysteresis = %+3.0f C) %s\n",1334 cur,max,min, alarms&MTP008_ALARM_TEMP2?"ALARM":"");1378 print_temp_info( cur, max, min ); 1379 printf(" %s\n", alarms&MTP008_ALARM_TEMP2?"ALARM":""); 1335 1380 } 1336 1381 } else … … 1344 1389 if (valid) { 1345 1390 print_label(label,10); 1346 print f("%+6.0f C (limit = %+3.0f C, hysteresis = %+3.0f C) %s\n",1347 cur,max,min, alarms&MTP008_ALARM_TEMP3?"ALARM":"");1391 print_temp_info( cur, max, min ); 1392 printf(" %s\n", alarms&MTP008_ALARM_TEMP3?"ALARM":""); 1348 1393 } 1349 1394 } else … … 1508 1553 } 1509 1554 } else 1510 printf("ERROR: Can't get IN 6data!\n");1555 printf("ERROR: Can't get IN8 data!\n"); 1511 1556 free_the_label(&label); 1512 1557 } … … 1559 1604 if((!is82d) && (!is83s)) { 1560 1605 print_label(label,10); 1561 print f("%+3.0f C (limit = %+3.0f C, hysteresis = %+3.0f C) %s %s\n",1562 cur,max,min, alarms&W83781D_ALARM_TEMP1 ?"ALARM":" ",1606 print_temp_info( cur, max, min ); 1607 printf(" %s %s\n", alarms&W83781D_ALARM_TEMP1 ?"ALARM":" ", 1563 1608 beeps&W83781D_ALARM_TEMP1?"(beep)":""); 1564 1609 } else { 1565 1610 if(!sensors_get_feature(*name,SENSORS_W83781D_SENS1,&sens)) { 1566 1611 print_label(label,10); 1567 printf( 1568 "%+3.0f C (limit = %+3.0f C, hysteresis = %+3.0f C, sensor = %s) %s %s\n", 1569 cur,max,min, 1612 print_temp_info( cur, max, min ); 1613 printf( " sensor = %s %s %s\n", 1570 1614 (((int)sens)==1)?"PII/Celeron diode":(((int)sens)==2)? 1571 1615 "3904 transistor":"thermistor", … … 1588 1632 if((!is82d) && (!is83s)) { 1589 1633 print_label(label,10); 1590 print f("%+3.1f C (limit = %+3.1f C, hysteresis = %+3.1f C) %s %s\n",1591 cur,max,min, alarms&W83781D_ALARM_TEMP23?"ALARM":" ",1592 beeps&W83781D_ALARM_TEMP2 3?"(beep)":"");1634 print_temp_info( cur, max, min ); 1635 printf(" %s %s\n", alarms&W83781D_ALARM_TEMP2 ?"ALARM":" ", 1636 beeps&W83781D_ALARM_TEMP2?"(beep)":""); 1593 1637 } else { 1594 1638 if(!sensors_get_feature(*name,SENSORS_W83781D_SENS2,&sens)) { 1595 1639 print_label(label,10); 1596 printf( 1597 "%+3.1f C (limit = %+3.1f C, hysteresis = %+3.1f C, sensor = %s) %s %s\n", 1598 cur,max,min, 1640 print_temp_info( cur, max, min ); 1641 printf( " sensor = %s %s %s\n", 1599 1642 (((int)sens)==1)?"PII/Celeron diode":(((int)sens)==2)? 1600 1643 "3904 transistor":"thermistor", … … 1618 1661 if(!is82d) { 1619 1662 print_label(label,10); 1620 print f("%+3.1f C (limit = %+3.1f C, hysteresis = %+3.1f C) %s %s\n",1621 cur,max,min, alarms&W83781D_ALARM_TEMP23?"ALARM":" ",1622 beeps&W83781D_ALARM_TEMP 23?"(beep)":"");1663 print_temp_info( cur, max, min ); 1664 printf(" %s %s\n", alarms&W83781D_ALARM_TEMP2 ?"ALARM":" ", 1665 beeps&W83781D_ALARM_TEMP3?"(beep)":""); 1623 1666 } else { 1624 1667 if(!sensors_get_feature(*name,SENSORS_W83781D_SENS3,&sens)) { 1625 1668 print_label(label,10); 1626 printf( 1627 "%+3.1f C (limit = %+3.1f C, hysteresis = %+3.1f C, sensor = %s) %s %s\n", 1628 cur,max,min, 1669 print_temp_info( cur, max, min ); 1670 printf( " sensor = %s %s %s\n", 1629 1671 (((int)sens)==1)?"PII/Celeron diode":(((int)sens)==2)? 1630 1672 "3904 transistor":"thermistor", … … 1692 1734 if (valid && (cur || max || min)) { 1693 1735 print_label(label, 12); 1694 printf("%+3.1f C (limit = %+3.1f C, hysteresis = %+3.1f C)\n", 1695 cur, max, min);1736 print_temp_info( cur, max, min ); 1737 printf("\n"); 1696 1738 } 1697 1739 } else … … 1705 1747 if (valid && (cur || max || min)) { 1706 1748 print_label(label, 12); 1707 printf("%+3.1f C (limit = %+3.1f C, hysteresis = %+3.1f C) %s\n", 1708 cur, max, min, alarms&MAXI_ALARM_TEMP2 ? "ALARM" : "");1749 print_temp_info( cur, max, min ); 1750 printf(" %s\n", alarms&MAXI_ALARM_TEMP2 ? "ALARM" : ""); 1709 1751 } 1710 1752 } else … … 1718 1760 if (valid && (cur || max || min)) { 1719 1761 print_label(label, 12); 1720 printf("%+3.1f C (limit = %+3.1f C, hysteresis = %+3.1f C)\n", 1721 cur, max, min);1762 print_temp_info( cur, max, min ); 1763 printf("\n"); 1722 1764 } 1723 1765 } else … … 1731 1773 if (valid && (cur || max || min)) { 1732 1774 print_label(label, 12); 1733 printf("%+3.1f C (limit = %+3.1f C, hysteresis = %+3.1f C) %s\n", 1734 cur, max, min, alarms&MAXI_ALARM_TEMP4 ? "ALARM" : "");1775 print_temp_info( cur, max, min ); 1776 printf(" %s\n", alarms&MAXI_ALARM_TEMP4 ? "ALARM" : ""); 1735 1777 } 1736 1778 } else … … 1744 1786 if (valid && (cur || max || min)) { 1745 1787 print_label(label, 12); 1746 printf("%+3.1f C (limit = %+3.1f C, hysteresis = %+3.1f C) %s\n", 1747 cur, max, min, alarms&MAXI_ALARM_TEMP5 ? "ALARM" : "");1788 print_temp_info( cur, max, min ); 1789 printf(" %s\n", alarms&MAXI_ALARM_TEMP5 ? "ALARM" : ""); 1748 1790 } 1749 1791 } else -
lm-sensors/trunk/prog/sensors/main.c
r909 r928 52 52 sensors_chip_name chips[CHIPS_MAX]; 53 53 int chips_count=0; 54 int do_sets, do_unknown ;54 int do_sets, do_unknown, fahrenheit; 55 55 56 56 void print_short_help(void) … … 65 65 printf(" -h, --help Display this help text\n"); 66 66 printf(" -s, --set Execute `set' statements too (root only)\n"); 67 printf(" -f, --fahrenheit Show temperatures in degrees fahrenheit\n" ); 67 68 printf(" -u, --unknown Treat chips as unknown ones (testing only)\n"); 68 69 printf(" -v, --version Display the program version\n"); … … 137 138 { "set", no_argument, NULL, 's' }, 138 139 { "version", no_argument, NULL, 'v'}, 140 { "fahrenheit", no_argument, NULL, 'f' }, 139 141 { "config-file", required_argument, NULL, 'c' }, 140 142 { "unknown", required_argument, NULL, 'u' }, … … 145 147 do_sets = 0; 146 148 while (1) { 147 c = getopt_long(argc,argv,"hvu sc:",long_opts,NULL);149 c = getopt_long(argc,argv,"hvufsc:",long_opts,NULL); 148 150 if (c == EOF) 149 151 break; … … 164 166 case 's': 165 167 do_sets = 1; 168 break; 169 case 'f': 170 fahrenheit = 1; 166 171 break; 167 172 case 'u': -
lm-sensors/trunk/prog/sensors/sensors.1
r848 r928 65 65 .IP -v 66 66 Returns the program version. 67 .IP -f 68 Prints the temperatures in degrees Fahrenheit instead of Celsius. 67 69 .SH FILES 68 70 .I /etc/sensors.conf
