Differenze tra le versioni di "Controllare la temperatura della CPU con le sole funzioni di Gambas"
Riga 30: | Riga 30: | ||
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"; | ||
− | If THERMAL &/ th &/ " | + | If Exist(THERMAL &/ th &/ "trip_point_0_type") Then |
Print " ("; RTrim(File.Load(THERMAL &/ th &/ "trip_point_0_type")); | Print " ("; RTrim(File.Load(THERMAL &/ th &/ "trip_point_0_type")); | ||
Print " = "; Val(RTrim(File.Load(THERMAL &/ th &/ "trip_point_0_temp"))) / 1000; "°)" | Print " = "; Val(RTrim(File.Load(THERMAL &/ th &/ "trip_point_0_temp"))) / 1000; "°)" |
Versione delle 08:48, 12 ott 2023
Per controllare la temperatura della o delle CPU con le sole funzioni di Gambas, si devono interrogare i seguenti file (se sono presenti nel sistema):
- /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.
V'è da sottolineare che i suddetti file non sono presenti in tutte le distribuzioni Linux.
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 "\e[1m"; th; "\e[0m" 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"; If Exist(THERMAL &/ th &/ "trip_point_0_type") Then Print " ("; RTrim(File.Load(THERMAL &/ th &/ "trip_point_0_type")); Print " = "; Val(RTrim(File.Load(THERMAL &/ th &/ "trip_point_0_temp"))) / 1000; "°)" Endif Endif Print Next End