Commit 17b36517 authored by 李远洪's avatar 李远洪

数据下行解析类完成

parent 29c73da2
...@@ -39,7 +39,7 @@ class DataUpstreamTransport_msg(MessageBase): ...@@ -39,7 +39,7 @@ class DataUpstreamTransport_msg(MessageBase):
# 0xF2 故障码数据(状态改变发送) # 0xF2 故障码数据(状态改变发送)
# 0xF3 休眠进入(进入休眠模式发送) # 0xF3 休眠进入(进入休眠模式发送)
# 0xF4 休眠唤醒(退出休眠模式发送) # 0xF4 休眠唤醒(退出休眠模式发送)
msgType = "F1" msgType = "F4"
msgContent = "" msgContent = ""
if msgType == "F1": if msgType == "F1":
msgContent = self.getDrivingData() #驾驶行程数据(熄火发送) msgContent = self.getDrivingData() #驾驶行程数据(熄火发送)
...@@ -121,7 +121,7 @@ class DataUpstreamTransport_msg(MessageBase): ...@@ -121,7 +121,7 @@ class DataUpstreamTransport_msg(MessageBase):
#一个驾驶循环脚刹次数支持与否,1 为支持 #一个驾驶循环脚刹次数支持与否,1 为支持
drivingCircleFootBrakeIsSupport = "0011" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(1) drivingCircleFootBrakeIsSupport = "0011" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(1)
#一个驾驶循环脚刹总次数,单位次 #一个驾驶循环脚刹总次数,单位次
drivingCircleFootBrakeTatalTimes = "0012" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(32) drivingCircleFootBrakeTatalTimes = "0012" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(32,2)
#一个驾驶循环急加速次数 #一个驾驶循环急加速次数
drivingCircleRapidlyAccelerateTimes = "0013" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(79,4) drivingCircleRapidlyAccelerateTimes = "0013" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(79,4)
#一个驾驶循环急减速次数 #一个驾驶循环急减速次数
...@@ -190,7 +190,7 @@ class DataUpstreamTransport_msg(MessageBase): ...@@ -190,7 +190,7 @@ class DataUpstreamTransport_msg(MessageBase):
return dataHex return dataHex
####################################################### #######################################################
# 火经度,单位:0.000001 度,Bit31=0/1 东经/西经 # 火经度,单位:0.000001 度,Bit31=0/1 东经/西经
####################################################### #######################################################
def getUnFireLongitude(self,data=106.54041): def getUnFireLongitude(self,data=106.54041):
orientation = 0 #0:东经 1:西经 (2147483648) orientation = 0 #0:东经 1:西经 (2147483648)
...@@ -218,8 +218,9 @@ class DataUpstreamTransport_msg(MessageBase): ...@@ -218,8 +218,9 @@ class DataUpstreamTransport_msg(MessageBase):
code1 = self.int2hexStringByBytes(10) code1 = self.int2hexStringByBytes(10)
code2 = self.int2hexStringByBytes(20) code2 = self.int2hexStringByBytes(20)
code3 = self.int2hexStringByBytes(30) code3 = self.int2hexStringByBytes(30)
troubleCode = systemId + code1 + code2 + code3 troubleCode = troubleCode + systemId + code1 + code2 + code3
data = infoTime + latitude + longitude + troubleCodeNumsHex + troubleCode data = infoTime + latitude + longitude + troubleCodeNumsHex + troubleCode
print(data)
return data return data
#获取维度 #获取维度
def getLatitude(self,data=29.40268): def getLatitude(self,data=29.40268):
......
This diff is collapsed.
...@@ -40,7 +40,7 @@ class PlatformCommon_res(ResponseBase): ...@@ -40,7 +40,7 @@ class PlatformCommon_res(ResponseBase):
phoneNum = header[8:20] #终端手机号 phoneNum = header[8:20] #终端手机号
msgWaterCode = header[20:24] #消息流水号 msgWaterCode = header[20:24] #消息流水号
json_header["msgId"] = int(msgId,16) json_header["msgId"] = msgId
json_header["msgBodyProperty"] = self.getMsgBodyProperty(msgBodyProperty) json_header["msgBodyProperty"] = self.getMsgBodyProperty(msgBodyProperty)
json_header["phoneNum"] = phoneNum[1:] json_header["phoneNum"] = phoneNum[1:]
json_header["msgWaterCode"] = int(msgWaterCode,16) json_header["msgWaterCode"] = int(msgWaterCode,16)
...@@ -48,7 +48,7 @@ class PlatformCommon_res(ResponseBase): ...@@ -48,7 +48,7 @@ class PlatformCommon_res(ResponseBase):
#获取消息体属性 #获取消息体属性
def getMsgBodyProperty(self,data): def getMsgBodyProperty(self,data):
data = self.int2binStr(int(data),2) data = self.int2binStr(int(data,16),2)
data = self.restore_7e7d(data) data = self.restore_7e7d(data)
json_data = {} json_data = {}
subPkg = data[2:3] #分包 subPkg = data[2:3] #分包
......
...@@ -43,6 +43,28 @@ class ResponseBase(Base): ...@@ -43,6 +43,28 @@ class ResponseBase(Base):
binStr = "0" + binStr binStr = "0" + binStr
return binStr return binStr
#######################################################
# 16进制字符串转换为整数
#######################################################
def hexString2int(self, data):
val = int(data,16)
return val
#######################################################
# BCD时间格式转换为GMD时间格式
#######################################################
def getBCD2GMTTime(self,data):
theTime = "20"
theTime = theTime + data[:2]
theTime = theTime + "-" + data[2:4]
theTime = theTime + "-" + data[4:6]
theTime = theTime + " " + data[6:8]
theTime = theTime + ":" + data[8:10]
theTime = theTime + ":" + data[10:]
return theTime
......
...@@ -40,7 +40,7 @@ class TerminalRegister_res(ResponseBase): ...@@ -40,7 +40,7 @@ class TerminalRegister_res(ResponseBase):
phoneNum = header[8:20] #终端手机号 phoneNum = header[8:20] #终端手机号
msgWaterCode = header[20:24] #消息流水号 msgWaterCode = header[20:24] #消息流水号
json_header["msgId"] = int(msgId,16) json_header["msgId"] = msgId
json_header["msgBodyProperty"] = self.getMsgBodyProperty(msgBodyProperty) json_header["msgBodyProperty"] = self.getMsgBodyProperty(msgBodyProperty)
json_header["phoneNum"] = phoneNum[1:] json_header["phoneNum"] = phoneNum[1:]
json_header["msgWaterCode"] = int(msgWaterCode,16) json_header["msgWaterCode"] = int(msgWaterCode,16)
...@@ -48,7 +48,7 @@ class TerminalRegister_res(ResponseBase): ...@@ -48,7 +48,7 @@ class TerminalRegister_res(ResponseBase):
#获取消息体属性 #获取消息体属性
def getMsgBodyProperty(self,data): def getMsgBodyProperty(self,data):
data = self.int2binStr(int(data),2) data = self.int2binStr(int(data,16),2)
data = self.restore_7e7d(data) data = self.restore_7e7d(data)
json_data = {} json_data = {}
subPkg = data[2:3] #分包 subPkg = data[2:3] #分包
......
...@@ -18,8 +18,8 @@ port = 9001 ...@@ -18,8 +18,8 @@ port = 9001
# msg = MessageBase().generateMsg() # msg = MessageBase().generateMsg()
# msg = TerminalCommonMsgRes_msg().generateMsg() #终端通用应答 # msg = TerminalCommonMsgRes_msg().generateMsg() #终端通用应答
# msg = TerminalHeartbeat_msg().generateMsg() #终端心跳 msg = TerminalHeartbeat_msg().generateMsg() #终端心跳
msg = TerminalRegister_msg().generateMsg() #终端注册 # msg = TerminalRegister_msg().generateMsg() #终端注册
# msg = TerminalCancle_msg().generateMsg() #终端注销 # msg = TerminalCancle_msg().generateMsg() #终端注销
# msg = TerminalAuthenticate_msg().generateMsg() #终端鉴权 # msg = TerminalAuthenticate_msg().generateMsg() #终端鉴权
# msg = Location_msg().generateMsg() #位置信息汇报 # msg = Location_msg().generateMsg() #位置信息汇报
...@@ -41,7 +41,7 @@ print(data) ...@@ -41,7 +41,7 @@ print(data)
# print(binascii.b2a_hex(data)) # print(binascii.b2a_hex(data))
# print(PlatformCommon_res(data).binary2ascii(data)) # print(PlatformCommon_res(data).binary2ascii(data))
# print(PlatformCommon_res(data).getOriginalMsg()) # print(PlatformCommon_res(data).getOriginalMsg())
# print(PlatformCommon_res(data).getMsg()) print(PlatformCommon_res(data).getMsg())
print(TerminalRegister_res(data).getMsg()) # print(TerminalRegister_res(data).getMsg())
client.close() client.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment