Restored CTSHolding check and added more report output for T-Balancer enumeration.
1.1 --- a/Hardware/Computer.cs Mon Feb 15 22:58:29 2010 +0000
1.2 +++ b/Hardware/Computer.cs Tue Feb 16 21:44:25 2010 +0000
1.3 @@ -162,7 +162,7 @@
1.4
1.5 foreach (IGroup group in groups) {
1.6 string report = group.GetReport();
1.7 - if (report != null) {
1.8 + if (report != null && report != "") {
1.9 NewSection(w);
1.10 w.Write(report);
1.11 }
1.12 @@ -170,7 +170,7 @@
1.13 IHardware[] hardwareArray = group.Hardware;
1.14 foreach (IHardware hardware in hardwareArray) {
1.15 string hardwareReport = hardware.GetReport();
1.16 - if (hardwareReport != null) {
1.17 + if (hardwareReport != null && hardwareReport != "") {
1.18 NewSection(w);
1.19 w.Write(hardwareReport);
1.20 }
2.1 --- a/Hardware/TBalancer/TBalancerGroup.cs Mon Feb 15 22:58:29 2010 +0000
2.2 +++ b/Hardware/TBalancer/TBalancerGroup.cs Tue Feb 16 21:44:25 2010 +0000
2.3 @@ -56,54 +56,64 @@
2.4
2.5 SerialPort serialPort =
2.6 new SerialPort(portNames[i], 19200, Parity.None, 8, StopBits.One);
2.7 - serialPort.Open();
2.8 +
2.9 bool isValid = false;
2.10 byte protocolVersion = 0;
2.11 report.Append("Port Name: "); report.AppendLine(portNames[i]);
2.12
2.13 + try {
2.14 + serialPort.Open();
2.15 + } catch (UnauthorizedAccessException) {
2.16 + report.AppendLine("Exception: Access Denied");
2.17 + }
2.18 +
2.19 if (serialPort.IsOpen) {
2.20 - serialPort.DiscardInBuffer();
2.21 - serialPort.DiscardOutBuffer();
2.22 - serialPort.Write(new byte[] { 0x38 }, 0, 1);
2.23 - int j = 0;
2.24 - while (serialPort.BytesToRead == 0 && j < 2) {
2.25 - Thread.Sleep(100);
2.26 - j++;
2.27 - }
2.28 - if (serialPort.BytesToRead > 0) {
2.29 - if (serialPort.ReadByte() == TBalancer.STARTFLAG) {
2.30 - while (serialPort.BytesToRead < 284 && j < 5) {
2.31 - Thread.Sleep(100);
2.32 - j++;
2.33 - }
2.34 - int length = serialPort.BytesToRead;
2.35 - if (length >= 284) {
2.36 - byte[] data = new byte[285];
2.37 - data[0] = TBalancer.STARTFLAG;
2.38 - for (int k = 1; k < data.Length; k++)
2.39 - data[k] = (byte)serialPort.ReadByte();
2.40 + if (serialPort.CtsHolding) {
2.41 + serialPort.DiscardInBuffer();
2.42 + serialPort.DiscardOutBuffer();
2.43 + serialPort.Write(new byte[] { 0x38 }, 0, 1);
2.44 + int j = 0;
2.45 + while (serialPort.BytesToRead == 0 && j < 2) {
2.46 + Thread.Sleep(100);
2.47 + j++;
2.48 + }
2.49 + if (serialPort.BytesToRead > 0) {
2.50 + if (serialPort.ReadByte() == TBalancer.STARTFLAG) {
2.51 + while (serialPort.BytesToRead < 284 && j < 5) {
2.52 + Thread.Sleep(100);
2.53 + j++;
2.54 + }
2.55 + int length = serialPort.BytesToRead;
2.56 + if (length >= 284) {
2.57 + byte[] data = new byte[285];
2.58 + data[0] = TBalancer.STARTFLAG;
2.59 + for (int k = 1; k < data.Length; k++)
2.60 + data[k] = (byte)serialPort.ReadByte();
2.61
2.62 - // check protocol version 2X (protocols seen: 2C, 2A, 28)
2.63 - isValid = (data[274] & 0xF0) == 0x20;
2.64 - protocolVersion = data[274];
2.65 - if (!isValid) {
2.66 - report.Append("Status: Wrong Protocol Version: 0x");
2.67 - report.AppendLine(protocolVersion.ToString("X"));
2.68 + // check protocol version 2X (protocols seen: 2C, 2A, 28)
2.69 + isValid = (data[274] & 0xF0) == 0x20;
2.70 + protocolVersion = data[274];
2.71 + if (!isValid) {
2.72 + report.Append("Status: Wrong Protocol Version: 0x");
2.73 + report.AppendLine(protocolVersion.ToString("X"));
2.74 + }
2.75 + } else {
2.76 + report.AppendLine("Status: Wrong Message Length: " +length);
2.77 }
2.78 } else {
2.79 - report.AppendLine("Status: Wrong Message Length: " + length);
2.80 + report.AppendLine("Status: Wrong Startflag");
2.81 }
2.82 } else {
2.83 - report.AppendLine("Status: Wrong Startflag");
2.84 + report.AppendLine("Status: No Response");
2.85 }
2.86 } else {
2.87 - report.AppendLine("Status: No Response");
2.88 + report.AppendLine("Status: Not Clear to Send");
2.89 }
2.90 - } else {
2.91 + serialPort.DiscardInBuffer();
2.92 + serialPort.Close();
2.93 + } else {
2.94 report.AppendLine("Status: Port not Open");
2.95 - }
2.96 - serialPort.DiscardInBuffer();
2.97 - serialPort.Close();
2.98 + }
2.99 if (isValid) {
2.100 report.AppendLine("Status: OK");
2.101 hardware.Add(new TBalancer(portNames[i], protocolVersion));
2.102 @@ -111,8 +121,6 @@
2.103 }
2.104 } catch (IOException ioe) {
2.105 report.AppendLine(ioe.ToString());
2.106 - } catch (UnauthorizedAccessException uae) {
2.107 - report.AppendLine(uae.ToString());
2.108 } catch (NullReferenceException ne) {
2.109 report.AppendLine(ne.ToString());
2.110 }
3.1 --- a/Properties/AssemblyInfo.cs Mon Feb 15 22:58:29 2010 +0000
3.2 +++ b/Properties/AssemblyInfo.cs Tue Feb 16 21:44:25 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.21.0")]
3.8 -[assembly: AssemblyFileVersion("0.1.21.0")]
3.9 +[assembly: AssemblyVersion("0.1.21.1")]
3.10 +[assembly: AssemblyFileVersion("0.1.21.1")]