From 54103e7b6646f4799c4ebeaf3fdb079432951e9b Mon Sep 17 00:00:00 2001 From: david rice Date: Tue, 21 Apr 2026 15:38:17 +0100 Subject: [PATCH] Updates --- __pycache__/csv_preprocessor.cpython-312.pyc | Bin 46638 -> 46722 bytes device_server.py | 22 ++++++++++++------- display_test_nexio.py | 4 ++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/__pycache__/csv_preprocessor.cpython-312.pyc b/__pycache__/csv_preprocessor.cpython-312.pyc index ee65eacad12001f50713dc99f503de9d745537d7..7d7e5782314c658a707c0d922029810e6b192fa5 100644 GIT binary patch delta 285 zcmZ4YhNb8_!0X&^W;X}pOe}CaWgQq8%^#{-n@DLlnPGqNJfSl(Gok5 zA`r-CVqmCXEb^P|H!t2+4k#y(!dVIwDV6}T^?tzP1e`6p({$-e9S-1vCaKkzUJ$Sz>Hz_0R&7sM3+ zaz6=zSP~3^atlH(2xxv{U=mcjA)+ vSU&mTdQo;`p_9zK;g*~Kt`}q#%VB0@o1yZ70Yopb{tTu+#BEmD%Ebr(p&?O- delta 217 zcmZpA%e3wd6YptWUM>b8C~_O&`D list: @app.route("/display", methods=["PUT"]) def control_display(): - data = request.get_json() + data = request.get_json(force=True) or {} state = data.get("state", "").lower() - if state == "off": - os.system("echo 4 > /sys/class/graphics/fb0/blank") - return jsonify({"status": "Display OFF"}), 200 - elif state == "on": + if state == "on": + with _video_lock: + if _video_proc is not None and _video_proc.poll() is None: + _video_proc.send_signal(signal.SIGUSR1) + return jsonify({"status": "video switched"}), 200 + # fallback when video is not running os.system("echo 0 > /sys/class/graphics/fb0/blank") return jsonify({"status": "Display ON"}), 200 + elif state == "off": + # nothing to do while video is managing the display + return jsonify({"status": "ok"}), 200 else: return jsonify({"error": "Invalid state. Use 'on' or 'off'"}), 400 @@ -205,8 +211,8 @@ def control_video(): return jsonify({"status": "already_running", "pid": _video_proc.pid}), 200 _video_proc = subprocess.Popen( ["python3", KIOSK_SCRIPT], - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, + stdout=open("/tmp/kiosk.log", "w"), + stderr=subprocess.STDOUT, ) return jsonify({"status": "started", "pid": _video_proc.pid}), 200 diff --git a/display_test_nexio.py b/display_test_nexio.py index 618efcb..54b5ae0 100644 --- a/display_test_nexio.py +++ b/display_test_nexio.py @@ -1,4 +1,5 @@ import gi +import signal import struct import os @@ -129,6 +130,9 @@ def play_kiosk(): manager = KioskManager(pipeline) pipeline.set_property("uri", manager.videos[0]) + # SIGUSR1 → switch video (used by device_server PUT /display {"state":"on"}) + signal.signal(signal.SIGUSR1, lambda sig, frame: manager.switch_video()) + # --- INPUT MONITORING --- try: btn_fd = open("/dev/input/event1", "rb")