diff options
author | Don Gagne <don@thegagnes.com> | 2015-04-16 12:55:20 -0700 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-04-18 11:14:12 +0200 |
commit | 9ac350a7d1c5c07a4e4ba7824744930f9110dedc (patch) | |
tree | df4215c31718bd1794b388a3adfa7e2658c6fc43 /Tools/px4params/srcparser.py | |
parent | 3a70e7bf1bef904c63f3bbe0a92e7c9aeda978aa (diff) | |
download | px4-firmware-9ac350a7d1c5c07a4e4ba7824744930f9110dedc.tar.gz px4-firmware-9ac350a7d1c5c07a4e4ba7824744930f9110dedc.tar.bz2 px4-firmware-9ac350a7d1c5c07a4e4ba7824744930f9110dedc.zip |
Added ability for board specific meta data generation
Use new @board meta data attribute for board specific ifdef support
Diffstat (limited to 'Tools/px4params/srcparser.py')
-rw-r--r-- | Tools/px4params/srcparser.py | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/Tools/px4params/srcparser.py b/Tools/px4params/srcparser.py index 891db7ecd..0d2413a75 100644 --- a/Tools/px4params/srcparser.py +++ b/Tools/px4params/srcparser.py @@ -37,20 +37,30 @@ class Parameter(object): # Define sorting order of the fields priority = { - "code": 10, - "type": 9, + "board": 9, "short_desc": 8, "long_desc": 7, - "default": 6, "min": 5, "max": 4, "unit": 3, # all others == 0 (sorted alphabetically) } - def __init__(self): + def __init__(self, name, type, default = ""): self.fields = {} + self.name = name + self.type = type + self.default = default + + def GetName(self): + return self.name + def GetType(self): + return self.type + + def GetDefault(self): + return self.default + def SetField(self, code, value): """ Set named field value @@ -88,7 +98,7 @@ class SourceParser(object): re_is_a_number = re.compile(r'^-?[0-9\.]') re_remove_dots = re.compile(r'\.+$') - valid_tags = set(["group", "min", "max", "unit"]) + valid_tags = set(["group", "board", "min", "max", "unit"]) # Order of parameter groups priority = { @@ -177,15 +187,12 @@ class SourceParser(object): # Non-empty line outside the comment m = self.re_parameter_definition.match(line) if m: - tp, code, defval = m.group(1, 2, 3) + tp, name, defval = m.group(1, 2, 3) # Remove trailing type specifier from numbers: 0.1f => 0.1 if self.re_is_a_number.match(defval): defval = self.re_cut_type_specifier.sub('', defval) - param = Parameter() - param.SetField("code", code) - param.SetField("short_desc", code) - param.SetField("type", tp) - param.SetField("default", defval) + param = Parameter(name, tp, defval) + param.SetField("short_desc", name) # If comment was found before the parameter declaration, # inject its data into the newly created parameter. group = "Miscellaneous" @@ -211,11 +218,9 @@ class SourceParser(object): # Nasty code dup, but this will all go away soon, so quick and dirty (DonLakeFlyer) m = self.re_px4_parameter_definition.match(line) if m: - tp, code = m.group(1, 2) - param = Parameter() - param.SetField("code", code) - param.SetField("short_desc", code) - param.SetField("type", tp) + tp, name = m.group(1, 2) + param = Parameter(name, tp) + param.SetField("short_desc", name) # If comment was found before the parameter declaration, # inject its data into the newly created parameter. group = "Miscellaneous" |