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;
|
||||
@@ -44,6 +44,7 @@ namespace LFP_Manager.Threads
|
||||
public event UartDataUpdate OnUpdate = null;
|
||||
public event UartDataRecv OnDataRecv = null;
|
||||
public event UartDataPrint OnPrint = null;
|
||||
public event UartDataPacket OnPacketLog = null;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -632,6 +633,7 @@ namespace LFP_Manager.Threads
|
||||
FlushBuff();
|
||||
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)
|
||||
@@ -669,6 +671,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 = 0;
|
||||
|
||||
@@ -691,8 +699,8 @@ namespace LFP_Manager.Threads
|
||||
WriteRegAddr = 0;
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -701,20 +709,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 = 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