|
|
|
@ -21,6 +21,7 @@
@@ -21,6 +21,7 @@
|
|
|
|
|
|
|
|
|
|
#include <AP_HAL/AP_HAL.h> |
|
|
|
|
#include <AP_Vehicle/AP_Vehicle_Type.h> |
|
|
|
|
#include <AP_Math/AP_Math.h> |
|
|
|
|
|
|
|
|
|
#include "StorageManager.h" |
|
|
|
|
|
|
|
|
@ -76,6 +77,12 @@ const StorageManager::StorageArea StorageManager::layout[STORAGE_NUM_AREAS] = {
@@ -76,6 +77,12 @@ const StorageManager::StorageArea StorageManager::layout[STORAGE_NUM_AREAS] = {
|
|
|
|
|
{ StorageFence, 9772, 256}, |
|
|
|
|
{ StorageMission, 10028, 5204}, // leave 128 byte gap for expansion
|
|
|
|
|
{ StorageCANDNA, 15232, 1024}, |
|
|
|
|
// 128 byte gap at end of first 16k
|
|
|
|
|
#endif |
|
|
|
|
#if STORAGE_NUM_AREAS >= 19 |
|
|
|
|
{ StorageParam, 16384, 1280}, |
|
|
|
|
{ StorageMission, 17664, 9842}, |
|
|
|
|
{ StorageParamBak, 27506, 5376}, |
|
|
|
|
#endif |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -113,6 +120,12 @@ const StorageManager::StorageArea StorageManager::layout[STORAGE_NUM_AREAS] = {
@@ -113,6 +120,12 @@ const StorageManager::StorageArea StorageManager::layout[STORAGE_NUM_AREAS] = {
|
|
|
|
|
{ StorageFence, 9772, 256}, |
|
|
|
|
{ StorageMission, 10028, 5204}, // leave 128 byte gap for expansion
|
|
|
|
|
{ StorageCANDNA, 15232, 1024}, |
|
|
|
|
// 128 byte gap at end of first 16k
|
|
|
|
|
#endif |
|
|
|
|
#if STORAGE_NUM_AREAS >= 19 |
|
|
|
|
{ StorageParam, 16384, 1280}, |
|
|
|
|
{ StorageMission, 17664, 9842}, |
|
|
|
|
{ StorageParamBak, 27506, 5376}, |
|
|
|
|
#endif |
|
|
|
|
}; |
|
|
|
|
#endif // STORAGE_NUM_AREAS == 1
|
|
|
|
@ -275,3 +288,25 @@ void StorageAccess::write_uint32(uint16_t loc, uint32_t value) const
@@ -275,3 +288,25 @@ void StorageAccess::write_uint32(uint16_t loc, uint32_t value) const
|
|
|
|
|
{ |
|
|
|
|
write_block(loc, &value, sizeof(value)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
copy one area to another |
|
|
|
|
*/ |
|
|
|
|
bool StorageAccess::copy_area(const StorageAccess &source) |
|
|
|
|
{ |
|
|
|
|
// we deliberately allow for copies from smaller areas. This
|
|
|
|
|
// allows for a partial backup region for parameters
|
|
|
|
|
uint16_t total = MIN(source.size(), size()); |
|
|
|
|
uint16_t ofs = 0; |
|
|
|
|
while (total > 0) { |
|
|
|
|
uint8_t block[32]; |
|
|
|
|
uint16_t n = MIN(sizeof(block), total); |
|
|
|
|
if (!source.read_block(block, ofs, n) || |
|
|
|
|
!write_block(ofs, block, n)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
total -= n; |
|
|
|
|
ofs += n; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|