Browse Source

generate_params.py: extend params 'definitions' section to support a list

allows to add multiple entries for a multi-instance param with different
instance_start
master
Beat Küng 3 years ago committed by Daniel Agar
parent
commit
db28ea9cfa
  1. 93
      Tools/module_config/generate_params.py

93
Tools/module_config/generate_params.py

@ -50,49 +50,56 @@ def parse_yaml_parameters_config(yaml_config, ethernet_supported):
definitions = parameters_section['definitions'] definitions = parameters_section['definitions']
param_group = parameters_section.get('group', None) param_group = parameters_section.get('group', None)
for param_name in definitions: for param_name in definitions:
param = definitions[param_name] # 'definitions' either contains the param definition directly (dict),
if param.get('requires_ethernet', False) and not ethernet_supported: # or a list of definitions with that name (multiple entries for a
continue # multi-instance param with different instance_start)
num_instances = param.get('num_instances', 1) param_list = definitions[param_name]
instance_start = param.get('instance_start', 0) # offset if not isinstance(param_list, list):
param_list = [param_list]
# get the type and extract all tags
tags = '@group {:}'.format(param_group) for param in param_list:
if param['type'] == 'enum': if param.get('requires_ethernet', False) and not ethernet_supported:
param_type = 'INT32' continue
for key in param['values']: num_instances = param.get('num_instances', 1)
tags += '\n * @value {:} {:}'.format(key, param['values'][key]) instance_start = param.get('instance_start', 0) # offset
elif param['type'] == 'boolean':
param_type = 'INT32' # get the type and extract all tags
tags += '\n * @boolean' tags = '@group {:}'.format(param_group)
elif param['type'] == 'int32': if param['type'] == 'enum':
param_type = 'INT32' param_type = 'INT32'
elif param['type'] == 'float': for key in param['values']:
param_type = 'FLOAT' tags += '\n * @value {:} {:}'.format(key, param['values'][key])
else: elif param['type'] == 'boolean':
raise Exception("unknown param type {:}".format(param['type'])) param_type = 'INT32'
tags += '\n * @boolean'
for tag in ['decimal', 'increment', 'category', 'volatile', 'bit', elif param['type'] == 'int32':
'min', 'max', 'unit', 'reboot_required']: param_type = 'INT32'
if tag in param: elif param['type'] == 'float':
tags += '\n * @{:} {:}'.format(tag, param[tag]) param_type = 'FLOAT'
else:
for i in range(num_instances): raise Exception("unknown param type {:}".format(param['type']))
# default value
default_value = 0 for tag in ['decimal', 'increment', 'category', 'volatile', 'bit',
if 'default' in param: 'min', 'max', 'unit', 'reboot_required']:
# default can be a list of num_instances or a single value if tag in param:
if type(param['default']) == list: tags += '\n * @{:} {:}'.format(tag, param[tag])
assert len(param['default']) == num_instances
default_value = param['default'][i] for i in range(num_instances):
else: # default value
default_value = param['default'] default_value = 0
if 'default' in param:
if type(default_value) == bool: # default can be a list of num_instances or a single value
default_value = int(default_value) if type(param['default']) == list:
assert len(param['default']) == num_instances
# output the existing C-style format default_value = param['default'][i]
ret += ''' else:
default_value = param['default']
if type(default_value) == bool:
default_value = int(default_value)
# output the existing C-style format
ret += '''
/** /**
* {short_descr} * {short_descr}
* *

Loading…
Cancel
Save