diff --git a/DFReader.py b/DFReader.py index 8c3f0c678..4f8f50711 100644 --- a/DFReader.py +++ b/DFReader.py @@ -382,17 +382,32 @@ def dump_verbose(self, f): f.write(" %s: %s" % (c, val)) except UnicodeDecodeError: f.write(" %s: %s" % (c, to_string(val))) + + # see if this is an enumeration entry, emit enumeration + # entry name if it is + if c in field_metadata_by_name: + fm = field_metadata_by_name[c] + fm_enum = getattr(fm, "enum", None) + if fm_enum is not None: + enum_entry_name = "?????" # default, "not found" value + for entry in fm_enum.iterchildren(): + if int(entry.value) == int(val): + enum_entry_name = entry.get('name') + break + + f.write(f" ({enum_entry_name})") + # Append the unit to the output unit = self.fmt.get_unit(c) - if unit == "": - # No unit specified - just output the newline - f.write("\n") - elif unit.startswith("rad"): + if unit.startswith("rad"): # For rad or rad/s, add the degrees conversion too - f.write(" %s (%s %s)\n" % (unit, math.degrees(val), unit.replace("rad","deg"))) + f.write(" %s (%s %s)" % (unit, math.degrees(val), unit.replace("rad","deg"))) else: # Append the unit - f.write(" %s\n" % (unit)) + f.write(" %s" % (unit)) + + # output the newline + f.write("\n") # if this is a bitmask then print out all bits set: if c in field_metadata_by_name: