From 09096cb3552459eab78dda4c51f3ab2f81a5dff4 Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Mon, 8 Nov 2021 19:51:31 +0530 Subject: [PATCH] AP_HAL_SITL: add get_storage_ptr method --- libraries/AP_HAL_SITL/Storage.cpp | 13 ++++++++++++- libraries/AP_HAL_SITL/Storage.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_SITL/Storage.cpp b/libraries/AP_HAL_SITL/Storage.cpp index 60ad8516a7..98e28e5f99 100644 --- a/libraries/AP_HAL_SITL/Storage.cpp +++ b/libraries/AP_HAL_SITL/Storage.cpp @@ -388,4 +388,15 @@ bool Storage::healthy(void) return AP_HAL::millis() - _last_empty_ms < 2000; } - +/* + get storage size and ptr + */ +bool Storage::get_storage_ptr(void *&ptr, size_t &size) +{ + if (_initialisedType==StorageBackend::None) { + return false; + } + ptr = _buffer; + size = sizeof(_buffer); + return true; +} diff --git a/libraries/AP_HAL_SITL/Storage.h b/libraries/AP_HAL_SITL/Storage.h index c3168fa821..a4bcf7278c 100644 --- a/libraries/AP_HAL_SITL/Storage.h +++ b/libraries/AP_HAL_SITL/Storage.h @@ -28,6 +28,7 @@ public: void init() override {} void read_block(void *dst, uint16_t src, size_t n) override; void write_block(uint16_t dst, const void* src, size_t n) override; + bool get_storage_ptr(void *&ptr, size_t &size) override; void _timer_tick(void) override; bool healthy(void) override;