From 24f25e01669e404a18fc912697d651f34cbe2134 Mon Sep 17 00:00:00 2001 From: dxl <64101226@qq.com> Date: Tue, 7 Mar 2023 18:35:40 +0800 Subject: [PATCH] Add a new command to open all card slots. --- software/script/chameleon_cli_main.py | 1 + software/script/chameleon_cli_unit.py | 33 ++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/software/script/chameleon_cli_main.py b/software/script/chameleon_cli_main.py index ed9c515..4c5cb93 100644 --- a/software/script/chameleon_cli_main.py +++ b/software/script/chameleon_cli_main.py @@ -72,6 +72,7 @@ class ChameleonCLI: 'help': "Get/Set tag nick name for slot", }, 'update': new_uint(chameleon_cli_unit.HWSlotUpdate, "Update config & data to device flash"), + 'openall': new_uint(chameleon_cli_unit.HWSlotOpenAll, "Open all slot and set to default data"), 'help': "Emulation tag slot.", }, 'help': "hardware controller", diff --git a/software/script/chameleon_cli_unit.py b/software/script/chameleon_cli_unit.py index f21d15b..3d3d83f 100644 --- a/software/script/chameleon_cli_unit.py +++ b/software/script/chameleon_cli_unit.py @@ -900,4 +900,35 @@ class HWSlotUpdate(DeviceRequiredUnit): # hw slot update def on_exec(self, args: argparse.Namespace): self.cmd_positive.update_slot_data_config() - print(f' - Update config and data from device memory to flash success.') \ No newline at end of file + print(f' - Update config and data from device memory to flash success.') + + +class HWSlotOpenAll(DeviceRequiredUnit): + + def args_parser(self) -> ArgumentParserNoExit or None: + return None + + # hw slot openall + def on_exec(self, args: argparse.Namespace): + # what type you need set to default? + hf_type = chameleon_cmd.TagSpecificType.TAG_TYPE_MIFARE_1024 + lf_type = chameleon_cmd.TagSpecificType.TAG_TYPE_EM410X + + # set all slot + for slot in range(8): + # the slot not from 0 offset, so we can inc 1. + slot = slot + 1 + print(f' Slot{slot} setting...') + # first to set tag type + self.cmd_positive.set_slot_tag_type(slot, hf_type) + self.cmd_positive.set_slot_tag_type(slot, lf_type) + # to init default data + self.cmd_positive.set_slot_data_default(slot, hf_type) + self.cmd_positive.set_slot_data_default(slot, lf_type) + # finally, we can enable this slot. + self.cmd_positive.set_slot_enable(slot, True) + print(f' Open slot{slot} finish') + + # update config and save to flash + self.cmd_positive.update_slot_data_config() + print(f' - Open all slot and set data to default success.')