Fixed the temperature reading and improved the report for the Nuvoton NCT6771F super I/O chip.
1.1 --- a/Hardware/HexStringArray.cs Sun Nov 21 17:31:25 2010 +0000
1.2 +++ b/Hardware/HexStringArray.cs Wed Dec 08 19:23:13 2010 +0000
1.3 @@ -39,22 +39,21 @@
1.4 using System.Collections.Generic;
1.5
1.6 namespace OpenHardwareMonitor.Hardware {
1.7 - internal class HexStringArray {
1.8 + internal static class HexStringArray {
1.9
1.10 - private readonly byte[] array;
1.11 + public static byte Read(string s, ushort address) {
1.12 + string[] lines = s.Split(new[] { '\r', '\n' },
1.13 + StringSplitOptions.RemoveEmptyEntries);
1.14
1.15 - public HexStringArray(string input) {
1.16 - List<byte> list = new List<byte>();
1.17 - foreach (string str in input.Split(' ')) {
1.18 - string s = str.Trim();
1.19 - if (s.Length > 0)
1.20 - list.Add(Convert.ToByte(s, 16));
1.21 + foreach (string line in lines) {
1.22 + string[] array = line.Split(new[] { ' ' },
1.23 + StringSplitOptions.RemoveEmptyEntries);
1.24 +
1.25 + if (Convert.ToInt32(array[0], 16) == (address & 0xFFF0))
1.26 + return Convert.ToByte(array[(address & 0x0F) + 1], 16);
1.27 }
1.28 - array = list.ToArray();
1.29 - }
1.30
1.31 - public byte this[int i] {
1.32 - get { return array[i]; }
1.33 + throw new ArgumentException();
1.34 }
1.35 }
1.36 }
2.1 --- a/Hardware/LPC/NCT677X.cs Sun Nov 21 17:31:25 2010 +0000
2.2 +++ b/Hardware/LPC/NCT677X.cs Wed Dec 08 19:23:13 2010 +0000
2.3 @@ -62,7 +62,7 @@
2.4 Ring0.WriteIoPort(port + DATA_REGISTER_OFFSET, bank);
2.5 Ring0.WriteIoPort(port + ADDRESS_REGISTER_OFFSET, register);
2.6 return Ring0.ReadIoPort(port + DATA_REGISTER_OFFSET);
2.7 - }
2.8 + }
2.9
2.10 // Consts
2.11 private const ushort NUVOTON_VENDOR_ID = 0x5CA3;
2.12 @@ -147,19 +147,23 @@
2.13 }
2.14
2.15 for (int i = 0; i < TEMPERATURE_REG.Length; i++) {
2.16 - float value = ReadByte(TEMPERATURE_REG[i]);
2.17 + int value = ((sbyte)ReadByte(TEMPERATURE_REG[i])) << 1;
2.18 if (TEMPERATURE_HALF_BIT[i] > 0) {
2.19 - value += 0.5f * ((ReadByte(TEMPERATURE_HALF_REG[i]) >>
2.20 + value |= ((ReadByte(TEMPERATURE_HALF_REG[i]) >>
2.21 TEMPERATURE_HALF_BIT[i]) & 0x1);
2.22 }
2.23
2.24 TemperatureSource source = (TemperatureSource)
2.25 ReadByte(TEMPERATURE_SRC_REG[i]);
2.26
2.27 + float? temperature = 0.5f * value;
2.28 + if (temperature > 125 || temperature < -55)
2.29 + temperature = null;
2.30 +
2.31 switch (source) {
2.32 - case TemperatureSource.CPUTIN: temperatures[0] = value; break;
2.33 - case TemperatureSource.AUXTIN: temperatures[1] = value; break;
2.34 - case TemperatureSource.SYSTIN: temperatures[2] = value; break;
2.35 + case TemperatureSource.CPUTIN: temperatures[0] = temperature; break;
2.36 + case TemperatureSource.AUXTIN: temperatures[1] = temperature; break;
2.37 + case TemperatureSource.SYSTIN: temperatures[2] = temperature; break;
2.38 }
2.39 }
2.40
2.41 @@ -187,33 +191,35 @@
2.42 if (!Ring0.WaitIsaBusMutex(100))
2.43 return r.ToString();
2.44
2.45 + ushort[] addresses = new ushort[] {
2.46 + 0x000, 0x010, 0x020, 0x030, 0x040, 0x050, 0x060, 0x070,
2.47 + 0x100, 0x110, 0x120, 0x130, 0x140, 0x150,
2.48 + 0x200, 0x220, 0x230, 0x240, 0x250,
2.49 + 0x300, 0x320, 0x330, 0x340,
2.50 + 0x400, 0x410, 0x420, 0x440, 0x450, 0x460,
2.51 + 0x500, 0x550,
2.52 + 0x600, 0x610 ,0x620, 0x630, 0x640, 0x650, 0x660, 0x670,
2.53 + 0xA00, 0xA10, 0xA20, 0xA30, 0xA50, 0xA60, 0xA70,
2.54 + 0xB00, 0xB10, 0xB20, 0xB30, 0xB50, 0xB60, 0xB70,
2.55 + 0xC00, 0xC10, 0xC20, 0xC30, 0xC50, 0xC60, 0xC70,
2.56 + 0xD00, 0xD10, 0xD20, 0xD30, 0xD50, 0xD60,
2.57 + 0xE00, 0xE10, 0xE20, 0xE30,
2.58 + 0xF00, 0xF10, 0xF20, 0xF30};
2.59 +
2.60 r.AppendLine("Hardware Monitor Registers");
2.61 r.AppendLine();
2.62 r.AppendLine(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
2.63 r.AppendLine();
2.64 - for (int i = 0; i <= 0x7; i++) {
2.65 - r.Append(" ");
2.66 - r.Append((i << 4).ToString("X3", CultureInfo.InvariantCulture));
2.67 - r.Append(" ");
2.68 - for (int j = 0; j <= 0xF; j++) {
2.69 + foreach (ushort address in addresses) {
2.70 r.Append(" ");
2.71 - r.Append(ReadByte((ushort)((i << 4) | j)).ToString(
2.72 - "X2", CultureInfo.InvariantCulture));
2.73 - }
2.74 - r.AppendLine();
2.75 - }
2.76 - for (int bank = 1; bank <= 15; bank++) {
2.77 - for (int i = 0x5; i < 0x6; i++) {
2.78 - r.Append(" ");
2.79 - r.Append((i << 4).ToString("X3", CultureInfo.InvariantCulture));
2.80 + r.Append(address.ToString("X3", CultureInfo.InvariantCulture));
2.81 r.Append(" ");
2.82 - for (int j = 0; j <= 0xF; j++) {
2.83 + for (ushort j = 0; j <= 0xF; j++) {
2.84 r.Append(" ");
2.85 - r.Append(ReadByte((ushort)((bank << 8) | (i << 4) | j)).ToString(
2.86 + r.Append(ReadByte((ushort)(address | j)).ToString(
2.87 "X2", CultureInfo.InvariantCulture));
2.88 }
2.89 r.AppendLine();
2.90 - }
2.91 }
2.92 r.AppendLine();
2.93