Exemple #1
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 #2
0
    	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 #3
0
# 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 waitNoTag(self):
		rfid.waitNoTag()