Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
04761ec3
Commit
04761ec3
authored
Mar 29, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复 TCPConn 启动CRC后,数据包异常,数据的长度0,就会出错
parent
ea4f1e33
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
TCPConn.cs
Project.FLY.FObjSys/FObjSys/TCPConn.cs
+14
-0
No files found.
Project.FLY.FObjSys/FObjSys/TCPConn.cs
View file @
04761ec3
...
...
@@ -113,7 +113,13 @@ namespace FObjBase
return
-
1
;
}
else
if
(
plen
<
2
)
{
//异常,包最短也有2个byte
logger
.
Error
(
$"TCPConn GetRecvInfoPacket 包.Size =
{
plen
}
,太小,不正常, 断开重新连接"
);
sock
.
Close
();
return
-
1
;
}
if
(
len
<
plen
)
{
return
0
;
...
...
@@ -121,6 +127,14 @@ namespace FObjBase
if
(
HasCRC
)
//TODO
{
if
(
plen
<
4
)
{
//
logger
.
Error
(
"TCPConn GetRecvInfoPacket 包.Size < 4, 无法 CRC 校验。 断开重新连接"
);
sock
.
Close
();
return
-
1
;
}
UInt16
crc
=
Misc
.
CRC
.
CRC16
(
in_buffer
,
0
,
plen
-
2
);
int
packet_crc_idx
=
plen
-
2
;
UInt16
packet_crc
=
BitConverter
.
ToUInt16
(
in_buffer
.
GetRange
(
packet_crc_idx
,
2
).
ToArray
(),
0
);
...
...
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