From 1e5da1915bde3fbd0b047035f227b29b0fe40744 Mon Sep 17 00:00:00 2001 From: MT <3075067877@qq.com> Date: Mon, 22 Sep 2025 10:57:59 +0800 Subject: [PATCH] fix 3 --- app/src/main/java/com/ouxuan/oxface/device/Ox485.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/ouxuan/oxface/device/Ox485.java b/app/src/main/java/com/ouxuan/oxface/device/Ox485.java index 4900f2e..38f9c25 100644 --- a/app/src/main/java/com/ouxuan/oxface/device/Ox485.java +++ b/app/src/main/java/com/ouxuan/oxface/device/Ox485.java @@ -645,25 +645,16 @@ public class Ox485 { return; } - // 验证串口是否真正打开 - if (!isSerialPortReallyOpen()) { - isConnecting = false; - String errorMsg = "485串口打开后状态检查失败,串口可能未正确初始化"; - LogManager.logError(TAG, errorMsg); - callback.onError(errorMsg); - return; - } - - // 启动读写线程 - serialPortManager.startReadThread(485); - serialPortManager.startSendThread(); - - // 连接成功 + // 先设置连接成功状态,再进行验证 isSerialPortOpen = true; isConnecting = false; lastSuccessTime = System.currentTimeMillis(); currentRetryCount = 0; + // 启动读写线程 + serialPortManager.startReadThread(485); + serialPortManager.startSendThread(); + LogManager.logInfo(TAG, "485连接建立成功,进入懒加载复用模式,最后成功时间: " + new java.text.SimpleDateFormat("HH:mm:ss.SSS").format(new java.util.Date(lastSuccessTime))); callback.onConnected();