mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Merge pull request #306 from merlokk/lf_read_adc
Adds generic ADC read functionality
This commit is contained in:
@@ -553,6 +553,7 @@ lf_em_410x = lf_em.subgroup('410x', 'EM410x commands')
|
||||
lf_hid = lf.subgroup('hid', 'HID commands')
|
||||
lf_hid_prox = lf_hid.subgroup('prox', 'HID Prox commands')
|
||||
lf_viking = lf.subgroup('viking', 'Viking commands')
|
||||
lf_generic = lf.subgroup('generic', 'Generic commands')
|
||||
|
||||
@root.command('clear')
|
||||
class RootClear(BaseCLIUnit):
|
||||
@@ -3827,6 +3828,32 @@ class LFVikingWriteT55xx(LFVikingIdArgsUnit, ReaderRequiredUnit):
|
||||
self.cmd.viking_write_to_t55xx(id_bytes)
|
||||
print(f" - Viking ID(8H): {id_hex} write done.")
|
||||
|
||||
@lf_generic.command('adcread')
|
||||
class LFADCGenericRead(ReaderRequiredUnit):
|
||||
def args_parser(self) -> ArgumentParserNoExit:
|
||||
parser = ArgumentParserNoExit()
|
||||
parser.description = 'Read ADC and return the array'
|
||||
return parser
|
||||
|
||||
def on_exec(self, args: argparse.Namespace):
|
||||
resp = self.cmd.adc_generic_read()
|
||||
|
||||
if resp is not None:
|
||||
print(f"generic read data[{len(resp)}]:")
|
||||
width = 50
|
||||
for i in range(0, len(resp), width):
|
||||
chunk = resp[i : i + width]
|
||||
hexpart = " ".join(f"{b:02x}" for b in chunk)
|
||||
binpart = "".join('1' if b >= 0xbf else '0' for b in chunk)
|
||||
print(f"{i:04x} {hexpart:<{width * 3}} {binpart}")
|
||||
|
||||
avg = 0
|
||||
for val in resp:
|
||||
avg += val
|
||||
print(f'avg: {hex(round(avg / len(resp)))}')
|
||||
else:
|
||||
print(f"generic read error")
|
||||
|
||||
@hw_slot.command('list')
|
||||
class HWSlotList(DeviceRequiredUnit):
|
||||
def args_parser(self) -> ArgumentParserNoExit:
|
||||
|
||||
@@ -534,6 +534,18 @@ class ChameleonCMD:
|
||||
data = struct.pack(f'!4s4s{4*len(old_keys)}s', id_bytes, new_key, b''.join(old_keys))
|
||||
return self.device.send_cmd_sync(Command.VIKING_WRITE_TO_T55XX, data)
|
||||
|
||||
@expect_response(Status.LF_TAG_OK)
|
||||
def adc_generic_read(self):
|
||||
"""
|
||||
Read the ADC when the field is on.
|
||||
|
||||
:return:
|
||||
"""
|
||||
resp = self.device.send_cmd_sync(Command.ADC_GENERIC_READ, None)
|
||||
if resp.status == Status.LF_TAG_OK:
|
||||
resp.parsed = resp.data
|
||||
return resp
|
||||
|
||||
@expect_response(Status.SUCCESS)
|
||||
def get_slot_info(self):
|
||||
"""
|
||||
|
||||
@@ -83,6 +83,7 @@ class Command(enum.IntEnum):
|
||||
HIDPROX_WRITE_TO_T55XX = 3003
|
||||
VIKING_SCAN = 3004
|
||||
VIKING_WRITE_TO_T55XX = 3005
|
||||
ADC_GENERIC_READ = 3006
|
||||
|
||||
MF1_WRITE_EMU_BLOCK_DATA = 4000
|
||||
HF14A_SET_ANTI_COLL_DATA = 4001
|
||||
|
||||
Reference in New Issue
Block a user