]> git.gag.com Git - fw/quantimotor/commitdiff
handle possibility that gpio interface is busy during pyro sensing function
authorBdale Garbee <bdale@gag.com>
Mon, 26 May 2025 22:00:25 +0000 (16:00 -0600)
committerBdale Garbee <bdale@gag.com>
Mon, 26 May 2025 22:00:25 +0000 (16:00 -0600)
ui/app.py

index 08bbccd19ecee0e975e662db01536541e61fac67..74bdefd1075ad4061a3b1b430ac763b476b1b084 100755 (executable)
--- 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