ACS ACR1252不支持Mifare Desfire / Mifare Plus的读取,因此需要使用其他读卡器。以下是使用Python的代码示例,通过PN532读卡器读取Mifare Plus卡片:
import time
import board
import busio
from adafruit_pn532.spi import PN532_SPI
from adafruit_pn532.ndef import NDEFMessage, NDEFRecord
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs_pin = board.D5
pn532 = PN532_SPI(spi, cs_pin, debug=False)
ic, ver, rev, support = pn532.firmware_version
pn532.SAM_configuration()
while True:
# Check if a card is available to read
uid = pn532.read_passive_target(timeout=0.5)
if uid is None:
continue
print("Found card with UID:", [hex(i) for i in uid])
# Reading Mifare Plus card
if len(uid) == 7:
key = b'\xFF\xFF\xFF\xFF\xFF\xFF' # default AES key for Mifare Plus
block1 = pn532.mifare_plus_aes_authentication(uid, 1, key, PN532_SPI.BLOCK_TYPE_4)
block2 = pn532.mifare_plus_read_block(2)
print("Block 1:", [hex(i) for i in block1])
print("Block 2:", [hex(i) for i in block2])
time.sleep(1)
注意:使用PN532读卡器需要安装库adafruit-circuitpython-pn532
。