diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index a27c38ac..57513cc3 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -311,44 +311,40 @@ function getChuankouFnMsg() { setTimeout(() => { getChuankouFnMsg() }, 200) - // let timeout = 50000; // 2秒超时 - // let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE - // testNapi.SerialSendAsync(globalThis.fd, databuff, (ret) => { - // testNapi.SerialRecvAsync(globalThis.fd, timeout, (revTestInfo) => { - // - // const message = revTestInfo?.recevedBuf?.toString() - // if (message == '') { - // globalThis.num = 1 - // // clearInterval(chuankou) - // testNapi.SerialClose(globalThis.fd); - // globalThis.fd = null - // setTimeout(() => { - // getChuankouFn() - // }, 2000) - // return - // } - // const msg = message?.split(',') - // if (!msg?.length) { - // - // } else if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) { - // - // } else if (msg.length < 12) { - // - // } else { - // globalThis.chuankoMsg = msg[9] - // } - // - // setTimeout(() => { - // getChuankouFnMsg() - // }, 500) - // - // // hilog.info(0x0000, 'testTag', 'Test NAPI SerialRecvAsync callback in'); - // // hilog.info(0x0000, 'testTag', 'Test NAPI SerialRecvAsync recevedLen = %{public}d', revTestInfo.recevedLen); - // // hilog.info(0x0000, 'testTag', 'Test NAPI SerialRecvAsync recevedBuf = %{public}s', revTestInfo.recevedBuf.toString()); - // }); - // - // }); - // let revTestInfo = testNapi?.SerialRecv(globalThis.fd, timeout); + let timeout = 50000; // 2秒超时 + let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE + testNapi.SerialSendAsync(globalThis.fd, databuff, (ret) => { + testNapi.SerialRecvAsync(globalThis.fd, timeout, (revTestInfo) => { + + const message = revTestInfo?.recevedBuf?.toString() + if (message == '') { + globalThis.num = 1 + // clearInterval(chuankou) + testNapi.SerialClose(globalThis.fd); + globalThis.fd = null + setTimeout(() => { + getChuankouFn() + }, 2000) + return + } + const msg = message?.split(',') + if (!msg?.length) { + + } else if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) { + + } else if (msg.length < 12) { + + } else { + globalThis.chuankoMsg = msg[9] + } + + setTimeout(() => { + getChuankouFnMsg() + }, 500) + + }); + + }); } let chuankou diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 0b5fbad6..642d3942 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -44,7 +44,7 @@ export default class EntryAbility extends UIAbility { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); setInterval(() => { console.log("examPeerOccupy", examPeerOccupy()) - }, 2000) + }, 5000) globalThis.carInfo = {}