Hardware/TBalancer/TBalancer.cs
changeset 33 800a36a1ca8e
parent 15 0e812fe67bac
child 45 eadad41d21a6
     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        }