# HG changeset patch # User moel.mich # Date 1265576353 0 # Node ID 800a36a1ca8e65d8078e0a4bbaf785ad77983b9f # Parent a7f5e400f0dae2d2a18bc852a0e98204efb89461 Release version 0.1.15. Added protocol 0x2C for T-Balancer. diff -r a7f5e400f0da -r 800a36a1ca8e Hardware/TBalancer/TBalancer.cs --- a/Hardware/TBalancer/TBalancer.cs Sun Feb 07 20:11:30 2010 +0000 +++ b/Hardware/TBalancer/TBalancer.cs Sun Feb 07 20:59:13 2010 +0000 @@ -48,6 +48,7 @@ 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 @@ 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 @@ 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 -r a7f5e400f0da -r 800a36a1ca8e Hardware/TBalancer/TBalancerGroup.cs --- a/Hardware/TBalancer/TBalancerGroup.cs Sun Feb 07 20:11:30 2010 +0000 +++ b/Hardware/TBalancer/TBalancerGroup.cs Sun Feb 07 20:59:13 2010 +0000 @@ -58,6 +58,7 @@ 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 @@ } 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 @@ 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 -r a7f5e400f0da -r 800a36a1ca8e Properties/AssemblyInfo.cs --- a/Properties/AssemblyInfo.cs Sun Feb 07 20:11:30 2010 +0000 +++ b/Properties/AssemblyInfo.cs Sun Feb 07 20:59:13 2010 +0000 @@ -69,5 +69,5 @@ // 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")]