V1.0.1.7-2 -- 2025/12/17

* CsRs485Thread12450.cs: Improved
This commit is contained in:
2025-12-17 19:27:12 +09:00
parent 5b5a4b4c59
commit ea26bb8214

View File

@@ -101,7 +101,7 @@ namespace LFP_Manager.Threads
if (_cts != null && !_cts.IsCancellationRequested) if (_cts != null && !_cts.IsCancellationRequested)
_cts.Cancel(); _cts.Cancel();
serialCommTask?.Wait(TimeSpan.FromSeconds(5)); serialCommTask?.Wait(TimeSpan.FromMilliseconds(500));
} }
catch (AggregateException) { } catch (AggregateException) { }
catch (OperationCanceledException) { } catch (OperationCanceledException) { }
@@ -310,7 +310,7 @@ namespace LFP_Manager.Threads
{ {
lock (_rxLock) lock (_rxLock)
{ {
int result = -1; int result = 0;
if (rBufStart != rBufEnd) if (rBufStart != rBufEnd)
{ {
@@ -360,32 +360,39 @@ namespace LFP_Manager.Threads
case 0: // Battery Status Data case 0: // Battery Status Data
addr_ch = 1; addr_ch = 1;
RequestRegAddr = 0x0FFF; //Byul Init 0x0000 RequestRegAddr = 0x0FFF; //Byul Init 0x0000
RequestRegLen = 0x4C; RequestRegLen = 0x20;
sCmd = CsSerialCommFunctionDelta.READ_INPUT_REG; // Command 0x04 sCmd = CsSerialCommFunctionDelta.READ_INPUT_REG; // Command 0x04
rFlag = true; rFlag = true;
break; break;
case 1: // Gyroscope Data case 1: // Battery Status Data
addr_ch = 2; addr_ch = 2;
RequestRegAddr = (0x0FFF + 0x20); //Byul Init 0x0000
RequestRegLen = 0x2C;
sCmd = CsSerialCommFunctionDelta.READ_INPUT_REG; // Command 0x04
rFlag = true;
break;
case 2: // Gyroscope Data
addr_ch = 3;
RequestRegAddr = 0x4000; RequestRegAddr = 0x4000;
RequestRegLen = 7; RequestRegLen = 7;
sCmd = CsSerialCommFunctionDelta.READ_INPUT_REG; // Command 0x17 sCmd = CsSerialCommFunctionDelta.READ_INPUT_REG; // Command 0x17
rFlag = true; rFlag = true;
break; break;
case 2: case 3:
addr_ch = 3; addr_ch = 4;
RequestRegAddr = 0x3000; RequestRegAddr = 0x3000;
RequestRegLen = 3; RequestRegLen = 3;
sCmd = CsSerialCommFunctionDelta.READ_INPUT_REG; // Command 0x19 sCmd = CsSerialCommFunctionDelta.READ_INPUT_REG; // Command 0x19
rFlag = true; rFlag = true;
break; break;
case 3: case 4:
addr_ch = 4; addr_ch = 5;
RequestRegAddr = 100; RequestRegAddr = 100;
RequestRegLen = 28; RequestRegLen = 28;
sCmd = CsSerialCommFunctionDelta.READ_HOLDING_REG; // Command 0x03 sCmd = CsSerialCommFunctionDelta.READ_HOLDING_REG; // Command 0x03
rFlag = true; rFlag = true;
break; break;
case 4: case 5:
if (Config.ModuleQty > 1) if (Config.ModuleQty > 1)
{ {
ModuleID++; ModuleID++;
@@ -441,6 +448,8 @@ namespace LFP_Manager.Threads
{ {
try try
{ {
OnPrint?.Invoke(this, $"uartCommThread Start");
int RecvTimeout = (Config != null) ? Config.RecvWaitTime : 1500; int RecvTimeout = (Config != null) ? Config.RecvWaitTime : 1500;
int getData = 0; int getData = 0;
byte cData = 0; byte cData = 0;
@@ -591,6 +600,7 @@ namespace LFP_Manager.Threads
finally finally
{ {
SerialPortThreadEnd = true; SerialPortThreadEnd = true;
OnPrint?.Invoke(this, $"uartCommThread End");
} }
} }