mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 06:43:33 +08:00
FlightTasks: error to char string message
This commit is contained in:
committed by
Lorenz Meier
parent
afd02aca92
commit
b2af9c3f58
@@ -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
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user