From 02a8750ce675cc9bbd5cd44cb2591500427aca74 Mon Sep 17 00:00:00 2001 From: wangzhongjie Date: Fri, 5 Sep 2025 17:24:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=A1=A3=E4=BD=8D=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/common/service/indexService.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index 64f6f86d..63ef3b11 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -296,19 +296,26 @@ async function openChuankouFn() { console.log('daihairet', ret) } +let readSerials = true + async function getChuankouFnMsg() { + if (!readSerials) { + return + } let timeout = 5000; // 2秒超时 let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE let uint8Arr = new Uint8Array(databuff); console.log('daihai', globalThis.fd) + readSerials = false let ret = await testNapi.SerialSend(globalThis.fd, uint8Arr); console.log('daihai SerialSend ret: ' + ret) testNapi.SerialRecv(globalThis.fd, timeout, 12).then(revTestInfo => { + readSerials = true console.log('daihai', revTestInfo?.recevedBuf?.toString()) const message = revTestInfo?.recevedBuf?.toString() - console.log("chuankou xinxi",message) + console.log("chuankou xinxi", message) if (message == '') { return } @@ -319,11 +326,14 @@ async function getChuankouFnMsg() { if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) { return } - console.log("chuankou 档位", msg[9]) - if(msg[9]==0||msg[9]==1||msg[9]==2||msg[9]==3||msg[9]==4||msg[9]==5){ + console.log("chuankou xinxi 档位", msg[9]) + if (msg[9] == 0 || msg[9] == 1 || msg[9] == 2 || msg[9] == 3 || msg[9] == 4 || msg[9] == 5) { + console.log("chuankou xinxi 111 message", message) globalThis.chuankoMsg = msg[9] + console.log("chuankou xinxi 111 档位", msg[9]) } }).catch((err) => { + readSerials = true console.log('daihaierror', JSON.stringify(err)) }) }