From 9cd086e069592e6c1ecfc3e851487ac35f910559 Mon Sep 17 00:00:00 2001 From: Svein Seldal Date: Fri, 13 Feb 2026 18:08:41 +0100 Subject: [PATCH 1/2] Add printing disabled cob-ids --- src/objdictgen/printing.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/objdictgen/printing.py b/src/objdictgen/printing.py index 5149d4c..dc3694b 100644 --- a/src/objdictgen/printing.py +++ b/src/objdictgen/printing.py @@ -267,6 +267,11 @@ def format_od_object( except ValueError: suffix = ' ???' if value else '' t_value = f"0x{value:x}{suffix}" + elif index_range and index_range.name in ('rpdop', 'tpdop'): + assert isinstance(value, int) + t_value = f"0x{value:x}" if 'COB ID' in info["name"] else str(value) + if i == 1 and value & 0x80000000: + t_value += f" {Fore.LIGHTYELLOW_EX}DISABLED{Style.RESET_ALL}" elif i and value and (index in (4120, ) or 'COB ID' in info["name"]): t_value = f"0x{value:x}" else: From a2873b7661b070e163f6865e3c4f0159dc10ccf9 Mon Sep 17 00:00:00 2001 From: Svein Seldal Date: Fri, 13 Feb 2026 18:41:17 +0100 Subject: [PATCH 2/2] * Add +NODEID message on COB-IDs * Add new option --nodeid to odg --- src/objdictgen/__main__.py | 5 +++++ src/objdictgen/printing.py | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/objdictgen/__main__.py b/src/objdictgen/__main__.py index c6557d5..865c124 100644 --- a/src/objdictgen/__main__.py +++ b/src/objdictgen/__main__.py @@ -174,6 +174,7 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None): subp.add_argument('--unused', action="store_true", help="Include unused profile parameters") subp.add_argument('--internal', action="store_true", help="Show internal data") subp.add_argument('--minus', help="Show only parameters that are not in this OD") + subp.add_argument('-n', '--nodeid', type=int, help="Set the $NODEID to this value") # -- NETWORK -- subp = subparser.add_parser('network', parents=[common_opts], help=""" @@ -313,6 +314,10 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None): print(Fore.LIGHTBLUE_EX + name + '\n' + "=" * len(name) + Style.RESET_ALL) od = open_od(name, validate=not opts.novalidate) + + if opts.nodeid: + od.ID = opts.nodeid + for line in format_node(od, name, index=opts.index, minus=minus, opts=opts): print(line) diff --git a/src/objdictgen/printing.py b/src/objdictgen/printing.py index dc3694b..6a6d8bd 100644 --- a/src/objdictgen/printing.py +++ b/src/objdictgen/printing.py @@ -226,9 +226,11 @@ def format_od_object( # Fetch the dictionary values and the parameters, if present if index in node.Dictionary: values = node.GetEntry(index, aslist=True, compute=not raw) + raw_values = node.GetEntry(index, aslist=True, compute=False) else: # Fill the values with N/A if the entry is not present values = ['__N/A__'] * len(obj["values"]) + raw_values = values if index in node.ParamsDictionary: # FIXME: Is there a risk that this return less than the length of @@ -238,16 +240,22 @@ def format_od_object( params = [maps.DEFAULT_PARAMS] * len(values) # For mypy to ensure that values and entries are lists - assert isinstance(values, list) and isinstance(params, list) + assert isinstance(values, list) and isinstance(raw_values, list) and isinstance(params, list) infos = [] # The strict=True will capture if the values and params are not the same - for i, (value, param) in enumerate(zip(values, params, strict=True)): + for i, (value, raw_value, param) in enumerate(zip(values, raw_values, params, strict=True)): # Prepare data for printing info = node.GetSubentryInfos(index, i) typename = node.GetTypeName(info['type']) + # Adding +NODEID text? + if 'COB ID' in info["name"] and isinstance(raw_value, str) and "$NODEID" in raw_value and not node.ID: + t_node = f"{Fore.GREEN}+NODEID{Style.RESET_ALL}" + else: + t_node = '' + # Type specific formatting of the value if value == "__N/A__": t_value = f'{Fore.LIGHTBLACK_EX}N/A{Style.RESET_ALL}' @@ -269,11 +277,11 @@ def format_od_object( t_value = f"0x{value:x}{suffix}" elif index_range and index_range.name in ('rpdop', 'tpdop'): assert isinstance(value, int) - t_value = f"0x{value:x}" if 'COB ID' in info["name"] else str(value) + t_value = f"0x{value:x}{t_node}" if 'COB ID' in info["name"] else f"{value}{t_node}" if i == 1 and value & 0x80000000: - t_value += f" {Fore.LIGHTYELLOW_EX}DISABLED{Style.RESET_ALL}" + t_value += f" {Fore.LIGHTYELLOW_EX}{Style.RESET_ALL}" elif i and value and (index in (4120, ) or 'COB ID' in info["name"]): - t_value = f"0x{value:x}" + t_value = f"0x{value:x}{t_node}" else: t_value = str(value)