From f2b8e15b0a2860c83a369097f483aafe599aa6e6 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Wed, 7 May 2025 15:28:15 -0600 Subject: [PATCH] successfully sensing armed input bit and including in status display --- application/app.py | 21 ++++++++++++++++++--- application/index.html | 3 +++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/application/app.py b/application/app.py index 3676fb2..1a2b6af 100755 --- a/application/app.py +++ b/application/app.py @@ -14,7 +14,7 @@ import sys n=0 -# set gpio lines +# set gpio output lines def set_line_values(chip_path, line_values): value_str = {Value.ACTIVE: "Active", Value.INACTIVE: "Inactive"} @@ -43,7 +43,19 @@ def handler(signum, frame): # having systemd use SIGINT to avoid CherryPy consuming the kill signal signal.signal(signal.SIGINT, handler) - + +def sense_armed(): + with gpiod.request_lines( + "/dev/gpiochip0", + consumer="get-line-value", + config={12: gpiod.LineSettings(direction=Direction.INPUT)}, + ) as request: + value = request.get_value(12) + if value == Value.ACTIVE: + return 'armed' + else: + return 'safe' + path = os.path.abspath(os.path.dirname(__file__)) config = { 'global' : { @@ -75,11 +87,14 @@ class App: t = str(n) + b pyro_v = str(n) + ' volts' batt_v = str(n) + ' volts' + armed = sense_armed() + return { 'pressure' : p, 'thrust' : t, 'pyro' : pyro_v, - 'battery' : batt_v + 'battery' : batt_v, + 'armed' : armed } diff --git a/application/index.html b/application/index.html index 3baaa97..2fdf1b6 100644 --- a/application/index.html +++ b/application/index.html @@ -16,6 +16,7 @@ $('#thrust').text(response.thrust); $('#pyro').text(response.pyro); $('#battery').text(response.battery); + $('#armed').text(response.armed); }); request.fail(function(jqXHR, textStatus) { @@ -36,5 +37,7 @@

Battery

+

Armed

+
-- 2.47.2