Notes16TMP112,End/Run 9548,控制Fan
Posted 码农编程录
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Notes16TMP112,End/Run 9548,控制Fan相关的知识,希望对你有一定的参考价值。
1.读TMP112进出口温度
# Read_TMP112_temperature.sh
Read_TMP112_temperature_Inlet()
{
i2c-test -b 7 -s 0x71 -w -d 0x08 # 出口0x40
tmp=$(i2c-test -b 7 -s 0x48 -m 1 -rc 2 -d 0x00)
tmp_h=${tmp:14:2}
tmp_l=${tmp:17:2}
tmp=${tmp_h}${tmp_l}
tmp=$((0x${tmp}>>8))"°C"
# echo $tmp
time=$(date "+%Y-%m-%d %H:%M:%S")
echo $time "TMP112 Inlet Temperature : " $tmp >> ./sensors.log
}
2.End 9548
# End_9548_sensors_info.sh:关闭主进程后重新开ipmitool
#!/bin/bash
start_ipmistack()
{
cnt=0
while true
do
/etc/init.d/ipmistack start >/dev/null 2>&1
s1=$(ps aux)
s2="/usr/local/bin/IPMIMain"
result=$(echo $s1 | grep "${s2}")
if [[ "$result" != "" ]]
then
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to start ipmistack !"
exit
fi
cnt=$(($cnt+1))
sleep 10
done
}
while true
do
ps -p $1
if [ $? -ne 0 ]
then
start_ipmistack
exit
fi
sleep 1
done
3.Run 9548
# Run_9548_sensors_info.sh
#!/bin/bash
stop_ipmistack()
{
cnt=0
while true
do
/etc/init.d/ipmistack stop >/dev/null 2>&1
s1=$(ps aux)
s2="/usr/local/bin/IPMIMain"
result=$(echo $s1 | grep "${s2}")
if [[ "$result" == "" ]]
then
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to stop ipmistack !"
exit
fi
cnt=$(($cnt+1))
sleep 10
done
}
delete()
{
cnt=0
while true
do
echo 0x73 > /sys/bus/i2c/devices/i2c-7/delete_device
if [ $? = 0 ]
then
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to delete device !"
exit
fi
cnt=$(($cnt+1))
done
}
access()
{
cnt=0
while true
do
i2c-test -b 7 -s 0x73 -w -d 0x08 >/dev/null 2>&1
if [ $? = 0 ]
then
break
fi
if [ $cnt -eq 5 ]
then
#echo $cnt
echo "Unable to access 9545 !"
exit
fi
cnt=$(($cnt+1))
#echo $cnt
done
}
start_ipmistack()
{
cnt=0
while true
do
/etc/init.d/ipmistack start >/dev/null 2>&1
s1=$(ps aux)
s2="/usr/local/bin/IPMIMain"
result=$(echo $s1 | grep "${s2}")
if [[ "$result" != "" ]]
then
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to start ipmistack !"
exit
fi
cnt=$(($cnt+1))
sleep 10
done
}
start_ipmistack
stop_ipmistack
delete
access
chmod +x ./*.sh
./End_9548_sensors_info.sh $$ & #这行Shell本身的PID
while :
do
./Read_TMP112_temperature.sh
./Read_PXE1410CDM_0X62_Voltage_Current.sh
./Read_PXE1410CDM_0X60_Voltage_Current.sh
./Read_INA220_Voltage.sh
./Read_FPGA_Power.sh
./Read_ADS7830_0x49_Voltage.sh
./Read_ADS7830_0x48_Voltage.sh
done
4.控制风扇速度
#!/bin/sh
usage(){
program=$(basename "$0")
echo "Usage:"
echo "$program <precent> "
echo " <precent> : fan speed set"
echo "Note:"
echo " precent:from 0 ro 100"
echo "Examples:"
echo " $program 30"
echo ""
}
check_parameter(){
if [ $# -ne 1 ];then
usage
exit 0
fi
if [ $1 -lt 0 -o $1 -gt 100 ];then
usage
exit 0
fi
}
dec2hex(){
printf "%x" $1
}
switch_arg(){
fullvalue=255
declare -i setvalue=(255*$1)/100
regvalue=$(dec2hex $setvalue)
echo "$regvalue"
}
do_action(){
regdata=$(switch_arg $1)
echo "i2cset -y 44 0x0d 0x22 0x$regdata"
#i2cset -y 44 0x0d 0x22 0x$regdata
#i2cset -y 44 0x0d 0x32 0x$regdata
#i2cset -y 44 0x0d 0x42 0x$regdata
#i2cset -y 44 0x0d 0x52 0x$regdata
#i2cset -y 108 0x0d 0x22 0x$regdata
#i2cset -y 108 0x0d 0x32 0x$regdata
#i2cset -y 108 0x0d 0x42 0x$regdata
#i2cset -y 108 0x0d 0x52 0x$regdata
}
check_parameter "$@"
do_action "$@"
以上是关于Notes16TMP112,End/Run 9548,控制Fan的主要内容,如果未能解决你的问题,请参考以下文章
[2016-03-16]How can I take better study notes?
Note3MPS/PXE/ADS/INA电流电压芯片,i2c设备在位和读访问,FPGA版本,PCIE读写,TMP112,Fan转速,uuid库