Commit d4df9057 authored by liyuanhong's avatar liyuanhong

提交备份

parent edd1c072
[socket] [socket]
host = 10.100.9.17 host = 10.100.11.20
port = 9001 port = 9001
...@@ -39,7 +39,7 @@ class DataUpstreamTransport_msg(MessageBase): ...@@ -39,7 +39,7 @@ class DataUpstreamTransport_msg(MessageBase):
# 0xF2 故障码数据(状态改变发送) # 0xF2 故障码数据(状态改变发送)
# 0xF3 休眠进入(进入休眠模式发送) # 0xF3 休眠进入(进入休眠模式发送)
# 0xF4 休眠唤醒(退出休眠模式发送) # 0xF4 休眠唤醒(退出休眠模式发送)
msgType = "F4" msgType = "F3"
msgContent = "" msgContent = ""
if msgType == "F1": if msgType == "F1":
msgContent = self.getDrivingData() #驾驶行程数据(熄火发送) msgContent = self.getDrivingData() #驾驶行程数据(熄火发送)
...@@ -214,13 +214,8 @@ class DataUpstreamTransport_msg(MessageBase): ...@@ -214,13 +214,8 @@ class DataUpstreamTransport_msg(MessageBase):
#故障码 #故障码
troubleCode = "" troubleCode = ""
for i in range(0,troubleCodeNums): for i in range(0,troubleCodeNums):
systemId = self.int2hexStringByBytes(1) troubleCode = troubleCode + self.int2hexStringByBytes(i,4)
code1 = self.int2hexStringByBytes(10)
code2 = self.int2hexStringByBytes(20)
code3 = self.int2hexStringByBytes(30)
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):
......
...@@ -169,7 +169,7 @@ class Location_msg(MessageBase): ...@@ -169,7 +169,7 @@ class Location_msg(MessageBase):
dataId_0007 = "0007" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(480000,4) dataId_0007 = "0007" + self.int2hexStringByBytes(4) + self.int2hexStringByBytes(480000,4)
dataId_0010 = "0010" + self.int2hexStringByBytes(int(len(self.getSpeedupInOneSeconds()) / 2)) + self.getSpeedupInOneSeconds() dataId_0010 = "0010" + self.int2hexStringByBytes(int(len(self.getSpeedupInOneSeconds()) / 2)) + self.getSpeedupInOneSeconds()
dataId_0011 = "0011" + self.int2hexStringByBytes(int(len(CarSafeStatusInfo().generateSecurityStatusData()) / 2)) + CarSafeStatusInfo().generateSecurityStatusData() dataId_0011 = "0011" + self.int2hexStringByBytes(int(len(CarSafeStatusInfo().generateSecurityStatusData()) / 2)) + CarSafeStatusInfo().generateSecurityStatusData()
dataId_0012 = "0012" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(362,2) dataId_0012 = "0012" + self.int2hexStringByBytes(2) + self.int2hexStringByBytes(36,2)
dataId_0013 = "0013" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(6) dataId_0013 = "0013" + self.int2hexStringByBytes(1) + self.int2hexStringByBytes(6)
#TODO 由于被置灰,所以没有实现 #TODO 由于被置灰,所以没有实现
# dataId_0015 = "0015" + self.int2hexStringByBytes(2) # dataId_0015 = "0015" + self.int2hexStringByBytes(2)
...@@ -354,6 +354,39 @@ class Location_msg(MessageBase): ...@@ -354,6 +354,39 @@ class Location_msg(MessageBase):
rollOverAlarm = 1073741824 #侧翻预警 rollOverAlarm = 1073741824 #侧翻预警
illegalOpenDoor = 2147483648 #非法开门报警(终端未设置区域时, 不判断非法开门) illegalOpenDoor = 2147483648 #非法开门报警(终端未设置区域时, 不判断非法开门)
# emergencyAlarm = 0 #紧急报警,触动报警开关后触发
# overspeedAlarm = 0 #超速报警
# fatigueDriving = 0 #疲劳驾驶
# dangerAlarm = 0 #危险预警
# GNSSTrouble = 0 #GNSS 模块发生故障
# GNSSAntennaeLost = 0 #GNSS 天线未接或被剪断
# GNSSAntennaeShortOut = 0 #GNSS 天线短路
# TerminalMainPowerLackVoltage = 0 #终端主电源欠压
# TerminalMainPowerLostConnect = 0 #终端主电源掉电(设备拔出告警)
# TerMinalLCDTrouble = 0 #终端 LCD 或显示器故障
# TTSTrouble = 0 #TTS 模块故障
# cameraTrouble = 0 #摄像头故障
# ICTrouble = 0 #道路运输证 IC 卡模块故障
# speedEarlyWarning = 0 #超速预警
# fatigueDrivingearlyWarning = 0 #疲劳驾驶预警
# retain1 = 0
# retain2 = 0
# retain3 = 0
# drivingOverTime = 0 #当天累计驾驶超时
# stoppingOverTime = 0 #超时停车
# InOutArea = 0 #进出区域
# InOutRouting = 0 #进出路线
# drivingLongOrShort = 0 #路段行驶时间不足/过长
# routingDivergeAlarm = 0 #路线偏离报警
# VSSTrouble = 0 #车辆 VSS 故障
# oilException = 0 #车辆油量异常
# carLost = 0 #车辆被盗(通过车辆防盗器)
# illegalFire = 0 #车辆非法点火
# illegalMoving = 0 #车辆非法位移(拖车告警)
# collisionAlarm = 0 #碰撞预警
# rollOverAlarm = 0 #侧翻预警
# illegalOpenDoor = 0 #非法开门报警(终端未设置区域时, 不判断非法开门)
data = emergencyAlarm + overspeedAlarm + fatigueDriving + dangerAlarm + GNSSTrouble + GNSSAntennaeLost data = emergencyAlarm + overspeedAlarm + fatigueDriving + dangerAlarm + GNSSTrouble + GNSSAntennaeLost
data = data + GNSSAntennaeShortOut + TerminalMainPowerLackVoltage + TerminalMainPowerLostConnect + TerMinalLCDTrouble data = data + GNSSAntennaeShortOut + TerminalMainPowerLackVoltage + TerminalMainPowerLostConnect + TerMinalLCDTrouble
data = data + TTSTrouble + cameraTrouble + ICTrouble + speedEarlyWarning + fatigueDrivingearlyWarning data = data + TTSTrouble + cameraTrouble + ICTrouble + speedEarlyWarning + fatigueDrivingearlyWarning
......
...@@ -54,8 +54,8 @@ class TerminalHeartbeat_msg(MessageBase): ...@@ -54,8 +54,8 @@ class TerminalHeartbeat_msg(MessageBase):
msgID = "0002" msgID = "0002"
subPkg = 0 subPkg = 0
msgBodyProperty = self.getMsgBodyProperty(msgBodyLen=int(len(self.getMsgBody()) / 2),subPkg=subPkg) #消息体属性 msgBodyProperty = self.getMsgBodyProperty(msgBodyLen=int(len(self.getMsgBody()) / 2),subPkg=subPkg) #消息体属性
phoneNum = self.int2BCD(13146201119) #终端手机号 phoneNum = self.int2BCD(13146201118) #终端手机号
msgWaterCode = self.int2hexStringByBytes(1,2) #消息流水号 msgWaterCode = self.int2hexStringByBytes(6,2) #消息流水号
if subPkg != 8192: if subPkg != 8192:
subPkgContent = "" #消息包封装项 subPkgContent = "" #消息包封装项
else: else:
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
''' '''
定义平台版本信息包上传应答解码类 定义平台版本信息包上传应答解码类
''' '''
import json
from lib.protocol.message.MessageBase import MessageBase from lib.protocol.message.MessageBase import MessageBase
from lib.protocol.messagePlateform.ResponseBase import ResponseBase from lib.protocol.messagePlateform.ResponseBase import ResponseBase
...@@ -25,6 +27,7 @@ class PlatefromVersionInfo_res(ResponseBase): ...@@ -25,6 +27,7 @@ class PlatefromVersionInfo_res(ResponseBase):
json_msg["body"] = self.getMsgBody() json_msg["body"] = self.getMsgBody()
json_msg["checkCode"] = self.getCheckCode() json_msg["checkCode"] = self.getCheckCode()
json_msg["calculateCheckCode"] = self.getCalculateCheckCode() #自己计算消息后得到的校验码 json_msg["calculateCheckCode"] = self.getCalculateCheckCode() #自己计算消息后得到的校验码
json_msg = json.dumps(json_msg)
return json_msg return json_msg
####################################################### #######################################################
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
''' '''
定义平台通用应答消息解码类 定义平台通用应答消息解码类
''' '''
import json
from lib.protocol.message.MessageBase import MessageBase from lib.protocol.message.MessageBase import MessageBase
from lib.protocol.messagePlateform.ResponseBase import ResponseBase from lib.protocol.messagePlateform.ResponseBase import ResponseBase
...@@ -25,6 +27,7 @@ class PlatformCommon_res(ResponseBase): ...@@ -25,6 +27,7 @@ class PlatformCommon_res(ResponseBase):
json_msg["body"] = self.getMsgBody() json_msg["body"] = self.getMsgBody()
json_msg["checkCode"] = self.getCheckCode() json_msg["checkCode"] = self.getCheckCode()
json_msg["calculateCheckCode"] = self.getCalculateCheckCode() #自己计算消息后得到的校验码 json_msg["calculateCheckCode"] = self.getCalculateCheckCode() #自己计算消息后得到的校验码
json_msg = json.dumps(json_msg)
return json_msg return json_msg
####################################################### #######################################################
......
...@@ -50,6 +50,17 @@ class ResponseBase(Base): ...@@ -50,6 +50,17 @@ class ResponseBase(Base):
val = int(data,16) val = int(data,16)
return val return val
#######################################################
# 16进制字符串转换为ascii字符串
#######################################################
def hex2string(self,data):
theStr = ""
while data != "":
tmp = data[:2]
data = data[2:]
theStr = theStr + chr(int(tmp, 16))
return theStr
####################################################### #######################################################
# BCD时间格式转换为GMD时间格式 # BCD时间格式转换为GMD时间格式
####################################################### #######################################################
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
''' '''
定义平台通用应答消息解码类 定义平台通用应答消息解码类
''' '''
import json
from lib.protocol.message.MessageBase import MessageBase from lib.protocol.message.MessageBase import MessageBase
from lib.protocol.messagePlateform.ResponseBase import ResponseBase from lib.protocol.messagePlateform.ResponseBase import ResponseBase
...@@ -25,6 +27,7 @@ class TerminalRegister_res(ResponseBase): ...@@ -25,6 +27,7 @@ class TerminalRegister_res(ResponseBase):
json_msg["body"] = self.getMsgBody() json_msg["body"] = self.getMsgBody()
json_msg["checkCode"] = self.getCheckCode() json_msg["checkCode"] = self.getCheckCode()
json_msg["calculateCheckCode"] = self.getCalculateCheckCode() #自己计算消息后得到的校验码 json_msg["calculateCheckCode"] = self.getCalculateCheckCode() #自己计算消息后得到的校验码
json_msg = json.dumps(json_msg)
return json_msg return json_msg
####################################################### #######################################################
...@@ -74,7 +77,7 @@ class TerminalRegister_res(ResponseBase): ...@@ -74,7 +77,7 @@ class TerminalRegister_res(ResponseBase):
authenticationCode = body[6:] #鉴权码 authenticationCode = body[6:] #鉴权码
json_body["resWaterCode"] = int(resWaterCode,16) json_body["resWaterCode"] = int(resWaterCode,16)
json_body["result"] = int(result,16) json_body["result"] = int(result,16)
json_body["authenticationCode"] = authenticationCode json_body["authenticationCode"] = self.hex2string(authenticationCode)
return json_body return json_body
####################################################### #######################################################
......
...@@ -12,10 +12,11 @@ from lib.protocol.message.TerminalHeartbeat_msg import TerminalHeartbeat_msg ...@@ -12,10 +12,11 @@ from lib.protocol.message.TerminalHeartbeat_msg import TerminalHeartbeat_msg
from lib.protocol.message.TerminalRegister_msg import TerminalRegister_msg from lib.protocol.message.TerminalRegister_msg import TerminalRegister_msg
from lib.protocol.message.TerminalVersionInfo_msg import TerminalVersionInfo_msg from lib.protocol.message.TerminalVersionInfo_msg import TerminalVersionInfo_msg
from lib.protocol.message.TextInfoUpload_msg import TextInfoUpload_msg from lib.protocol.message.TextInfoUpload_msg import TextInfoUpload_msg
from lib.protocol.messagePlateform.PlateformVersionInfo_res import PlatefromVersionInfo_res
from lib.protocol.messagePlateform.PlatformCommon_res import PlatformCommon_res from lib.protocol.messagePlateform.PlatformCommon_res import PlatformCommon_res
from lib.protocol.messagePlateform.TerminalRegister_res import TerminalRegister_res from lib.protocol.messagePlateform.TerminalRegister_res import TerminalRegister_res
host = "10.100.9.17" host = "10.100.11.20"
port = 9001 port = 9001
# msg = MessageBase().generateMsg() # msg = MessageBase().generateMsg()
...@@ -27,12 +28,12 @@ port = 9001 ...@@ -27,12 +28,12 @@ port = 9001
# msg = TerminalVersionInfo_msg().generateMsg() #终端版本信息上报 # msg = TerminalVersionInfo_msg().generateMsg() #终端版本信息上报
# msg = QueryTerminalParam_res().generateMsg() #查询终端参数应答 # msg = QueryTerminalParam_res().generateMsg() #查询终端参数应答
# msg = QueryTerminalProperty_res().generateMsg() #查询终端属性应答消息 # msg = QueryTerminalProperty_res().generateMsg() #查询终端属性应答消息
# msg = Location_msg().generateMsg() #位置信息汇报 msg = Location_msg().generateMsg() #位置信息汇报
# msg = DataUpstreamTransport_msg().generateMsg() #数据上行透传消息 # msg = DataUpstreamTransport_msg().generateMsg() #数据上行透传消息
# msg = TerminalUpdataResult_msg().generateMsg() #终端升级结果通知 # msg = TerminalUpdataResult_msg().generateMsg() #终端升级结果通知
# msg = LocationDataBatchUpdate_msg().generateMsg() #定位数据批量上传 # msg = LocationDataBatchUpdate_msg().generateMsg() #定位数据批量上传
# msg = TextInfoUpload_msg().generateMsg() #文本信息上传 # msg = TextInfoUpload_msg().generateMsg() #文本信息上传
msg = PlateformUpdateRes_msg().generateMsg() #平台升级数据包应答 # msg = PlateformUpdateRes_msg().generateMsg() #平台升级数据包应答
#发送单条消息 #发送单条消息
def sendSingleMsg(msg): def sendSingleMsg(msg):
...@@ -48,6 +49,7 @@ def sendSingleMsg(msg): ...@@ -48,6 +49,7 @@ def sendSingleMsg(msg):
print(data) print(data)
print(PlatformCommon_res(data).getMsg()) #解析平台通用应答消息 print(PlatformCommon_res(data).getMsg()) #解析平台通用应答消息
# print(TerminalRegister_res(data).getMsg()) #解析终端注册应答消息 # print(TerminalRegister_res(data).getMsg()) #解析终端注册应答消息
# print(PlatefromVersionInfo_res(data).getMsg()) #解析平台版本信息包上传应答
client.close() client.close()
def closeSocket(soc): def closeSocket(soc):
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
</div> </div>
<H3 style="border-bottom: 1px solid #eee;">设置心跳消息内容:</H3> <H3 style="border-bottom: 1px solid #eee;">设置心跳消息内容:</H3>
<ul class="protocol_content" style="padding:0px;"> <ul class="protocol_content" style="padding:0px;">
<label style="color:red;">心跳消息无消息体...</label> <label style="color:red;width:130px;">心跳消息无消息体...</label>
</ul> </ul>
<H3 style="border-bottom: 1px solid #eee;">控制:</H3> <H3 style="border-bottom: 1px solid #eee;">控制:</H3>
<div style="width:100%;padding:5px;margin-top:10px;"> <div style="width:100%;padding:5px;margin-top:10px;">
......
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