from gpiod.line import Direction, Value
import sys
+# set gpio lines
def set_line_values(chip_path, line_values):
value_str = {Value.ACTIVE: "Active", Value.INACTIVE: "Inactive"}
},
)
request.set_values(line_values)
+
+# put hardware back in a safe configuration if application killed
+def handler(signum, frame):
+ set_line_values(
+ "/dev/gpiochip0",
+ { 4: Value.INACTIVE, # indicate 'not ready' to LPC
+ 16: Value.INACTIVE, # pyro off
+ 17: Value.INACTIVE, # alarm b off
+ 20: Value.INACTIVE, # turn continuity LED off
+ 21: Value.INACTIVE, # turn armed LED off
+ 27: Value.INACTIVE # alarm a off
+ }
+ )
+ sys.exit(0)
+
+# having systemd use SIGINT to avoid CherryPy consuming the kill signal
+signal.signal(signal.SIGINT, handler)
path = os.path.abspath(os.path.dirname(__file__))
config = {