args = parser.parse_args() config = yaml.load(open(args.config, 'r')) reader = PyRFIDGeek(config) try: led_enabled = False uids = [] prev_uids = [[], []] while True: uids = list(reader.inventory()) successful_reads = [] print '%d tags' % len(uids) if len(uids) > 0 and not led_enabled: reader.enable_led(3) led_enabled = True elif len(uids) == 0 and led_enabled: reader.disable_led(3) led_enabled = False for uid in uids: if not uid in prev_uids[0] and not uid in prev_uids[1]: # and not uid in prev_uids[2]: item = reader.read_danish_model_tag(uid) if item['error'] != '': print 'error reading tag: ',item['error'] else: if item['is_blank']: print ' Found blank tag' elif 'id' in item:
import logging import thread import time import json import argparse import yaml import time from copy import copy from pyrfidgeek import PyRFIDGeek logger = logging.getLogger() logger.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) logger.addHandler(ch) parser = argparse.ArgumentParser(description='PyRfidGeek write patron card example') parser.add_argument('--config', nargs='?', default='config.yml', help='Config file') args = parser.parse_args() config = yaml.load(open(args.config, 'r')) rfid = PyRFIDGeek(config) uids = list(rfid.inventory()) if len(uids) == 1: rfid.enable_led(5) tag = rfid.erase_card(uids[0]) rfid.disable_led(5) else: logger.error('Found %d tags, not 1' % (len(uids)))