From ef2d4385625dee060c34a43fb0d3c5ae6be408b1 Mon Sep 17 00:00:00 2001 From: GameTec_live Date: Mon, 17 Jul 2023 16:59:36 +0200 Subject: [PATCH] Make eload -t optional --- software/script/chameleon_cli_unit.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/software/script/chameleon_cli_unit.py b/software/script/chameleon_cli_unit.py index 618bc55..a91cab1 100644 --- a/software/script/chameleon_cli_unit.py +++ b/software/script/chameleon_cli_unit.py @@ -629,14 +629,22 @@ class HFMFELoad(DeviceRequiredUnit): def args_parser(self) -> ArgumentParserNoExit or None: parser = ArgumentParserNoExit() parser.add_argument('-f', '--file', type=str, required=True, help="file path") - parser.add_argument('-t', '--type', type=str, required=True, help="content type", choices=['bin', 'hex']) + parser.add_argument('-t', '--type', type=str, required=False, help="content type", choices=['bin', 'hex']) return parser # hf mf eload -f test.bin -t bin # hf mf eload -f test.eml -t hex def on_exec(self, args: argparse.Namespace): file = args.file - content_type = args.type + if args.type is None: + if file.endswith('.bin'): + content_type = 'bin' + elif file.endswith('.eml'): + content_type = 'hex' + else: + raise Exception("Unknown file format, Specify content type with -t option") + else: + content_type = args.type buffer = bytearray() with open(file, mode='rb') as fd: