Release version 0.1.15. Added protocol 0x2C for T-Balancer.
authormoel.mich
Sun, 07 Feb 2010 20:59:13 +0000
changeset 33800a36a1ca8e
parent 32 a7f5e400f0da
child 34 dc276daadb2c
Release version 0.1.15. Added protocol 0x2C for T-Balancer.
Hardware/TBalancer/TBalancer.cs
Hardware/TBalancer/TBalancerGroup.cs
Properties/AssemblyInfo.cs
     1.1 --- a/Hardware/TBalancer/TBalancer.cs	Sun Feb 07 20:11:30 2010 +0000
     1.2 +++ b/Hardware/TBalancer/TBalancer.cs	Sun Feb 07 20:59:13 2010 +0000
     1.3 @@ -48,6 +48,7 @@
     1.4  
     1.5      private Image icon;
     1.6      private SerialPort serialPort;
     1.7 +    private byte protocolVersion;
     1.8      private Sensor[] digitalTemperatures = new Sensor[8];
     1.9      private Sensor[] analogTemperatures = new Sensor[4];
    1.10      private Sensor[] fans = new Sensor[4];
    1.11 @@ -56,10 +57,12 @@
    1.12      private int[] data;
    1.13  
    1.14      public const byte STARTFLAG = 100;
    1.15 -    public const byte PROTOCOL_VERSION = 0x2A;
    1.16 +    public const byte PROTOCOL_VERSION_2A = 0x2A;
    1.17 +    public const byte PROTOCOL_VERSION_2C = 0x2C;
    1.18  
    1.19 -    public TBalancer(string portName) {
    1.20 +    public TBalancer(string portName, byte protocolVersion) {
    1.21        icon = Utilities.EmbeddedResources.GetImage("bigng.png");
    1.22 +      this.protocolVersion = protocolVersion;
    1.23  
    1.24        try {
    1.25          serialPort = new SerialPort(portName, 19200, Parity.None, 8,
    1.26 @@ -102,7 +105,7 @@
    1.27        for (int i = 0; i < data.Length; i++)
    1.28          data[i] = serialPort.ReadByte();
    1.29  
    1.30 -      if (data[0] != STARTFLAG || data[274] != PROTOCOL_VERSION) {
    1.31 +      if (data[0] != STARTFLAG || data[274] != protocolVersion) {
    1.32          serialPort.DiscardInBuffer();   
    1.33          return;
    1.34        }
     2.1 --- a/Hardware/TBalancer/TBalancerGroup.cs	Sun Feb 07 20:11:30 2010 +0000
     2.2 +++ b/Hardware/TBalancer/TBalancerGroup.cs	Sun Feb 07 20:59:13 2010 +0000
     2.3 @@ -58,6 +58,7 @@
     2.4              new SerialPort(portNames[i], 19200, Parity.None, 8, StopBits.One);
     2.5            serialPort.Open();
     2.6            bool isValid = false;
     2.7 +          byte protocolVersion = 0;
     2.8            if (serialPort.IsOpen && serialPort.CDHolding &&
     2.9              serialPort.CtsHolding) {
    2.10  
    2.11 @@ -79,16 +80,19 @@
    2.12                }
    2.13                int length = serialPort.BytesToRead;
    2.14                if (length >= 284) {
    2.15 -                int[] data = new int[285];
    2.16 +                byte[] data = new byte[285];
    2.17                  data[0] = TBalancer.STARTFLAG;
    2.18                  for (int k = 1; k < data.Length; k++)
    2.19 -                  data[k] = serialPort.ReadByte();
    2.20 +                  data[k] = (byte)serialPort.ReadByte();
    2.21  
    2.22                  // check protocol version
    2.23 -                isValid = (data[274] == TBalancer.PROTOCOL_VERSION);
    2.24 +                isValid = 
    2.25 +                  data[274] == TBalancer.PROTOCOL_VERSION_2A ||
    2.26 +                  data[274] == TBalancer.PROTOCOL_VERSION_2C;
    2.27 +                protocolVersion = data[274];
    2.28                  if (!isValid) {
    2.29                    report.Append("Status: Wrong Protocol Version: 0x");
    2.30 -                  report.AppendLine(data[274].ToString("X"));
    2.31 +                  report.AppendLine(protocolVersion.ToString("X"));
    2.32                  }
    2.33                } else {
    2.34                  report.AppendLine("Status: Wrong Message Length: " + length);
    2.35 @@ -101,7 +105,7 @@
    2.36            serialPort.Close();
    2.37            if (isValid) {
    2.38              report.AppendLine("Status: OK");
    2.39 -            hardware.Add(new TBalancer(portNames[i]));
    2.40 +            hardware.Add(new TBalancer(portNames[i], protocolVersion));
    2.41              return;
    2.42            }
    2.43          } catch (IOException ioe) {
     3.1 --- a/Properties/AssemblyInfo.cs	Sun Feb 07 20:11:30 2010 +0000
     3.2 +++ b/Properties/AssemblyInfo.cs	Sun Feb 07 20:59:13 2010 +0000
     3.3 @@ -69,5 +69,5 @@
     3.4  // You can specify all the values or you can default the Build and Revision Numbers 
     3.5  // by using the '*' as shown below:
     3.6  // [assembly: AssemblyVersion("1.0.*")]
     3.7 -[assembly: AssemblyVersion("0.1.14.0")]
     3.8 -[assembly: AssemblyFileVersion("0.1.14.0")]
     3.9 +[assembly: AssemblyVersion("0.1.15.0")]
    3.10 +[assembly: AssemblyFileVersion("0.1.15.0")]