Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
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
Valentin Platzgummer
qgroundcontrol
Commits
2fd70162
Commit
2fd70162
authored
Aug 27, 2019
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent Microhard handler from locking main thread
parent
ec7f7406
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
11 deletions
+31
-11
MicrohardHandler.cc
src/Microhard/MicrohardHandler.cc
+13
-7
MicrohardHandler.h
src/Microhard/MicrohardHandler.h
+2
-1
MicrohardManager.cc
src/Microhard/MicrohardManager.cc
+14
-2
MicrohardSettings.cc
src/Microhard/MicrohardSettings.cc
+2
-1
No files found.
src/Microhard/MicrohardHandler.cc
View file @
2fd70162
...
@@ -42,21 +42,27 @@ MicrohardHandler::close()
...
@@ -42,21 +42,27 @@ MicrohardHandler::close()
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool
void
MicrohardHandler
::
_start
(
uint16_t
port
,
QHostAddress
addr
)
MicrohardHandler
::
_start
(
uint16_t
port
,
QHostAddress
addr
)
{
{
close
();
close
();
_tcpSocket
=
new
QTcpSocket
();
_tcpSocket
=
new
QTcpSocket
();
QObject
::
connect
(
_tcpSocket
,
&
QIODevice
::
readyRead
,
this
,
&
MicrohardHandler
::
_readBytes
);
QObject
::
connect
(
_tcpSocket
,
&
QIODevice
::
readyRead
,
this
,
&
MicrohardHandler
::
_readBytes
);
qCDebug
(
MicrohardLog
)
<<
"Connecting to"
<<
addr
;
qCDebug
(
MicrohardLog
)
<<
"Connecting to"
<<
addr
;
_tcpSocket
->
connectToHost
(
addr
,
port
);
_tcpSocket
->
connectToHost
(
addr
,
port
);
//-- TODO: This has to be removed. It's blocking the main thread.
QTimer
::
singleShot
(
1000
,
this
,
&
MicrohardHandler
::
_testConnection
);
if
(
!
_tcpSocket
->
waitForConnected
(
1000
))
{
}
//-----------------------------------------------------------------------------
void
MicrohardHandler
::
_testConnection
()
{
if
(
_tcpSocket
)
{
if
(
_tcpSocket
->
state
()
==
QAbstractSocket
::
ConnectedState
)
{
qCDebug
(
MicrohardLog
)
<<
"Connected"
;
return
;
}
emit
connected
(
0
);
emit
connected
(
0
);
close
();
close
();
return
false
;
}
}
return
true
;
}
}
src/Microhard/MicrohardHandler.h
View file @
2fd70162
...
@@ -29,10 +29,11 @@ public:
...
@@ -29,10 +29,11 @@ public:
virtual
bool
close
();
virtual
bool
close
();
protected:
protected:
virtual
bool
_start
(
uint16_t
port
,
QHostAddress
addr
=
QHostAddress
::
AnyIPv4
);
virtual
void
_start
(
uint16_t
port
,
QHostAddress
addr
=
QHostAddress
::
AnyIPv4
);
protected
slots
:
protected
slots
:
virtual
void
_readBytes
()
=
0
;
virtual
void
_readBytes
()
=
0
;
virtual
void
_testConnection
();
signals:
signals:
void
connected
(
int
status
);
void
connected
(
int
status
);
...
...
src/Microhard/MicrohardManager.cc
View file @
2fd70162
...
@@ -205,7 +205,13 @@ MicrohardManager::_setEnabled()
...
@@ -205,7 +205,13 @@ MicrohardManager::_setEnabled()
void
void
MicrohardManager
::
_connectedLoc
(
int
status
)
MicrohardManager
::
_connectedLoc
(
int
status
)
{
{
qCDebug
(
MicrohardLog
)
<<
"GND Microhard Settings Connected"
;
static
const
char
*
msg
=
"GND Microhard Settings: "
;
if
(
status
>
0
)
qCDebug
(
MicrohardLog
)
<<
msg
<<
"Connected"
;
else
if
(
status
<
0
)
qCDebug
(
MicrohardLog
)
<<
msg
<<
"Error"
;
else
qCDebug
(
MicrohardLog
)
<<
msg
<<
"Not Connected"
;
_connectedStatus
=
status
;
_connectedStatus
=
status
;
_locTimer
.
start
(
LONG_TIMEOUT
);
_locTimer
.
start
(
LONG_TIMEOUT
);
emit
connectedChanged
();
emit
connectedChanged
();
...
@@ -215,7 +221,13 @@ MicrohardManager::_connectedLoc(int status)
...
@@ -215,7 +221,13 @@ MicrohardManager::_connectedLoc(int status)
void
void
MicrohardManager
::
_connectedRem
(
int
status
)
MicrohardManager
::
_connectedRem
(
int
status
)
{
{
qCDebug
(
MicrohardLog
)
<<
"AIR Microhard Settings Connected"
;
static
const
char
*
msg
=
"AIR Microhard Settings: "
;
if
(
status
>
0
)
qCDebug
(
MicrohardLog
)
<<
msg
<<
"Connected"
;
else
if
(
status
<
0
)
qCDebug
(
MicrohardLog
)
<<
msg
<<
"Error"
;
else
qCDebug
(
MicrohardLog
)
<<
msg
<<
"Not Connected"
;
_linkConnectedStatus
=
status
;
_linkConnectedStatus
=
status
;
_remTimer
.
start
(
LONG_TIMEOUT
);
_remTimer
.
start
(
LONG_TIMEOUT
);
emit
linkConnectedChanged
();
emit
linkConnectedChanged
();
...
...
src/Microhard/MicrohardSettings.cc
View file @
2fd70162
...
@@ -27,7 +27,8 @@ MicrohardSettings::start()
...
@@ -27,7 +27,8 @@ MicrohardSettings::start()
{
{
qCDebug
(
MicrohardLog
)
<<
"Start Microhard Settings"
;
qCDebug
(
MicrohardLog
)
<<
"Start Microhard Settings"
;
_loggedIn
=
false
;
_loggedIn
=
false
;
return
_start
(
MICROHARD_SETTINGS_PORT
,
QHostAddress
(
_address
));
_start
(
MICROHARD_SETTINGS_PORT
,
QHostAddress
(
_address
));
return
true
;
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
...
...
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