Release version 0.1.15. Added protocol 0x2C for T-Balancer.
This commit is contained in:
@@ -48,6 +48,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
|
||||
private Image icon;
|
||||
private SerialPort serialPort;
|
||||
private byte protocolVersion;
|
||||
private Sensor[] digitalTemperatures = new Sensor[8];
|
||||
private Sensor[] analogTemperatures = new Sensor[4];
|
||||
private Sensor[] fans = new Sensor[4];
|
||||
@@ -56,10 +57,12 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
private int[] data;
|
||||
|
||||
public const byte STARTFLAG = 100;
|
||||
public const byte PROTOCOL_VERSION = 0x2A;
|
||||
public const byte PROTOCOL_VERSION_2A = 0x2A;
|
||||
public const byte PROTOCOL_VERSION_2C = 0x2C;
|
||||
|
||||
public TBalancer(string portName) {
|
||||
public TBalancer(string portName, byte protocolVersion) {
|
||||
icon = Utilities.EmbeddedResources.GetImage("bigng.png");
|
||||
this.protocolVersion = protocolVersion;
|
||||
|
||||
try {
|
||||
serialPort = new SerialPort(portName, 19200, Parity.None, 8,
|
||||
@@ -102,7 +105,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
data[i] = serialPort.ReadByte();
|
||||
|
||||
if (data[0] != STARTFLAG || data[274] != PROTOCOL_VERSION) {
|
||||
if (data[0] != STARTFLAG || data[274] != protocolVersion) {
|
||||
serialPort.DiscardInBuffer();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
new SerialPort(portNames[i], 19200, Parity.None, 8, StopBits.One);
|
||||
serialPort.Open();
|
||||
bool isValid = false;
|
||||
byte protocolVersion = 0;
|
||||
if (serialPort.IsOpen && serialPort.CDHolding &&
|
||||
serialPort.CtsHolding) {
|
||||
|
||||
@@ -79,16 +80,19 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
}
|
||||
int length = serialPort.BytesToRead;
|
||||
if (length >= 284) {
|
||||
int[] data = new int[285];
|
||||
byte[] data = new byte[285];
|
||||
data[0] = TBalancer.STARTFLAG;
|
||||
for (int k = 1; k < data.Length; k++)
|
||||
data[k] = serialPort.ReadByte();
|
||||
data[k] = (byte)serialPort.ReadByte();
|
||||
|
||||
// check protocol version
|
||||
isValid = (data[274] == TBalancer.PROTOCOL_VERSION);
|
||||
isValid =
|
||||
data[274] == TBalancer.PROTOCOL_VERSION_2A ||
|
||||
data[274] == TBalancer.PROTOCOL_VERSION_2C;
|
||||
protocolVersion = data[274];
|
||||
if (!isValid) {
|
||||
report.Append("Status: Wrong Protocol Version: 0x");
|
||||
report.AppendLine(data[274].ToString("X"));
|
||||
report.AppendLine(protocolVersion.ToString("X"));
|
||||
}
|
||||
} else {
|
||||
report.AppendLine("Status: Wrong Message Length: " + length);
|
||||
@@ -101,7 +105,7 @@ namespace OpenHardwareMonitor.Hardware.TBalancer {
|
||||
serialPort.Close();
|
||||
if (isValid) {
|
||||
report.AppendLine("Status: OK");
|
||||
hardware.Add(new TBalancer(portNames[i]));
|
||||
hardware.Add(new TBalancer(portNames[i], protocolVersion));
|
||||
return;
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
|
||||
@@ -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.14.0")]
|
||||
[assembly: AssemblyFileVersion("0.1.14.0")]
|
||||
[assembly: AssemblyVersion("0.1.15.0")]
|
||||
[assembly: AssemblyFileVersion("0.1.15.0")]
|
||||
|
||||
Reference in New Issue
Block a user