mirror of https://github.com/ArduPilot/ardupilot
AC_Fence: allow for fence storage on microSD
This commit is contained in:
parent
95ee2c437e
commit
0e6a32a3e2
|
@ -159,6 +159,12 @@ public:
|
||||||
|
|
||||||
static const struct AP_Param::GroupInfo var_info[];
|
static const struct AP_Param::GroupInfo var_info[];
|
||||||
|
|
||||||
|
#if AP_SDCARD_STORAGE_ENABLED
|
||||||
|
bool failed_sdcard_storage(void) const {
|
||||||
|
return _poly_loader.failed_sdcard_storage();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static AC_Fence *_singleton;
|
static AC_Fence *_singleton;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#if AP_FENCE_ENABLED
|
#if AP_FENCE_ENABLED
|
||||||
|
|
||||||
#include <AP_Vehicle/AP_Vehicle_Type.h>
|
#include <AP_Vehicle/AP_Vehicle_Type.h>
|
||||||
|
#include <AP_BoardConfig/AP_BoardConfig.h>
|
||||||
|
|
||||||
#ifndef AC_FENCE_DUMMY_METHODS_ENABLED
|
#ifndef AC_FENCE_DUMMY_METHODS_ENABLED
|
||||||
#define AC_FENCE_DUMMY_METHODS_ENABLED (!(APM_BUILD_TYPE(APM_BUILD_Rover) | APM_BUILD_COPTER_OR_HELI | APM_BUILD_TYPE(APM_BUILD_ArduPlane) | APM_BUILD_TYPE(APM_BUILD_ArduSub) | (AP_FENCE_ENABLED == 1)))
|
#define AC_FENCE_DUMMY_METHODS_ENABLED (!(APM_BUILD_TYPE(APM_BUILD_Rover) | APM_BUILD_COPTER_OR_HELI | APM_BUILD_TYPE(APM_BUILD_ArduPlane) | APM_BUILD_TYPE(APM_BUILD_ArduSub) | (AP_FENCE_ENABLED == 1)))
|
||||||
|
@ -27,10 +28,32 @@
|
||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
static const StorageAccess fence_storage(StorageManager::StorageFence);
|
static StorageAccess fence_storage(StorageManager::StorageFence);
|
||||||
|
|
||||||
|
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
|
||||||
|
#define AC_FENCE_SDCARD_FILENAME "APM/fence.stg"
|
||||||
|
#else
|
||||||
|
#define AC_FENCE_SDCARD_FILENAME "fence.stg"
|
||||||
|
#endif
|
||||||
|
|
||||||
void AC_PolyFence_loader::init()
|
void AC_PolyFence_loader::init()
|
||||||
{
|
{
|
||||||
|
#if AP_SDCARD_STORAGE_ENABLED
|
||||||
|
// check for extra storage on microsd
|
||||||
|
const auto *bc = AP::boardConfig();
|
||||||
|
if (bc != nullptr) {
|
||||||
|
const auto size_kb = bc->get_sdcard_fence_kb();
|
||||||
|
if (size_kb > 0) {
|
||||||
|
_failed_sdcard_storage = !fence_storage.attach_file(AC_FENCE_SDCARD_FILENAME, size_kb);
|
||||||
|
if (_failed_sdcard_storage) {
|
||||||
|
// wipe fence if storage not available, but don't
|
||||||
|
// save. This allows sdcard error to be fixed and
|
||||||
|
// reboot
|
||||||
|
_total.set(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (!check_indexed()) {
|
if (!check_indexed()) {
|
||||||
// tell the user, perhaps?
|
// tell the user, perhaps?
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,6 +186,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if AP_SDCARD_STORAGE_ENABLED
|
||||||
|
bool failed_sdcard_storage(void) const {
|
||||||
|
return _failed_sdcard_storage;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// multi-thread access support
|
// multi-thread access support
|
||||||
|
@ -423,6 +428,11 @@ private:
|
||||||
bool index_eeprom() WARN_IF_UNUSED;
|
bool index_eeprom() WARN_IF_UNUSED;
|
||||||
|
|
||||||
uint16_t fence_storage_space_required(const AC_PolyFenceItem *new_items, uint16_t count);
|
uint16_t fence_storage_space_required(const AC_PolyFenceItem *new_items, uint16_t count);
|
||||||
|
|
||||||
|
#if AP_SDCARD_STORAGE_ENABLED
|
||||||
|
// true if we failed to load SDCard storage on init
|
||||||
|
bool _failed_sdcard_storage;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AP_FENCE_ENABLED
|
#endif // AP_FENCE_ENABLED
|
||||||
|
|
Loading…
Reference in New Issue