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
17b36517
Commit
17b36517
authored
Feb 07, 2020
by
李远洪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据下行解析类完成
parent
29c73da2
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
473 additions
and
12 deletions
+473
-12
lib/protocol/message/DataUpstreamTransport_msg.py
lib/protocol/message/DataUpstreamTransport_msg.py
+5
-4
lib/protocol/messageRes/DataDownStreamTransport_res.py
lib/protocol/messageRes/DataDownStreamTransport_res.py
+438
-0
lib/protocol/messageRes/PlatformCommon_res.py
lib/protocol/messageRes/PlatformCommon_res.py
+2
-2
lib/protocol/messageRes/ResponseBase.py
lib/protocol/messageRes/ResponseBase.py
+22
-0
lib/protocol/messageRes/TerminalRegister_res.py
lib/protocol/messageRes/TerminalRegister_res.py
+2
-2
lib/socket/messageTest.py
lib/socket/messageTest.py
+4
-4
No files found.
lib/protocol/message/DataUpstreamTransport_msg.py
View file @
17b36517
...
@@ -39,7 +39,7 @@ class DataUpstreamTransport_msg(MessageBase):
...
@@ -39,7 +39,7 @@ class DataUpstreamTransport_msg(MessageBase):
# 0xF2 故障码数据(状态改变发送)
# 0xF2 故障码数据(状态改变发送)
# 0xF3 休眠进入(进入休眠模式发送)
# 0xF3 休眠进入(进入休眠模式发送)
# 0xF4 休眠唤醒(退出休眠模式发送)
# 0xF4 休眠唤醒(退出休眠模式发送)
msgType
=
"F
1
"
msgType
=
"F
4
"
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
):
...
...
lib/protocol/messageRes/DataDownStreamTransport_res.py
0 → 100644
View file @
17b36517
This diff is collapsed.
Click to expand it.
lib/protocol/messageRes/PlatformCommon_res.py
View file @
17b36517
...
@@ -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
]
#分包
...
...
lib/protocol/messageRes/ResponseBase.py
View file @
17b36517
...
@@ -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
...
...
lib/protocol/messageRes/TerminalRegister_res.py
View file @
17b36517
...
@@ -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
]
#分包
...
...
lib/socket/messageTest.py
View file @
17b36517
...
@@ -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
()
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