mirror of
https://github.com/DigitalDevices/octonet.git
synced 2023-10-10 13:36:52 +02:00
add fancontrol for MaxSX8 and other temp devices
This commit is contained in:
parent
dbb3354015
commit
ca2e8601c9
41
octoserve/var/monitor/fancontrol.lua
Executable file → Normal file
41
octoserve/var/monitor/fancontrol.lua
Executable file → Normal file
@ -9,9 +9,31 @@ local LogFile = "/tmp/Temperatur.log"
|
||||
local HighTemp = 50
|
||||
local LowTemp = 45
|
||||
|
||||
function ReadAttribute(attribute)
|
||||
local value = 0
|
||||
local ddbridge = io.open(devicepath.."/"..attribute,"r");
|
||||
if ddbridge then
|
||||
value = ddbridge:read("*l")
|
||||
ddbridge:close()
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
function ReadTemp(sensor)
|
||||
local temp = 0
|
||||
local file = io.open(devicepath.."/temp"..sensor)
|
||||
local file;
|
||||
|
||||
if sensor > 3 then
|
||||
sensor = sensor - 4
|
||||
if sensor == 0 then
|
||||
file = io.open(devicepath.."/temp")
|
||||
else
|
||||
file = io.open(devicepath.."/templ"..sensor)
|
||||
end
|
||||
else
|
||||
file = io.open(devicepath.."/temp"..sensor)
|
||||
end
|
||||
|
||||
if file then
|
||||
temp = file:read()
|
||||
if temp == "no sensor" then
|
||||
@ -55,24 +77,21 @@ local fanstate = -1
|
||||
|
||||
sleep(30)
|
||||
|
||||
local ddbridge = io.open("/sys/class/ddbridge/ddbridge0/devid0","r");
|
||||
if ddbridge then
|
||||
local devid = ddbridge:read("*l")
|
||||
ddbridge:close()
|
||||
local devid = ReadAttribute("devid0")
|
||||
if devid == "0307dd01" then
|
||||
fanstate = 1
|
||||
ddbridge = io.open("/sys/class/ddbridge/ddbridge0/fanspeed1","r");
|
||||
if ddbridge then
|
||||
local fs = tonumber(ddbridge:read("*l"))
|
||||
ddbridge:close()
|
||||
local devid1 = ReadAttribute("devid1")
|
||||
if devid1 == "0009dd01" or devid1 == "000add01" then
|
||||
fanstate = -2
|
||||
else
|
||||
local fs = tonumber(ReadAttribute("fanspeed1"))
|
||||
if fs > 0 and fs < 17000 then
|
||||
fanstate = -2
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i = 0,4,1 do
|
||||
for i = 0,8,1 do
|
||||
temp = ReadTemp(i)
|
||||
if temp > 0 then
|
||||
Sensor[NumSensors] = i
|
||||
|
Loading…
Reference in New Issue
Block a user