润和修改
This commit is contained in:
		
							parent
							
								
									71b42ce2b1
								
							
						
					
					
						commit
						7c02a122a2
					
				| @ -323,81 +323,50 @@ export async function takePhotoFn(context) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| let fd | 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) { |   // let parity = 0x4e; // 'N'
 | ||||||
|   console.log('SerialOpen in indexservice, path=' + devPath) |   let ret =await testNapi.SerialSet(fd, 115200,0, 8, 1, 0) | ||||||
| 
 |   console.log('daihairet',ret) | ||||||
|   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() |  | ||||||
|     }); |  | ||||||
|   }); |  | ||||||
| } | } | ||||||
| 
 | async function getChuankouFnMsg() { | ||||||
| function getChuankouFnMsg() { |   let timeout = 1000; // 2秒超时
 | ||||||
|   let timeout = 50000; // 2秒超时
 |  | ||||||
|   let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE
 |   let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE
 | ||||||
|   console.log('fdfd', globalThis.fd) |   let uint8Arr = new Uint8Array(databuff); | ||||||
|   console.log('zzc 1 try send msg') |   console.log('daihai',globalThis.fd) | ||||||
|   testNapi.SerialSendAsync(globalThis.fd, databuff, (ret) => { |   let ret = await testNapi.SerialSend(globalThis.fd, uint8Arr); | ||||||
|     console.log('zzc 2 send finished') |   console.log('daihai SerialSend ret: ' + ret) | ||||||
|     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) |  | ||||||
| 
 | 
 | ||||||
|       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)) | ||||||
|  |   }) | ||||||
| } | } | ||||||
| 
 | export async function getChuankouFn(){ | ||||||
| let chuankou |   if(globalThis.fd){ | ||||||
| 
 |  | ||||||
| export async function getChuankouFn() { |  | ||||||
|   if (globalThis.fd) { |  | ||||||
|     return |     return | ||||||
|   } |   } | ||||||
|   openChuankouFn(getChuankouFnMsg) |   openChuankouFn() | ||||||
|   // clearInterval(chuankou)
 |   setInterval(()=>{ | ||||||
|   // chuankou=setInterval(()=>{
 |     getChuankouFnMsg() | ||||||
|   // getChuankouFnMsg()
 |   },1500) | ||||||
|   // },1000)
 |  | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ import socket, { UDPSocket } from '@ohos.net.socket'; | |||||||
| import { Array2Byte } from '../utils/tools' | import { Array2Byte } from '../utils/tools' | ||||||
| import FileUtil from '../../common/utils/File' | import FileUtil from '../../common/utils/File' | ||||||
| import { fillZero, string2Bytes } from '../utils/tools' | import { fillZero, string2Bytes } from '../utils/tools' | ||||||
| 
 | import {getChuankouFn} from '../../common/service/indexService' | ||||||
| const TAG = '[UdpDemo.UdpClient]' | const TAG = '[UdpDemo.UdpClient]' | ||||||
| import hilog from '@ohos.hilog'; | import hilog from '@ohos.hilog'; | ||||||
| import prompt from '@ohos.prompt' | import prompt from '@ohos.prompt' | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ import {  testKm2Items,testKm3Items } from '../../pages/judgeSDK/dataTest/index' | |||||||
| import { judgeConfig } from '../../pages/judgeSDK/utils/judgeConfig'; | import { judgeConfig } from '../../pages/judgeSDK/utils/judgeConfig'; | ||||||
| import { setJudgeUdp, setTopLineUdp } from './GlobalUdp'; | import { setJudgeUdp, setTopLineUdp } from './GlobalUdp'; | ||||||
| import { convertGpsCoord2 } from '../utils/tools'; | import { convertGpsCoord2 } from '../utils/tools'; | ||||||
| 
 | // import {examCalcGpsDistance} from '../../pages/judgeSDK/api'
 | ||||||
| //@ts-ignore
 | //@ts-ignore
 | ||||||
| import libJudgeSdk from '@ohos.judgesdk' | import libJudgeSdk from '@ohos.judgesdk' | ||||||
| import GetDistance from '../utils/GetDistance' | import GetDistance from '../utils/GetDistance' | ||||||
| @ -45,8 +45,8 @@ export const initJudgeUdp = async () => { | |||||||
|         //   wd2:wd,
 |         //   wd2:wd,
 | ||||||
|         //   h:msgArr[90]*1 || 1,
 |         //   h:msgArr[90]*1 || 1,
 | ||||||
|         // })
 |         // })
 | ||||||
|         //@ts-ignore
 |         // //@ts-ignore
 | ||||||
|         globalThis.distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1) |         // globalThis.distanceClass?.setTimeData(((distance / 100).toFixed(2)) * 1)
 | ||||||
|       } |       } | ||||||
|       prevJd = jd; |       prevJd = jd; | ||||||
|       preWd = wd; |       preWd = wd; | ||||||
|  | |||||||
| @ -135,7 +135,6 @@ struct Index { | |||||||
|   // 获取扣分代码信息 |   // 获取扣分代码信息 | ||||||
|   async initMarkRules(markRules ?: MarkRule[]) { |   async initMarkRules(markRules ?: MarkRule[]) { | ||||||
|     const markRuleParams = markRules || (await getSyncData('MA_MARKRULE') as MarkRule[]) |     const markRuleParams = markRules || (await getSyncData('MA_MARKRULE') as MarkRule[]) | ||||||
| 
 |  | ||||||
|     markRuleParams.forEach(mark => { |     markRuleParams.forEach(mark => { | ||||||
|       const tempObj = { |       const tempObj = { | ||||||
|         itemno: mark.itemno * 1, |         itemno: mark.itemno * 1, | ||||||
|  | |||||||
| @ -1,10 +1,9 @@ | |||||||
| 
 |  | ||||||
| //考试回放开关
 | //考试回放开关
 | ||||||
| export const judgeConfig = { | export const judgeConfig = { | ||||||
|   //本地目录开关
 |   //本地目录开关
 | ||||||
|   isTrajectoryOpen: true, |   isTrajectoryOpen: false, | ||||||
|   //是否开启拍照
 |   //是否开启拍照
 | ||||||
|   isPhotoOpen: false, |   isPhotoOpen: true, | ||||||
|   //扣分语音是否强制开启
 |   //扣分语音是否强制开启
 | ||||||
|   kfVoiceOpen: false, |   kfVoiceOpen: false, | ||||||
|   //忽略的考试项目
 |   //忽略的考试项目
 | ||||||
| @ -16,14 +15,12 @@ export const judgeConfig = { | |||||||
|   // 本地模型地址
 |   // 本地模型地址
 | ||||||
|   modelPath: 'models/model_enc', |   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:{ |   fourInOneScreen:{ | ||||||
|     //gps位数
 |     //gps位数
 | ||||||
|     gpsDigit:6 |     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',
 |   // trajectoryPath: 'logs/2024_07_19/0000000000001_342323199501470011_测试学员1_2024_07_19_06_49_12/judge_exam_data.txt',
 | ||||||
|   //TODO 济南临时特殊配置
 |   //TODO 济南临时特殊配置
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user