Skip to content

Commit

Permalink
AP_HAL_SITL: allow overriding args on reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
magicrub committed Sep 11, 2024
1 parent fcbf1a7 commit 3ad0d11
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions libraries/AP_HAL_SITL/HAL_SITL_Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,22 @@ void HAL_SITL::run(int argc, char * const argv[], Callbacks* callbacks) const
actually_reboot();
}

void HAL_SITL::update_new_args(const char* opt, const char* val)
{
for (uint8_t i=0; i<ARRAY_SIZE(new_argv)-1; i++) {
if (new_argv[i] == nullptr && new_argv[i+1] == nullptr) {
// add new option and value
new_argv[i] = (char*)opt;
new_argv[i+1] = (char*)val;
return;
} else if (!strcmp(new_argv[i], opt)) {
// update existing value
strncpy(new_argv[i+1], val, 100);
return;
}
}
}

void HAL_SITL::actually_reboot()
{
execv(new_argv[0], new_argv);
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_HAL_SITL/HAL_SITL_Class.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class HAL_SITL : public AP_HAL::HAL {
HAL_SITL();
void run(int argc, char * const argv[], Callbacks* callbacks) const override;
static void actually_reboot();
static void update_new_args(const char* opt, const char* val);

void set_storage_posix_enabled(bool _enabled) {
storage_posix_enabled = _enabled;
Expand Down

0 comments on commit 3ad0d11

Please sign in to comment.