Added support for reading the TAMG ACPI table on Gigabyte mainboards. Fixed a small problem with HDD/SSD names (0 chars are trimmed now as well).
3 Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 The contents of this file are subject to the Mozilla Public License Version
6 1.1 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
9 http://www.mozilla.org/MPL/
11 Software distributed under the License is distributed on an "AS IS" basis,
12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 for the specific language governing rights and limitations under the License.
15 The Original Code is the Open Hardware Monitor code.
17 The Initial Developer of the Original Code is
18 Michael Möller <m.moeller@gmx.ch>.
19 Portions created by the Initial Developer are Copyright (C) 2009-2011
20 the Initial Developer. All Rights Reserved.
24 Alternatively, the contents of this file may be used under the terms of
25 either the GNU General Public License Version 2 or later (the "GPL"), or
26 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 in which case the provisions of the GPL or the LGPL are applicable instead
28 of those above. If you wish to allow use of your version of this file only
29 under the terms of either the GPL or the LGPL, and not to allow others to
30 use your version of this file under the terms of the MPL, indicate your
31 decision by deleting the provisions above and replace them with the notice
32 and other provisions required by the GPL or the LGPL. If you do not delete
33 the provisions above, a recipient may use your version of this file under
34 the terms of any one of the MPL, the GPL or the LGPL.
38 using System.Collections.Generic;
39 using System.Globalization;
43 namespace OpenHardwareMonitor.Hardware.LPC {
45 internal class LMSensors {
47 private readonly List<LMChip> lmChips = new List<LMChip>();
50 string[] basePaths = Directory.GetDirectories("/sys/class/hwmon/");
51 foreach (string basePath in basePaths) {
52 foreach (string devicePath in new[] { "/device", "" }) {
53 string path = basePath + devicePath;
57 using (StreamReader reader = new StreamReader(path + "/name"))
58 name = reader.ReadLine();
59 } catch (IOException) { }
63 lmChips.Add(new LMChip(Chip.ATK0110, path)); break;
66 lmChips.Add(new LMChip(Chip.F71858, path)); break;
68 lmChips.Add(new LMChip(Chip.F71862, path)); break;
70 lmChips.Add(new LMChip(Chip.F71882, path)); break;
72 lmChips.Add(new LMChip(Chip.F71889F, path)); break;
75 lmChips.Add(new LMChip(Chip.IT8712F, path)); break;
77 lmChips.Add(new LMChip(Chip.IT8716F, path)); break;
79 lmChips.Add(new LMChip(Chip.IT8718F, path)); break;
81 lmChips.Add(new LMChip(Chip.IT8720F, path)); break;
84 lmChips.Add(new LMChip(Chip.W83627EHF, path)); break;
86 lmChips.Add(new LMChip(Chip.W83627DHG, path)); break;
88 lmChips.Add(new LMChip(Chip.W83667HG, path)); break;
90 lmChips.Add(new LMChip(Chip.W83627HF, path)); break;
92 lmChips.Add(new LMChip(Chip.W83627THF, path)); break;
94 lmChips.Add(new LMChip(Chip.W83687THF, path)); break;
100 public void Close() {
101 foreach (LMChip lmChip in lmChips)
105 public ISuperIO[] SuperIO {
107 return lmChips.ToArray();
111 private class LMChip : ISuperIO {
114 private readonly Chip chip;
116 private readonly float?[] voltages;
117 private readonly float?[] temperatures;
118 private readonly float?[] fans;
120 private readonly FileStream[] voltageStreams;
121 private readonly FileStream[] temperatureStreams;
122 private readonly FileStream[] fanStreams;
124 public Chip Chip { get { return chip; } }
125 public float?[] Voltages { get { return voltages; } }
126 public float?[] Temperatures { get { return temperatures; } }
127 public float?[] Fans { get { return fans; } }
130 public LMChip(Chip chip, string path) {
134 string[] voltagePaths = Directory.GetFiles(path, "in*_input");
135 this.voltages = new float?[voltagePaths.Length];
136 this.voltageStreams = new FileStream[voltagePaths.Length];
137 for (int i = 0; i < voltagePaths.Length; i++)
138 voltageStreams[i] = new FileStream(voltagePaths[i],
139 FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
141 string[] temperaturePaths = Directory.GetFiles(path, "temp*_input");
142 this.temperatures = new float?[temperaturePaths.Length];
143 this.temperatureStreams = new FileStream[temperaturePaths.Length];
144 for (int i = 0; i < temperaturePaths.Length; i++)
145 temperatureStreams[i] = new FileStream(temperaturePaths[i],
146 FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
148 string[] fanPaths = Directory.GetFiles(path, "fan*_input");
149 this.fans = new float?[fanPaths.Length];
150 this.fanStreams = new FileStream[fanPaths.Length];
151 for (int i = 0; i < fanPaths.Length; i++)
152 fanStreams[i] = new FileStream(fanPaths[i],
153 FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
156 public byte? ReadGPIO(int index) {
160 public void WriteGPIO(int index, byte value) { }
162 public string GetReport() {
166 private string ReadFirstLine(Stream stream) {
167 StringBuilder sb = new StringBuilder();
169 stream.Seek(0, SeekOrigin.Begin);
170 int b = stream.ReadByte();
171 while (b != -1 && b != 10) {
173 b = stream.ReadByte();
176 return sb.ToString();
179 public void Update() {
180 for (int i = 0; i < voltages.Length; i++) {
181 string s = ReadFirstLine(voltageStreams[i]);
183 voltages[i] = 0.001f *
184 long.Parse(s, CultureInfo.InvariantCulture);
190 for (int i = 0; i < temperatures.Length; i++) {
191 string s = ReadFirstLine(temperatureStreams[i]);
193 temperatures[i] = 0.001f *
194 long.Parse(s, CultureInfo.InvariantCulture);
196 temperatures[i] = null;
200 for (int i = 0; i < fans.Length; i++) {
201 string s = ReadFirstLine(fanStreams[i]);
203 fans[i] = long.Parse(s, CultureInfo.InvariantCulture);
210 public void Close() {
211 foreach (FileStream stream in voltageStreams)
213 foreach (FileStream stream in temperatureStreams)
215 foreach (FileStream stream in fanStreams)