Browse Source

Plane: re-enable geofencing on APM2

it only just fits ...
master
Andrew Tridgell 10 years ago
parent
commit
49f7adcc80
  1. 4
      ArduPlane/config.h
  2. 5
      ArduPlane/geofence.cpp

4
ArduPlane/config.h

@ -420,11 +420,7 @@ @@ -420,11 +420,7 @@
// use this to disable geo-fencing
#ifndef GEOFENCE_ENABLED
#if HAL_CPU_CLASS > HAL_CPU_CLASS_16
# define GEOFENCE_ENABLED ENABLED
#else
# define GEOFENCE_ENABLED DISABLE
#endif
#endif
// pwm value on FENCE_CHANNEL to use to enable fenced mode

5
ArduPlane/geofence.cpp

@ -94,7 +94,8 @@ void Plane::geofence_load(void) @@ -94,7 +94,8 @@ void Plane::geofence_load(void)
uint8_t i;
if (geofence_state == NULL) {
if (hal.util->available_memory() < 512 + sizeof(struct GeofenceState)) {
uint16_t boundary_size = sizeof(Vector2l) * max_fencepoints();
if (hal.util->available_memory() < 100 + boundary_size + sizeof(struct GeofenceState)) {
// too risky to enable as we could run out of stack
goto failed;
}
@ -104,7 +105,7 @@ void Plane::geofence_load(void) @@ -104,7 +105,7 @@ void Plane::geofence_load(void)
goto failed;
}
geofence_state->boundary = (Vector2l *)calloc(sizeof(Vector2l), max_fencepoints());
geofence_state->boundary = (Vector2l *)calloc(1, boundary_size);
if (geofence_state->boundary == NULL) {
free(geofence_state);
geofence_state = NULL;

Loading…
Cancel
Save