Table des matières


Script de gestion de la vitesse de rotation du ventillateur avec le module it-87:

Dernière version

Script Bash

#!/bin/bash
# Fichier de gestion de la vitesse de ventillo

lsmod | grep it87;

if [ $? = 1 ]
then modprobe it87 && modprobe i2c_isa
fi

vitesse_ventil="/sys/bus/i2c/devices/1-0290/driver/1-0290/pwm2";

while [ 1 ];do
# Lecture de la température stockée dans $temp
temp=`cat /sys/bus/i2c/devices/1-0290/temp2_input`;

# le ventillateur (echo 0)
if [ $temp -le 40000 ]
then
echo 0 > $vitesse_ventil
#echo $temp" vitesse=0";
fi


if [ $temp -gt 50000 ] && [ $temp -lt 55000 ]
then echo 100 > $vitesse_ventil
#echo $temp" vitesse=100";
fi

if [ $temp -gt 55000 ] && [ $temp -lt 60000 ]
then echo 150 > $vitesse_ventil
#echo $temp" vitesse=150";
fi

if [ $temp -gt 60000 ] && [ $temp -lt 63000 ]
then echo 200 > $vitesse_ventil
#echo $temp" vitesse=200";
fi

if [ $temp -gt 63000 ]
then echo 250 > $vitesse_ventil
#echo $temp" vitesse=250";
fi


sleep 1;
done;

Script Perl

#!/usr/bin/perl -w

# Fichier de gestion de la vitesse de ventillo
#$vitesse_ventil= "/sys/bus/i2c/devices/0-0290/driver/0-0290/pwm2";
#Test de determination du peripherique i2c present
#$i2c_device= `ls -x /sys/bus/i2c/devices`;
#print "periph i2c = ".$i2c_device;

$i2c_device="0-0290";

$it87_path= "/sys/bus/i2c/devices/".$i2c_device;

$vitesse_ventil= $it87_path."/pwm2";
print "vitesse ventillo = ".$vitesse_ventil;

while (1) {
# Lecture de la température stockée dans $temp
$temp = `cat $it87_path/temp2_input`;
print "temperature = ".$temp.`cat $vitesse_ventil`;
#print "vitesse ventillo ".$vitesse_ventil." = ".`cat $vitesse_ventil`;

# Si temperature inferieure à 51 degres on peut couper
# le ventillateur (echo 0)
if($temp < 43000)
{exec (`echo 0 > $vitesse_ventil`);}

if($temp > 43000 and $temp < 45000)
{exec (`echo 5 > $vitesse_ventil`);}

if($temp > 45000 and $temp < 46000)
{exec (`echo 10 > $vitesse_ventil`);}

if($temp > 46000 and $temp < 48000)
{exec (`echo 15 > $vitesse_ventil`);}

if($temp > 48000 and $temp < 50000)
{exec (`echo 20 > $vitesse_ventil`);}

if($temp > 50000 and $temp < 51000)
{exec (`echo 25 > $vitesse_ventil`);}

if($temp > 51000 and $temp < 52000)
{exec (`echo 30 > $vitesse_ventil`);}

if($temp > 52000 and $temp < 55000)
{exec (`echo 50 > $vitesse_ventil`);}

if($temp > 55000 and $temp < 58000)
{exec (`echo 60 > $vitesse_ventil`);}

if($temp > 58000 and $temp < 60000)
{exec (`echo 100 > $vitesse_ventil`);}

if($temp > 60000 and $temp < 62000)
{exec (`echo 150 > $vitesse_ventil`);}

if($temp > 62000 and $temp < 64000)
{exec (`echo 210 > $vitesse_ventil`);}

if($temp > 64000 and $temp < 66000)
{exec (`echo 230 > $vitesse_ventil`);}

# Ca commence à chauffer
if($temp > 75000)
{
# la commande print permet de ressortir un message
# permettant le debogage
print "superieur:".$temp."\n";

# On passe les ventillos à fond
exec (`echo 250 > $vitesse_ventil`);

# On devrait pouvoir faire chuter la fréquence
#exec (`echo 532000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed & echo 532000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq & echo 532000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq`);
exec (`echo 532000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed`);
# On informe le journal systeme que nous avons depassé 75°C

exec (`echo "ATTENTION Temperature depasse 75°: $temp" >> /var/log/syslog`);
}

# pause entre chaque lecture
sleep 1;
}


^ Haut de Page ^

RSS ~ Copyright 2004-2008 © Linucie - Asso. Loi 1901 - CNIL : 1045544 - Notre hébergeur : APINC.org
Publication sous Licence GNU/FDL propulsée par PmWiki - XHTML 1.0, CSS 2.1, WAI.