我正在将 RC-522 模块与橙色pi零一起使用。我将库用作 MFRC522-python 。 (https://github.com/mxgxw/MFRC522-python)
我对读取和验证卡没有问题。 我的问题是同时读取多张卡。想象一下,我的代客卡上有5张rfid卡,其中1张卡是经过身份验证的卡,其他的则不是。在我的系统中,如果将vallet放在rfid读取器上,它将随机选择一张卡,并始终读取该卡。我想编程选择每张卡,而不仅仅是一张卡。 (如果您删除vallet并再次放入,程序应该选择另一张卡,但是我的意思是,我不想每次都删除vallet,当我将读卡器放在我的vallet上时,它必须同时选择所有卡。我的问题是,如何在我的while循环中选择不同的卡片,而又不删除我的vallet并重新放置。
这是我的代码
while continue_reading:
# Scan for cards
(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
# If a card is found
if status == MIFAREReader.MI_OK:
print "Card detected"
# Get the UID of the card
(status,uid) = MIFAREReader.MFRC522_Anticoll()
# If we have the UID, continue
if status == MIFAREReader.MI_OK:
# Print UID
print "Card read UID: %s,%s,%s,%s" % (uid[0], uid[1], uid[2], uid[3])
# This is the default key for authentication
key = [0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]
# Select the scanned tag
MIFAREReader.MFRC522_SelectTag(uid)
# Authenticate
status = MIFAREReader.MFRC522_Auth(MIFAREReader.PICC_AUTHENT1A, 8, key, uid)
# Check if authenticated
if status == MIFAREReader.MI_OK:
MIFAREReader.MFRC522_Read(8)
MIFAREReader.MFRC522_StopCrypto1()
else:
print "Authentication error"