Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
familyMart_takeaway
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanghui.cui
familyMart_takeaway
Commits
2f3d0d98
Commit
2f3d0d98
authored
Jun 19, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
检测数据包类型时,增加返回类型:非法数据,用于处理非法数据
parent
fbf9f931
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
8 deletions
+12
-8
src/JsonModule.cpp
+4
-4
src/JsonModule.h
+2
-2
src/main.cpp
+6
-2
No files found.
src/JsonModule.cpp
View file @
2f3d0d98
...
...
@@ -481,20 +481,20 @@ bool JsonModule::isInitData(const std::string &data)
return
document
[
"fm_cmd"
].
GetInt
()
==
1000
;
}
bool
JsonModule
::
isHeartbeatData
(
IN
const
char
*
data
)
int
JsonModule
::
isHeartbeatData
(
IN
const
char
*
data
)
{
rapidjson
::
Document
document
;
// 定义一个Document对象
document
.
Parse
(
data
);
// 解析,Parse()无返回值,也不会抛异常
if
(
document
.
HasParseError
())
// 通过HasParseError()来判断解析是否成功
{
LOG
(
ERROR
)
<<
"isHeartbeatData JSON parse error:"
<<
document
.
GetParseError
()
<<
":"
<<
document
.
GetErrorOffset
();
return
false
;
return
3
;
}
if
(
document
.
HasMember
(
"fm_cmd"
)){
if
(
document
[
"fm_cmd"
].
GetInt
()
==
3
)
return
true
;
return
1
;
}
return
false
;
return
2
;
}
bool
JsonModule
::
checkInitData
(
const
std
::
string
&
data
,
int
&
posListenPort
)
...
...
src/JsonModule.h
View file @
2f3d0d98
...
...
@@ -32,9 +32,9 @@ public:
/* 功能:判断是否是心跳包
* 参数:[1]待判断数据
* 返回:
...
* 返回:
1:心跳包 2:非心跳包 3:非法数据
* */
bool
isHeartbeatData
(
IN
const
char
*
data
);
int
isHeartbeatData
(
IN
const
char
*
data
);
/* 功能:检查初始化数据是否可用
* 参数:[1]待检查数据[2]POS监听端口
...
...
src/main.cpp
View file @
2f3d0d98
...
...
@@ -413,7 +413,8 @@ int main(int argc,char *argv[])
{
LOG
(
INFO
)
<<
"---------------- ODS ===>> PLUGIN ---------------"
;
LOG
(
INFO
)
<<
odsPushData
;
if
(
!
jsonTool
.
isHeartbeatData
(
odsPushData
.
data
())){
int
dataType
=
jsonTool
.
isHeartbeatData
(
odsPushData
.
data
());
if
(
2
==
dataType
){
if
(
jsonTool
.
convertDataOds2Pos
(
odsPushData
,
pushPosData
)
)
{
LOG
(
INFO
)
<<
"----------- PLUGIN ===>> POS ------------"
;
...
...
@@ -441,12 +442,15 @@ int main(int argc,char *argv[])
bool
rlt
=
ods
.
send
(
responseData
);
LOG
(
INFO
)
<<
"send to ods result:"
<<
rlt
;
}
else
{
else
if
(
1
==
dataType
)
{
if
(
!
bInitDone
){
ods
.
setValid
(
false
);
LOG
(
INFO
)
<<
"maybe pos restart,reconnect!!!"
;
}
}
else
if
(
3
==
dataType
){
LOG
(
INFO
)
<<
"illegal data!!"
;
}
}
else
{
...
...
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