* 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:
2026-11-06 15:35:44 +09:00
parent 56e341a48a
commit e041527b56
42 changed files with 5888 additions and 160 deletions

View File

@@ -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 UartDataUpdate(object sender, ref DeviceSystemData aSystemData);
public delegate void UartDataRecv(byte[] data);
public delegate void UartDataPrint(object sender, string msg);
public delegate void UartDataPacket(DateTime timestamp, bool isTx, byte[] data, string description);
#endregion
class csUartThread
@@ -50,6 +51,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
@@ -643,6 +645,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)
@@ -680,6 +683,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;
@@ -702,8 +711,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);
}
}
@@ -712,20 +721,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;