#!/usr/bin/python3
-import time, socket
+import time, socket, atexit
import RPi.GPIO as GPIO
tuerSock = "/run/tuer.sock"
GPIO.setmode(GPIO.BOARD)
GPIO.setup(ringPin, GPIO.IN)
+atexit.register(GPIO.cleanup);
lastEvent = 0
if data != b'1':
print("Received unexpected answer %s" % str(data))
-GPIO.cleanup()
+
#!/usr/bin/python3
-import time, socket, os, stat
+import time, socket, os, stat, atexit
from datetime import datetime
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
# ******** main *********
+# at the end do a cleanup
+atexit.register(GPIO.cleanup);
+
# convert list of pin objects to dictionary for command lookup
pindict = {}
for pin in pinlist:
# close connection cleanly
conn.close()
-# FIXME will this be executed after receiving a terminating signal?
-GPIO.cleanup()
-