Browse Source

AP_HAL_SITL: add support for starting node in maintenance mode

apm_2208
bugobliterator 3 years ago committed by Andrew Tridgell
parent
commit
8e81ee0292
  1. 7
      libraries/AP_HAL_SITL/HAL_SITL_Class.cpp
  2. 4
      libraries/AP_HAL_SITL/HAL_SITL_Class.h
  3. 10
      libraries/AP_HAL_SITL/SITL_Periph_State.cpp
  4. 3
      libraries/AP_HAL_SITL/SITL_Periph_State.h

7
libraries/AP_HAL_SITL/HAL_SITL_Class.cpp

@ -193,6 +193,13 @@ uint8_t HAL_SITL::get_instance() const @@ -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);

4
libraries/AP_HAL_SITL/HAL_SITL_Class.h

@ -37,6 +37,10 @@ public: @@ -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;

10
libraries/AP_HAL_SITL/SITL_Periph_State.cpp

@ -29,12 +29,13 @@ void SITL_State::init(int argc, char * const argv[]) { @@ -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[]) { @@ -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);
}
}

3
libraries/AP_HAL_SITL/SITL_Periph_State.h

@ -61,6 +61,8 @@ public: @@ -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: @@ -74,6 +76,7 @@ private:
const char *defaults_path = HAL_PARAM_DEFAULTS_PATH;
uint8_t _instance;
bool _maintenance;
};
#endif

Loading…
Cancel
Save