Beispiel #1
0
    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
Beispiel #2
0
 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)
Beispiel #3
0
 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
Beispiel #4
0
    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')
Beispiel #5
0
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")
Beispiel #6
0
# ...run automated tests if library is started as a script

if __name__ == "__main__":
	fplog.l("+++ In: fprfid.py Test +++ ","test")

        # GPIO_YELLOW_LED = output => Ansteuerung der gelben LED = Warten auf TAG
    	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")
Beispiel #7
0
cards = {
    "2B53B49B": "whaleygeek",
    "04982B29EE0280": "elektor RFID card",
    "EAC85517": "white card 1",
    "24B1E145": "white card 2",
    "C2091F58": "label 1",
    "22F51E58": "label 2"
}

# 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:" + user)
        except KeyError:
Beispiel #8
0
	def waitTag(self):
		rfid.waitTag()