Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
GnssServer
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
zhushanglei
GnssServer
Commits
fffed4bb
Commit
fffed4bb
authored
Apr 06, 2022
by
zhushanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
cc86d1bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
TcpServerHandler.java
src/main/java/server/TcpServerHandler.java
+8
-8
No files found.
src/main/java/server/TcpServerHandler.java
View file @
fffed4bb
...
...
@@ -141,10 +141,10 @@ public class TcpServerHandler extends SimpleChannelInboundHandler<Object> {
serialPort
.
closePort
();
}
private
int
writeComm
(
SerialPort
serialPort
,
byte
[]
data
)
throws
InterruptedException
{
if
(
serialPort
==
null
||
!
serialPort
.
isOpen
()){
logger
.
info
(
"COM口未打开"
);
return
-
2
;
}
//
if(serialPort == null || !serialPort.isOpen()){
//
logger.info("COM口未打开");
//
return -2;
//
}
int
result
=
serialPort
.
writeBytes
(
data
,
data
.
length
);
//将字节数组全部写入串口
if
(
result
!=
-
1
){
logger
.
info
(
"COM口已成功写入数据"
);
...
...
@@ -155,10 +155,10 @@ public class TcpServerHandler extends SimpleChannelInboundHandler<Object> {
}
private
String
readComm
(
SerialPort
serialPort
)
{
if
(
serialPort
==
null
||
!
serialPort
.
isOpen
())
{
logger
.
error
(
"COM口未打开"
);
return
null
;
}
//
if (serialPort == null || !serialPort.isOpen()) {
//
logger.error("COM口未打开");
//
return null;
//
}
String
readData
=
""
;
while
(
serialPort
.
bytesAvailable
()>
0
){
//循环读取所有的返回数据。如果可读取数据长度为0或-1,则停止读取
byte
[]
newData
=
new
byte
[
serialPort
.
bytesAvailable
()];
//创建一个字节数组,长度为可读取的字节长度
...
...
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