diff --git a/entry/src/main/ets/common/service/indexService.ts b/entry/src/main/ets/common/service/indexService.ts index f606ddfc..b20ca1c8 100644 --- a/entry/src/main/ets/common/service/indexService.ts +++ b/entry/src/main/ets/common/service/indexService.ts @@ -323,81 +323,50 @@ export async function takePhotoFn(context) { } let fd -const devPath = "/dev/ttyS3" +const devPath="/dev/ttyS1" +async function openChuankouFn() { + fd =await testNapi.SerialOpen(devPath); + globalThis.fd=fd + console.log('chuankoufd',globalThis.fd) -function openChuankouFn(callback) { - console.log('SerialOpen in indexservice, path=' + devPath) - - 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() - }); - }); + // let parity = 0x4e; // 'N' + let ret =await testNapi.SerialSet(fd, 115200,0, 8, 1, 0) + console.log('daihairet',ret) } - -function getChuankouFnMsg() { - let timeout = 50000; // 2秒超时 +async function getChuankouFnMsg() { + let timeout = 1000; // 2秒超时 let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE - console.log('fdfd', globalThis.fd) - console.log('zzc 1 try send msg') - testNapi.SerialSendAsync(globalThis.fd, databuff, (ret) => { - console.log('zzc 2 send finished') - console.log('zzc 3 try receive msg') - testNapi.SerialRecvAsync(globalThis.fd, timeout, (revTestInfo) => { - console.log('zzc 4 received msg') - console.log('revTestInfo', revTestInfo.recevedBuf.length) + let uint8Arr = new Uint8Array(databuff); + console.log('daihai',globalThis.fd) + let ret = await testNapi.SerialSend(globalThis.fd, uint8Arr); + console.log('daihai SerialSend ret: ' + ret) - const message = revTestInfo?.recevedBuf?.toString() - console.log('chuankou', message) - if (message == '') { - console.log('zzc error msg is emptry') - globalThis.num = 1 - console.log('zzc 9 num=3 close serial') - // clearInterval(chuankou) - testNapi.SerialClose(globalThis.fd); - globalThis.fd = null - getChuankouFn() - 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] - } - - console.log('zzc 5 sleep 1s') - 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); + testNapi.SerialRecv(globalThis.fd, timeout,12).then(revTestInfo=>{ + console.log('daihai',revTestInfo?.recevedBuf?.toString()) + const message = revTestInfo?.recevedBuf?.toString() + if (message == '') { + return + } + const msg = message?.split(',') + if(!msg?.length){ + return + } + if (msg[0] != '98' || msg[1] != '85' || msg.length < 9) { + return + } + globalThis.chuankoMsg=msg[9] + }).catch((err)=>{ + console.log('daihaierror',JSON.stringify(err)) + }) } - -let chuankou - -export async function getChuankouFn() { - if (globalThis.fd) { +export async function getChuankouFn(){ + if(globalThis.fd){ return } - openChuankouFn(getChuankouFnMsg) - // clearInterval(chuankou) - // chuankou=setInterval(()=>{ - // getChuankouFnMsg() - // },1000) + openChuankouFn() + setInterval(()=>{ + getChuankouFnMsg() + },1500) -} \ No newline at end of file +} diff --git a/entry/src/main/ets/common/utils/UdpClientByCenter.ts b/entry/src/main/ets/common/utils/UdpClientByCenter.ts index be3072d2..5fef4003 100644 --- a/entry/src/main/ets/common/utils/UdpClientByCenter.ts +++ b/entry/src/main/ets/common/utils/UdpClientByCenter.ts @@ -18,7 +18,7 @@ import socket, { UDPSocket } from '@ohos.net.socket'; import { Array2Byte } from '../utils/tools' import FileUtil from '../../common/utils/File' import { fillZero, string2Bytes } from '../utils/tools' - +import {getChuankouFn} from '../../common/service/indexService' const TAG = '[UdpDemo.UdpClient]' import hilog from '@ohos.hilog'; import prompt from '@ohos.prompt' diff --git a/entry/src/main/ets/common/utils/UdpJudge.ts b/entry/src/main/ets/common/utils/UdpJudge.ts index 243b0f67..61a063d6 100644 --- a/entry/src/main/ets/common/utils/UdpJudge.ts +++ b/entry/src/main/ets/common/utils/UdpJudge.ts @@ -4,7 +4,7 @@ import { testKm2Items,testKm3Items } from '../../pages/judgeSDK/dataTest/index' import { judgeConfig } from '../../pages/judgeSDK/utils/judgeConfig'; import { setJudgeUdp, setTopLineUdp } from './GlobalUdp'; import { convertGpsCoord2 } from '../utils/tools'; - +// import {examCalcGpsDistance} from '../../pages/judgeSDK/api' //@ts-ignore import libJudgeSdk from '@ohos.judgesdk' import GetDistance from '../utils/GetDistance' @@ -45,8 +45,8 @@ export const initJudgeUdp = async () => { // wd2:wd, // h:msgArr[90]*1 || 1, // }) - //@ts-ignore - globalThis.distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1) + // //@ts-ignore + // globalThis.distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1) } prevJd = jd; preWd = wd; diff --git a/entry/src/main/ets/pages/Judge.ets b/entry/src/main/ets/pages/Judge.ets index fca80179..219c77c5 100644 --- a/entry/src/main/ets/pages/Judge.ets +++ b/entry/src/main/ets/pages/Judge.ets @@ -135,7 +135,6 @@ struct Index { // 获取扣分代码信息 async initMarkRules(markRules ?: MarkRule[]) { const markRuleParams = markRules || (await getSyncData('MA_MARKRULE') as MarkRule[]) - markRuleParams.forEach(mark => { const tempObj = { itemno: mark.itemno * 1, diff --git a/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts b/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts index c9a0bab4..c6e6838d 100644 --- a/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts +++ b/entry/src/main/ets/pages/judgeSDK/utils/judgeConfig.ts @@ -1,10 +1,9 @@ - //考试回放开关 export const judgeConfig = { //本地目录开关 - isTrajectoryOpen: true, + isTrajectoryOpen: false, //是否开启拍照 - isPhotoOpen: false, + isPhotoOpen: true, //扣分语音是否强制开启 kfVoiceOpen: false, //忽略的考试项目 @@ -16,14 +15,12 @@ export const judgeConfig = { // 本地模型地址 modelPath: 'models/model_enc', // 济南科目三 - trajectoryPath: 'logs/2024_08_07_13_33_17_9999945345838_614384489851629952_管婕/judge_exam_data.txt', + trajectoryPath: 'logs/2024_10_12/2024_10_12_11_50_10_9999427676823_744299437502336256_隋统/judge_exam_data.txt', //四合一画面配置 fourInOneScreen:{ //gps位数 gpsDigit:6 }, - //后置机类型 0=>三代机 1=>一体机 2=>二代机 - rearEndUnitsType:0, // 杭州科目二 // trajectoryPath: 'logs/2024_07_19/0000000000001_342323199501470011_测试学员1_2024_07_19_06_49_12/judge_exam_data.txt', //TODO 济南临时特殊配置