AP_HAL_SITL: add support for starting node in maintenance mode

This commit is contained in:
bugobliterator 2022-04-29 17:18:37 +05:30 committed by Andrew Tridgell
parent 48f1e18161
commit 8e81ee0292
4 changed files with 22 additions and 2 deletions

View File

@ -193,6 +193,13 @@ uint8_t HAL_SITL::get_instance() const
return _sitl_state->get_instance();
}
#if defined(HAL_BUILD_AP_PERIPH)
bool HAL_SITL::run_in_maintenance_mode() const
{
return _sitl_state->run_in_maintenance_mode();
}
#endif
void HAL_SITL::run(int argc, char * const argv[], Callbacks* callbacks) const
{
assert(callbacks);

View File

@ -37,6 +37,10 @@ public:
uint8_t get_instance() const;
#if defined(HAL_BUILD_AP_PERIPH)
bool run_in_maintenance_mode() const;
#endif
private:
HALSITL::SITL_State *_sitl_state;

View File

@ -29,12 +29,13 @@ void SITL_State::init(int argc, char * const argv[]) {
const struct GetOptLong::option options[] = {
{"help", false, 0, 'h'},
{"instance", true, 0, 'I'},
{"maintenance", false, 0, 'M'},
};
setvbuf(stdout, (char *)0, _IONBF, 0);
setvbuf(stderr, (char *)0, _IONBF, 0);
GetOptLong gopt(argc, argv, "hI:",
GetOptLong gopt(argc, argv, "hI:M",
options);
while((opt = gopt.getoption()) != -1) {
@ -42,10 +43,15 @@ void SITL_State::init(int argc, char * const argv[]) {
case 'I':
_instance = atoi(gopt.optarg);
break;
case 'M':
printf("Running in Maintenance Mode\n");
_maintenance = true;
break;
default:
printf("Options:\n"
"\t--help|-h display this help information\n"
"\t--instance|-I N set instance of SITL Periph\n");
"\t--instance|-I N set instance of SITL Periph\n"
"\t--maintenance|-M run in maintenance mode\n");
exit(1);
}
}

View File

@ -61,6 +61,8 @@ public:
uint8_t get_instance() const { return _instance; }
bool run_in_maintenance_mode() const { return _maintenance; }
SITL::SerialDevice *create_serial_sim(const char *name, const char *arg) {
return nullptr;
}
@ -74,6 +76,7 @@ private:
const char *defaults_path = HAL_PARAM_DEFAULTS_PATH;
uint8_t _instance;
bool _maintenance;
};
#endif