Skip to content

Commit 6b7687f

Browse files
committed
feat(python-ofm-gls): configure generator using gls tool
Note, that it breaks backward compatibity of the tool because displaying generator configuration can be only done by -C argument and not by -L c combination (example).
1 parent be1abfb commit 6b7687f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

python/ofm/ofm/comp/mfb_tools/debug/gen_loop_switch/gen_loop_switch.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,12 @@ def _main():
262262
"right" : "select the RIGHT side of the GLS to use the MFB Generator or set loopback",
263263
"left" : "select the LEFT side of the GLS to use the MFB Generator or set loopback",
264264
"loopback" : "enable (1) or disable (0) loopback (on the '-R' or '-L' side)",
265-
"generate" : "start (1) or stop (0) generating (to the '-R' or '-L' side), 'c' to print its config",
265+
"generate" : "start (1) or stop (0) generating (to the '-R' or '-L' side)",
266266
"size" : "set frame size for the ('-R' or '-L') MFB Generator",
267267
"measure" : "measure the throughput using selected Speed Meter (SM), 'a' for all, '0,1' by default",
268268
"config" : "print full configuration and exit",
269+
"gen-config" : "generator config - either print full configuration (no args) or set a value"
270+
" with two extra args"
269271
}
270272

271273
gls_desc = """
@@ -307,10 +309,11 @@ def _main():
307309
arg_parser.add_argument("-R", "--right", action="store_true", help=help_dict["right"])
308310
arg_parser.add_argument("-L", "--left", action="store_true", help=help_dict["left"])
309311
arg_parser.add_argument("-l", "--loopback", type=int, choices=[0, 1], help=help_dict["loopback"])
310-
arg_parser.add_argument("-g", "--generate", nargs="?", choices=["0", "1", "c"], help=help_dict["generate"])
312+
arg_parser.add_argument("-g", "--generate", nargs="?", choices=["0", "1"], help=help_dict["generate"])
311313
arg_parser.add_argument("-s", "--size", type=int, help=help_dict["size"])
312314
arg_parser.add_argument("-m", "--measure", nargs='?', const="default", choices=["default", "0", "1", "2", "3", "a"], help=help_dict["measure"])
313315
arg_parser.add_argument("-c", "--config", action="store_true", help=help_dict["config"])
316+
arg_parser.add_argument("-C", "--gen-config", nargs="*", help=help_dict["gen-config"])
314317
args = arg_parser.parse_args()
315318

316319
try:
@@ -377,9 +380,15 @@ def _main():
377380
elif "0" in args.generate:
378381
s.gen_stop()
379382

380-
if "c" in args.generate:
383+
if args.gen_config is not None:
384+
if len(args.gen_config) == 0:
381385
print("MFB Generator configuration:")
382386
print(tabulate(s.gen.get_fconfiguration()))
387+
elif len(args.gen_config) == 2:
388+
attr, value = args.gen_config
389+
s.gen.configure_attr(attr, value)
390+
else:
391+
raise ValueError("Invalid number of arguments")
383392

384393

385394
def main():

0 commit comments

Comments
 (0)