AP_HAL_SITL: fix rebooting while in sensor config error loop

This commit is contained in:
Peter Barker 2019-07-08 18:02:18 +10:00 committed by Andrew Tridgell
parent 9afb334f0c
commit 848a70acd4
3 changed files with 13 additions and 0 deletions

View File

@ -191,6 +191,11 @@ void HAL_SITL::run(int argc, char * const argv[], Callbacks* callbacks) const
} }
} }
actually_reboot();
}
void HAL_SITL::actually_reboot()
{
execv(new_argv[0], new_argv); execv(new_argv[0], new_argv);
AP_HAL::panic("PANIC: REBOOT FAILED: %s", strerror(errno)); AP_HAL::panic("PANIC: REBOOT FAILED: %s", strerror(errno));
} }

View File

@ -12,6 +12,7 @@ class HAL_SITL : public AP_HAL::HAL {
public: public:
HAL_SITL(); HAL_SITL();
void run(int argc, char * const argv[], Callbacks* callbacks) const override; void run(int argc, char * const argv[], Callbacks* callbacks) const override;
static void actually_reboot();
private: private:
HALSITL::SITL_State *_sitl_state; HALSITL::SITL_State *_sitl_state;

View File

@ -5,6 +5,7 @@
#include "UARTDriver.h" #include "UARTDriver.h"
#include <sys/time.h> #include <sys/time.h>
#include <fenv.h> #include <fenv.h>
#include <AP_BoardConfig/AP_BoardConfig.h>
#if defined (__clang__) #if defined (__clang__)
#include <stdlib.h> #include <stdlib.h>
#else #else
@ -137,6 +138,12 @@ void Scheduler::sitl_end_atomic() {
void Scheduler::reboot(bool hold_in_bootloader) void Scheduler::reboot(bool hold_in_bootloader)
{ {
if (AP_BoardConfig::in_sensor_config_error()) {
// the _should_reboot flag set below is not checked by the
// sensor-config-error loop, so force the reboot here:
HAL_SITL::actually_reboot();
abort();
}
_should_reboot = true; _should_reboot = true;
} }