mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Add EM410x slot reading ability
This commit is contained in:
@@ -319,6 +319,14 @@ data_frame_tx_t* cmd_processor_set_em410x_emu_id(uint16_t cmd, uint16_t status,
|
||||
return data_frame_make(cmd, status, 0, NULL);
|
||||
}
|
||||
|
||||
data_frame_tx_t* cmd_processor_get_em410x_emu_id(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
tag_data_buffer_t* buffer = get_buffer_by_tag_type(TAG_TYPE_EM410X);
|
||||
uint8_t responseData[LF_EM410X_TAG_ID_SIZE];
|
||||
memcpy(responseData, buffer->buffer, LF_EM410X_TAG_ID_SIZE);
|
||||
status = STATUS_DEVICE_SUCCESS;
|
||||
return data_frame_make(cmd, status, LF_EM410X_TAG_ID_SIZE, responseData);
|
||||
}
|
||||
|
||||
data_frame_tx_t* cmd_processor_set_mf1_detection_enable(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
if (length == 1 && (data[0] == 0 || data[0] == 1)) {
|
||||
nfc_tag_mf1_detection_log_clear();
|
||||
@@ -553,6 +561,7 @@ static cmd_data_map_t m_data_cmd_map[] = {
|
||||
|
||||
|
||||
{ DATA_CMD_SET_EM410X_EMU_ID, NULL, cmd_processor_set_em410x_emu_id, NULL },
|
||||
{ DATA_CMD_GET_EM410X_EMU_ID, NULL, cmd_processor_get_em410x_emu_id, NULL },
|
||||
|
||||
{ DATA_CMD_GET_MF1_DETECTION_STATUS, NULL, cmd_processor_get_mf1_detection_status, NULL },
|
||||
{ DATA_CMD_SET_MF1_DETECTION_ENABLE, NULL, cmd_processor_set_mf1_detection_enable, NULL },
|
||||
|
||||
@@ -116,7 +116,11 @@ class ChameleonCLI:
|
||||
'em': {
|
||||
'read': new_uint(chameleon_cli_unit.LFEMRead, "Scan em410x tag and print id"),
|
||||
'write': new_uint(chameleon_cli_unit.LFEMWriteT55xx, "Write em410x id to t55xx"),
|
||||
'sim': new_uint(chameleon_cli_unit.LFEMSim, "Simulation a em410x id card"),
|
||||
'sim': {
|
||||
'set': new_uint(chameleon_cli_unit.LFEMSimSet, "Set simulated em410x card id"),
|
||||
'get': new_uint(chameleon_cli_unit.LFEMSimGet, "Get simulated em410x card id"),
|
||||
'help': "Manage EM410x emulation data for selected slot"
|
||||
},
|
||||
'help': "EM410x read/write/emulator",
|
||||
},
|
||||
'help': "low frequency tag/reader",
|
||||
|
||||
@@ -891,19 +891,30 @@ class HWSlotEnableSet(SlotIndexRequireUint):
|
||||
print(f' - Set slot {slot_num} {"enable" if enable else "disable"} success.')
|
||||
|
||||
|
||||
class LFEMSim(LFEMCardRequiredUint):
|
||||
class LFEMSimSet(LFEMCardRequiredUint):
|
||||
|
||||
def args_parser(self) -> ArgumentParserNoExit or None:
|
||||
parser = ArgumentParserNoExit()
|
||||
return self.add_card_arg(parser)
|
||||
|
||||
# lf em sim --id 4545454545
|
||||
# lf em sim set --id 4545454545
|
||||
def on_exec(self, args: argparse.Namespace):
|
||||
id_hex = args.id
|
||||
id_bytes = bytearray.fromhex(id_hex)
|
||||
self.cmd_positive.set_em140x_sim_id(id_bytes)
|
||||
self.cmd_positive.set_em410x_sim_id(id_bytes)
|
||||
print(f' - Set em410x tag id success.')
|
||||
|
||||
class LFEMSimGet(DeviceRequiredUnit):
|
||||
|
||||
def args_parser(self) -> ArgumentParserNoExit or None:
|
||||
return None
|
||||
|
||||
# lf em sim get
|
||||
def on_exec(self, args: argparse.Namespace):
|
||||
response = self.cmd_positive.get_em410x_sim_id()
|
||||
print(f' - Get em410x tag id success.')
|
||||
print(f'ID: {response.data.hex()}')
|
||||
|
||||
|
||||
class HWSlotNickSet(SlotIndexRequireUint, SenseTypeRequireUint):
|
||||
def args_parser(self) -> ArgumentParserNoExit or None:
|
||||
|
||||
@@ -327,7 +327,7 @@ class BaseChameleonCMD:
|
||||
data.append(0x01 if enable else 0x00)
|
||||
return self.device.send_cmd_sync(DATA_CMD_SET_SLOT_ENABLE, 0X00, data)
|
||||
|
||||
def set_em140x_sim_id(self, id_bytes: bytearray):
|
||||
def set_em410x_sim_id(self, id_bytes: bytearray):
|
||||
"""
|
||||
设置EM410x模拟的卡号
|
||||
:param id_bytes: 卡号的字节
|
||||
@@ -336,6 +336,12 @@ class BaseChameleonCMD:
|
||||
if len(id_bytes) != 5:
|
||||
raise ValueError("The id bytes length must equal 5")
|
||||
return self.device.send_cmd_sync(DATA_CMD_SET_EM410X_EMU_ID, 0x00, id_bytes)
|
||||
|
||||
def get_em410x_sim_id(self):
|
||||
"""
|
||||
Get the simulated EM410x card id
|
||||
"""
|
||||
return self.device.send_cmd_sync(DATA_CMD_GET_EM410X_EMU_ID, 0x00)
|
||||
|
||||
def set_mf1_detection_enable(self, enable: bool):
|
||||
"""
|
||||
@@ -528,8 +534,8 @@ class PositiveChameleonCMD(BaseChameleonCMD):
|
||||
self.check_status(ret.status, chameleon_status.Device.STATUS_DEVICE_SUCCESS)
|
||||
return ret
|
||||
|
||||
def set_em140x_sim_id(self, id_bytes: bytearray):
|
||||
ret = super(PositiveChameleonCMD, self).set_em140x_sim_id(id_bytes)
|
||||
def set_em410x_sim_id(self, id_bytes: bytearray):
|
||||
ret = super(PositiveChameleonCMD, self).set_em410x_sim_id(id_bytes)
|
||||
self.check_status(ret.status, chameleon_status.Device.STATUS_DEVICE_SUCCESS)
|
||||
return ret
|
||||
|
||||
|
||||
Reference in New Issue
Block a user