Differenze tra le versioni di "Controllare la temperatura della CPU con le sole funzioni di Gambas"
Da Gambas-it.org - Wikipedia.
(Creata pagina con "Per controllare la temperatura della o delle CPU con le sole funzioni di Gambas, si devono interrogare i seguenti file: * ''/sys/class/thermal/thermal_zoneX/type'' Stringa che...") |
|||
Riga 24: | Riga 24: | ||
For Each th In Dir(THERMAL, "thermal_zone*", gb.Directory) | For Each th In Dir(THERMAL, "thermal_zone*", gb.Directory) | ||
− | + | If Exist(THERMAL &/ th) Then | |
− | If | + | Print th |
If RTrim(File.Load(THERMAL &/ th &/ "type")) = "acpitz" Then Print "ACPI interface" | If RTrim(File.Load(THERMAL &/ th &/ "type")) = "acpitz" Then Print "ACPI interface" | ||
Print "Temperatura: \e[31m"; Val(RTrim(File.Load(THERMAL &/ th &/ "temp"))) / 1000; "°\e[0m"; | Print "Temperatura: \e[31m"; Val(RTrim(File.Load(THERMAL &/ th &/ "temp"))) / 1000; "°\e[0m"; |
Versione delle 11:30, 4 ott 2023
Per controllare la temperatura della o delle CPU con le sole funzioni di Gambas, si devono interrogare i seguenti file:
- /sys/class/thermal/thermal_zoneX/type
Stringa che rappresenta il tipo di zona termica.
Ad esempio, "acpitz" indica che si tratta di un dispositivo termico ACPI.
- /sys/class/thermal/thermal_zoneX/temp
Temperatura attuale riportata dalla zona termica (sensore).
Unità: millesimi di grado Celsius.
- /sys/class/thermal/thermal_zone0/trip_point_X_type
Stringa che indica il tipo di punto di intervento.
Ad esempio, può essere uno dei seguenti: critico, caldo, passivo, 'attivo[0-*]' per la zona termica ACPI.
- /sys/class/thermal/thermal_zoneX/trip_point_X_temp
La temperatura al di sopra della quale il punto di intervento viene attivato.
Unità: millesimi di grado Celsius.
Mostriamo un esempio pratico:
Private Const THERMAL As String = "/sys/class/thermal" Public Sub Main() Dim th As String For Each th In Dir(THERMAL, "thermal_zone*", gb.Directory) If Exist(THERMAL &/ th) Then Print th If RTrim(File.Load(THERMAL &/ th &/ "type")) = "acpitz" Then Print "ACPI interface" Print "Temperatura: \e[31m"; Val(RTrim(File.Load(THERMAL &/ th &/ "temp"))) / 1000; "°\e[0m"; Print " ("; RTrim(File.Load(THERMAL &/ th &/ "trip_point_0_type")); Print " = "; Val(RTrim(File.Load(THERMAL &/ th &/ "trip_point_0_temp"))) / 1000; "°)" Print Endif Next End