Exemple #1
0
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 reader example')
parser.add_argument('--config', nargs='?', default='config.yml',
                    help='Config file')
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)
Exemple #2
0

logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.addHandler(ch)

parser = argparse.ArgumentParser(description='PyRfidGeek writer example')
parser.add_argument('--config', nargs='?', default='config.yml',
                    help='Config file')
args = parser.parse_args()
config = yaml.load(open(args.config, 'r'))

try:
    reader = PyRFIDGeek(config)
except serial.serialutil.SerialException:
    print "Failed to open serialport " + config['serial']['port']
    sys.exit(1)


try:

    uids = []
    while len(uids) == 0:
        uids = list(reader.inventory())
        print
        if len(uids) == 0:
            print
            print 'Klar for ny bok!'
            print
Exemple #3
0
                    prev_uids[1] = copy(prev_uids[0])
                    prev_uids[0] = copy(uids)
                self.scanning = False
                time.sleep(0.5)

        finally:
            print "Thread is exiting..."
            # rfid.close()

        time.sleep(1)
        # ws.close()

        print "Thread is terminating..."


rfid = PyRFIDGeek(config)


class WsSock(object):
    def __init__(self):
        self.mailbox = Queue.Queue()
        self.connect()

    def connect(self):
        logger.info('Trying to connect to linode2.biblionaut.net:8080')
        self.ws = websocket.WebSocketApp('ws://linode2.biblionaut.net:8080',
                                         on_open=self.on_open,
                                         on_message=self.on_message,
                                         on_error=self.on_error,
                                         on_close=self.on_close)
        self.ws.run_forever()
Exemple #4
0
                    prev_uids[1] = copy(prev_uids[0])
                    prev_uids[0] = copy(uids)
                self.scanning = False
                time.sleep(0.5)

        finally:
            print "Thread is exiting..."
            #rfid.close()

        time.sleep(1)
        #ws.close()

        print "Thread is terminating..."


rfid = PyRFIDGeek(config)

class WsSock(object):

    def __init__(self):
        self.mailbox = Queue.Queue()
        self.connect()

    def connect(self):
        logger.info('Trying to connect to linode2.biblionaut.net:8080')
        self.ws = websocket.WebSocketApp('ws://linode2.biblionaut.net:8080',
                                 on_open = self.on_open,
                                 on_message = self.on_message,
                                 on_error = self.on_error,
                                 on_close = self.on_close)
        self.ws.run_forever()
Exemple #5
0
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)))