V1.0.2.0
* Added RS232/RS485 Packet Analyzer (Tools -> Packet Analyzer) * Updated BMS History register request/response length by model * Fixed decimal truncation issue in Brazil locale for DB/CSV Log and Excel Export
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
using System.Threading;
|
||||
using System.IO.Ports;
|
||||
@@ -15,6 +15,7 @@ namespace LFP_Manager.Threads
|
||||
public delegate void UartDataUpdateRS485(object sender, ref DeviceSystemData[] aSystemData);
|
||||
public delegate void UartDataRecvRS485(byte[] data);
|
||||
public delegate void UartDataPrintRS485(object sender, string msg);
|
||||
public delegate void UartDataPacketRS485(DateTime timestamp, bool isTx, byte[] data, string description);
|
||||
#endregion
|
||||
|
||||
class CsUartThreadDelta
|
||||
@@ -50,6 +51,7 @@ namespace LFP_Manager.Threads
|
||||
public event UartDataUpdateRS485 OnUpdate = null;
|
||||
public event UartDataRecvRS485 OnDataRecv = null;
|
||||
public event UartDataPrintRS485 OnPrint = null;
|
||||
public event UartDataPacketRS485 OnPacketLog = null;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -451,6 +453,7 @@ namespace LFP_Manager.Threads
|
||||
{
|
||||
sPort.Write(txData, 0, txData.Length);
|
||||
OnPrint?.Invoke(this, csLog.trx_data_print(txData, txData.Length, 0));
|
||||
OnPacketLog?.Invoke(DateTime.Now, true, txData, null);
|
||||
}
|
||||
|
||||
if (rFlag == true)
|
||||
@@ -491,6 +494,12 @@ namespace LFP_Manager.Threads
|
||||
break;
|
||||
case 1: // Packet OK, no error
|
||||
OnPrint?.Invoke(this, csLog.trx_data_print(ReadBuf, rPosition, 1));
|
||||
if (OnPacketLog != null)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, null);
|
||||
}
|
||||
|
||||
TimeOutCount[ModuleID - 1] = 0;
|
||||
|
||||
@@ -507,20 +516,29 @@ namespace LFP_Manager.Threads
|
||||
goto StartSend;
|
||||
case 2: // Fw Update Packet OK
|
||||
OnPrint?.Invoke(this, csLog.trx_data_print(ReadBuf, rPosition, 1));
|
||||
if (OnPacketLog != null)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, "FW Update Response");
|
||||
}
|
||||
|
||||
TimeOutCount[ModuleID - 1] = 0;
|
||||
rFlag = false;
|
||||
if (OnDataRecv != null)
|
||||
{
|
||||
byte[] adata = new byte[rPosition + 1];
|
||||
for (int j = 0; j < adata.Length; j++)
|
||||
{
|
||||
adata[j] = ReadBuf[j];
|
||||
}
|
||||
byte[] adata = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, adata, 0, rPosition);
|
||||
OnDataRecv(adata);
|
||||
}
|
||||
goto StartSend;
|
||||
case -1: // Packet error
|
||||
if (OnPacketLog != null && rPosition > 0)
|
||||
{
|
||||
byte[] pData = new byte[rPosition];
|
||||
Array.Copy(ReadBuf, 0, pData, 0, rPosition);
|
||||
OnPacketLog(DateTime.Now, false, pData, "Packet Error / CRC Mismatch");
|
||||
}
|
||||
RecvPacketInit();
|
||||
Thread.Sleep(100);
|
||||
goto StartSend;
|
||||
|
||||
Reference in New Issue
Block a user