Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
new-socketemulator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李远洪
new-socketemulator
Commits
8a781e7c
Commit
8a781e7c
authored
Feb 14, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文本信息上报报文开发完成
parent
f9458667
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
2 deletions
+119
-2
lib/protocol/message/TerminalVersionInfo_msg.py
lib/protocol/message/TerminalVersionInfo_msg.py
+1
-1
lib/protocol/message/TextInfoUpload_msg.py
lib/protocol/message/TextInfoUpload_msg.py
+115
-0
lib/socket/messageTest.py
lib/socket/messageTest.py
+3
-1
No files found.
lib/protocol/message/TerminalVersionInfo_msg.py
View file @
8a781e7c
...
...
@@ -33,7 +33,7 @@ class TerminalVersionInfo_msg(MessageBase):
totalMileage
=
389000
,
totalOilExpend
=
420000
):
msg
=
""
msgHeader
=
self
.
getMsgHeader
(
)
msgHeader
=
self
.
getMsgHeader
_GUI
(
msgID
,
phoneNum
,
msgWaterCode
,
encryptionType
,
subPkg
)
msgBody
=
self
.
getMsgBody_GUI
(
softwareVersion
,
softwareVersionDate
,
CPUId
,
GMSType
,
GMS_IMEI
,
SIM_IMSI
,
SIM_ICCID
,
carType
,
VIN
,
\
totalMileage
,
totalOilExpend
)
checkCode
=
self
.
getCheckCode
(
msgHeader
+
msgBody
)
...
...
lib/protocol/message/TextInfoUpload_msg.py
0 → 100644
View file @
8a781e7c
#encoding:utf-8
'''
定义文本信息上传消息
'''
from
lib.protocol.message.MessageBase
import
MessageBase
class
TextInfoUpload_msg
(
MessageBase
):
def
__init__
(
self
):
super
()
.
__init__
()
#不执行该方法,无法使用父类里面定义的属性
pass
#######################################################
# 生成一条完整的消息
#######################################################
def
generateMsg
(
self
):
msg
=
""
msgHeader
=
self
.
getMsgHeader
()
msgBody
=
self
.
getMsgBody
()
checkCode
=
self
.
getCheckCode
(
msgHeader
+
msgBody
)
msg
=
msg
+
self
.
IDENTIFY
info
=
msgHeader
+
msgBody
+
checkCode
info
=
self
.
replace7e7d
(
info
)
msg
=
msg
+
info
msg
=
msg
+
self
.
IDENTIFY
return
msg
# 生成一条完整的消息,针对图形界面,可传递参数
def
generateMsg_GUI
(
self
,
msgID
=
"8300"
,
phoneNum
=
"13146201119"
,
msgWaterCode
=
1
,
encryptionType
=
0
,
subPkg
=
0
):
msg
=
""
msgHeader
=
self
.
getMsgHeader_GUI
(
msgID
,
phoneNum
,
msgWaterCode
,
encryptionType
,
subPkg
)
msgBody
=
self
.
getMsgBody
()
checkCode
=
self
.
getCheckCode
(
msgHeader
+
msgBody
)
msg
=
msg
+
self
.
IDENTIFY
info
=
msgHeader
+
msgBody
+
checkCode
info
=
self
.
replace7e7d
(
info
)
msg
=
msg
+
info
msg
=
msg
+
self
.
IDENTIFY
return
msg
#######################################################
# 获取消息体
#######################################################
def
getMsgBody
(
self
):
msg
=
""
flag
=
self
.
getFlag
()
#标志
textInfo
=
self
.
GBKString2Hex
(
"textInfo_123456"
)
#文本信息
msg
=
flag
+
textInfo
return
msg
#######################################################
# 获取消息头
#######################################################
def
getMsgHeader
(
self
):
# msgID = self.int2hexStringByBytes(102,2) #消息id
msgID
=
"8300"
subPkg
=
0
msgBodyProperty
=
self
.
getMsgBodyProperty
(
msgBodyLen
=
int
(
len
(
self
.
getMsgBody
())
/
2
),
subPkg
=
subPkg
)
#消息体属性
phoneNum
=
self
.
int2BCD
(
13146201119
)
#终端手机号
msgWaterCode
=
self
.
int2hexStringByBytes
(
1
,
2
)
#消息流水号
if
subPkg
!=
8192
:
subPkgContent
=
""
#消息包封装项
else
:
subPkgContent
=
self
.
getMsgPackage
()
data
=
msgID
+
msgBodyProperty
+
phoneNum
+
msgWaterCode
+
subPkgContent
return
data
#获取消息体属性
def
getMsgBodyProperty
(
self
,
msgBodyLen
=
128
,
encryptionType
=
0
,
subPkg
=
0
):
if
msgBodyLen
>=
512
:
raise
RuntimeError
(
'消息体长度超长!'
)
msgBodyLen
=
msgBodyLen
#消息体长度
encryptionType
=
encryptionType
#加密方式
subPkg
=
subPkg
#分包
retain
=
0
#保留位
data
=
msgBodyLen
+
encryptionType
+
subPkg
+
retain
dataHex
=
self
.
int2hexStringByBytes
(
data
,
2
)
return
dataHex
#获取消息体属性,针对图形界面,可传递参数
def
getMsgBodyProperty_GUI
(
self
,
msgBodyLen
=
128
,
encryptionType
=
0
,
subPkg
=
0
):
if
msgBodyLen
>=
512
:
raise
RuntimeError
(
'消息体长度超长!'
)
msgBodyLen
=
msgBodyLen
#消息体长度
encryptionType
=
encryptionType
#加密方式
subPkg
=
subPkg
#分包
retain
=
0
#保留位
data
=
msgBodyLen
+
encryptionType
+
subPkg
+
retain
dataHex
=
self
.
int2hexStringByBytes
(
data
,
2
)
return
dataHex
#######################################################
# 获取文本信息标志
#######################################################
def
getFlag
(
self
):
#0 1:紧急(备注:主要用于设备厂商私有协议 ASCII 文本控制指令下发)
# 1 保留
# 2 1:终端显示器显示
# 3 1:终端 TTS 播读
# 4 1:广告屏显示
# 5 0:中心导航信息,1:CAN 故障码信息
# 6-7 保留
bit0
=
0
bit2
=
4
bit3
=
8
bit4
=
16
bit5
=
32
data
=
bit0
+
bit2
+
bit3
+
bit4
+
bit5
dataHex
=
self
.
int2hexStringByBytes
(
data
)
return
dataHex
if
__name__
==
"__main__"
:
pass
\ No newline at end of file
lib/socket/messageTest.py
View file @
8a781e7c
...
...
@@ -10,6 +10,7 @@ from lib.protocol.message.TerminalCommonMsgRes_msg import TerminalCommonMsgRes_m
from
lib.protocol.message.TerminalHeartbeat_msg
import
TerminalHeartbeat_msg
from
lib.protocol.message.TerminalRegister_msg
import
TerminalRegister_msg
from
lib.protocol.message.TerminalVersionInfo_msg
import
TerminalVersionInfo_msg
from
lib.protocol.message.TextInfoUpload_msg
import
TextInfoUpload_msg
from
lib.protocol.messagePlateform.PlatformCommon_res
import
PlatformCommon_res
from
lib.protocol.messagePlateform.TerminalRegister_res
import
TerminalRegister_res
...
...
@@ -26,9 +27,10 @@ port = 9001
# msg = QueryTerminalParam_res().generateMsg() #查询终端参数应答
# msg = QueryTerminalProperty_res().generateMsg() #查询终端属性应答消息
# msg = Location_msg().generateMsg() #位置信息汇报
msg
=
DataUpstreamTransport_msg
()
.
generateMsg
()
#数据上行透传消息
#
msg = DataUpstreamTransport_msg().generateMsg() #数据上行透传消息
# msg = TerminalUpdataResult_msg().generateMsg() #终端升级结果通知
# msg = LocationDataBatchUpdate_msg().generateMsg() #定位数据批量上传
msg
=
TextInfoUpload_msg
()
.
generateMsg
()
#文本信息上传
#发送单条消息
def
sendSingleMsg
(
msg
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment