From 5ac58a29816ebd6511f941fc8cb9b830c6d2265c Mon Sep 17 00:00:00 2001 From: surenjun Date: Wed, 18 Jun 2025 14:17:55 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E6=A1=A3=E4=BD=8D=E4=B8=B2?= =?UTF-8?q?=E5=8F=A3=E4=BC=98=E5=8C=96&=E4=BB=A3=E7=90=86=E5=B1=8F?= =?UTF-8?q?=E8=94=BD=E6=8E=89tcp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ServiceExtAbility/ServiceExtAbility.ets | 2 +- .../main/ets/common/service/indexService.ts | 18 ++++++++++-------- entry/src/main/ets/pages/Index.ets | 5 ++++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ets b/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ets index c6b1ec91..3e9aea5b 100644 --- a/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ets +++ b/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ets @@ -14,7 +14,7 @@ export default class ServiceExtAbility extends ServiceExtension { async onCreate(want): Promise { // tcp创建连接 - await tcpUtil.init() + // await tcpUtil.init() hilog.info(DOMAIN_NUMBER, TAG, `js-test ServiceExtensionAbility-- onCreate, want: ${want.abilityName}`); }; diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index e89e7db3..d63ebe72 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -436,15 +436,17 @@ const devPath = "/dev/ttyS3" function openChuankouFn(callback) { console.log('SerialOpen in indexservice, path=' + devPath) - //TODO 自动挡车不读取串口 - testNapi.SerialOpenAsync(devPath, (fd) => { - globalThis.fd = fd; - globalThis.num = 0 - let parity = 0x4e; // 'N' - let ret = testNapi.SerialSetAsync(globalThis.fd, 115200, 0, 8, 1, parity, (ret) => { - callback() + //自动挡车不读取串口 + if(globalThis.carInfo && globalThis.carInfo.kscx == 'C1'){ + testNapi.SerialOpenAsync(devPath, (fd) => { + globalThis.fd = fd; + globalThis.num = 0 + let parity = 0x4e; // 'N' + let ret = testNapi.SerialSetAsync(globalThis.fd, 115200, 0, 8, 1, parity, (ret) => { + callback() + }); }); - }); + } } function getChuankouFnMsg() { diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 164fe023..28c66063 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -739,7 +739,10 @@ struct Index { } }, 1000) this.createAlbum() - + getSyncData('ES_CARINFO').then(result => { + const carInfo = result[0] || {}; + globalThis.carInfo.kscx = carInfo.kscx + }) // clearInterval(globalThis.demo) // globalThis.demo= setInterval(()=>{ // const str= {"carId":"1062","examinationRoomId":"2","videoVersion":"1.0","judgeVersion":"2023.09.30.1","shellVersion":"2023.12.13.01","host":"http://172.37.55.191:8082"}