Now works in a service on boot.

This commit is contained in:
Ben Nicholson
2025-11-19 21:41:22 +11:00
parent 1d7e56f837
commit 9cbbfc12bc
4 changed files with 43 additions and 7 deletions

18
ras_pi_RRCS_BusyLight.py Normal file → Executable file
View File

@@ -4,15 +4,17 @@ os.environ['RPI_LGPIO_REVISION'] = "800012"
import time
import requests
import RPi.GPIO as GPIO
import socket
RED = "\033[91m"
GREEN = "\033[92m"
RESET = "\033[0m"
BenBusyRRCSdataRising = '''<?xml version="1.0"?>
PressVirtKey1OnBench = '''<?xml version="1.0"?>
<methodCall>
<methodName>PressKeyEx</methodName>
<methodName>PressKeyEx</metßhodName>
<params>
<param><value><string>C0000000001</string></value></param>
<param><value><i4>64</i4></value></param>
@@ -28,7 +30,7 @@ BenBusyRRCSdataRising = '''<?xml version="1.0"?>
</methodCall>
'''
BenBusyRRCSdataFalling = '''<?xml version="1.0"?>
ReleasePressVirtKey1OnBench = '''<?xml version="1.0"?>
<methodCall>
<methodName>PressKeyEx</methodName>
<params>
@@ -49,15 +51,19 @@ BenBusyRRCSdataFalling = '''<?xml version="1.0"?>
def button_callback(channel):
if GPIO.input(channel):
print(f"{RED}Button pressed{RESET}")
r = requests.post('http://10.75.120.229:8193',headers={'content-type': 'text/xml'},data=BenBusyRRCSdataRising)
r = requests.post('http://10.75.120.229:8193',headers={'content-type': 'text/xml'},data=PressVirtKey1OnBench)
time.sleep(0.05)
print(f"{GREEN}Button released{RESET}")
r = requests.post('http://10.75.120.229:8193',headers={'content-type': 'text/xml'},data=BenBusyRRCSdataFalling)
r = requests.post('http://10.75.120.229:8193',headers={'content-type': 'text/xml'},data=ReleasePressVirtKey1OnBench)
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(12, GPIO.RISING, callback=button_callback, bouncetime=200)
input("Press enter to quit\n\n")
print("RRCS-Trigger ready for input")
[sockA, sockB] = socket.socketpair()
junk = sockA.recv(1) # will never return since sockA will never receive any data
print("This should never get printed")
GPIO.cleanup()