Added experimental lm-sensors super I/O support for Linux.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Hardware/LPC/LMSensors.cs Sun Jun 06 14:44:53 2010 +0000
1.3 @@ -0,0 +1,191 @@
1.4 +/*
1.5 +
1.6 + Version: MPL 1.1/GPL 2.0/LGPL 2.1
1.7 +
1.8 + The contents of this file are subject to the Mozilla Public License Version
1.9 + 1.1 (the "License"); you may not use this file except in compliance with
1.10 + the License. You may obtain a copy of the License at
1.11 +
1.12 + http://www.mozilla.org/MPL/
1.13 +
1.14 + Software distributed under the License is distributed on an "AS IS" basis,
1.15 + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1.16 + for the specific language governing rights and limitations under the License.
1.17 +
1.18 + The Original Code is the Open Hardware Monitor code.
1.19 +
1.20 + The Initial Developer of the Original Code is
1.21 + Michael Möller <m.moeller@gmx.ch>.
1.22 + Portions created by the Initial Developer are Copyright (C) 2009-2010
1.23 + the Initial Developer. All Rights Reserved.
1.24 +
1.25 + Contributor(s):
1.26 +
1.27 + Alternatively, the contents of this file may be used under the terms of
1.28 + either the GNU General Public License Version 2 or later (the "GPL"), or
1.29 + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1.30 + in which case the provisions of the GPL or the LGPL are applicable instead
1.31 + of those above. If you wish to allow use of your version of this file only
1.32 + under the terms of either the GPL or the LGPL, and not to allow others to
1.33 + use your version of this file under the terms of the MPL, indicate your
1.34 + decision by deleting the provisions above and replace them with the notice
1.35 + and other provisions required by the GPL or the LGPL. If you do not delete
1.36 + the provisions above, a recipient may use your version of this file under
1.37 + the terms of any one of the MPL, the GPL or the LGPL.
1.38 +
1.39 +*/
1.40 +
1.41 +using System;
1.42 +using System.Collections.Generic;
1.43 +using System.IO;
1.44 +
1.45 +namespace OpenHardwareMonitor.Hardware.LPC {
1.46 +
1.47 + public class LMSensors {
1.48 +
1.49 + private List<LMChip> lmChips = new List<LMChip>();
1.50 +
1.51 + public LMSensors () {
1.52 + string[] devicePaths = Directory.GetDirectories("/sys/class/hwmon/");
1.53 + foreach (string path in devicePaths) {
1.54 + string name = null;
1.55 + try {
1.56 + StreamReader reader = new StreamReader(path + "/device/name");
1.57 + name = reader.ReadLine();
1.58 + reader.Close();
1.59 + } catch (IOException) { }
1.60 + switch (name) {
1.61 + case "f71858fg":
1.62 + lmChips.Add(new LMChip(Chip.F71858, path + "/device")); break;
1.63 + case "f71862fg":
1.64 + lmChips.Add(new LMChip(Chip.F71862, path + "/device")); break;
1.65 + case "f71882fg":
1.66 + lmChips.Add(new LMChip(Chip.F71882, path + "/device")); break;
1.67 + case "f71889fg":
1.68 + lmChips.Add(new LMChip(Chip.F71889F, path + "/device")); break;
1.69 +
1.70 + case "it8712":
1.71 + lmChips.Add(new LMChip(Chip.IT8712F, path + "/device")); break;
1.72 + case "it8716":
1.73 + lmChips.Add(new LMChip(Chip.IT8716F, path + "/device")); break;
1.74 + case "it8718":
1.75 + lmChips.Add(new LMChip(Chip.IT8718F, path + "/device")); break;
1.76 + case "it8720":
1.77 + lmChips.Add(new LMChip(Chip.IT8720F, path + "/device")); break;
1.78 +
1.79 + case "w83627ehf":
1.80 + lmChips.Add(new LMChip(Chip.W83627EHF, path + "/device")); break;
1.81 + case "w83627dhg":
1.82 + lmChips.Add(new LMChip(Chip.W83627DHG, path + "/device")); break;
1.83 + case "w83667hg":
1.84 + lmChips.Add(new LMChip(Chip.W83667HG, path + "/device")); break;
1.85 + case "w83627hf":
1.86 + lmChips.Add(new LMChip(Chip.W83627HF, path + "/device")); break;
1.87 + case "w83627thf":
1.88 + lmChips.Add(new LMChip(Chip.W83627THF, path + "/device")); break;
1.89 + case "w83687thf":
1.90 + lmChips.Add(new LMChip(Chip.W83687THF, path + "/device")); break;
1.91 + }
1.92 + }
1.93 + }
1.94 +
1.95 + public void Close() {
1.96 + foreach (LMChip lmChip in lmChips)
1.97 + lmChip.Close();
1.98 + }
1.99 +
1.100 + public ISuperIO[] SuperIO {
1.101 + get {
1.102 + return lmChips.ToArray();
1.103 + }
1.104 + }
1.105 +
1.106 + private class LMChip : ISuperIO {
1.107 +
1.108 + private string path;
1.109 + private Chip chip;
1.110 +
1.111 + private float?[] voltages;
1.112 + private float?[] temperatures ;
1.113 + private float?[] fans;
1.114 +
1.115 + private StreamReader[] voltageReaders;
1.116 + private StreamReader[] temperatureReaders;
1.117 + private StreamReader[] fanReaders;
1.118 +
1.119 + public Chip Chip { get { return chip; } }
1.120 + public float?[] Voltages { get { return voltages; } }
1.121 + public float?[] Temperatures { get { return temperatures; } }
1.122 + public float?[] Fans { get { return fans; } }
1.123 +
1.124 +
1.125 + public LMChip(Chip chip, string path) {
1.126 + this.path = path;
1.127 + this.chip = chip;
1.128 +
1.129 + string[] voltagePaths = Directory.GetFiles(path, "in*_input");
1.130 + this.voltages = new float?[voltagePaths.Length];
1.131 + this.voltageReaders = new StreamReader[voltagePaths.Length];
1.132 + for (int i = 0; i < voltagePaths.Length; i++)
1.133 + voltageReaders[i] = new StreamReader(voltagePaths[i]);
1.134 +
1.135 + string[] temperaturePaths = Directory.GetFiles(path, "temp*_input");
1.136 + this.temperatures = new float?[temperaturePaths.Length];
1.137 + this.temperatureReaders = new StreamReader[temperaturePaths.Length];
1.138 + for (int i = 0; i < temperaturePaths.Length; i++)
1.139 + temperatureReaders[i] = new StreamReader(temperaturePaths[i]);
1.140 +
1.141 + string[] fanPaths = Directory.GetFiles(path, "fan*_input");
1.142 + this.fans = new float?[fanPaths.Length];
1.143 + this.fanReaders = new StreamReader[fanPaths.Length];
1.144 + for (int i = 0; i < fanPaths.Length; i++)
1.145 + fanReaders[i] = new StreamReader(fanPaths[i]);
1.146 + }
1.147 +
1.148 + public string GetReport() {
1.149 + return null;
1.150 + }
1.151 +
1.152 + public void Update() {
1.153 + for (int i = 0; i < voltages.Length; i++) {
1.154 + voltageReaders[i].BaseStream.Seek(0, SeekOrigin.Begin);
1.155 + string s = voltageReaders[i].ReadLine();
1.156 + try {
1.157 + voltages[i] = 0.001f * long.Parse(s);
1.158 + } catch {
1.159 + voltages[i] = null;
1.160 + }
1.161 + }
1.162 +
1.163 + for (int i = 0; i < temperatures.Length; i++) {
1.164 + temperatureReaders[i].BaseStream.Seek(0, SeekOrigin.Begin);
1.165 + string s = temperatureReaders[i].ReadLine();
1.166 + try {
1.167 + temperatures[i] = 0.001f * long.Parse(s);
1.168 + } catch {
1.169 + temperatures[i] = null;
1.170 + }
1.171 + }
1.172 +
1.173 + for (int i = 0; i < fans.Length; i++) {
1.174 + fanReaders[i].BaseStream.Seek(0, SeekOrigin.Begin);
1.175 + string s = fanReaders[i].ReadLine();
1.176 + try {
1.177 + fans[i] = long.Parse(s);
1.178 + } catch {
1.179 + fans[i] = null;
1.180 + }
1.181 + }
1.182 + }
1.183 +
1.184 + public void Close() {
1.185 + foreach (StreamReader reader in voltageReaders)
1.186 + reader.Close();
1.187 + foreach (StreamReader reader in temperatureReaders)
1.188 + reader.Close();
1.189 + foreach (StreamReader reader in fanReaders)
1.190 + reader.Close();
1.191 + }
1.192 + }
1.193 + }
1.194 +}
2.1 --- a/Hardware/Mainboard/Mainboard.cs Sun Jun 06 11:07:57 2010 +0000
2.2 +++ b/Hardware/Mainboard/Mainboard.cs Sun Jun 06 14:44:53 2010 +0000
2.3 @@ -1,4 +1,4 @@
2.4 -/*
2.5 +/*
2.6
2.7 Version: MPL 1.1/GPL 2.0/LGPL 2.1
2.8
2.9 @@ -48,6 +48,7 @@
2.10 private Image icon;
2.11
2.12 private LPCIO lpcio;
2.13 + private LMSensors lmSensors;
2.14 private IHardware[] superIOHardware;
2.15
2.16 public Mainboard() {
2.17 @@ -69,8 +70,16 @@
2.18 }
2.19
2.20 this.icon = Utilities.EmbeddedResources.GetImage("mainboard.png");
2.21 - this.lpcio = new LPCIO();
2.22 - ISuperIO[] superIO = lpcio.SuperIO;
2.23 + ISuperIO[] superIO;
2.24 + int p = (int)System.Environment.OSVersion.Platform;
2.25 + if ((p == 4) || (p == 128)) {
2.26 + this.lmSensors = new LMSensors();
2.27 + superIO = lmSensors.SuperIO;
2.28 + } else {
2.29 + this.lpcio = new LPCIO();
2.30 + superIO = lpcio.SuperIO;
2.31 + }
2.32 +
2.33 superIOHardware = new IHardware[superIO.Length];
2.34 for (int i = 0; i < superIO.Length; i++)
2.35 superIOHardware[i] = new SuperIOHardware(superIO[i],
2.36 @@ -105,7 +114,10 @@
2.37
2.38 public void Update() { }
2.39
2.40 - public void Close() { }
2.41 + public void Close() {
2.42 + if (lmSensors != null)
2.43 + lmSensors.Close();
2.44 + }
2.45
2.46 public IHardware[] SubHardware {
2.47 get { return superIOHardware; }
3.1 --- a/Hardware/Mainboard/SuperIOHardware.cs Sun Jun 06 11:07:57 2010 +0000
3.2 +++ b/Hardware/Mainboard/SuperIOHardware.cs Sun Jun 06 14:44:53 2010 +0000
3.3 @@ -1,4 +1,4 @@
3.4 -/*
3.5 +/*
3.6
3.7 Version: MPL 1.1/GPL 2.0/LGPL 2.1
3.8
3.9 @@ -77,6 +77,7 @@
3.10 case Chip.W83667HG: this.name = "Winbond W83667HG"; break;
3.11 case Chip.W83667HGB: this.name = "Winbond W83667HG-B"; break;
3.12 case Chip.W83687THF: this.name = "Winbond W83687THF"; break;
3.13 + case Chip.Unknown: this.name = "Unkown"; break;
3.14 }
3.15
3.16 List<Voltage> v = new List<Voltage>();
4.1 --- a/OpenHardwareMonitor.csproj Sun Jun 06 11:07:57 2010 +0000
4.2 +++ b/OpenHardwareMonitor.csproj Sun Jun 06 14:44:53 2010 +0000
4.3 @@ -1,4 +1,4 @@
4.4 -<?xml version="1.0" encoding="utf-8"?>
4.5 +<?xml version="1.0" encoding="utf-8"?>
4.6 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
4.7 <PropertyGroup>
4.8 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4.9 @@ -34,7 +34,6 @@
4.10 <ErrorReport>prompt</ErrorReport>
4.11 <WarningLevel>4</WarningLevel>
4.12 <UseVSHostingProcess>false</UseVSHostingProcess>
4.13 - <DebugSymbols>false</DebugSymbols>
4.14 </PropertyGroup>
4.15 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Merge|AnyCPU' ">
4.16 <OutputPath>bin\Merge\</OutputPath>
4.17 @@ -44,12 +43,10 @@
4.18 <UseVSHostingProcess>false</UseVSHostingProcess>
4.19 <ErrorReport>prompt</ErrorReport>
4.20 <OutputType>Module</OutputType>
4.21 + <DebugType>none</DebugType>
4.22 + <WarningLevel>4</WarningLevel>
4.23 </PropertyGroup>
4.24 <ItemGroup>
4.25 - <Reference Include="Aga.Controls, Version=1.7.0.0, Culture=neutral, PublicKeyToken=fcc90fbf924463a3, processorArchitecture=MSIL">
4.26 - <SpecificVersion>False</SpecificVersion>
4.27 - <HintPath>External\Aga.Controls.dll</HintPath>
4.28 - </Reference>
4.29 <Reference Include="System" />
4.30 <Reference Include="System.Configuration" />
4.31 <Reference Include="System.Data" />
4.32 @@ -58,6 +55,10 @@
4.33 <Reference Include="System.Web" />
4.34 <Reference Include="System.Windows.Forms" />
4.35 <Reference Include="System.Xml" />
4.36 + <Reference Include="Aga.Controls, Version=1.7.0.0, Culture=neutral, PublicKeyToken=fcc90fbf924463a3">
4.37 + <SpecificVersion>False</SpecificVersion>
4.38 + <HintPath>External\Aga.Controls.dll</HintPath>
4.39 + </Reference>
4.40 </ItemGroup>
4.41 <ItemGroup>
4.42 <Compile Include="GUI\CrashReportForm.cs">
4.43 @@ -154,6 +155,7 @@
4.44 <Compile Include="Hardware\TBalancer\TBalancerGroup.cs" />
4.45 <Compile Include="Hardware\WinRing0.cs" />
4.46 <Compile Include="Utilities\ReadOnlyArray.cs" />
4.47 + <Compile Include="Hardware\LPC\LMSensors.cs" />
4.48 </ItemGroup>
4.49 <ItemGroup>
4.50 <EmbeddedResource Include="GUI\AboutBox.resx">