Xlua invoke C# fetch NVIDIA-SMI temperature and control uart fan speed. #147
jameskong9999
announced in
脚本 Scripts publish
Replies: 1 comment 1 reply
-
lua有个东西叫io.popen
…---Original---
From: ***@***.***>
Date: Sun, Oct 15, 2023 22:36 PM
To: ***@***.***>;
Cc: ***@***.***>;
Subject: [chenxuuu/llcom] Xlua invoke C# fetch NVIDIA-SMI temperature andcontrol uart fan speed. (Discussion #147)
作者 jameskong9999
脚本名 fancontrol
脚本功能 Xlua invoke C# fetch NVIDIA-SMI temperature and control uart fan speed.
版本 vesion 0.1
备注 notes : 5 Nvidia Card, Should refine the tempswitch make one function for all card, but I just been lazy.
require "CS"
function checkGPUtemp (id)
local process = CS.System.Diagnostics.Process();
process.StartInfo.FileName = "C:\Windows\System32\nvidia-smi.exe";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
--process.StartInfo.WindowStyle = 1;
process.StartInfo.Arguments = "-i " .. id .. " -q";
process:Start()
sys.wait(1000)
while (1) do
local result = process.StandardOutput:ReadLine()
if result == nil then
break
end
local temp = string.match(result,'GPU Current Temp.*(%d%d) C')
if temp ~= nil then
return temp
end
end
end
function GPUtempswitch1 (temp)
if temp <= 20 then
return "7365745F6368303310"
elseif temp > 20 and temp <= 21 then
return "7365745F6368303311"
elseif temp > 21 and temp <= 22 then
return "7365745F6368303312"
elseif temp > 22 and temp <= 23 then
return "7365745F6368303313"
elseif temp > 23 and temp <= 24 then
return "7365745F6368303314"
elseif temp > 24 and temp <= 25 then
return "7365745F6368303315"
elseif temp > 25 and temp <= 26 then
return "7365745F6368303316"
elseif temp > 26 and temp <= 27 then
return "7365745F6368303317"
elseif temp > 27 and temp <= 28 then
return "7365745F6368303318"
elseif temp > 28 and temp <= 29 then
return "7365745F6368303319"
elseif temp > 29 and temp <= 30 then
return "7365745F636830331A"
elseif temp > 30 and temp <= 31 then
return "7365745F636830331B"
elseif temp > 31 and temp <= 32 then
return "7365745F636830331C"
elseif temp > 32 and temp <= 33 then
return "7365745F636830331D"
elseif temp > 33 and temp <= 34 then
return "7365745F636830331E"
elseif temp > 34 and temp <= 35 then
return "7365745F636830331F"
elseif temp > 35 and temp <= 36 then
return "7365745F6368303331"
elseif temp > 36 and temp <= 37 then
return "7365745F6368303332"
elseif temp > 37 and temp <= 38 then
return "7365745F6368303333"
elseif temp > 38 and temp <= 39 then
return "7365745F6368303334"
elseif temp > 39 and temp <= 40 then
return "7365745F6368303335"
elseif temp > 40 and temp <= 41 then
return "7365745F6368303336"
elseif temp > 41 and temp <= 42 then
return "7365745F6368303337"
elseif temp > 42 and temp <= 43 then
return "7365745F6368303338"
elseif temp > 43 and temp <= 44 then
return "7365745F6368303339"
elseif temp > 44 and temp <= 45 then
return "7365745F636830333A"
elseif temp > 45 and temp <= 46 then
return "7365745F6368303360"
elseif temp > 46 and temp <= 47 then
return "7365745F6368303362"
elseif temp > 47 and temp <= 48 then
return "7365745F6368303364"
elseif temp > 48 and temp <= 49 then
return "7365745F6368303366"
elseif temp > 49 and temp <= 50 then
return "7365745F6368303368"
elseif temp > 50 and temp <= 51 then
return "7365745F6368303380"
elseif temp > 51 and temp <= 52 then
return "7365745F6368303384"
elseif temp > 52 and temp <= 53 then
return "7365745F6368303388"
elseif temp > 53 and temp <= 54 then
return "7365745F6368303390"
elseif temp > 54 and temp <= 55 then
return "7365745F6368303398"
elseif temp > 55 and temp <= 56 then
return "7365745F636830339B"
elseif temp > 56 then
return "7365745F63683033F0"
else
return "7365745F63683033F0"
end
end
function GPUtempswitch2 (temp)
if temp <= 20 then
return "7365745F6368303410"
elseif temp > 20 and temp <= 21 then
return "7365745F6368303411"
elseif temp > 21 and temp <= 22 then
return "7365745F6368303412"
elseif temp > 22 and temp <= 23 then
return "7365745F6368303413"
elseif temp > 23 and temp <= 24 then
return "7365745F6368303414"
elseif temp > 24 and temp <= 25 then
return "7365745F6368303415"
elseif temp > 25 and temp <= 26 then
return "7365745F6368303416"
elseif temp > 26 and temp <= 27 then
return "7365745F6368303417"
elseif temp > 27 and temp <= 28 then
return "7365745F6368303418"
elseif temp > 28 and temp <= 29 then
return "7365745F6368303419"
elseif temp > 29 and temp <= 30 then
return "7365745F636830341A"
elseif temp > 30 and temp <= 31 then
return "7365745F636830341B"
elseif temp > 31 and temp <= 32 then
return "7365745F636830341C"
elseif temp > 32 and temp <= 33 then
return "7365745F636830341D"
elseif temp > 33 and temp <= 34 then
return "7365745F636830341E"
elseif temp > 34 and temp <= 35 then
return "7365745F636830341F"
elseif temp > 35 and temp <= 36 then
return "7365745F6368303431"
elseif temp > 36 and temp <= 37 then
return "7365745F6368303432"
elseif temp > 37 and temp <= 38 then
return "7365745F6368303433"
elseif temp > 38 and temp <= 39 then
return "7365745F6368303434"
elseif temp > 39 and temp <= 40 then
return "7365745F6368303435"
elseif temp > 40 and temp <= 41 then
return "7365745F6368303436"
elseif temp > 41 and temp <= 42 then
return "7365745F6368303437"
elseif temp > 42 and temp <= 43 then
return "7365745F6368303438"
elseif temp > 43 and temp <= 44 then
return "7365745F6368303439"
elseif temp > 44 and temp <= 45 then
return "7365745F636830343A"
elseif temp > 45 and temp <= 46 then
return "7365745F6368303460"
elseif temp > 46 and temp <= 47 then
return "7365745F6368303462"
elseif temp > 47 and temp <= 48 then
return "7365745F6368303464"
elseif temp > 48 and temp <= 49 then
return "7365745F6368303466"
elseif temp > 49 and temp <= 50 then
return "7365745F6368303468"
elseif temp > 50 and temp <= 51 then
return "7365745F6368303480"
elseif temp > 51 and temp <= 52 then
return "7365745F6368303484"
elseif temp > 52 and temp <= 53 then
return "7365745F6368303488"
elseif temp > 53 and temp <= 54 then
return "7365745F6368303490"
elseif temp > 54 and temp <= 55 then
return "7365745F6368303498"
elseif temp > 55 and temp <= 56 then
return "7365745F636830349B"
elseif temp > 56 then
return "7365745F63683034F0"
else
return "7365745F63683034F0"
end
end
function GPUtempswitch3 (temp)
if temp <= 20 then
return "7365745F6368303501"
elseif temp > 20 and temp <= 21 then
return "7365745F6368303501"
elseif temp > 21 and temp <= 22 then
return "7365745F6368303502"
elseif temp > 22 and temp <= 23 then
return "7365745F6368303503"
elseif temp > 23 and temp <= 24 then
return "7365745F6368303504"
elseif temp > 24 and temp <= 25 then
return "7365745F6368303505"
elseif temp > 25 and temp <= 26 then
return "7365745F6368303506"
elseif temp > 26 and temp <= 27 then
return "7365745F6368303507"
elseif temp > 27 and temp <= 28 then
return "7365745F6368303508"
elseif temp > 28 and temp <= 29 then
return "7365745F6368303509"
elseif temp > 29 and temp <= 30 then
return "7365745F636830350A"
elseif temp > 30 and temp <= 31 then
return "7365745F636830350B"
elseif temp > 31 and temp <= 32 then
return "7365745F636830351C"
elseif temp > 32 and temp <= 33 then
return "7365745F636830351D"
elseif temp > 33 and temp <= 34 then
return "7365745F636830351E"
elseif temp > 34 and temp <= 35 then
return "7365745F636830351F"
elseif temp > 35 and temp <= 36 then
return "7365745F6368303531"
elseif temp > 36 and temp <= 37 then
return "7365745F6368303532"
elseif temp > 37 and temp <= 38 then
return "7365745F6368303533"
elseif temp > 38 and temp <= 39 then
return "7365745F6368303534"
elseif temp > 39 and temp <= 40 then
return "7365745F6368303535"
elseif temp > 40 and temp <= 41 then
return "7365745F6368303536"
elseif temp > 41 and temp <= 42 then
return "7365745F6368303537"
elseif temp > 42 and temp <= 43 then
return "7365745F6368303538"
elseif temp > 43 and temp <= 44 then
return "7365745F6368303539"
elseif temp > 44 and temp <= 45 then
return "7365745F636830353A"
elseif temp > 45 and temp <= 46 then
return "7365745F6368303560"
elseif temp > 46 and temp <= 47 then
return "7365745F6368303562"
elseif temp > 47 and temp <= 48 then
return "7365745F6368303564"
elseif temp > 48 and temp <= 49 then
return "7365745F6368303566"
elseif temp > 49 and temp <= 50 then
return "7365745F6368303568"
elseif temp > 50 and temp <= 51 then
return "7365745F6368303580"
elseif temp > 51 and temp <= 52 then
return "7365745F6368303584"
elseif temp > 52 and temp <= 53 then
return "7365745F6368303588"
elseif temp > 53 and temp <= 54 then
return "7365745F6368303590"
elseif temp > 54 and temp <= 55 then
return "7365745F6368303598"
elseif temp > 55 and temp <= 56 then
return "7365745F636830359B"
elseif temp > 56 then
return "7365745F63683035F0"
else
return "7365745F63683035F0"
end
end
function GPUtempswitch4 (temp)
if temp <= 20 then
return "7365745F6368303601"
elseif temp > 20 and temp <= 21 then
return "7365745F6368303601"
elseif temp > 21 and temp <= 22 then
return "7365745F6368303602"
elseif temp > 22 and temp <= 23 then
return "7365745F6368303603"
elseif temp > 23 and temp <= 24 then
return "7365745F6368303604"
elseif temp > 24 and temp <= 25 then
return "7365745F6368303605"
elseif temp > 25 and temp <= 26 then
return "7365745F6368303606"
elseif temp > 26 and temp <= 27 then
return "7365745F6368303607"
elseif temp > 27 and temp <= 28 then
return "7365745F6368303608"
elseif temp > 28 and temp <= 29 then
return "7365745F6368303609"
elseif temp > 29 and temp <= 30 then
return "7365745F636830360A"
elseif temp > 30 and temp <= 31 then
return "7365745F636830360B"
elseif temp > 31 and temp <= 32 then
return "7365745F636830361C"
elseif temp > 32 and temp <= 33 then
return "7365745F636830361D"
elseif temp > 33 and temp <= 34 then
return "7365745F636830361E"
elseif temp > 34 and temp <= 35 then
return "7365745F636830361F"
elseif temp > 35 and temp <= 36 then
return "7365745F6368303631"
elseif temp > 36 and temp <= 37 then
return "7365745F6368303632"
elseif temp > 37 and temp <= 38 then
return "7365745F6368303633"
elseif temp > 38 and temp <= 39 then
return "7365745F6368303634"
elseif temp > 39 and temp <= 40 then
return "7365745F6368303635"
elseif temp > 40 and temp <= 41 then
return "7365745F6368303636"
elseif temp > 41 and temp <= 42 then
return "7365745F6368303637"
elseif temp > 42 and temp <= 43 then
return "7365745F6368303638"
elseif temp > 43 and temp <= 44 then
return "7365745F6368303639"
elseif temp > 44 and temp <= 45 then
return "7365745F636830363A"
elseif temp > 45 and temp <= 46 then
return "7365745F6368303660"
elseif temp > 46 and temp <= 47 then
return "7365745F6368303662"
elseif temp > 47 and temp <= 48 then
return "7365745F6368303664"
elseif temp > 48 and temp <= 49 then
return "7365745F6368303666"
elseif temp > 49 and temp <= 50 then
return "7365745F6368303668"
elseif temp > 50 and temp <= 51 then
return "7365745F6368303680"
elseif temp > 51 and temp <= 52 then
return "7365745F6368303684"
elseif temp > 52 and temp <= 53 then
return "7365745F6368303688"
elseif temp > 53 and temp <= 54 then
return "7365745F6368303690"
elseif temp > 54 and temp <= 55 then
return "7365745F6368303698"
elseif temp > 55 and temp <= 56 then
return "7365745F636830369B"
elseif temp > 56 then
return "7365745F63683036F0"
else
return "7365745F63683036F0"
end
end
function GPUtempswitch5 (temp)
if temp <= 20 then
return "7365745F6368303810"
elseif temp > 20 and temp <= 21 then
return "7365745F6368303811"
elseif temp > 21 and temp <= 22 then
return "7365745F6368303812"
elseif temp > 22 and temp <= 23 then
return "7365745F6368303813"
elseif temp > 23 and temp <= 24 then
return "7365745F6368303814"
elseif temp > 24 and temp <= 25 then
return "7365745F6368303815"
elseif temp > 25 and temp <= 26 then
return "7365745F6368303816"
elseif temp > 26 and temp <= 27 then
return "7365745F6368303817"
elseif temp > 27 and temp <= 28 then
return "7365745F6368303818"
elseif temp > 28 and temp <= 29 then
return "7365745F6368303819"
elseif temp > 29 and temp <= 30 then
return "7365745F636830381A"
elseif temp > 30 and temp <= 31 then
return "7365745F636830381B"
elseif temp > 31 and temp <= 32 then
return "7365745F636830381C"
elseif temp > 32 and temp <= 33 then
return "7365745F636830381D"
elseif temp > 33 and temp <= 34 then
return "7365745F636830381E"
elseif temp > 34 and temp <= 35 then
return "7365745F636830381F"
elseif temp > 35 and temp <= 36 then
return "7365745F6368303831"
elseif temp > 36 and temp <= 37 then
return "7365745F6368303832"
elseif temp > 37 and temp <= 38 then
return "7365745F6368303833"
elseif temp > 38 and temp <= 39 then
return "7365745F6368303834"
elseif temp > 39 and temp <= 40 then
return "7365745F6368303835"
elseif temp > 40 and temp <= 41 then
return "7365745F6368303836"
elseif temp > 41 and temp <= 42 then
return "7365745F6368303837"
elseif temp > 42 and temp <= 43 then
return "7365745F6368303838"
elseif temp > 43 and temp <= 44 then
return "7365745F6368303839"
elseif temp > 44 and temp <= 45 then
return "7365745F636830383A"
elseif temp > 45 and temp <= 46 then
return "7365745F6368303860"
elseif temp > 46 and temp <= 47 then
return "7365745F6368303862"
elseif temp > 47 and temp <= 48 then
return "7365745F6368303864"
elseif temp > 48 and temp <= 49 then
return "7365745F6368303866"
elseif temp > 49 and temp <= 50 then
return "7365745F6368303868"
elseif temp > 50 and temp <= 51 then
return "7365745F6368303880"
elseif temp > 51 and temp <= 52 then
return "7365745F6368303884"
elseif temp > 52 and temp <= 53 then
return "7365745F6368303888"
elseif temp > 53 and temp <= 54 then
return "7365745F6368303890"
elseif temp > 54 and temp <= 55 then
return "7365745F6368303898"
elseif temp > 55 and temp <= 56 then
return "7365745F636830389B"
elseif temp > 56 then
return "7365745F63683038F0"
else
return "7365745F63683038F0"
end
end
sys.taskInit(function()
while true do
sys.wait(1000)--等待1000ms
local card0 = checkGPUtemp(0)
local card1 = checkGPUtemp(1)
local card2 = checkGPUtemp(2)
local card3 = checkGPUtemp(3)
local card4 = checkGPUtemp(4)
print ("Card 1 Temp : ", card0)
print ("Card 2 Temp : ", card1)
print ("Card 3 Temp : ", card2)
print ("Card 4 Temp : ", card3)
print ("Card 5 Temp : ", card4)
local str0 = (GPUtempswitch1(tonumber(card0))):fromHex()
local result0 = apiSend("uart",str0)
sys.wait(1000)--等待1000ms
local str1 = (GPUtempswitch2(tonumber(card1))):fromHex()
local result1 = apiSend("uart",str1)
sys.wait(1000)--等待1000ms
local str2 = (GPUtempswitch3(tonumber(card2))):fromHex()
local result2 = apiSend("uart",str2)
sys.wait(1000)--等待1000ms
local str3 = (GPUtempswitch4(tonumber(card3))):fromHex()
local result3 = apiSend("uart",str3)
sys.wait(1000)--等待1000ms
local str4 = (GPUtempswitch5(tonumber(card4))):fromHex()
local result4 = apiSend("uart",str4)
end
end)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Beta Was this translation helpful? Give feedback.
All reactions