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