mirror of
https://github.com/brmlab/brmdoor_libnfc.git
synced 2025-06-08 08:34:00 +02:00
First broken daemon
This commit is contained in:
parent
fc74d89a19
commit
8869d25261
1 changed files with 6 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import Queue
|
import Queue
|
||||||
import logging
|
import logging
|
||||||
|
@ -17,7 +18,6 @@ class NfcThread(threading.Thread):
|
||||||
def __init__(self, uidQueue):
|
def __init__(self, uidQueue):
|
||||||
"""Create thread reading UIDs from PN53x reader.
|
"""Create thread reading UIDs from PN53x reader.
|
||||||
"""
|
"""
|
||||||
self.nfc = NFCDevice()
|
|
||||||
self.uidQueue = uidQueue
|
self.uidQueue = uidQueue
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
|
@ -26,8 +26,10 @@ class NfcThread(threading.Thread):
|
||||||
Waits for a card to get into reader field. Reads its UID and
|
Waits for a card to get into reader field. Reads its UID and
|
||||||
stores it into uidQueue for later authentication check.
|
stores it into uidQueue for later authentication check.
|
||||||
"""
|
"""
|
||||||
|
self.nfc = NFCDevice()
|
||||||
try:
|
try:
|
||||||
uid_hex = hexlify(self.nfc.scanUID())
|
uid_hex = hexlify(self.nfc.scanUID())
|
||||||
|
print uid_hex
|
||||||
logging.info("Got UID %s" % uid_hex)
|
logging.info("Got UID %s" % uid_hex)
|
||||||
self.uidQueue.put(uid_hex)
|
self.uidQueue.put(uid_hex)
|
||||||
except NFCError, e:
|
except NFCError, e:
|
||||||
|
@ -63,6 +65,9 @@ class UnlockThread(threading.Thread):
|
||||||
logging.info("Unlocking for %s", record)
|
logging.info("Unlocking for %s", record)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
|
||||||
|
format="%(asctime)s %(levelname)s %(message)s [%(pathname)s:%(lineno)d]")
|
||||||
|
|
||||||
uidQueue = Queue.Queue(512)
|
uidQueue = Queue.Queue(512)
|
||||||
#TODO use SafeConfigParser to get actual config data
|
#TODO use SafeConfigParser to get actual config data
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue