增加消息队列及重连

This commit is contained in:
2026-06-01 09:38:11 +08:00
parent 7b911acf7a
commit 562881cc6c
3 changed files with 106 additions and 21 deletions
+6 -6
View File
@@ -190,7 +190,7 @@ export default {
this.startRS485()
this.startRS232()
// 启动心跳检测
this.startHeartbeat()
// this.startHeartbeat()
} catch (e) {
// console.log(e)
uni.showToast({
@@ -377,11 +377,11 @@ export default {
this.readData()
// 串口打开成功后,重置重连计数器和时间戳
this.reconnectCount = 0
this.last485DataTime = Date.now()
// this.reconnectCount = 0
// this.last485DataTime = Date.now()
// 记录通信恢复日志
this.addLog('485通信', '通信已恢复(重连成功)')
// this.addLog('485通信', '通信已恢复(重连成功)')
}
},
async startRS232() {
@@ -526,9 +526,9 @@ export default {
readData() {
this.timer = setInterval(async () => {
cmd.getTemp()
await cmd.getTemp()
await delay(1000)
cmd.getPressure()
await cmd.getPressure()
}, 5000)
},
async handle485HexData(hex) {