1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-1122 OP-1145 added more path plan checks :

- empty plan (i.e. no waypoints defined)
- out of range waypoint and path action ids

+review OPReview-609
This commit is contained in:
Philippe Renon 2014-01-14 21:00:44 +01:00
parent 8ccdb252d1
commit 1fca85784c

View File

@ -265,10 +265,16 @@ static uint8_t checkPathPlan()
uint16_t actionCount;
uint8_t pathCrc;
PathPlanData pathPlan;
//WaypointData waypoint; // using global instead (?)
//PathActionData action; // using global instead (?)
PathPlanGet(&pathPlan);
waypointCount = pathPlan.WaypointCount;
if (waypointCount == 0) {
// an empty path plan is invalid
return false;
}
actionCount = pathPlan.PathActionCount;
// check count consistency
@ -295,6 +301,28 @@ static uint8_t checkPathPlan()
return false;
}
// waypoint consistency
for (i = 0; i < waypointCount; i++) {
WaypointInstGet(i, &waypoint);
if (waypoint.Action >= actionCount) {
// path action id is out of range
return false;
}
}
// path action consistency
for (i = 0; i < actionCount; i++) {
PathActionInstGet(i, &pathAction);
if (pathAction.ErrorDestination >= waypointCount) {
// waypoint id is out of range
return false;
}
if (pathAction.JumpDestination >= waypointCount) {
// waypoint id is out of range
return false;
}
}
// path plan passed checks
return true;