feat: v0.3.6 — PN532 driver working, badge UID read
This commit is contained in:
12
pn532.py
12
pn532.py
@@ -122,12 +122,16 @@ class PN532_I2C:
|
||||
"""Wait for ISO14443A card. Returns UID bytes or None."""
|
||||
self._send_command([PN532_CMD_INLISTPASSIVETARGET, 0x01, 0x00])
|
||||
resp = self._read_response(length=32, timeout=timeout)
|
||||
if not resp or len(resp) < 6:
|
||||
if not resp:
|
||||
return None
|
||||
if resp[0] != 0x01:
|
||||
# resp[0]=cmd_response(0x4B), resp[1]=num_targets, resp[2]=tg
|
||||
# resp[3][4]=ATQA, resp[5]=SAK, resp[6]=uid_len, resp[7+]=UID
|
||||
if len(resp) < 8:
|
||||
return None
|
||||
uid_len = resp[4]
|
||||
return bytes(resp[5:5 + uid_len])
|
||||
if resp[1] != 0x01:
|
||||
return None
|
||||
uid_len = resp[6]
|
||||
return bytes(resp[7:7 + uid_len])
|
||||
|
||||
def read_uid(self, timeout=500) -> bytes:
|
||||
return self.read_passive_target(timeout=timeout)
|
||||
|
||||
Reference in New Issue
Block a user