润和串口调试
This commit is contained in:
parent
9623750d0b
commit
600dfbe397
@ -259,15 +259,25 @@ export async function takePhotoFn(context) {
|
||||
}
|
||||
let fd
|
||||
const devPath="/dev/ttyS3"
|
||||
function openChuankouFn() {
|
||||
function openChuankouFn(callback) {
|
||||
console.log('SerialOpen in indexservice, path=' + devPath)
|
||||
fd = testNapi.SerialOpen(devPath);
|
||||
globalThis.num=0
|
||||
globalThis.fd=fd
|
||||
console.log('fdfd1111',globalThis.fd)
|
||||
// fd = testNapi.SerialOpen(devPath);
|
||||
// globalThis.num=0
|
||||
// globalThis.fd=fd
|
||||
// console.log('fdfd1111',globalThis.fd)
|
||||
//
|
||||
// let parity = 0x4e; // 'N'
|
||||
// let ret = testNapi.SerialSet(globalThis.fd, 115200, 0, 8, 1, parity);
|
||||
|
||||
|
||||
testNapi.SerialOpenAsync(devPath, (fd)=> {
|
||||
globalThis.fd = fd;
|
||||
globalThis.num=0
|
||||
let parity = 0x4e; // 'N'
|
||||
let ret = testNapi.SerialSet(globalThis.fd, 115200, 0, 8, 1, parity);
|
||||
let ret = testNapi.SerialSetAsync(globalThis.fd, 115200, 0, 8, 1, parity, (ret) => {
|
||||
callback()
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getChuankouFnMsg() {
|
||||
@ -327,10 +337,10 @@ export async function getChuankouFn(){
|
||||
if(globalThis.fd){
|
||||
return
|
||||
}
|
||||
openChuankouFn()
|
||||
openChuankouFn(getChuankouFnMsg)
|
||||
// clearInterval(chuankou)
|
||||
// chuankou=setInterval(()=>{
|
||||
getChuankouFnMsg()
|
||||
// getChuankouFnMsg()
|
||||
// },1000)
|
||||
|
||||
}
|
||||
@ -1,19 +1,18 @@
|
||||
import TcpClient from './TcpClient';
|
||||
import { getSyncData } from '../service/initable'
|
||||
import hilog from '@ohos.hilog';
|
||||
export async function getTCP(flag=false) {
|
||||
|
||||
export async function getTCP(flag?) {
|
||||
|
||||
getSyncData('IpConfigTable').then(async (result: Array<any>) => {
|
||||
console.log('result222', JSON.stringify(result))
|
||||
if (result.length) {
|
||||
if (globalThis.TcpClient && globalThis.TcpClient.closeTcp) {
|
||||
globalThis.TcpClient.closeTcp(async () => {
|
||||
if(!flag){
|
||||
return
|
||||
}
|
||||
globalThis.TcpClient.closeTcp(async ()=>{
|
||||
// const tcpClient: TcpClient =new TcpClient(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
|
||||
// globalThis.TcpClient = tcpClient
|
||||
|
||||
setTimeout(async () => {
|
||||
await globalThis.TcpClient.rebindTcp(result[0].tcplocalIp, result[0].tcplocalIpPort, result[0].tcpOppositeIp, result[0].tcpOppositePort)
|
||||
await globalThis.TcpClient.connectTcp()
|
||||
await globalThis.TcpClient.sendMsg(globalThis.carInfo?.carNo || '402') //1002
|
||||
@ -48,7 +47,7 @@ export async function getTCP(flag=false) {
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
},1000)
|
||||
})
|
||||
|
||||
}
|
||||
@ -99,7 +98,8 @@ export async function getTCP(flag=false) {
|
||||
|
||||
} else {
|
||||
globalThis.TcpClient = {}
|
||||
globalThis.TcpClient.onMessage=()=>{}
|
||||
globalThis.TcpClient.onMessage = () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -8,19 +8,21 @@ import {string2Bytes} from '../../common/utils/tools'
|
||||
export async function sendMsg(val){
|
||||
// globalThis.udpClient1&&globalThis.udpClient1.sendMsg(val)
|
||||
}
|
||||
export async function getUDP(flag:Boolean=false) {
|
||||
export async function getUDP(flag?) {
|
||||
getSyncData('IpConfigTable').then((result:Array<any>)=>{
|
||||
if(result.length){
|
||||
if(globalThis.udpClient&&globalThis.udpClient.closeUdp){
|
||||
if(!flag){
|
||||
return
|
||||
}
|
||||
if(globalThis.udpClient&&globalThis.udpClient.closeUdp){
|
||||
globalThis.udpClient.closeUdp(()=>{
|
||||
setTimeout(()=>{
|
||||
globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort,result[0].udpOppositeIp,result[0].udpOppositeIpPort)
|
||||
globalThis.udpClient.sendMsg('111')
|
||||
globalThis.host=`http://${result[0].centerIp}:${result[0].centerPort}`
|
||||
globalThis.udpClient.onError(globalThis.udpClient.onMessage?globalThis.udpClient.onMessage:()=>{})
|
||||
|
||||
},1000)
|
||||
})
|
||||
}else{
|
||||
|
||||
@ -41,7 +43,7 @@ export async function getUDP(flag:Boolean=false) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function getUDP2(flag:Boolean=false) {
|
||||
export async function getUDP2(flag?) {
|
||||
getSyncData('IpConfigTable').then(async (result:Array<any>)=>{
|
||||
if(result.length){
|
||||
if(globalThis.udpClient2&&globalThis.udpClient2.closeUdp){
|
||||
@ -49,11 +51,13 @@ export async function getUDP2(flag:Boolean=false) {
|
||||
return
|
||||
}
|
||||
globalThis.udpClient2.closeUdp(async ()=>{
|
||||
setTimeout(()=>{
|
||||
globalThis.udpClient2.rebindUdp(result[0].udplocalIp, '8800',globalThis.carInfo?.udpAddress,globalThis.carInfo?.messagePort)
|
||||
globalThis.udpClient2.onMessage((val)=>{
|
||||
})
|
||||
globalThis.udpClient2.onError()
|
||||
globalThis.udpClient2.setMsgCallBack=()=>{}
|
||||
},1000)
|
||||
|
||||
})
|
||||
}else{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user