2016-02-17 21:25:28 -04:00
|
|
|
#pragma once
|
2012-12-18 21:13:01 -04:00
|
|
|
|
2015-08-11 03:28:43 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2015-05-04 03:15:12 -03:00
|
|
|
#include "AP_HAL_SITL_Namespace.h"
|
2018-08-07 03:39:42 -03:00
|
|
|
#include "AP_HAL_SITL.h"
|
2015-12-20 16:33:11 -04:00
|
|
|
#include "Semaphores.h"
|
2019-03-19 23:19:41 -03:00
|
|
|
#include "ToneAlarm_SF.h"
|
2012-12-18 21:13:01 -04:00
|
|
|
|
2016-01-10 02:23:32 -04:00
|
|
|
class HALSITL::Util : public AP_HAL::Util {
|
2012-12-18 21:13:01 -04:00
|
|
|
public:
|
2016-01-10 02:23:32 -04:00
|
|
|
Util(SITL_State *_sitlState) :
|
2016-01-06 18:09:40 -04:00
|
|
|
sitlState(_sitlState) {}
|
|
|
|
|
2018-11-07 06:59:48 -04:00
|
|
|
bool run_debug_shell(AP_HAL::BetterStream *stream) override {
|
2015-05-04 21:59:07 -03:00
|
|
|
return false;
|
|
|
|
}
|
2015-11-05 00:41:46 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
how much free memory do we have in bytes.
|
|
|
|
*/
|
|
|
|
uint32_t available_memory(void) override {
|
|
|
|
// SITL is assumed to always have plenty of memory. Return 128k for now
|
|
|
|
return 0x20000;
|
|
|
|
}
|
2015-12-20 16:33:11 -04:00
|
|
|
|
2016-01-06 18:09:40 -04:00
|
|
|
// get path to custom defaults file for AP_Param
|
|
|
|
const char* get_custom_defaults_file() const override {
|
|
|
|
return sitlState->defaults_path;
|
|
|
|
}
|
2018-04-24 09:25:25 -03:00
|
|
|
|
|
|
|
uint64_t get_hw_rtc() const override;
|
|
|
|
|
2018-11-16 17:32:38 -04:00
|
|
|
bool get_system_id(char buf[40]) override;
|
|
|
|
bool get_system_id_unformatted(uint8_t buf[], uint8_t &len) override;
|
2019-06-10 23:15:27 -03:00
|
|
|
void dump_stack_trace();
|
2018-12-08 22:34:54 -04:00
|
|
|
|
|
|
|
#ifdef ENABLE_HEAP
|
|
|
|
// heap functions, note that a heap once alloc'd cannot be dealloc'd
|
2019-06-17 20:15:25 -03:00
|
|
|
void *allocate_heap_memory(size_t size) override;
|
|
|
|
void *heap_realloc(void *heap, void *ptr, size_t new_size) override;
|
2018-12-08 22:34:54 -04:00
|
|
|
#endif // ENABLE_HEAP
|
2019-03-19 23:19:41 -03:00
|
|
|
|
|
|
|
#ifdef WITH_SITL_TONEALARM
|
|
|
|
bool toneAlarm_init() override { return _toneAlarm.init(); }
|
|
|
|
void toneAlarm_set_buzzer_tone(float frequency, float volume, uint32_t duration_ms) override {
|
|
|
|
_toneAlarm.set_buzzer_tone(frequency, volume, duration_ms);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-05-09 05:48:37 -03:00
|
|
|
// return true if the reason for the reboot was a watchdog reset
|
|
|
|
bool was_watchdog_reset() const override { return getenv("SITL_WATCHDOG_RESET") != nullptr; }
|
|
|
|
|
2016-01-06 18:09:40 -04:00
|
|
|
private:
|
|
|
|
SITL_State *sitlState;
|
2018-12-08 22:34:54 -04:00
|
|
|
|
2019-03-19 23:19:41 -03:00
|
|
|
#ifdef WITH_SITL_TONEALARM
|
|
|
|
static ToneAlarm_SF _toneAlarm;
|
|
|
|
#endif
|
|
|
|
|
2018-12-08 22:34:54 -04:00
|
|
|
#ifdef ENABLE_HEAP
|
|
|
|
struct heap_allocation_header {
|
|
|
|
size_t allocation_size; // size of allocated block, not including this header
|
|
|
|
};
|
|
|
|
|
|
|
|
struct heap {
|
|
|
|
size_t scripting_max_heap_size;
|
|
|
|
size_t current_heap_usage;
|
|
|
|
};
|
|
|
|
#endif // ENABLE_HEAP
|
2012-12-18 21:13:01 -04:00
|
|
|
};
|