فهرست منبع

fix(control): 修复 HAL借用ComBin重开端口不复活发送线程致串口握手死锁(D1-08)

真机闭环阻塞根因:HAL.ScanDevices 扫描每口后经 SerialChannelImpl.Close() 置
ComBin.IsStop=true,发送线程 while(IsStop)return 永久退出;采集端 serialBin.Start()
借用同一缓存 ComBin 直接 OpenPort 重开端口(返回True)再 ShakeHandsWait 入队握手,
但发送线程已死无人出队,taskAutoResetEvent.WaitOne()(无超时)永久死锁。
旧合并 operate 僵尸进程卡死在同一 serialBin.Start() 即此因。

修复:ComBin.OpenPort 重开端口成功且发送线程已停时,复位 IsStop 并重启发送线程
(SendCommandLock 防并发双起)。不改命令内容/时序/电机逻辑,仅复活被误杀的工作线程。

真机验证:control 独立进程 started:true、tlSn=NEO-1-20230411、7模块握手通过、
温度/压力/门状态/缓冲瓶换气真实串口收发,自控环在真机运行;HouseComRecord 日志恢复产出。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
huangjie 3 روز پیش
والد
کامیت
b5e581467e
1فایلهای تغییر یافته به همراه18 افزوده شده و 1 حذف شده
  1. 18 1
      ivf_tl_operate_2.0/control/ivf_tl_SerialHelper/Util/ComBin.cs

+ 18 - 1
ivf_tl_operate_2.0/control/ivf_tl_SerialHelper/Util/ComBin.cs

@@ -269,7 +269,24 @@ namespace ivf_tl_SerialHelper.Util
 
         public bool OpenPort()
         {
-            return _channel.OpenPort();
+            bool ok = _channel.OpenPort();
+            // 借用复用死锁修复(D1-08):HAL.ScanDevices 扫描每口后经 SerialChannelImpl.Close() 置 IsStop=true,
+            // 令发送线程 while(IsStop)return 永久退出;采集端 serialBin.Start() 随后借用同一缓存 ComBin、
+            // 直接调本方法重开端口(返回 True)再 ShakeHandsWait 入队握手指令,但发送线程已死、无人出队处理,
+            // ShakeHandsWait 的 taskAutoResetEvent.WaitOne()(无超时)→ 永久死锁(旧合并 operate 僵尸即卡此)。
+            // 故:重开端口成功且发送线程处于停止态时,复位 IsStop 并重启发送线程(SendCommandLock 防并发双起)。
+            if (ok)
+            {
+                lock (SendCommandLock)
+                {
+                    if (IsStop)
+                    {
+                        IsStop = false;
+                        StartSendCommandThread();
+                    }
+                }
+            }
+            return ok;
         }
 
         public bool ClosePort()