mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-30 05:47:38 +00:00
Changed the T-Balancer detection and added more report details.
This commit is contained in:
parent
3ac00a41de
commit
1b965a3ab3
@ -59,11 +59,9 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
|||||||
serialPort.Open();
|
serialPort.Open();
|
||||||
bool isValid = false;
|
bool isValid = false;
|
||||||
byte protocolVersion = 0;
|
byte protocolVersion = 0;
|
||||||
if (serialPort.IsOpen && serialPort.CDHolding &&
|
report.Append("Port Name: "); report.AppendLine(portNames[i]);
|
||||||
serialPort.CtsHolding) {
|
|
||||||
|
|
||||||
report.Append("Port Name: "); report.AppendLine(portNames[i]);
|
|
||||||
|
|
||||||
|
if (serialPort.IsOpen) {
|
||||||
serialPort.DiscardInBuffer();
|
serialPort.DiscardInBuffer();
|
||||||
serialPort.DiscardOutBuffer();
|
serialPort.DiscardOutBuffer();
|
||||||
serialPort.Write(new byte[] { 0x38 }, 0, 1);
|
serialPort.Write(new byte[] { 0x38 }, 0, 1);
|
||||||
@ -72,34 +70,39 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
|||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
if (serialPort.BytesToRead > 0 &&
|
if (serialPort.BytesToRead > 0) {
|
||||||
serialPort.ReadByte() == TBalancer.STARTFLAG) {
|
if (serialPort.ReadByte() == TBalancer.STARTFLAG) {
|
||||||
while (serialPort.BytesToRead < 284 && j < 5) {
|
while (serialPort.BytesToRead < 284 && j < 5) {
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
int length = serialPort.BytesToRead;
|
int length = serialPort.BytesToRead;
|
||||||
if (length >= 284) {
|
if (length >= 284) {
|
||||||
byte[] data = new byte[285];
|
byte[] data = new byte[285];
|
||||||
data[0] = TBalancer.STARTFLAG;
|
data[0] = TBalancer.STARTFLAG;
|
||||||
for (int k = 1; k < data.Length; k++)
|
for (int k = 1; k < data.Length; k++)
|
||||||
data[k] = (byte)serialPort.ReadByte();
|
data[k] = (byte)serialPort.ReadByte();
|
||||||
|
|
||||||
// check protocol version
|
// check protocol version
|
||||||
isValid =
|
isValid =
|
||||||
data[274] == TBalancer.PROTOCOL_VERSION_2A ||
|
data[274] == TBalancer.PROTOCOL_VERSION_2A ||
|
||||||
data[274] == TBalancer.PROTOCOL_VERSION_2C;
|
data[274] == TBalancer.PROTOCOL_VERSION_2C;
|
||||||
protocolVersion = data[274];
|
protocolVersion = data[274];
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
report.Append("Status: Wrong Protocol Version: 0x");
|
report.Append("Status: Wrong Protocol Version: 0x");
|
||||||
report.AppendLine(protocolVersion.ToString("X"));
|
report.AppendLine(protocolVersion.ToString("X"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
report.AppendLine("Status: Wrong Message Length: " + length);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
report.AppendLine("Status: Wrong Message Length: " + length);
|
report.AppendLine("Status: Wrong Startflag");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
report.AppendLine("Status: Wrong Startflag");
|
report.AppendLine("Status: No Response");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
report.AppendLine("Status: Port not Open");
|
||||||
}
|
}
|
||||||
serialPort.DiscardInBuffer();
|
serialPort.DiscardInBuffer();
|
||||||
serialPort.Close();
|
serialPort.Close();
|
||||||
@ -115,6 +118,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
|||||||
} catch (NullReferenceException ne) {
|
} catch (NullReferenceException ne) {
|
||||||
report.AppendLine(ne.ToString());
|
report.AppendLine(ne.ToString());
|
||||||
}
|
}
|
||||||
|
report.AppendLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,8 +131,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
|||||||
public string GetReport() {
|
public string GetReport() {
|
||||||
if (report.Length > 0) {
|
if (report.Length > 0) {
|
||||||
report.Insert(0, "Serial Port T-Balancer" + Environment.NewLine +
|
report.Insert(0, "Serial Port T-Balancer" + Environment.NewLine +
|
||||||
Environment.NewLine);
|
Environment.NewLine);
|
||||||
report.AppendLine();
|
|
||||||
return report.ToString();
|
return report.ToString();
|
||||||
} else
|
} else
|
||||||
return null;
|
return null;
|
||||||
|
@ -69,5 +69,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.1.18.0")]
|
[assembly: AssemblyVersion("0.1.18.1")]
|
||||||
[assembly: AssemblyFileVersion("0.1.18.0")]
|
[assembly: AssemblyFileVersion("0.1.18.1")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user