HAL_SITL: support command line args for replay

This commit is contained in:
Andrew Tridgell 2020-11-09 08:48:25 +11:00
parent f966e92d99
commit d380447cd5
4 changed files with 25 additions and 0 deletions

View File

@ -176,6 +176,7 @@ void HAL_SITL::run(int argc, char * const argv[], Callbacks* callbacks) const
{
assert(callbacks);
utilInstance.init(argc, argv);
_sitl_state->init(argc, argv);
scheduler->init();

View File

@ -593,6 +593,7 @@ bool UARTDriver::_select_check(int fd)
if (fd == -1) {
return false;
}
#if !APM_BUILD_TYPE(APM_BUILD_Replay)
fd_set fds;
struct timeval tv;
@ -606,6 +607,7 @@ bool UARTDriver::_select_check(int fd)
if (select(fd+1, &fds, nullptr, nullptr, &tv) == 1) {
return true;
}
#endif
return false;
}

View File

@ -147,4 +147,13 @@ void HALSITL::Util::set_cmdline_parameters()
AP_Param::set_default_by_name(param.name, param.value);
}
}
/**
return commandline arguments, if available
*/
void HALSITL::Util::commandline_arguments(uint8_t &argc, char * const *&argv)
{
argc = saved_argc;
argv = saved_argv;
}
#endif

View File

@ -33,6 +33,11 @@ public:
return sitlState->defaults_path;
}
/**
return commandline arguments, if available
*/
void commandline_arguments(uint8_t &argc, char * const *&argv) override;
uint64_t get_hw_rtc() const override;
bool get_system_id(char buf[40]) override;
@ -71,6 +76,11 @@ public:
#endif
}
void init(int argc, char *const *argv) {
saved_argc = argc;
saved_argv = argv;
}
private:
SITL_State *sitlState;
@ -88,4 +98,7 @@ private:
size_t current_heap_usage;
};
#endif // ENABLE_HEAP
int saved_argc;
char *const *saved_argv;
};