diff --git a/feature/rfid-read/source/read.py b/feature/rfid-read/source/read.py index f86276c..c02ed3a 100644 --- a/feature/rfid-read/source/read.py +++ b/feature/rfid-read/source/read.py @@ -6,31 +6,25 @@ import MFRC522 -# Create an object of the class MFRC522 +# [1] Create an object of the class MFRC522 GPIO.setwarnings(False); MIFAREReader = MFRC522.MFRC522() - - -# Scan for cards +# [2] Scan for cards (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() +# [5] If no UID read -> exit 1 +if status != MIFAREReader.MI_OK: + exit(1); -# If we have the UID, continue -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 +# [6] Print UID suid = str(hex(uid[0]))[2:]; suid += '-' + str(hex(uid[1]))[2:]; suid += '-' + str(hex(uid[2]))[2:];