From 0662aaa299dba92f054e784834c86aea9f9b2095 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 14 Jan 2007 15:20:06 +0000 Subject: [PATCH] fancontrol.pl: * Disable debugging by default * Add support for non-i2c drivers * More tolerant config file parsing (for some reason pwmconfig adds unneeded spaces, it should probably be fixed but it's always better to be tolrant nevertheless) git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4295 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 3 +++ prog/pwm/fancontrol.pl | 30 ++++++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index e46bd0e6..1bb66953 100644 --- a/CHANGES +++ b/CHANGES @@ -32,6 +32,9 @@ SVN HEAD Programs dump/*: More robust handling of user inputs Programs pwmconfig, fancontrol: Handle write errors for bash 3.1 Add support for non-i2c drivers + Program fancontrol.pl: Disable debugging by default + Add support for non-i2c drivers + More tolerant config file parsing Program sensord: Add pc87247 support (fans only) Add vt1211 support (#2150) Add w83627dhg support (David Holl, #2157) diff --git a/prog/pwm/fancontrol.pl b/prog/pwm/fancontrol.pl index 112be1ed..83c2a920 100755 --- a/prog/pwm/fancontrol.pl +++ b/prog/pwm/fancontrol.pl @@ -47,15 +47,13 @@ use POSIX; $ENV{PATH} = "/bin:/usr/bin"; ##### Configuration ##### -use constant DEBUG => 1; +use constant DEBUG => 0; use constant MAX => 255; use constant PIDFILE => '/var/run/fancontrol.pid'; use constant CONFFILE => '/etc/fancontrol'; use constant LOGFILE => '/var/log/fancontrol/fancontrol.log'; use constant ERRFILE => '/var/log/fancontrol/fancontrol.err'; - -use constant SDIR => '/sys/bus/i2c/devices'; ### End Configuration ### our $interval; @@ -119,13 +117,21 @@ our $sysfs = 0; our $dir = '/proc/sys/dev/sensors'; if (!(-d $dir)) { - if (!(-d SDIR)) + if ($afcpwm[0] =~ m/^hwmon\d/) + { + $dir = '/sys/class/hwmon'; + } + else + { + $dir = '/sys/bus/i2c/devices'; + } + + if (!(-d $dir)) { die("No sensors found! (are the necessary modules loaded?) : $!\n"); } else { $sysfs = 1; - $dir = SDIR; } } @@ -173,13 +179,13 @@ $minstop); while($_ = ) { if ($_ =~ /^\s+$/) { next; } - elsif ($_ =~ /^INTERVAL=(.*)$/) { $interval = $1; next; } - elsif ($_ =~ /^FCTEMPS=(.*)$/) { $fctemps = $1; next; } - elsif ($_ =~ /^FCFANS=(.*)$/) { $fcfans = $1; next; } - elsif ($_ =~ /^MINTEMP=(.*)$/) { $mintemp = $1; next; } - elsif ($_ =~ /^MAXTEMP=(.*)$/) { $maxtemp = $1; next; } - elsif ($_ =~ /^MINSTART=(.*)$/) { $minstart = $1; next; } - elsif ($_ =~ /^MINSTOP=(.*)$/) { $minstop = $1; next; } + elsif ($_ =~ /^INTERVAL=\s*(.*)$/) { $interval = $1; next; } + elsif ($_ =~ /^FCTEMPS=\s*(.*)$/) { $fctemps = $1; next; } + elsif ($_ =~ /^FCFANS=\s*(.*)$/) { $fcfans = $1; next; } + elsif ($_ =~ /^MINTEMP=\s*(.*)$/) { $mintemp = $1; next; } + elsif ($_ =~ /^MAXTEMP=\s*(.*)$/) { $maxtemp = $1; next; } + elsif ($_ =~ /^MINSTART=\s*(.*)$/) { $minstart = $1; next; } + elsif ($_ =~ /^MINSTOP=\s*(.*)$/) { $minstop = $1; next; } } close(F);