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
c9f81c35
Commit
c9f81c35
authored
Oct 09, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1935 from DonLakeFlyer/MissionManagerError
Mission manager errors now show up in UI
parents
a2448c15
af7d7eaa
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
56 deletions
+46
-56
MissionManager.cc
src/MissionManager/MissionManager.cc
+28
-11
MissionManager.h
src/MissionManager/MissionManager.h
+1
-0
MissionManagerTest.cc
src/MissionManager/MissionManagerTest.cc
+7
-43
MissionManagerTest.h
src/MissionManager/MissionManagerTest.h
+2
-2
Vehicle.cc
src/Vehicle/Vehicle.cc
+7
-0
Vehicle.h
src/Vehicle/Vehicle.h
+1
-0
No files found.
src/MissionManager/MissionManager.cc
View file @
c9f81c35
...
...
@@ -154,8 +154,8 @@ void MissionManager::_ackTimeout(void)
}
if
(
!
_retrySequence
(
timedOutAck
))
{
qCDebug
(
MissionManagerLog
)
<<
"_ackTimeout failed after max retries _retryAck:_retryCount"
<<
timedOutAck
<<
_retryCount
;
_sendError
(
AckTimeoutError
,
QString
(
"Vehicle did not respond to mission item communication: %1"
).
arg
(
timedOutAck
));
qCDebug
(
MissionManagerLog
)
<<
"_ackTimeout failed after max retries _retryAck:_retryCount"
<<
_ackTypeToString
(
timedOutAck
)
<<
_retryCount
;
_sendError
(
AckTimeoutError
,
QString
(
"Vehicle did not respond to mission item communication: %1"
).
arg
(
_ackTypeToString
(
timedOutAck
)
));
}
}
...
...
@@ -175,10 +175,10 @@ bool MissionManager::_stopAckTimeout(AckType_t expectedAck)
_ackTimeoutTimer
->
stop
();
if
(
savedRetryAck
!=
expectedAck
)
{
qCDebug
(
MissionManagerLog
)
<<
"Invalid ack sequence _retryAck:expectedAck"
<<
savedRetryAck
<<
expectedAck
;
qCDebug
(
MissionManagerLog
)
<<
"Invalid ack sequence _retryAck:expectedAck"
<<
_ackTypeToString
(
savedRetryAck
)
<<
_ackTypeToString
(
expectedAck
)
;
if
(
_retrySequence
(
expectedAck
))
{
_sendError
(
ProtocolOrderError
,
QString
(
"Vehicle responded incorrectly to mission item protocol sequence: %1:%2"
).
arg
(
savedRetryAck
).
arg
(
expectedAck
));
_sendError
(
ProtocolOrderError
,
QString
(
"Vehicle responded incorrectly to mission item protocol sequence: %1:%2"
).
arg
(
_ackTypeToString
(
savedRetryAck
)).
arg
(
_ackTypeToString
(
expectedAck
)
));
}
success
=
false
;
}
else
{
...
...
@@ -375,19 +375,19 @@ void MissionManager::_handleMissionAck(const mavlink_message_t& message)
switch
(
savedRetryAck
)
{
case
AckNone
:
// State machine is idle. Vehicle is confused.
qCDebug
(
MissionManagerLog
)
<<
"_handleMissionAck vehicle sent ack while state machine is idle:
type
:"
<<
missionAck
.
type
;
_sendError
(
VehicleError
,
"Vehicle sent unexpected MISSION_ACK message."
);
qCDebug
(
MissionManagerLog
)
<<
"_handleMissionAck vehicle sent ack while state machine is idle:
error
:"
<<
missionAck
.
type
;
_sendError
(
VehicleError
,
QString
(
"Vehicle sent unexpected MISSION_ACK message, error: %1"
).
arg
(
missionAck
.
type
)
);
break
;
case
AckMissionCount
:
// MISSION_COUNT message expected
qCDebug
(
MissionManagerLog
)
<<
"_handleMissionAck vehicle sent ack when MISSION_COUNT expected:
type
:"
<<
missionAck
.
type
;
qCDebug
(
MissionManagerLog
)
<<
"_handleMissionAck vehicle sent ack when MISSION_COUNT expected:
error
:"
<<
missionAck
.
type
;
if
(
!
_retrySequence
(
AckMissionCount
))
{
_sendError
(
VehicleError
,
QString
(
"Vehicle returned error: %1. Partial list of mission items may have been returned."
).
arg
(
missionAck
.
type
));
}
break
;
case
AckMissionItem
:
// MISSION_ITEM expected
qCDebug
(
MissionManagerLog
)
<<
"_handleMissionAck vehicle sent ack when MISSION_ITEM expected:
type
:"
<<
missionAck
.
type
;
qCDebug
(
MissionManagerLog
)
<<
"_handleMissionAck vehicle sent ack when MISSION_ITEM expected:
error
:"
<<
missionAck
.
type
;
if
(
!
_retrySequence
(
AckMissionItem
))
{
_sendError
(
VehicleError
,
QString
(
"Vehicle returned error: %1. Partial list of mission items may have been returned."
).
arg
(
missionAck
.
type
));
}
...
...
@@ -465,7 +465,7 @@ void MissionManager::_sendError(ErrorCode_t errorCode, const QString& errorMsg)
/// @return true: sequence retried, false: out of retries
bool
MissionManager
::
_retrySequence
(
AckType_t
ackType
)
{
qCDebug
(
MissionManagerLog
)
<<
"_retrySequence ackType:"
<<
ackType
<<
"_retryCount"
<<
_retryCount
;
qCDebug
(
MissionManagerLog
)
<<
"_retrySequence ackType:"
<<
_ackTypeToString
(
ackType
)
<<
"_retryCount"
<<
_retryCount
;
switch
(
ackType
)
{
case
AckMissionCount
:
...
...
@@ -490,8 +490,25 @@ bool MissionManager::_retrySequence(AckType_t ackType)
}
break
;
default:
qCWarning
(
MissionManagerLog
)
<<
"_retrySequence fell through switch: ackType:"
<<
ackType
;
_sendError
(
InternalError
,
QString
(
"Internal error occured during Mission Item communication: _retrySequence fell through switch: ackType:"
).
arg
(
ackType
));
qCWarning
(
MissionManagerLog
)
<<
"_retrySequence fell through switch: ackType:"
<<
_ackTypeToString
(
ackType
)
;
_sendError
(
InternalError
,
QString
(
"Internal error occured during Mission Item communication: _retrySequence fell through switch: ackType:"
).
arg
(
_ackTypeToString
(
ackType
)
));
return
false
;
}
}
QString
MissionManager
::
_ackTypeToString
(
AckType_t
ackType
)
{
switch
(
ackType
)
{
case
AckNone
:
// State machine is idle
return
QString
(
"No Ack"
);
case
AckMissionCount
:
// MISSION_COUNT message expected
return
QString
(
"MISSION_COUNT"
);
case
AckMissionItem
:
///< MISSION_ITEM expected
return
QString
(
"MISSION_ITEM"
);
case
AckMissionRequest
:
///< MISSION_REQUEST is expected, or MISSION_ACK to end sequence
return
QString
(
"MISSION_REQUEST"
);
default:
qWarning
(
MissionManagerLog
)
<<
"Fell off end of switch statement"
;
return
QString
(
"Internal Error"
);
}
}
src/MissionManager/MissionManager.h
View file @
c9f81c35
...
...
@@ -115,6 +115,7 @@ private:
void
_retryWrite
(
void
);
void
_retryRead
(
void
);
bool
_retrySequence
(
AckType_t
ackType
);
QString
_ackTypeToString
(
AckType_t
ackType
);
private:
Vehicle
*
_vehicle
;
...
...
src/MissionManager/MissionManagerTest.cc
View file @
c9f81c35
...
...
@@ -183,6 +183,8 @@ void MissionManagerTest::_writeItems(MockLinkMissionItemHandler::FailureMode_t f
}
else
{
// This should be a failed run
setExpectedMessageBox
(
QMessageBox
::
Ok
);
// Wait for write sequence to complete. We should get:
// inProgressChanged(false) signal
// error(errorCode, QString) signal
...
...
@@ -199,30 +201,7 @@ void MissionManagerTest::_writeItems(MockLinkMissionItemHandler::FailureMode_t f
qDebug
()
<<
signalArgs
[
1
].
toString
();
QCOMPARE
(
signalArgs
[
0
].
toInt
(),
(
int
)
errorCode
);
/*
// FIXME: This should be on the read side
// Validate correct number of mission items
int expectedMissionCount = 0;
switch (ErrorCode) {
case FailWriteRequest0NoResponse:
// Don't respond to MISSION_COUNT with MISSION_REQUEST 0
expectedMissionCount = 0;
break;
case FailWriteRequest1NoResponse: // Don't respond to MISSION_ITEM 0 with MISSION_REQUEST 1
case FailWriteRequest0IncorrectSequence: // Respond to MISSION_COUNT 0 with MISSION_REQUEST with wrong sequence number
case FailWriteRequest1IncorrectSequence: // Respond to MISSION_ITEM 0 with MISSION_REQUEST with wrong sequence number
case FailWriteRequest0ErrorAck: // Respond to MISSION_COUNT 0 with MISSION_ACK error
case FailWriteRequest1ErrorAck: // Respond to MISSION_ITEM 0 with MISSION_ACK error
case FailWriteFinalAckNoResponse: // Don't send the final MISSION_ACK
case FailWriteFinalAckErrorAck: // Send an error as the final MISSION_ACK
case FailWriteFinalAckMissingRequests: // Send the MISSION_ACK before all items have been requested
break;
}
// FIXME: Count depends on errorCode
//QCOMPARE(_missionManager->missionItems()->count(), (int)cTestCases);
*/
checkExpectedMessageBox
();
}
QCOMPARE
(
_missionManager
->
canEdit
(),
true
);
...
...
@@ -265,6 +244,8 @@ void MissionManagerTest::_roundTripItems(MockLinkMissionItemHandler::FailureMode
}
else
{
// This should be a failed run
setExpectedMessageBox
(
QMessageBox
::
Ok
);
// Wait for read sequence to complete. We should get:
// inProgressChanged(false) signal to signal completion
// error(errorCode, QString) signal
...
...
@@ -281,6 +262,8 @@ void MissionManagerTest::_roundTripItems(MockLinkMissionItemHandler::FailureMode
QCOMPARE
(
signalArgs
.
count
(),
2
);
qDebug
()
<<
signalArgs
[
1
].
toString
();
QCOMPARE
(
signalArgs
[
0
].
toInt
(),
(
int
)
errorCode
);
checkExpectedMessageBox
();
}
_multiSpy
->
clearAllSignals
();
...
...
@@ -377,25 +360,6 @@ void MissionManagerTest::_testWriteFailureHandling(void)
void
MissionManagerTest
::
_testReadFailureHandling
(
void
)
{
/*
FailReadRequestListNoResponse, // Don't send MISSION_COUNT in response to MISSION_REQUEST_LIST
FailReadRequest0NoResponse, // Don't send MISSION_ITEM in response to MISSION_REQUEST item 0
FailReadRequest1NoResponse, // Don't send MISSION_ITEM in response to MISSION_REQUEST item 1
FailReadRequest0IncorrectSequence, // Respond to MISSION_REQUEST 0 with incorrect sequence number in MISSION_ITEM
FailReadRequest1IncorrectSequence, // Respond to MISSION_REQUEST 1 with incorrect sequence number in MISSION_ITEM
FailReadRequest0ErrorAck, // Respond to MISSION_REQUEST 0 with MISSION_ACK error
FailReadRequest1ErrorAck, // Respond to MISSION_REQUEST 1 bogus MISSION_ACK error
FailWriteRequest0NoResponse, // Don't respond to MISSION_COUNT with MISSION_REQUEST 0
FailWriteRequest1NoResponse, // Don't respond to MISSION_ITEM 0 with MISSION_REQUEST 1
FailWriteRequest0IncorrectSequence, // Respond to MISSION_COUNT 0 with MISSION_REQUEST with wrong sequence number
FailWriteRequest1IncorrectSequence, // Respond to MISSION_ITEM 0 with MISSION_REQUEST with wrong sequence number
FailWriteRequest0ErrorAck, // Respond to MISSION_COUNT 0 with MISSION_ACK error
FailWriteRequest1ErrorAck, // Respond to MISSION_ITEM 0 with MISSION_ACK error
FailWriteFinalAckNoResponse, // Don't send the final MISSION_ACK
FailWriteFinalAckErrorAck, // Send an error as the final MISSION_ACK
FailWriteFinalAckMissingRequests, // Send the MISSION_ACK before all items have been requested
*/
/*
/// Called to send a MISSION_ACK message while the MissionManager is in idle state
void sendUnexpectedMissionAck(MAV_MISSION_RESULT ackType) { _missionItemHandler.sendUnexpectedMissionAck(ackType); }
...
...
src/MissionManager/MissionManagerTest.h
View file @
c9f81c35
...
...
@@ -40,15 +40,15 @@ private slots:
void
init
(
void
);
void
cleanup
(
void
);
void
_testWriteFailureHandling
(
void
);
void
_testReadFailureHandling
(
void
);
private:
void
_checkInProgressValues
(
bool
inProgress
);
void
_roundTripItems
(
MockLinkMissionItemHandler
::
FailureMode_t
failureMode
,
MissionManager
::
ErrorCode_t
errorCode
,
bool
failFirstTimeOnly
);
void
_writeItems
(
MockLinkMissionItemHandler
::
FailureMode_t
failureMode
,
MissionManager
::
ErrorCode_t
errorCode
,
bool
failFirstTimeOnly
);
void
_readEmptyVehicle
(
void
);
void
_testWriteFailureHandling
(
void
);
MockLink
*
_mockLink
;
MissionManager
*
_missionManager
;
...
...
src/Vehicle/Vehicle.cc
View file @
c9f81c35
...
...
@@ -161,6 +161,7 @@ Vehicle::Vehicle(LinkInterface* link, int vehicleId, MAV_AUTOPILOT firmwareType)
if
(
qgcApp
()
->
useNewMissionEditor
())
{
_missionManager
=
new
MissionManager
(
this
);
connect
(
_missionManager
,
&
MissionManager
::
error
,
this
,
&
Vehicle
::
_missionManagerError
);
}
_firmwarePlugin
->
initializeVehicle
(
this
);
...
...
@@ -1121,3 +1122,9 @@ void Vehicle::sendMessageMultiple(mavlink_message_t message)
_sendMessageMultipleList
.
append
(
info
);
}
void
Vehicle
::
_missionManagerError
(
int
errorCode
,
const
QString
&
errorMsg
)
{
Q_UNUSED
(
errorCode
);
qgcApp
()
->
showToolBarMessage
(
QString
(
"Error during Mission communication with Vehicle: %1"
).
arg
(
errorMsg
));
}
src/Vehicle/Vehicle.h
View file @
c9f81c35
...
...
@@ -333,6 +333,7 @@ private:
void
_startJoystick
(
bool
start
);
void
_handleHomePosition
(
mavlink_message_t
&
message
);
void
_handleHeartbeat
(
mavlink_message_t
&
message
);
void
_missionManagerError
(
int
errorCode
,
const
QString
&
errorMsg
);
bool
_isAirplane
();
void
_addChange
(
int
id
);
...
...
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