Exemple #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
Exemple #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)
Exemple #3
0
 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
Exemple #4
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
Exemple #5
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')
Exemple #6
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")
Exemple #7
0
        # 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")

	  # wait for the card to be removed
	  fplog.l("Waiting for card to be removed...","test")
	  rfid.waitNoTag()
	  fplog.l("Card removed","test")

# END
Exemple #8
0
    "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:"******"Unknown card:" + uid)

    # wait for the card to be removed
    print("Waiting for card to be removed...")
#   This, like, forever!
while True:

    # try to check to see if a card is present
    try:
        tagIsPresent = rfid.tagIsPresent()
    except:
        time.sleep(0.2)
        continue

    #   If one is, see if it's different to the one we had before
    if tagIsPresent:
        #   try and grab the data
        try:
            rfid.readMifare()
            uid = rfid.getUniqueId()
        except:
            time.sleep(0.2)
            continue

        #   If it's a new tag, then do the thing!
        if uid != old_tag:
            #   try and call the brain api endpoint
            try:
                response = urllib2.urlopen(api + "miab.tag.detected?id=" + uid)
                response.close()
                old_tag = uid
            except:
                time.sleep(0.5)
                continue
Exemple #10
0
	def isCard(self,cardtype):
		ret = rfid.readMifare()
		return ret