Changed the T-Balancer detection and added more report details.

This commit is contained in:
Michael Möller 2010-02-12 08:17:51 +00:00
parent 3ac00a41de
commit 1b965a3ab3
2 changed files with 33 additions and 30 deletions

View File

@ -59,11 +59,9 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
serialPort.Open();
bool isValid = false;
byte protocolVersion = 0;
if (serialPort.IsOpen && serialPort.CDHolding &&
serialPort.CtsHolding) {
report.Append("Port Name: "); report.AppendLine(portNames[i]);
if (serialPort.IsOpen) {
serialPort.DiscardInBuffer();
serialPort.DiscardOutBuffer();
serialPort.Write(new byte[] { 0x38 }, 0, 1);
@ -72,8 +70,8 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
Thread.Sleep(100);
j++;
}
if (serialPort.BytesToRead > 0 &&
serialPort.ReadByte() == TBalancer.STARTFLAG) {
if (serialPort.BytesToRead > 0) {
if (serialPort.ReadByte() == TBalancer.STARTFLAG) {
while (serialPort.BytesToRead < 284 && j < 5) {
Thread.Sleep(100);
j++;
@ -100,6 +98,11 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
} else {
report.AppendLine("Status: Wrong Startflag");
}
} else {
report.AppendLine("Status: No Response");
}
} else {
report.AppendLine("Status: Port not Open");
}
serialPort.DiscardInBuffer();
serialPort.Close();
@ -115,6 +118,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
} catch (NullReferenceException ne) {
report.AppendLine(ne.ToString());
}
report.AppendLine();
}
}
@ -128,7 +132,6 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
if (report.Length > 0) {
report.Insert(0, "Serial Port T-Balancer" + Environment.NewLine +
Environment.NewLine);
report.AppendLine();
return report.ToString();
} else
return null;

View File

@ -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.18.0")]
[assembly: AssemblyFileVersion("0.1.18.0")]
[assembly: AssemblyVersion("0.1.18.1")]
[assembly: AssemblyFileVersion("0.1.18.1")]