def wait_for_next(self): # Import this module to gain access to the RFID driver # fill in this map with the names of your card ID's # wait for a card to be detected as present print("Waiting for a card...") rfid.waitTag() print("Card present") # This demo only uses Mifare cards if not rfid.readMifare(): print("This is not a mifare card") else: # What type of Mifare card is it? (there are different types) print("Card type:" + rfid.getTypeName()) # look up the unique ID to see if we recognise the user uid = rfid.getUniqueId() # wait for the card to be removed #print("Waiting for card to be removed...") #rfid.waitNoTag() #print("Card removed") return uid
def do(): while True: rfid.waitTag() if rfid.readMifare(): uid = rfid.getUniqueId() if self.myDatabase.cardExists(uid): print('Card found:'+uid) else: print('Card NOT found:'+uid)
def checkCard(self): if rfid.tagIsPresent(): if rfid.readMifare(): uid = rfid.getUniqueId() cid = self.myDatabase.cardExists(uid) if cid >= 0: #print ("CHECK: Card found") return cid else: #print ("CHECK: Card NOT found") return -1 else: return -1 else: return -1
def readCard(self): while True: rfid.waitTag() if rfid.readMifare(): uid = rfid.getUniqueId() cid = self.myDatabase.cardExists(uid) if cid >= 0: #print ("READ: Card found") self.beepShort() return cid else: #print ("READ: Card NOT found") self.beepLong() return -1 break else: return -1
def readCard(self): while True: rfid.waitTag() if rfid.readMifare(): uid = rfid.getUniqueId() id = self.parentApp.myDatabase.cardExists(uid) if (id >= 0): self.parentApp.getForm('EDITRECORDFM').value = id else: self.parentApp.getForm('EDITRECORDFM').value = -1 break else: self.cardUID = "" break #self.parent.parentApp.getForm('EDITRECORDFM').value =act_on_this[0] self.parentApp.switchForm('EDITRECORDFM')
def phase2readrfid(): global RFIDREAD; RFIDREAD = False fplog.l("PHASE2: wait for RF-ID tag") fertilizercheck() # wait for a card to be detected as present GPIO.output(GPIO_YELLOW_LED, GPIO.HIGH) fplog.l("Waiting for a card...") rfid.waitTag() fplog.l("Card is present") # This program expects Mifare cards if not rfid.readMifare(): fplog.l("Error: The scanned RF-id tag is not a mifare card") blinkredled() rfid.waitNoTag() rfid.waitTag() # get unique ID if the card rfidid = rfid.getUniqueId() # overriding GLOBAL variable with local content global RFIDUID; RFIDUID = rfidid fplog.l("Card UID:" + RFIDUID) blinkyellowled() # wait for the card to be removed fplog.l("Waiting for card to be removed...") rfid.waitNoTag() fplog.l("Card removed") GPIO.output(GPIO_YELLOW_LED, GPIO.LOW) RFIDREAD = True fplog.l("PHASE2: done - RF-ID tag available") if RFIDUID == "A1CF06B0": fplog.l("Read Shutdown-Tag; shutdown will be initiated; goodby!") os.system("sudo shutdown -h now")
GPIO.setup(GPIO_YELLOW_LED, GPIO.OUT) while True: # wait for a card to be detected as present GPIO.output(GPIO_YELLOW_LED, GPIO.HIGH) fplog.l("Waiting for a card...","test") rfid.waitTag() fplog.l("Card is present","test") GPIO.output(GPIO_YELLOW_LED, GPIO.LOW) # This demo only uses Mifare cards if not rfid.readMifare(): fplog.l("This is not a mifare card","test") else: # What type of Mifare card is it? (there are different types) fplog.l("Card type:" + rfid.getTypeName(),"test") # get unique ID if the card uid = rfid.getUniqueId() fplog.l("Card UID:" + uid,"test") # wait for the card to be removed fplog.l("Waiting for card to be removed...","test") rfid.waitNoTag() fplog.l("Card removed","test") # END
# MAIN PROGRAM while True: # wait for a card to be detected as present print("Waiting for a card...") rfid.waitTag() print("Card present") # This demo only uses Mifare cards if not rfid.readMifare(): print("This is not a mifare card") else: # What type of Mifare card is it? (there are different types) print("Card type:" + rfid.getTypeName()) # look up the unique ID to see if we recognise the user uid = rfid.getUniqueId() try: user = cards[uid] print("User:"******"Unknown card:" + uid) # wait for the card to be removed print("Waiting for card to be removed...") rfid.waitNoTag() print("Card removed") # END
def getUID(self): return rfid.getUniqueId()