px_generate_params: Sort parameters by name after parsing the xml file.

This commit is contained in:
Stephan Brown 2017-01-04 13:21:51 -08:00 committed by Beat Küng
parent 272f1dd4b9
commit e90bf8f8e5
1 changed files with 15 additions and 29 deletions

View File

@ -45,12 +45,9 @@ struct px4_parameters_t {
start_name = ""
end_name = ""
params = []
for group in root:
if group.tag == "group" and "no_code_generation" not in group.attrib:
section = """
/*****************************************************************
* %s
****************************************************************/""" % group.attrib["name"]
for param in group:
scope_ = param.find('scope').text
if not cmake_scope.Has(scope_):
@ -58,10 +55,13 @@ for group in root:
if not start_name:
start_name = param.attrib["name"]
end_name = param.attrib["name"]
header += section
section =""
header += """
params.append(param)
params = sorted(params, key=lambda name: name.attrib["name"])
for param in params:
header += """
const struct param_info_s __param__%s;""" % param.attrib["name"]
header += """
const unsigned int param_count;
};
@ -83,28 +83,14 @@ __attribute__((used, section("__param")))
struct px4_parameters_t px4_parameters = {
"""
i=0
for group in root:
if group.tag == "group" and "no_code_generation" not in group.attrib:
section = """
/*****************************************************************
* %s
****************************************************************/""" % group.attrib["name"]
for param in group:
scope_ = param.find('scope').text
if not cmake_scope.Has(scope_):
continue
if not start_name:
start_name = param.attrib["name"]
end_name = param.attrib["name"]
val_str = "#error UNKNOWN PARAM TYPE, FIX px_generate_params.py"
if (param.attrib["type"] == "FLOAT"):
val_str = ".val.f = "
elif (param.attrib["type"] == "INT32"):
val_str = ".val.i = "
i+=1
src += section
section =""
src += """
for param in params:
val_str = "#error UNKNOWN PARAM TYPE, FIX px_generate_params.py"
if (param.attrib["type"] == "FLOAT"):
val_str = ".val.f = "
elif (param.attrib["type"] == "INT32"):
val_str = ".val.i = "
i+=1
src += """
{
"%s",
PARAM_TYPE_%s,