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
d18e0394
Commit
d18e0394
authored
Aug 22, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure timer start/stop happens on class thread
parent
a02485c9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
19 deletions
+63
-19
UASParameterCommsMgr.cc
src/uas/UASParameterCommsMgr.cc
+16
-5
UASParameterCommsMgr.h
src/uas/UASParameterCommsMgr.h
+9
-1
UASWaypointManager.cc
src/uas/UASWaypointManager.cc
+31
-13
UASWaypointManager.h
src/uas/UASWaypointManager.h
+7
-0
No files found.
src/uas/UASParameterCommsMgr.cc
View file @
d18e0394
...
...
@@ -19,8 +19,9 @@ UASParameterCommsMgr::UASParameterCommsMgr(QObject *parent) :
silenceTimeout
(
1000
),
transmissionListMode
(
false
)
{
// We signal to ourselves to start/stop timer on our own thread
connect
(
this
,
SIGNAL
(
_startSilenceTimer
(
void
)),
this
,
SLOT
(
_startSilenceTimerOnThisThread
(
void
)));
connect
(
this
,
SIGNAL
(
_stopSilenceTimer
(
void
)),
this
,
SLOT
(
_stopSilenceTimerOnThisThread
(
void
)));
}
UASParameterCommsMgr
*
UASParameterCommsMgr
::
initWithUAS
(
UASInterface
*
uas
)
...
...
@@ -254,7 +255,7 @@ void UASParameterCommsMgr::silenceTimerExpired()
qDebug
()
<<
"maxSilenceTimeout exceeded: "
<<
totalElapsed
;
int
missingReads
,
missingWrites
;
clearRetransmissionLists
(
missingReads
,
missingWrites
);
silenceTimer
.
stop
()
;
emit
_stopSilenceTimer
();
// Stop timer on our thread
;
lastReceiveTime
=
0
;
lastSilenceTimerReset
=
curTime
;
setParameterStatusMsg
(
tr
(
"TIMEOUT: Abandoning %1 reads %2 writes after %3 seconds"
).
arg
(
missingReads
).
arg
(
missingWrites
).
arg
(
totalElapsed
/
1000
));
...
...
@@ -370,13 +371,14 @@ void UASParameterCommsMgr::updateSilenceTimer()
if
(
0
==
lastReceiveTime
)
{
lastReceiveTime
=
lastSilenceTimerReset
;
}
silenceTimer
.
start
(
silenceTimeout
);
// We signal this to ourselves so timer is started on the right thread
emit
_startSilenceTimer
();
}
else
{
//all parameters have been received, broadcast to UI
emit
parameterListUpToDate
();
resetAfterListReceive
();
silenceTimer
.
stop
()
;
emit
_stopSilenceTimer
();
// Stop timer on our thread
;
lastReceiveTime
=
0
;
}
...
...
@@ -547,3 +549,12 @@ UASParameterCommsMgr::~UASParameterCommsMgr()
}
void
UASParameterCommsMgr
::
_startSilenceTimerOnThisThread
(
void
)
{
silenceTimer
.
start
(
silenceTimeout
);
}
void
UASParameterCommsMgr
::
_stopSilenceTimerOnThisThread
(
void
)
{
silenceTimer
.
stop
();
}
src/uas/UASParameterCommsMgr.h
View file @
d18e0394
...
...
@@ -68,6 +68,11 @@ signals:
/** @brief We updated the parameter status message */
void
parameterStatusMsgUpdated
(
QString
msg
,
int
level
);
/// @brief We signal this to ourselves in order to get timer started/stopped on our own thread.
void
_startSilenceTimer
(
void
);
void
_stopSilenceTimer
(
void
);
public
slots
:
/** @brief Iterate through all components, through all pending parameters and send them to UAS */
...
...
@@ -113,7 +118,10 @@ protected:
bool
transmissionListMode
;
///< Currently requesting list
QMap
<
int
,
QMap
<
QString
,
QVariant
>*
>
writesWaiting
;
///< All writes that have not yet been ack'd, by component ID
private
slots
:
/// @brief We signal this to ourselves in order to get timer started/stopped on our own thread.
void
_startSilenceTimerOnThisThread
(
void
);
void
_stopSilenceTimerOnThisThread
(
void
);
};
...
...
src/uas/UASWaypointManager.cc
View file @
d18e0394
...
...
@@ -61,6 +61,10 @@ UASWaypointManager::UASWaypointManager(UAS* _uas)
{
uasid
=
0
;
}
// We signal to ourselves here so that tiemrs are started and stopped on correct thread
connect
(
this
,
SIGNAL
(
_startProtocolTimer
(
void
)),
this
,
SLOT
(
_startProtocolTimerOnThisThread
(
void
)));
connect
(
this
,
SIGNAL
(
_stopProtocolTimer
(
void
)),
this
,
SLOT
(
_stopProtocolTimerOnThisThread
(
void
)));
}
UASWaypointManager
::~
UASWaypointManager
()
...
...
@@ -133,7 +137,7 @@ void UASWaypointManager::handleGlobalPositionChanged(UASInterface* mav, double l
void
UASWaypointManager
::
handleWaypointCount
(
quint8
systemId
,
quint8
compId
,
quint16
count
)
{
if
(
current_state
==
WP_GETLIST
&&
systemId
==
current_partner_systemid
)
{
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
emit
_startProtocolTimer
();
// Start timer on correct thread
current_retries
=
PROTOCOL_MAX_RETRIES
;
//Clear the old edit-list before receiving the new one
...
...
@@ -152,7 +156,7 @@ void UASWaypointManager::handleWaypointCount(quint8 systemId, quint8 compId, qui
current_state
=
WP_GETLIST_GETWPS
;
sendWaypointRequest
(
current_wp_id
);
}
else
{
protocol_timer
.
stop
();
emit
_stopProtocolTimer
();
// Stop the time on our thread
QTime
time
=
QTime
::
currentTime
();
emit
updateStatusString
(
tr
(
"Done. (updated at %1)"
).
arg
(
time
.
toString
()));
current_state
=
WP_IDLE
;
...
...
@@ -171,7 +175,7 @@ void UASWaypointManager::handleWaypointCount(quint8 systemId, quint8 compId, qui
void
UASWaypointManager
::
handleWaypoint
(
quint8
systemId
,
quint8
compId
,
mavlink_mission_item_t
*
wp
)
{
if
(
systemId
==
current_partner_systemid
&&
current_state
==
WP_GETLIST_GETWPS
&&
wp
->
seq
==
current_wp_id
)
{
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
emit
_startProtocolTimer
();
// Start timer on our thread
current_retries
=
PROTOCOL_MAX_RETRIES
;
if
(
wp
->
seq
==
current_wp_id
)
{
...
...
@@ -202,7 +206,7 @@ void UASWaypointManager::handleWaypoint(quint8 systemId, quint8 compId, mavlink_
current_partner_systemid
=
0
;
current_partner_compid
=
0
;
protocol_timer
.
stop
();
emit
_stopProtocolTimer
();
// Stop timer on our thread
emit
readGlobalWPFromUAS
(
false
);
QTime
time
=
QTime
::
currentTime
();
emit
updateStatusString
(
tr
(
"Done. (updated at %1)"
).
arg
(
time
.
toString
()));
...
...
@@ -230,7 +234,7 @@ void UASWaypointManager::handleWaypointAck(quint8 systemId, quint8 compId, mavli
if
(
compId
==
current_partner_compid
||
compId
==
MAV_COMP_ID_ALL
)
{
if
((
current_state
==
WP_SENDLIST
||
current_state
==
WP_SENDLIST_SENDWPS
)
&&
(
current_wp_id
==
waypoint_buffer
.
count
()
-
1
&&
wpa
->
type
==
0
))
{
//all waypoints sent and ack received
protocol_timer
.
stop
();
emit
_stopProtocolTimer
();
// Stop timer on our thread
current_state
=
WP_IDLE
;
readWaypoints
(
false
);
//Update "Onboard Waypoints"-tab immediately after the waypoint list has been sent.
QTime
time
=
QTime
::
currentTime
();
...
...
@@ -269,10 +273,10 @@ void UASWaypointManager::handleWaypointAck(quint8 systemId, quint8 compId, mavli
emit
updateStatusString
(
tr
(
"ERROR: Unspecified error"
));
break
;
}
protocol_timer
.
stop
();
emit
_stopProtocolTimer
();
// Stop timer on our thread
current_state
=
WP_IDLE
;
}
else
if
(
current_state
==
WP_CLEARLIST
)
{
protocol_timer
.
stop
();
emit
_stopProtocolTimer
();
// Stop timer on our thread
current_state
=
WP_IDLE
;
QTime
time
=
QTime
::
currentTime
();
emit
updateStatusString
(
tr
(
"Done. (updated at %1)"
).
arg
(
time
.
toString
()));
...
...
@@ -283,7 +287,7 @@ void UASWaypointManager::handleWaypointAck(quint8 systemId, quint8 compId, mavli
void
UASWaypointManager
::
handleWaypointRequest
(
quint8
systemId
,
quint8
compId
,
mavlink_mission_request_t
*
wpr
)
{
if
(
systemId
==
current_partner_systemid
&&
((
current_state
==
WP_SENDLIST
&&
wpr
->
seq
==
0
)
||
(
current_state
==
WP_SENDLIST_SENDWPS
&&
(
wpr
->
seq
==
current_wp_id
||
wpr
->
seq
==
current_wp_id
+
1
))))
{
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
emit
_startProtocolTimer
();
// Start timer on our thread
current_retries
=
PROTOCOL_MAX_RETRIES
;
if
(
wpr
->
seq
<
waypoint_buffer
.
count
())
{
...
...
@@ -314,7 +318,7 @@ void UASWaypointManager::handleWaypointCurrent(quint8 systemId, quint8 compId, m
if
(
systemId
==
uasid
)
{
// FIXME Petri
if
(
current_state
==
WP_SETCURRENT
)
{
protocol_timer
.
stop
();
emit
_stopProtocolTimer
();
// Stop timer on our thread
current_state
=
WP_IDLE
;
// update the local main storage
...
...
@@ -362,7 +366,7 @@ int UASWaypointManager::setCurrentWaypoint(quint16 seq)
if
(
current_state
==
WP_IDLE
)
{
//send change to UAS - important to note: if the transmission fails, we have inconsistencies
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
emit
_startProtocolTimer
();
// Start timer on our thread
current_retries
=
PROTOCOL_MAX_RETRIES
;
current_state
=
WP_SETCURRENT
;
...
...
@@ -594,7 +598,7 @@ void UASWaypointManager::clearWaypointList()
{
if
(
current_state
==
WP_IDLE
)
{
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
emit
_startProtocolTimer
();
// Start timer on our thread
current_retries
=
PROTOCOL_MAX_RETRIES
;
current_state
=
WP_CLEARLIST
;
...
...
@@ -847,7 +851,10 @@ void UASWaypointManager::readWaypoints(bool readToEdit)
emit waypointEditableListChanged();
}
*/
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
// We are signalling ourselves here so that the timer gets started on the right thread
emit
_startProtocolTimer
();
current_retries
=
PROTOCOL_MAX_RETRIES
;
current_state
=
WP_GETLIST
;
...
...
@@ -899,7 +906,7 @@ void UASWaypointManager::writeWaypoints()
if
(
current_state
==
WP_IDLE
)
{
// Send clear all if count == 0
if
(
waypointsEditable
.
count
()
>
0
)
{
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
emit
_startProtocolTimer
();
// Start timer on our thread
current_retries
=
PROTOCOL_MAX_RETRIES
;
current_count
=
waypointsEditable
.
count
();
...
...
@@ -1128,3 +1135,14 @@ float UASWaypointManager::getHomeAltitudeOffsetDefault()
{
return
defaultAltitudeHomeOffset
;
}
void
UASWaypointManager
::
_startProtocolTimerOnThisThread
(
void
)
{
protocol_timer
.
start
(
PROTOCOL_TIMEOUT_MS
);
}
void
UASWaypointManager
::
_stopProtocolTimerOnThisThread
(
void
)
{
protocol_timer
.
stop
();
}
src/uas/UASWaypointManager.h
View file @
d18e0394
...
...
@@ -160,6 +160,13 @@ signals:
void
loadWPFile
();
///< emits signal that a file wp has been load
void
readGlobalWPFromUAS
(
bool
value
);
///< emits signal when finish to read Global WP from UAS
void
_startProtocolTimer
(
void
);
///< emits signal to start protocol timer
void
_stopProtocolTimer
(
void
);
///< emits signal to stop protocol timer
private
slots
:
void
_startProtocolTimerOnThisThread
(
void
);
///< Starts the protocol timer
void
_stopProtocolTimerOnThisThread
(
void
);
///< Starts the protocol timer
private:
UAS
*
uas
;
///< Reference to the corresponding UAS
...
...
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