From: Bdale Garbee Date: Mon, 26 May 2025 22:00:25 +0000 (-0600) Subject: handle possibility that gpio interface is busy during pyro sensing function X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=b671667e6dcf4e28903a4557c854665f23a92abc;p=fw%2Fquantimotor handle possibility that gpio interface is busy during pyro sensing function --- diff --git a/ui/app.py b/ui/app.py index 08bbccd..74bdefd 100755 --- a/ui/app.py +++ b/ui/app.py @@ -24,10 +24,14 @@ pressure = 0 thrust = 0 pyro = 0 battery = 0 +lastsense = "safe" # global to keep track of whether user wants system armed armreq = "disarm" +# global to keep track of whether we're actively running a test +status = "idle" + ctx = iio.LocalContext() ctrl = ctx.find_device('ads8688') # configuration for each channel on ADS8688 @@ -66,6 +70,7 @@ def handler(signum, frame): signal.signal(signal.SIGINT, handler) def sense_armed(): + try: with gpiod.request_lines( "/dev/gpiochip0", consumer="get-line-value", @@ -74,11 +79,13 @@ def sense_armed(): value = request.get_value(12) if value == Value.ACTIVE: if armreq == "arm": - return 'armed' + lastsense = 'armed' else: - return 'remote' + lastsense = 'remote' else: - return 'safe' + lastsense = 'safe' + finally: + return lastsense # LED (and alarms) management function we'll arrange to run periodically def manageLEDs(): @@ -172,6 +179,8 @@ class App: # copy metadata into test directory metadata_path = DATAPATH + "metadata.json" shutil.copy(metadata_path, test_path) + status = "testing" + cherrypy.log("status " + status) return "Test " + test_path + " started" else: return "Method not allowed", 405