From bf5b2f96915c85274717e1e93aae2dd8a0543dea Mon Sep 17 00:00:00 2001 From: "CSSC-WORK\\murmur" Date: Wed, 20 Sep 2023 09:34:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E4=BD=8D=E7=BD=AE=E9=99=84?= =?UTF-8?q?=E5=B8=A6=E7=94=B5=E6=B1=A0=E4=BF=A1=E6=81=AF=EF=BC=8C=E6=8D=AE?= =?UTF-8?q?=E6=AD=A4=E6=9B=B4=E6=96=B0=E8=A7=A3=E6=9E=90=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0jd=20wd=20=E7=94=B5=E5=8E=8B=20=E7=94=B5=E9=87=8F?= =?UTF-8?q?=E7=BB=98=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 解析TT数据.lua | 51 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/解析TT数据.lua b/解析TT数据.lua index 1adc7e0..3a5ccc5 100644 --- a/解析TT数据.lua +++ b/解析TT数据.lua @@ -37,6 +37,32 @@ function getCFG( str ) return rst end +function getBattInfo(str) + local a1,a2,a3,a4,a5,a6,a7,a8,a9,b1,b2,b3,b4,b5,b6,b7,b8= string.unpack(">hhhhhhhhhhhhhhhhh",str) + local rst = "" + .."实际电压 "..(a1/100).."V\r\n" + .."电芯数量 "..a2.."\r\n" + .."电量 "..a3.."%\r\n" + .."容量 "..(a4/100).."AH\r\n" + .."输出电流 "..(a5/100).."A\r\n" + .."充电电流 "..(a6/100).."A\r\n" + .."温度1 "..a7.."℃\r\n" + .."温度2 "..a8.."℃\r\n" + .."温度3 "..a9.."℃\r\n" + .."电芯1电压 "..(b1/1000).."V\r\n" + .."电芯2电压 "..(b2/1000).."V\r\n" + .."电芯3电压 "..(b3/1000).."V\r\n" + .."电芯4电压 "..(b4/1000).."V\r\n" + .."电芯5电压 "..(b5/1000).."V\r\n" + .."电芯6电压 "..(b6/1000).."V\r\n" + .."电芯7电压 "..(b7/1000).."V\r\n" + .."电芯8电压 "..(b8/1000).."V\r\n" + + apiAddPoint((a1/100),8) + apiAddPoint(a3,9) + return rst +end + --解析 function parseInfo(data) local selfTest = 0x7001 @@ -92,35 +118,20 @@ function parseInfo(data) local islocok = string.unpack("B",data:sub(8+1)) rst.info = rst.info.."位置状态 "..(islocok == 0 and "正常" or "异常").."\r\n" rst.info = rst.info.. "信号, 经度, 纬度, 高度\r\n" - for i = 1, 100, 10 do + for i = 1, 80, 10 do local xh, jd, wd, gd = string.unpack("BBBBBBBhhhhhhhhh",data:sub(9,-1)) - rst.info = rst.info - .."实际电压 "..(a1/100).."V\r\n" - -- .."电芯数量 "..a2.."\r\n" - .."电量 "..a3.."%\r\n" - -- .."容量 "..a4.."\r\n" - -- .."输出电流 "..a5.."\r\n" - -- .."充电电流 ".. - .."温度1 "..a7.."℃\r\n" - .."温度2 "..a8.."℃\r\n" - .."温度3 "..a9.."℃\r\n" - -- .."电芯 1电压 ".. - -- .."电芯 2电压 ".. - -- .."电芯 3电压 ".. - -- .."电芯 4电压 ".. - -- .."电芯 5电压 ".. - -- .."电芯 6电压 ".. - -- .."电芯 7电压 ".. - -- .."电芯 8电压 ".. + rst.info = rst.info..getBattInfo(data:sub(8+1+7,-1)) end if cmd == signalInfo then