fix: 修复后端数码管无法正常读取/关闭的问题
This commit is contained in:
parent
a00cc84e48
commit
774c9575d4
|
@ -100,7 +100,7 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
|
|||
return Task.Run(async () =>
|
||||
{
|
||||
var cntError = 0;
|
||||
while (info.IsRunning && !info.CTS.IsCancellationRequested)
|
||||
while (!info.CTS.IsCancellationRequested)
|
||||
{
|
||||
var beginTime = DateTime.Now;
|
||||
var waitTime = TimeSpan.FromMilliseconds(1000 / info.Frequency);
|
||||
|
@ -142,6 +142,11 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
|
|||
if (!info.IsRunning)
|
||||
{
|
||||
info.IsRunning = true;
|
||||
if (info.CTS.IsCancellationRequested)
|
||||
{
|
||||
info.CTS.Dispose();
|
||||
info.CTS = new CancellationTokenSource();
|
||||
}
|
||||
_ = ScanAllTubes(info);
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +172,8 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
|
|||
new SevenDigitalTubesCtrl(board.IpAddr, board.Port, 2))
|
||||
) is DigitalTubeInfo info)
|
||||
{
|
||||
if (info.IsRunning) info.IsRunning = false;
|
||||
info.IsRunning = false;
|
||||
info.CTS.Cancel();
|
||||
}
|
||||
|
||||
return Task.FromResult(true);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class SevenDigitalTubesCtrl
|
|||
if (ret.Value.Options.Data == null || ret.Value.Options.Data.Length < 4)
|
||||
return new(new Exception("Data length is too short"));
|
||||
|
||||
var data = Number.BytesToUInt32(ret.Value.Options.Data, 0, 4, true).Value;
|
||||
var data = Number.BytesToUInt32(ret.Value.Options.Data, 0, 4).Value;
|
||||
|
||||
if ((data >> 8) != num)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue