Changeset 4442
- Timestamp:
- 06/12/07 13:37:19 (6 years ago)
- Location:
- lm-sensors/branches/lm-sensors-3.0.0
- Files:
-
- 5 modified
-
CHANGES (modified) (1 diff)
-
doc/fancontrol.txt (modified) (5 diffs)
-
prog/pwm/fancontrol (modified) (9 diffs)
-
prog/pwm/fancontrol.8 (modified) (5 diffs)
-
prog/pwm/pwmconfig (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/CHANGES
r4441 r4442 23 23 No longer need awk and grep 24 24 Limit calls to external programs (Linux 2.6 only) 25 Check for configuration file validity 26 Support optional min and max PWM values 25 27 Program pwmconfig: Use smaller steps for low PWM values 28 Support optional min and max PWM values 26 29 Program rrd: Support only hwmon class devices 27 30 Look for rrd in /usr/bin by default -
lm-sensors/branches/lm-sensors-3.0.0/doc/fancontrol.txt
r4064 r4442 27 27 Configuration 28 28 29 Since most of you are going to use the p rog/pwm/pwmconfig script, the config29 Since most of you are going to use the pwmconfig script, the config 30 30 file syntax will be discussed last. First I'm going to describe the various 31 31 variables available for changing fancontrol's behaviour: … … 36 36 37 37 FCTEMPS 38 Maps pwm outputs to temperature sensors so fancontrol know which38 Maps pwm outputs to temperature sensors so fancontrol knows which 39 39 temperature sensors should be used for calculation of new values for 40 40 the corresponding pwm outputs. … … 46 46 47 47 MINTEMP 48 The temperature at which the fan gets switched off completely.48 The temperature below which the fan gets switched to minimum speed. 49 49 50 50 MAXTEMP 51 The temperature at which the fan gets switched to fullspeed.51 The temperature over which the fan gets switched to maximum speed. 52 52 53 53 MINSTART … … 56 56 57 57 MINSTOP 58 The minimum speed at which the fan still spins. Use a sa ve value here,58 The minimum speed at which the fan still spins. Use a safe value here, 59 59 too. 60 60 61 If you set up your configuration by hand, be sure to include ALL variables and 62 use valid values, there's no error handling yet! The file format is a bit 63 strange: 61 MINPWM 62 The PWM value to use when the temperature is below MINTEMP. 63 Typically, this will be either 0 if it is OK for the fan to plain 64 stop, or the same value as MINSTOP if you don't want the fan to 65 ever stop. 66 If this value isn't defined, it defaults to 0 (stopped fan). 64 67 65 VARIABLE=chip/pwmdev=value chip/pwmdev2=value2 [...] VARIABLE2=[...] 68 MAXPWM 69 The PWM value to use when the temperature is over MAXTEMP. 70 If this value isn't defined, it defaults to 255 (full speed). 71 72 A graph might help you understand how the different values relate 73 to each other: 74 75 PWM ^ 76 255 + 77 | 78 | 79 | ,-------------- MAXPWM 80 | ,'. 81 | ,' . 82 | ,' . 83 | ,' . 84 | ,' . 85 | ,' . 86 | MINSTOP .' . 87 | | . 88 | | . 89 | | . 90 MINPWM |---------------' . 91 | . . 92 | . . 93 | . . 94 0 +---------------+-------------+----------------> 95 MINTEMP MAXTEMP t (degree C) 96 97 The configuration file format is a bit strange: 98 99 VARIABLE=chip/pwmdev=value chip/pwmdev2=value2 [...] 100 VARIABLE2=[...] 66 101 67 102 Each variable has its own line. The variable name is followed by an equal sign 68 103 and the device=value pairs. These consist of the relative path to the pwm 69 output (from /proc/sys/dev/sensors/) for which the value is valid, equal sign 70 followed by the value and are seperated by a blank. 104 output (from /proc/sys/dev/sensors, /sys/bus/i2c/devices or /sys/class/hwmon 105 depending on the kernel version) for which the value is valid, equal sign 106 followed by the value and are separated by a blank. 71 107 72 108 Example: … … 83 119 fancontrol first reads its configuration, writes it to arrays and loops its 84 120 main function. This function gets the temperatures and fanspeeds from 85 lm_sensors procfiles and calculates new speeds depending on temperature121 kernel driver files and calculates new speeds depending on temperature 86 122 changes, but only if the temp is between MINTEMP and MAXTEMP. After that, the 87 123 new values are written to the pwm outputs. Currently the speed increases -
lm-sensors/branches/lm-sensors-3.0.0/prog/pwm/fancontrol
r4441 r4442 3 3 # Simple script implementing a temperature dependent fan speed control 4 4 # 5 # Version 0.6 55 # Version 0.66 6 6 # 7 7 # Usage: fancontrol [CONFIGFILE] … … 23 23 # 24 24 # Copyright 2003 Marius Reiner <marius.reiner@hdev.de> 25 # Copyright (C) 2007 Jean Delvare <khali@linux-fr.org> 25 26 # 26 27 # This program is free software; you can redistribute it and/or modify … … 56 57 # optional settings: 57 58 FCFANS=`egrep '^FCFANS=.*$' $1 | sed -e 's/FCFANS=//g'` 59 MINPWM=`egrep '^MINPWM=.*$' $1 | sed -e 's/MINPWM=//g'` 60 MAXPWM=`egrep '^MAXPWM=.*$' $1 | sed -e 's/MAXPWM=//g'` 58 61 59 62 # Check whether all mandatory settings are set … … 63 66 exit 1 64 67 fi 65 # here the other settings should be verified 66 68 if [ "$INTERVAL" -le 0 ] 69 then 70 echo "Error in configuration file:" 71 echo "INTERVAL must be at least 1" 72 exit 1 73 fi 67 74 68 75 # write settings to arrays for easier use and print them … … 81 88 AFCMINSTART[$fcvcount]=`echo $MINSTART |sed -e 's/ /\n/g' |egrep "${AFCPWM[$fcvcount]}" |cut -d'=' -f2` 82 89 AFCMINSTOP[$fcvcount]=`echo $MINSTOP |sed -e 's/ /\n/g' |egrep "${AFCPWM[$fcvcount]}" |cut -d'=' -f2` 90 AFCMINPWM[$fcvcount]=`echo $MINPWM |sed -e 's/ /\n/g' |egrep "${AFCPWM[$fcvcount]}" |cut -d'=' -f2` 91 [ -z "${AFCMINPWM[$fcvcount]}" ] && AFCMINPWM[$fcvcount]=0 92 AFCMAXPWM[$fcvcount]=`echo $MAXPWM |sed -e 's/ /\n/g' |egrep "${AFCPWM[$fcvcount]}" |cut -d'=' -f2` 93 [ -z "${AFCMAXPWM[$fcvcount]}" ] && AFCMAXPWM[$fcvcount]=255 94 95 # verify the validity of the settings 96 if [ "${AFCMINTEMP[$fcvcount]}" -ge "${AFCMAXTEMP[$fcvcount]}" ] 97 then 98 echo "Error in configuration file (${AFCPWM[$fcvcount]}):" 99 echo "MINTEMP must be less than MAXTEMP" 100 exit 1 101 fi 102 if [ "${AFCMAXPWM[$fcvcount]}" -gt 255 ] 103 then 104 echo "Error in configuration file (${AFCPWM[$fcvcount]}):" 105 echo "MAXPWM must be at most 255" 106 exit 1 107 fi 108 if [ "${AFCMINSTOP[$fcvcount]}" -ge "${AFCMAXPWM[$fcvcount]}" ] 109 then 110 echo "Error in configuration file (${AFCPWM[$fcvcount]}):" 111 echo "MINSTOP must be less than MAXPWM" 112 exit 1 113 fi 114 if [ "${AFCMINSTOP[$fcvcount]}" -lt "${AFCMINPWM[$fcvcount]}" ] 115 then 116 echo "Error in configuration file (${AFCPWM[$fcvcount]}):" 117 echo "MINSTOP must be greater than or equal to MINPWM" 118 exit 1 119 fi 120 if [ "${AFCMINPWM[$fcvcount]}" -lt 0 ] 121 then 122 echo "Error in configuration file (${AFCPWM[$fcvcount]}):" 123 echo "MINPWM must be at least 0" 124 exit 1 125 fi 126 83 127 echo 84 128 echo "Settings for ${AFCPWM[$fcvcount]}:" … … 89 133 echo " MINSTART=${AFCMINSTART[$fcvcount]}" 90 134 echo " MINSTOP=${AFCMINSTOP[$fcvcount]}" 135 echo " MINPWM=${AFCMINPWM[$fcvcount]}" 136 echo " MAXPWM=${AFCMAXPWM[$fcvcount]}" 91 137 let fcvcount=fcvcount+1 92 138 done … … 210 256 minsa=${AFCMINSTART[$fcvcount]} 211 257 minso=${AFCMINSTOP[$fcvcount]} 258 minpwm=${AFCMINPWM[$fcvcount]} 259 maxpwm=${AFCMAXPWM[$fcvcount]} 212 260 213 261 read tval < ${tsens} … … 262 310 echo "minsa=$minsa" 263 311 echo "minso=$minso" 312 echo "minpwm=$minpwm" 313 echo "maxpwm=$maxpwm" 264 314 echo "tval=$tval" 265 315 echo "pwmpval=$pwmpval" … … 268 318 269 319 if (( $tval <= $mint )) 270 then pwmval= 0 # at specified mintemp shut fan off320 then pwmval=$minpwm # below min temp, use defined min pwm 271 321 elif (( $tval >= $maxt )) 272 then pwmval= 255 # at specified maxtemp switch to 100%322 then pwmval=$maxpwm # over max temp, use defined max pwm 273 323 else 274 324 # calculate the new value from temperature and settings 275 let pwmval="((${tval}-${mint})**2)*( 255-${minso})/((${maxt}-${mint})**2)+${minso}"325 let pwmval="((${tval}-${mint})**2)*(${maxpwm}-${minso})/((${maxt}-${mint})**2)+${minso}" 276 326 if [ $pwmpval -eq 0 -o $fanval -eq 0 ] 277 327 then # if fan was stopped start it using a safe value -
lm-sensors/branches/lm-sensors-3.0.0/prog/pwm/fancontrol.8
r2873 r4442 1 .TH FANCONTROL 8 "J anuary 27, 2005"1 .TH FANCONTROL 8 "June 2007" 2 2 .SH NAME 3 3 fancontrol \- automated software based fan speed regulation … … 50 50 .TP 51 51 .B MINTEMP 52 The temperature below which the fan gets switched off completely.52 The temperature below which the fan gets switched to minimum speed. 53 53 .TP 54 54 .B MAXTEMP 55 The temperature over which the fan gets switched to fullspeed.55 The temperature over which the fan gets switched to maximum speed. 56 56 .TP 57 57 .B MINSTART … … 62 62 The minimum speed at which the fan still spins. Use a safe value here, 63 63 too. 64 .TP 65 .B MINPWM 66 The PWM value to use when the temperature is below MINTEMP. 67 Typically, this will be either 0 if it is OK for the fan to plain 68 stop, or the same value as MINSTOP if you don't want the fan to 69 ever stop. 70 If this value isn't defined, it defaults to 0 (stopped fan). 71 .TP 72 .B MAXPWM 73 The PWM value to use when the temperature is over MAXTEMP. 74 If this value isn't defined, it defaults to 255 (full speed). 64 75 .PP 65 If you set up your configuration by hand, be sure to include ALL variables and 66 use valid values, there's no error handling yet! The file format is a bit 67 strange: 76 The configuration file format is a bit strange: 68 77 .IP 69 78 .nf … … 74 83 Each variable has its own line. The variable name is followed by an equal sign 75 84 and the device=value pairs. These consist of the relative path to the pwm 76 output (from /proc/sys/dev/sensors/) for which the value is valid, equal sign 77 followed by the value and are seperated by a blank. Example: 85 output (from /proc/sys/dev/sensors, /sys/bus/i2c/devices or /sys/class/hwmon 86 depending on the kernel version) for which the value is valid, equal sign 87 followed by the value and are separated by a blank. Example: 78 88 .IP 79 89 MINTEMP=w83627hf-isa-0290/pwm2=40 w83627hf-isa-0290/pwm1=54 … … 87 97 \fBfancontrol\fP first reads its configuration, writes it to arrays and loops its 88 98 main function. This function gets the temperatures and fanspeeds from 89 lm_sensors procfiles and calculates new speeds depending on temperature99 kernel driver files and calculates new speeds depending on temperature 90 100 changes, but only if the temp is between MINTEMP and MAXTEMP. After that, the 91 101 new values are written to the PWM outputs. Currently the speed increases -
lm-sensors/branches/lm-sensors-3.0.0/prog/pwm/pwmconfig
r4381 r4442 1 1 #!/bin/bash 2 2 # 3 # pwmconfig v0. 73 # pwmconfig v0.8 4 4 # Tests the pwm outputs of sensors and configures fancontrol 5 5 # … … 11 11 # 12 12 # Copyright 2003-2005 The lm_sensors project 13 # Copyright (C) 2007 Jean Delvare <khali@linux-fr.org> 13 14 # 14 15 # This program is free software; you can redistribute it and/or modify … … 486 487 MINSTART=`egrep '^MINSTART=.*$' $1 | sed -e 's/MINSTART= *//g'` 487 488 MINSTOP=`egrep '^MINSTOP=.*$' $1 | sed -e 's/MINSTOP= *//g'` 489 MINPWM=`egrep '^MINPWM=.*$' $1 | sed -e 's/MINPWM= *//g'` 490 MAXPWM=`egrep '^MAXPWM=.*$' $1 | sed -e 's/MAXPWM= *//g'` 488 491 489 492 # Check for configuration change … … 500 503 MINSTART="" 501 504 MINSTOP="" 505 MINPWM="" 506 MAXPWM="" 502 507 fi 503 508 done … … 557 562 tmpfile=`mktemp -t pwmcfg.XXXXXXXXXX` || { echo "$0: Cannot create temporary file" >&2; exit 1; } 558 563 trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15 559 egrep -v '(INTERVAL|FCTEMPS|FCFANS|MAXTEMP|MINTEMP|MINSTART|MINSTOP )' $FCCONFIG >$tmpfile564 egrep -v '(INTERVAL|FCTEMPS|FCFANS|MAXTEMP|MINTEMP|MINSTART|MINSTOP|MINPWM|MAXPWM)' $FCCONFIG >$tmpfile 560 565 echo -e "INTERVAL=$INTERVAL\nFCTEMPS=$FCTEMPS\nFCFANS=$FCFANS\nMINTEMP=$MINTEMP\nMAXTEMP=$MAXTEMP\nMINSTART=$MINSTART\nMINSTOP=$MINSTOP" >>$tmpfile 566 [ -n "$MINPWM" ] && echo "MINPWM=$MINPWM" >>$tmpfile 567 [ -n "$MAXPWM" ] && echo "MAXPWM=$MAXPWM" >>$tmpfile 561 568 mv $tmpfile $FCCONFIG 562 569 #check if file was written correctly … … 600 607 echo " MINSTART=`echo $MINSTART |sed -e \"s/ /\n/g\" |egrep \"${pwmo}\" |sed -e \"s/.*=//g\"`" 601 608 echo " MINSTOP=`echo $MINSTOP |sed -e \"s/ /\n/g\" |egrep \"${pwmo}\" |sed -e \"s/.*=//g\"`" 609 echo " MINPWM=`echo $MINPWM |sed -e \"s/ /\n/g\" |egrep \"${pwmo}\" |sed -e \"s/.*=//g\"`" 610 echo " MAXPWM=`echo $MAXPWM |sed -e \"s/ /\n/g\" |egrep \"${pwmo}\" |sed -e \"s/.*=//g\"`" 602 611 done 603 612 echo ;; … … 641 650 fi 642 651 echo 643 echo 'Enter the low temperature ( C)'644 echo -n " at which the fan should be switched off($DEFMINTEMP): "652 echo 'Enter the low temperature (degree C)' 653 echo -n "below which the fan should spin at minimum speed ($DEFMINTEMP): " 645 654 read XMT 646 655 if [ "$XMT" = "" ] … … 655 664 fi 656 665 echo 657 echo 'Enter the high temperature ( C)'658 echo -n " at which the fan should be switched to fullspeed ($DEFMAXTEMP): "666 echo 'Enter the high temperature (degree C)' 667 echo -n "over which the fan should spin at maximum speed ($DEFMAXTEMP): " 659 668 read XMT 660 669 if [ "$XMT" = "" ] … … 705 714 else 706 715 MINSTOP="`echo $MINSTOP | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMV}" 716 fi 717 echo 718 echo "Enter the PWM value (0-$XMV) to use when the temperature" 719 echo -n "is below the low temperature limit (0): " 720 read XMINP 721 if [ -n "$XMINP" ] 722 then 723 if [ "$MINPWM" = "" ] 724 then 725 MINPWM="${pwms}=${XMINP}" 726 else 727 MINPWM="`echo $MINPWM | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMINP}" 728 fi 729 fi 730 echo 731 echo "Enter the PWM value ($XMV-$MAX) to use when the temperature" 732 echo -n "is over the high temperature limit ($MAX): " 733 read XMAXP 734 if [ -n "$XMAXP" ] 735 then 736 if [ "$MAXPWM" = "" ] 737 then 738 MAXPWM="${pwms}=${XMAXP}" 739 else 740 MAXPWM="`echo $MAXPWM | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMAXP}" 741 fi 707 742 fi 708 743 echo
