From 7394e5e60ec25ede11d1ef88358454da8f9c7390 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期二, 14 十一月 2023 18:28:51 +0800
Subject: [PATCH] 增加通讯
---
src/samples/deviceApi/TM2655VP.ts | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/samples/deviceApi/yaoHua.ts b/src/samples/deviceApi/TM2655VP.ts
similarity index 66%
rename from src/samples/deviceApi/yaoHua.ts
rename to src/samples/deviceApi/TM2655VP.ts
index 5a17553..c94e0e1 100644
--- a/src/samples/deviceApi/yaoHua.ts
+++ b/src/samples/deviceApi/TM2655VP.ts
@@ -1,4 +1,4 @@
-// 欧姆龙 HBP-9030 115200
+// 6.诊之助 TM2655VP
import { ElMessage } from 'element-plus'
const { SerialPort } = require('serialport')
const { DelimiterParser } = require('@serialport/parser-delimiter')
@@ -7,40 +7,40 @@
const initPort=(path:String,baudRate:Number)=>{
- console.log('初始化打开耀华体重秤端口')
+ console.log('初始化打开诊之助 TM2655VP端口')
const serialport = new SerialPort({ path, baudRate }, (err: any) => {
if (err) {
console.log(err)
ElMessage({
- message: '耀华体重秤端口打开失败!',
+ message: '诊之助 TM2655VP端口打开失败!',
type: 'error',
})
console.log(err)
}else{
ElMessage({
- message: '耀华体重秤端口打开成功',
+ message: '诊之助 TM2655VP端口打开成功',
type: 'success',
})
}
})
serialport.on("close",(err: any)=>{
- console.log('耀华体重秤端口异常端口链接断开')
+ console.log('诊之助 TM2655VP端口异常端口链接断开')
console.log(err)
})
// 解析分割数据流
- const parser = serialport.pipe(new ByteLengthParser({ length: 14*4-1 }))
+ const parser = serialport.pipe(new ByteLengthParser({ length: 32*2 }))
parser.on('data', (value: string | any[])=>{
console.log(value.toString())
const str=value.toString()
- const list=str.split(',')
- console.log(list)
- if(list.length===11){
-
+ console.log(str.length)
+ const re=str.substring(34,37)+','+str.substring(39,41)+','+str.substring(44,46)
+ console.log(re)
+ if(str.length>=11){
sockteStore().setxyjSockte(
{
- deviceName:'HBP-9030',
+ deviceName:'TM2655VP',
type:"血压计",
- result:list[7]+','+list[8]+','+list[9],
+ result:str.substring(34,37)+','+str.substring(44,47)+','+str.substring(49,52),
resultTime:new Date().toString(),
state:2
}
--
Gitblit v1.8.0