Commit 53cb4f55 authored by Amy Blank's avatar Amy Blank 🌈
Browse files

make default value optional in a place that didn't already have a conditional...

make default value optional in a place that didn't already have a conditional (most others already did) and added some code comments
parent 53c6199a
......@@ -108,3 +108,7 @@ ENV/
*.csv
*.eds
bin/
# vim swap files
*.swp
*.swo
......@@ -28,6 +28,8 @@ def generate_eds_section(objdict):
eds_config = configparser.ConfigParser()
eds_config.optionxform = str
for entry in objdict['indexes']:
# Note that an index with multiple subindices *must* have its
# first subindex be 0 for this code to work properly.
if entry['subindex'] == 0:
section_name = "{:04x}".format(entry['index'])
eds_config[section_name] = OrderedDict([
......@@ -47,8 +49,7 @@ def generate_eds_section(objdict):
base_entry = "{:04x}".format(entry['index'])
eds_config[base_entry]["ObjectType"] = "0x08"
eds_config[base_entry].pop("PDOMapping", None)
default_value = eds_config[
base_entry].pop("DefaultValue", None)
section_name = "{:04x}sub0".format(entry['index'])
eds_config[section_name] = OrderedDict([
......@@ -56,8 +57,11 @@ def generate_eds_section(objdict):
("DataType", eds_config[base_entry]['DataType']),
("ParameterName", "NumberOfEntries"),
("AccessType", eds_config[base_entry]['AccessType'].lower()),
("PDOMapping", 0),
("DefaultValue", default_value)])
("PDOMapping", 0)])
if "default" in entry:
default_value = eds_config[base_entry].pop("DefaultValue", None)
eds_config[section_name]["DefaultValue"] = default_value
# generate the subN index
section_name = "{0:04x}sub{1:X}".format(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment