FlightTasks: error to char string message

This commit is contained in:
Dennis Mannhart
2018-07-20 09:26:18 +02:00
committed by Lorenz Meier
parent afd02aca92
commit b2af9c3f58
2 changed files with 31 additions and 0 deletions
+11
View File
@@ -140,6 +140,17 @@ void FlightTasks::handleParameterUpdate()
}
}
const char *FlightTasks::errorToString(const int error)
{
for (auto e : _taskError) {
if (e.error == error) {
return e.msg;
}
}
return "This error is not mapped to a string or is unknown.";
}
void FlightTasks::_updateCommand()
{
// TODO: port flight task mavlink command to have support for this functionality
+20
View File
@@ -134,6 +134,11 @@ public:
*/
void handleParameterUpdate();
/**
* Call this method to get the description of a task error.
*/
const char *errorToString(const int error);
private:
/**
@@ -161,6 +166,21 @@ private:
SubscriptionArray _subscription_array;
struct task_error_t {
int error;
const char *msg;
};
static const int _numError = 4;
/**
* Map from Error int to user friendly string.
*/
task_error_t _taskError[_numError] = {
{0, "No Error"},
{-1, "Invalid Task "},
{-2, "Subscription Failed"},
{-3, "Activation Failed"}
};
/**
* Check for vehicle commands (received via MAVLink), evaluate and acknowledge them
*/