Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Param: fixed setting of defaults for dynamic param trees #159

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions libraries/AP_Param/AP_Param.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ uint16_t AP_Param::num_read_only = 0;
ObjectBuffer_TS<AP_Param::param_save> AP_Param::save_queue{30};
bool AP_Param::registered_save_handler;

bool AP_Param::done_all_default_params;

AP_Param::defaults_list *AP_Param::default_list;
#if AP_PARAM_MAX_EMBEDDED_PARAM > 0
AP_Param::defaults_list *AP_Param::embedded_default_list;
Expand Down Expand Up @@ -1635,6 +1637,13 @@ void AP_Param::load_object_from_eeprom(const void *object_pointer, const struct
}
}

if (!done_all_default_params) {
/*
the new subtree may need defaults from defaults.parm
*/
reload_defaults_file(false);
}

// reset cached param counter as we may be loading a dynamic var_info
invalidate_count();
}
Expand Down Expand Up @@ -2191,6 +2200,7 @@ bool AP_Param::read_param_defaults_file(const char *filename, bool last_pass)
return false;
}

bool done_all = true;
uint16_t idx = 0;
char line[100];
while (AP::FS().fgets(line, sizeof(line)-1, file_apfs)) {
Expand All @@ -2212,6 +2222,7 @@ bool AP_Param::read_param_defaults_file(const char *filename, bool last_pass)
pname, filename);
#endif
}
done_all = false;
continue;
}
param_overrides[idx].object_ptr = vp;
Expand All @@ -2227,6 +2238,8 @@ bool AP_Param::read_param_defaults_file(const char *filename, bool last_pass)
}
AP::FS().close(file_apfs);

done_all_default_params = done_all;

return true;
}

Expand Down
5 changes: 5 additions & 0 deletions libraries/AP_Param/AP_Param.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,11 @@ class AP_Param

static uint16_t _frame_type_flags;

/*
this is true if when scanning a defaults file we find all of the parameters
*/
static bool done_all_default_params;

/*
structure for built-in defaults file that can be modified using apj_tool.py
*/
Expand Down
Loading