Loop new implementation test@3

This commit is contained in:
xdrm-brackets 2017-09-28 10:50:49 +02:00
parent 34a15fa16a
commit 7240fc87c2
1 changed files with 10 additions and 16 deletions

View File

@ -6,31 +6,25 @@ import MFRC522
# Create an object of the class MFRC522 # [1] Create an object of the class MFRC522
GPIO.setwarnings(False); GPIO.setwarnings(False);
MIFAREReader = MFRC522.MFRC522() MIFAREReader = MFRC522.MFRC522()
# [2] Scan for cards
# Scan for cards
(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL) (status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
# [3] If no card found -> exit 1
if status != MIFAREReader.MI_OK:
exit(1);
# Get the UID of the card # [4] Get the UID of the card
(status,uid) = MIFAREReader.MFRC522_Anticoll() (status,uid) = MIFAREReader.MFRC522_Anticoll()
# [5] If no UID read -> exit 1
if status != MIFAREReader.MI_OK:
exit(1);
# If we have the UID, continue # [6] Print UID
while status != MIFAREReader.MI_OK:
# Scan for cards
(status,TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
# Get the UID of the card
(status,uid) = MIFAREReader.MFRC522_Anticoll()
# Print UID
suid = str(hex(uid[0]))[2:]; suid = str(hex(uid[0]))[2:];
suid += '-' + str(hex(uid[1]))[2:]; suid += '-' + str(hex(uid[1]))[2:];
suid += '-' + str(hex(uid[2]))[2:]; suid += '-' + str(hex(uid[2]))[2:];