HAL_Linux: added --defaults option to Linux HAL

useful for initial parameters
This commit is contained in:
Andrew Tridgell 2021-02-06 17:59:54 +11:00
parent ae088f792d
commit fd3bf0f639
2 changed files with 13 additions and 0 deletions

View File

@ -311,6 +311,7 @@ void HAL_Linux::run(int argc, char* const argv[], Callbacks* callbacks) const
{"terrain-directory", true, 0, 't'},
{"storage-directory", true, 0, 's'},
{"module-directory", true, 0, 'M'},
{"defaults", true, 0, 'd'},
{"help", false, 0, 'h'},
{0, false, 0, 0}
};
@ -364,6 +365,9 @@ void HAL_Linux::run(int argc, char* const argv[], Callbacks* callbacks) const
module_path = gopt.optarg;
break;
#endif
case 'd':
utilInstance.set_custom_defaults_path(gopt.optarg);
break;
case 'h':
_usage();
exit(0);

View File

@ -50,6 +50,14 @@ public:
void set_custom_storage_directory(const char *_custom_storage_directory) {
custom_storage_directory = _custom_storage_directory;
}
void set_custom_defaults_path(const char *_custom_defaults) {
custom_defaults = _custom_defaults;
}
// get path to custom defaults file for AP_Param
const char* get_custom_defaults_file() const override final {
return custom_defaults;
}
bool is_chardev_node(const char *path);
void set_imu_temp(float current) override;
@ -119,6 +127,7 @@ private:
const char *custom_log_directory = nullptr;
const char *custom_terrain_directory = nullptr;
const char *custom_storage_directory = nullptr;
const char *custom_defaults = HAL_PARAM_DEFAULTS_PATH;
static const char *_hw_names[UTIL_NUM_HARDWARES];
#ifdef ENABLE_HEAP