mirror of
https://github.com/brmlab/brmdoor_libnfc.git
synced 2025-06-09 08:54:00 +02:00
Make sure lock pin is pulled down when exiting on interrupt
This commit is contained in:
parent
e181278df5
commit
19721744a0
2 changed files with 16 additions and 0 deletions
|
@ -99,6 +99,7 @@ class NFCScanner(object):
|
||||||
logging.info("Exiting on keyboard interrupt")
|
logging.info("Exiting on keyboard interrupt")
|
||||||
self.nfc.close()
|
self.nfc.close()
|
||||||
self.nfc.unload()
|
self.nfc.unload()
|
||||||
|
self.unlocker.lock()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception("Exception in main unlock thread")
|
logging.exception("Exception in main unlock thread")
|
||||||
|
|
15
unlocker.py
15
unlocker.py
|
@ -22,6 +22,13 @@ class Unlocker(object):
|
||||||
"""
|
"""
|
||||||
time.sleep(self.lockOpenedSecs)
|
time.sleep(self.lockOpenedSecs)
|
||||||
|
|
||||||
|
def lock(self):
|
||||||
|
"""
|
||||||
|
Lock the lock back. Meant to be used when program is shut down
|
||||||
|
so that lock is not left disengaged.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class UnlockerWiringPi(Unlocker):
|
class UnlockerWiringPi(Unlocker):
|
||||||
"""Uses configured pings via WiringPi to open lock.
|
"""Uses configured pings via WiringPi to open lock.
|
||||||
|
@ -39,3 +46,11 @@ class UnlockerWiringPi(Unlocker):
|
||||||
wiringpi.digitalWrite(self.lockPin, 1)
|
wiringpi.digitalWrite(self.lockPin, 1)
|
||||||
time.sleep(self.lockOpenedSecs)
|
time.sleep(self.lockOpenedSecs)
|
||||||
wiringpi.digitalWrite(self.lockPin, 0)
|
wiringpi.digitalWrite(self.lockPin, 0)
|
||||||
|
|
||||||
|
def lock(self):
|
||||||
|
"""
|
||||||
|
Lock the lock back. Meant to be used when program is shut down
|
||||||
|
so that lock is not left disengaged.
|
||||||
|
"""
|
||||||
|
wiringpi.digitalWrite(self.lockPin, 0)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue