张世豪
5 小时以前 a6077217e25f5804027194a5c2848e773eda1abd
src/chuankou/SerialPortService.java
@@ -160,16 +160,17 @@
               byte[] data = buffer.toByteArray();
               SystemDebugDialog.appendHexData(data);
               // 新增:将数据传递给协议解析器
                   // 新增:将数据传递给协议解析器 - 确保始终执行
               if (protocolParser != null) {
                  protocolParser.receiveData(data);
               }
               if (!paused) {
                  onReceived.accept(data);
                  if (responseConsumer != null) {
                     responseConsumer.accept(data);
                   // 确保数据回调始终执行,不受暂停状态影响
                   if (dataReceivedCallback != null && !paused) {
                       dataReceivedCallback.accept(data);
                  }
                   if (responseConsumer != null && !paused) {
                       responseConsumer.accept(data);
               }
               buffer.reset();
            }
@@ -191,23 +192,35 @@
            byte[] data = buffer.toByteArray();              
            SystemDebugDialog.appendHexData(data);
            // 新增:将数据传递给协议解析器
               // 新增:将数据传递给协议解析器 - 确保始终执行
            if (protocolParser != null) {
               protocolParser.receiveData(data);
            }
            if (!paused) {
               onReceived.accept(data);
               if (responseConsumer != null) {
                  responseConsumer.accept(data);
               // 确保数据回调始终执行,不受暂停状态影响
               if (dataReceivedCallback != null && !paused) {
                   dataReceivedCallback.accept(data);
               }
               if (responseConsumer != null && !paused) {
                   responseConsumer.accept(data);
            }
         }
      });
      readerThread.setDaemon(true);
      readerThread.start();
   }
   // 新增:设置暂停状态但不影响协议解析器
   public void setPaused(boolean paused) {
       this.paused = paused;
       // 注意:不停止协议解析器,只暂停UI回调
   }
   // 新增:单独停止数据捕获而不影响协议解析器
   public void stopDataCaptureOnly() {
       // 只停止数据回调,不影响协议解析器
       this.dataReceivedCallback = null;
       this.responseConsumer = null;
   }
   /**
    * 停止数据接收线程
    */
@@ -219,9 +232,6 @@
      }
   }
   public void setPaused(boolean paused) {
      this.paused = paused;
   }
   public boolean isPaused() {
      return paused;