mirror of
https://github.com/brmlab/brmdoor_libnfc.git
synced 2025-06-08 00:24:00 +02:00
Warning about open-switch thread not working properly
This commit is contained in:
parent
ef1d8b8080
commit
8a35b8b884
2 changed files with 10 additions and 7 deletions
|
@ -46,9 +46,10 @@ reconnect_delay = 300
|
||||||
# Controls showing status of "OPEN/CLOSE" switch that is connected to some GPIO pin
|
# Controls showing status of "OPEN/CLOSE" switch that is connected to some GPIO pin
|
||||||
# Changes topic of connected IRC channels if IRC is enabled
|
# Changes topic of connected IRC channels if IRC is enabled
|
||||||
# There is no point in enabling this if you disabled IRC
|
# There is no point in enabling this if you disabled IRC
|
||||||
|
# Not yet usable - do not use because of GIL and python-irc not retrieving topic from channel
|
||||||
# enabled - True/False
|
# enabled - True/False
|
||||||
# status_file - file in sysfs that contains 1 or 0 defining the state of button
|
# status_file - file in sysfs that contains 1 or 0 defining the state of button
|
||||||
# open_value - which value in status_file respresents the switch being in "OPEN" position, 1 character
|
# open_value - which value in status_file respresents the switch being in "OPEN" position, 1 character
|
||||||
enabled = True
|
enabled = False
|
||||||
status_file = /sys/class/gpio/gpio11/value
|
status_file = /sys/class/gpio/gpio11/value
|
||||||
open_value = 1
|
open_value = 1
|
||||||
|
|
|
@ -120,7 +120,8 @@ class NFCScanner(object):
|
||||||
self.actOnUid(uid_hex)
|
self.actOnUid(uid_hex)
|
||||||
else:
|
else:
|
||||||
#prevent busy loop if reader goes awry
|
#prevent busy loop if reader goes awry
|
||||||
time.sleep(0.3)
|
e = threading.Event()
|
||||||
|
e.wait(timeout=0.3)
|
||||||
except NFCError, e:
|
except NFCError, e:
|
||||||
#this exception happens also when scanUID times out
|
#this exception happens also when scanUID times out
|
||||||
logging.debug("Failed to wait for RFID card: %s", e)
|
logging.debug("Failed to wait for RFID card: %s", e)
|
||||||
|
@ -177,8 +178,9 @@ class NFCScanner(object):
|
||||||
|
|
||||||
logging.info("Unknown UID %s", uid_hex)
|
logging.info("Unknown UID %s", uid_hex)
|
||||||
self.sendIrcMessage("Denied unauthorized card")
|
self.sendIrcMessage("Denied unauthorized card")
|
||||||
time.sleep(self.unknownUidTimeoutSecs)
|
e = threading.Event()
|
||||||
|
e.wait(timeout=self.unknownUidTimeoutSecs)
|
||||||
|
|
||||||
class IrcThread(threading.Thread):
|
class IrcThread(threading.Thread):
|
||||||
"""
|
"""
|
||||||
Class for showing messages about lock events and denied/accepted cards
|
Class for showing messages about lock events and denied/accepted cards
|
||||||
|
@ -318,6 +320,7 @@ class OpenSwitchThread(threading.Thread):
|
||||||
|
|
||||||
if self.ircThread.connected:
|
if self.ircThread.connected:
|
||||||
for channel in self.ircThread.channels:
|
for channel in self.ircThread.channels:
|
||||||
|
#TODO: this always returns None, don't know why
|
||||||
topic = self.ircThread.getTopic(channel)
|
topic = self.ircThread.getTopic(channel)
|
||||||
if not topic or not re.match(r"^\s*(OPEN|CLOSED) \|", topic):
|
if not topic or not re.match(r"^\s*(OPEN|CLOSED) \|", topic):
|
||||||
newTopic = strStatus
|
newTopic = strStatus
|
||||||
|
@ -329,9 +332,8 @@ class OpenSwitchThread(threading.Thread):
|
||||||
pass #silently ignore non-existent file and other errors, otherwise it'd spam log
|
pass #silently ignore non-existent file and other errors, otherwise it'd spam log
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception("Exception in open switch thread")
|
logging.exception("Exception in open switch thread")
|
||||||
logging.info("Before sleep")
|
e = threading.Event()
|
||||||
time.sleep(1)
|
e.wait(timeout=1)
|
||||||
logging.info("After sleep")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue