mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-09-02 15:25:22 +00:00
Added experimental lm-sensors super I/O support for Linux.
This commit is contained in:
191
Hardware/LPC/LMSensors.cs
Executable file
191
Hardware/LPC/LMSensors.cs
Executable file
@@ -0,0 +1,191 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
|
||||||
|
The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.mozilla.org/MPL/
|
||||||
|
|
||||||
|
Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
for the specific language governing rights and limitations under the License.
|
||||||
|
|
||||||
|
The Original Code is the Open Hardware Monitor code.
|
||||||
|
|
||||||
|
The Initial Developer of the Original Code is
|
||||||
|
Michael Möller <m.moeller@gmx.ch>.
|
||||||
|
Portions created by the Initial Developer are Copyright (C) 2009-2010
|
||||||
|
the Initial Developer. All Rights Reserved.
|
||||||
|
|
||||||
|
Contributor(s):
|
||||||
|
|
||||||
|
Alternatively, the contents of this file may be used under the terms of
|
||||||
|
either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
of those above. If you wish to allow use of your version of this file only
|
||||||
|
under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
use your version of this file under the terms of the MPL, indicate your
|
||||||
|
decision by deleting the provisions above and replace them with the notice
|
||||||
|
and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
the provisions above, a recipient may use your version of this file under
|
||||||
|
the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace OpenHardwareMonitor.Hardware.LPC {
|
||||||
|
|
||||||
|
public class LMSensors {
|
||||||
|
|
||||||
|
private List<LMChip> lmChips = new List<LMChip>();
|
||||||
|
|
||||||
|
public LMSensors () {
|
||||||
|
string[] devicePaths = Directory.GetDirectories("/sys/class/hwmon/");
|
||||||
|
foreach (string path in devicePaths) {
|
||||||
|
string name = null;
|
||||||
|
try {
|
||||||
|
StreamReader reader = new StreamReader(path + "/device/name");
|
||||||
|
name = reader.ReadLine();
|
||||||
|
reader.Close();
|
||||||
|
} catch (IOException) { }
|
||||||
|
switch (name) {
|
||||||
|
case "f71858fg":
|
||||||
|
lmChips.Add(new LMChip(Chip.F71858, path + "/device")); break;
|
||||||
|
case "f71862fg":
|
||||||
|
lmChips.Add(new LMChip(Chip.F71862, path + "/device")); break;
|
||||||
|
case "f71882fg":
|
||||||
|
lmChips.Add(new LMChip(Chip.F71882, path + "/device")); break;
|
||||||
|
case "f71889fg":
|
||||||
|
lmChips.Add(new LMChip(Chip.F71889F, path + "/device")); break;
|
||||||
|
|
||||||
|
case "it8712":
|
||||||
|
lmChips.Add(new LMChip(Chip.IT8712F, path + "/device")); break;
|
||||||
|
case "it8716":
|
||||||
|
lmChips.Add(new LMChip(Chip.IT8716F, path + "/device")); break;
|
||||||
|
case "it8718":
|
||||||
|
lmChips.Add(new LMChip(Chip.IT8718F, path + "/device")); break;
|
||||||
|
case "it8720":
|
||||||
|
lmChips.Add(new LMChip(Chip.IT8720F, path + "/device")); break;
|
||||||
|
|
||||||
|
case "w83627ehf":
|
||||||
|
lmChips.Add(new LMChip(Chip.W83627EHF, path + "/device")); break;
|
||||||
|
case "w83627dhg":
|
||||||
|
lmChips.Add(new LMChip(Chip.W83627DHG, path + "/device")); break;
|
||||||
|
case "w83667hg":
|
||||||
|
lmChips.Add(new LMChip(Chip.W83667HG, path + "/device")); break;
|
||||||
|
case "w83627hf":
|
||||||
|
lmChips.Add(new LMChip(Chip.W83627HF, path + "/device")); break;
|
||||||
|
case "w83627thf":
|
||||||
|
lmChips.Add(new LMChip(Chip.W83627THF, path + "/device")); break;
|
||||||
|
case "w83687thf":
|
||||||
|
lmChips.Add(new LMChip(Chip.W83687THF, path + "/device")); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close() {
|
||||||
|
foreach (LMChip lmChip in lmChips)
|
||||||
|
lmChip.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISuperIO[] SuperIO {
|
||||||
|
get {
|
||||||
|
return lmChips.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class LMChip : ISuperIO {
|
||||||
|
|
||||||
|
private string path;
|
||||||
|
private Chip chip;
|
||||||
|
|
||||||
|
private float?[] voltages;
|
||||||
|
private float?[] temperatures ;
|
||||||
|
private float?[] fans;
|
||||||
|
|
||||||
|
private StreamReader[] voltageReaders;
|
||||||
|
private StreamReader[] temperatureReaders;
|
||||||
|
private StreamReader[] fanReaders;
|
||||||
|
|
||||||
|
public Chip Chip { get { return chip; } }
|
||||||
|
public float?[] Voltages { get { return voltages; } }
|
||||||
|
public float?[] Temperatures { get { return temperatures; } }
|
||||||
|
public float?[] Fans { get { return fans; } }
|
||||||
|
|
||||||
|
|
||||||
|
public LMChip(Chip chip, string path) {
|
||||||
|
this.path = path;
|
||||||
|
this.chip = chip;
|
||||||
|
|
||||||
|
string[] voltagePaths = Directory.GetFiles(path, "in*_input");
|
||||||
|
this.voltages = new float?[voltagePaths.Length];
|
||||||
|
this.voltageReaders = new StreamReader[voltagePaths.Length];
|
||||||
|
for (int i = 0; i < voltagePaths.Length; i++)
|
||||||
|
voltageReaders[i] = new StreamReader(voltagePaths[i]);
|
||||||
|
|
||||||
|
string[] temperaturePaths = Directory.GetFiles(path, "temp*_input");
|
||||||
|
this.temperatures = new float?[temperaturePaths.Length];
|
||||||
|
this.temperatureReaders = new StreamReader[temperaturePaths.Length];
|
||||||
|
for (int i = 0; i < temperaturePaths.Length; i++)
|
||||||
|
temperatureReaders[i] = new StreamReader(temperaturePaths[i]);
|
||||||
|
|
||||||
|
string[] fanPaths = Directory.GetFiles(path, "fan*_input");
|
||||||
|
this.fans = new float?[fanPaths.Length];
|
||||||
|
this.fanReaders = new StreamReader[fanPaths.Length];
|
||||||
|
for (int i = 0; i < fanPaths.Length; i++)
|
||||||
|
fanReaders[i] = new StreamReader(fanPaths[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetReport() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update() {
|
||||||
|
for (int i = 0; i < voltages.Length; i++) {
|
||||||
|
voltageReaders[i].BaseStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
string s = voltageReaders[i].ReadLine();
|
||||||
|
try {
|
||||||
|
voltages[i] = 0.001f * long.Parse(s);
|
||||||
|
} catch {
|
||||||
|
voltages[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < temperatures.Length; i++) {
|
||||||
|
temperatureReaders[i].BaseStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
string s = temperatureReaders[i].ReadLine();
|
||||||
|
try {
|
||||||
|
temperatures[i] = 0.001f * long.Parse(s);
|
||||||
|
} catch {
|
||||||
|
temperatures[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < fans.Length; i++) {
|
||||||
|
fanReaders[i].BaseStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
string s = fanReaders[i].ReadLine();
|
||||||
|
try {
|
||||||
|
fans[i] = long.Parse(s);
|
||||||
|
} catch {
|
||||||
|
fans[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close() {
|
||||||
|
foreach (StreamReader reader in voltageReaders)
|
||||||
|
reader.Close();
|
||||||
|
foreach (StreamReader reader in temperatureReaders)
|
||||||
|
reader.Close();
|
||||||
|
foreach (StreamReader reader in fanReaders)
|
||||||
|
reader.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
|
||||||
@@ -48,6 +48,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
private Image icon;
|
private Image icon;
|
||||||
|
|
||||||
private LPCIO lpcio;
|
private LPCIO lpcio;
|
||||||
|
private LMSensors lmSensors;
|
||||||
private IHardware[] superIOHardware;
|
private IHardware[] superIOHardware;
|
||||||
|
|
||||||
public Mainboard() {
|
public Mainboard() {
|
||||||
@@ -69,8 +70,16 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.icon = Utilities.EmbeddedResources.GetImage("mainboard.png");
|
this.icon = Utilities.EmbeddedResources.GetImage("mainboard.png");
|
||||||
this.lpcio = new LPCIO();
|
ISuperIO[] superIO;
|
||||||
ISuperIO[] superIO = lpcio.SuperIO;
|
int p = (int)System.Environment.OSVersion.Platform;
|
||||||
|
if ((p == 4) || (p == 128)) {
|
||||||
|
this.lmSensors = new LMSensors();
|
||||||
|
superIO = lmSensors.SuperIO;
|
||||||
|
} else {
|
||||||
|
this.lpcio = new LPCIO();
|
||||||
|
superIO = lpcio.SuperIO;
|
||||||
|
}
|
||||||
|
|
||||||
superIOHardware = new IHardware[superIO.Length];
|
superIOHardware = new IHardware[superIO.Length];
|
||||||
for (int i = 0; i < superIO.Length; i++)
|
for (int i = 0; i < superIO.Length; i++)
|
||||||
superIOHardware[i] = new SuperIOHardware(superIO[i],
|
superIOHardware[i] = new SuperIOHardware(superIO[i],
|
||||||
@@ -105,7 +114,10 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
|
|
||||||
public void Update() { }
|
public void Update() { }
|
||||||
|
|
||||||
public void Close() { }
|
public void Close() {
|
||||||
|
if (lmSensors != null)
|
||||||
|
lmSensors.Close();
|
||||||
|
}
|
||||||
|
|
||||||
public IHardware[] SubHardware {
|
public IHardware[] SubHardware {
|
||||||
get { return superIOHardware; }
|
get { return superIOHardware; }
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
|
||||||
@@ -77,6 +77,7 @@ namespace OpenHardwareMonitor.Hardware.Mainboard {
|
|||||||
case Chip.W83667HG: this.name = "Winbond W83667HG"; break;
|
case Chip.W83667HG: this.name = "Winbond W83667HG"; break;
|
||||||
case Chip.W83667HGB: this.name = "Winbond W83667HG-B"; break;
|
case Chip.W83667HGB: this.name = "Winbond W83667HG-B"; break;
|
||||||
case Chip.W83687THF: this.name = "Winbond W83687THF"; break;
|
case Chip.W83687THF: this.name = "Winbond W83687THF"; break;
|
||||||
|
case Chip.Unknown: this.name = "Unkown"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Voltage> v = new List<Voltage>();
|
List<Voltage> v = new List<Voltage>();
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@@ -34,7 +34,6 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
<DebugSymbols>false</DebugSymbols>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Merge|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Merge|AnyCPU' ">
|
||||||
<OutputPath>bin\Merge\</OutputPath>
|
<OutputPath>bin\Merge\</OutputPath>
|
||||||
@@ -44,12 +43,10 @@
|
|||||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<OutputType>Module</OutputType>
|
<OutputType>Module</OutputType>
|
||||||
|
<DebugType>none</DebugType>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Aga.Controls, Version=1.7.0.0, Culture=neutral, PublicKeyToken=fcc90fbf924463a3, processorArchitecture=MSIL">
|
|
||||||
<SpecificVersion>False</SpecificVersion>
|
|
||||||
<HintPath>External\Aga.Controls.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
@@ -58,6 +55,10 @@
|
|||||||
<Reference Include="System.Web" />
|
<Reference Include="System.Web" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="Aga.Controls, Version=1.7.0.0, Culture=neutral, PublicKeyToken=fcc90fbf924463a3">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>External\Aga.Controls.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="GUI\CrashReportForm.cs">
|
<Compile Include="GUI\CrashReportForm.cs">
|
||||||
@@ -154,6 +155,7 @@
|
|||||||
<Compile Include="Hardware\TBalancer\TBalancerGroup.cs" />
|
<Compile Include="Hardware\TBalancer\TBalancerGroup.cs" />
|
||||||
<Compile Include="Hardware\WinRing0.cs" />
|
<Compile Include="Hardware\WinRing0.cs" />
|
||||||
<Compile Include="Utilities\ReadOnlyArray.cs" />
|
<Compile Include="Utilities\ReadOnlyArray.cs" />
|
||||||
|
<Compile Include="Hardware\LPC\LMSensors.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="GUI\AboutBox.resx">
|
<EmbeddedResource Include="GUI\AboutBox.resx">
|
||||||
|
Reference in New Issue
Block a user