From ba97d6524fd4cbe3865c73a45fe66cf3b92fe332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Sun, 7 Feb 2010 20:59:13 +0000 Subject: [PATCH] Release version 0.1.15. Added protocol 0x2C for T-Balancer. --- Hardware/TBalancer/TBalancer.cs | 9 ++++++--- Hardware/TBalancer/TBalancerGroup.cs | 14 +++++++++----- Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Hardware/TBalancer/TBalancer.cs b/Hardware/TBalancer/TBalancer.cs index 278c545..9ad391e 100644 --- a/Hardware/TBalancer/TBalancer.cs +++ b/Hardware/TBalancer/TBalancer.cs @@ -48,6 +48,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer { private Image icon; private SerialPort serialPort; + private byte protocolVersion; private Sensor[] digitalTemperatures = new Sensor[8]; private Sensor[] analogTemperatures = new Sensor[4]; private Sensor[] fans = new Sensor[4]; @@ -56,10 +57,12 @@ namespace OpenHardwareMonitor.Hardware.TBalancer { private int[] data; public const byte STARTFLAG = 100; - public const byte PROTOCOL_VERSION = 0x2A; + public const byte PROTOCOL_VERSION_2A = 0x2A; + public const byte PROTOCOL_VERSION_2C = 0x2C; - public TBalancer(string portName) { + public TBalancer(string portName, byte protocolVersion) { icon = Utilities.EmbeddedResources.GetImage("bigng.png"); + this.protocolVersion = protocolVersion; try { serialPort = new SerialPort(portName, 19200, Parity.None, 8, @@ -102,7 +105,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer { for (int i = 0; i < data.Length; i++) data[i] = serialPort.ReadByte(); - if (data[0] != STARTFLAG || data[274] != PROTOCOL_VERSION) { + if (data[0] != STARTFLAG || data[274] != protocolVersion) { serialPort.DiscardInBuffer(); return; } diff --git a/Hardware/TBalancer/TBalancerGroup.cs b/Hardware/TBalancer/TBalancerGroup.cs index 2ca5c0e..254eb40 100644 --- a/Hardware/TBalancer/TBalancerGroup.cs +++ b/Hardware/TBalancer/TBalancerGroup.cs @@ -58,6 +58,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer { new SerialPort(portNames[i], 19200, Parity.None, 8, StopBits.One); serialPort.Open(); bool isValid = false; + byte protocolVersion = 0; if (serialPort.IsOpen && serialPort.CDHolding && serialPort.CtsHolding) { @@ -79,16 +80,19 @@ namespace OpenHardwareMonitor.Hardware.TBalancer { } int length = serialPort.BytesToRead; if (length >= 284) { - int[] data = new int[285]; + byte[] data = new byte[285]; data[0] = TBalancer.STARTFLAG; for (int k = 1; k < data.Length; k++) - data[k] = serialPort.ReadByte(); + data[k] = (byte)serialPort.ReadByte(); // check protocol version - isValid = (data[274] == TBalancer.PROTOCOL_VERSION); + isValid = + data[274] == TBalancer.PROTOCOL_VERSION_2A || + data[274] == TBalancer.PROTOCOL_VERSION_2C; + protocolVersion = data[274]; if (!isValid) { report.Append("Status: Wrong Protocol Version: 0x"); - report.AppendLine(data[274].ToString("X")); + report.AppendLine(protocolVersion.ToString("X")); } } else { report.AppendLine("Status: Wrong Message Length: " + length); @@ -101,7 +105,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer { serialPort.Close(); if (isValid) { report.AppendLine("Status: OK"); - hardware.Add(new TBalancer(portNames[i])); + hardware.Add(new TBalancer(portNames[i], protocolVersion)); return; } } catch (IOException ioe) { diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index eae484e..7af771d 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -69,5 +69,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.14.0")] -[assembly: AssemblyFileVersion("0.1.14.0")] +[assembly: AssemblyVersion("0.1.15.0")] +[assembly: AssemblyFileVersion("0.1.15.0")]