From 9cbbfc12bc0c067a7c4b12c6ac9d7afa714be8d2 Mon Sep 17 00:00:00 2001 From: Ben Nicholson Date: Wed, 19 Nov 2025 21:41:22 +1100 Subject: [PATCH 1/5] Now works in a service on boot. --- README.md | 12 +++++++++++- ras_pi_RRCS_BusyLight.py | 18 ++++++++++++------ rrcs-trigger | 2 ++ rrcs-trigger.service | 18 ++++++++++++++++++ 4 files changed, 43 insertions(+), 7 deletions(-) mode change 100644 => 100755 ras_pi_RRCS_BusyLight.py create mode 100755 rrcs-trigger create mode 100755 rrcs-trigger.service diff --git a/README.md b/README.md index c4c0488..53d37cc 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,14 @@ - Raspian/Debian - Python 3 - Python 3 Requets - - Python 3 RPi.GPIO \ No newline at end of file + - Python 3 RPi.GPIO + +## Install instructions + + - Downloand script into /usr/local/bin/ + - Download rrcs-trigger file and place into /usr/local/bin/ + - Download rrcs-trigger.service and place it into /etc/systemd/system/ + - Run the follwoing commands to enable the service on boot. ```sudo systemctl enable rrcs-trigger.service``` and ```sudo systemctl start rrcs-trigger.service``` + - RUn the following command to see how its booting up. ```watch systemctl status rrcs-triggers.service``` + +- Modify the script to have your RRCS Server IP address and port. \ No newline at end of file diff --git a/ras_pi_RRCS_BusyLight.py b/ras_pi_RRCS_BusyLight.py old mode 100644 new mode 100755 index 0617111..64b4615 --- a/ras_pi_RRCS_BusyLight.py +++ b/ras_pi_RRCS_BusyLight.py @@ -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 = ''' +PressVirtKey1OnBench = ''' - PressKeyEx + PressKeyEx C0000000001 64 @@ -28,7 +30,7 @@ BenBusyRRCSdataRising = ''' ''' -BenBusyRRCSdataFalling = ''' +ReleasePressVirtKey1OnBench = ''' PressKeyEx @@ -49,15 +51,19 @@ BenBusyRRCSdataFalling = ''' 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() \ No newline at end of file diff --git a/rrcs-trigger b/rrcs-trigger new file mode 100755 index 0000000..edffc4c --- /dev/null +++ b/rrcs-trigger @@ -0,0 +1,2 @@ +#!/bin/bash +exec /usr/bin/python3 /usr/local/bin/ras_pi_RRCS_BusyLight.py \ No newline at end of file diff --git a/rrcs-trigger.service b/rrcs-trigger.service new file mode 100755 index 0000000..9af86a0 --- /dev/null +++ b/rrcs-trigger.service @@ -0,0 +1,18 @@ +[Unit] +Description=Runs the ras_pi_RRCS_BusyLight.py script at boot +After=network.target +#StartLimitIntervalSec=5 + +[Service] +Type=simple +Restart=always +RestartSec=5 +User=root +ExecStart=/usr/local/bin/rrcs-trigger /usr/local/bin/ras_pi_RRCS_BusyLight.py +WorkingDirectory=/tmp +StandardOutput=journal +StandardError=journal +Environment=PYTHONUNBUFFERED=1 + +[Install] +WantedBy=multi-user.target \ No newline at end of file -- 2.49.1 From 0654c19faced31118f9bc88b5cd38dde52511c23 Mon Sep 17 00:00:00 2001 From: Ben Nicholson Date: Wed, 19 Nov 2025 21:42:51 +1100 Subject: [PATCH 2/5] Fixed spelling mistake --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 53d37cc..427858b 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,6 @@ - Download rrcs-trigger file and place into /usr/local/bin/ - Download rrcs-trigger.service and place it into /etc/systemd/system/ - Run the follwoing commands to enable the service on boot. ```sudo systemctl enable rrcs-trigger.service``` and ```sudo systemctl start rrcs-trigger.service``` - - RUn the following command to see how its booting up. ```watch systemctl status rrcs-triggers.service``` + - Run the following command to see how its booting up. ```watch systemctl status rrcs-triggers.service``` - Modify the script to have your RRCS Server IP address and port. \ No newline at end of file -- 2.49.1 From b3ade2db864ad4bd4a12ad7694af434d13cde321 Mon Sep 17 00:00:00 2001 From: Ben Nicholson Date: Wed, 19 Nov 2025 21:44:47 +1100 Subject: [PATCH 3/5] Added logging info --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 427858b..e02868e 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,7 @@ - Run the follwoing commands to enable the service on boot. ```sudo systemctl enable rrcs-trigger.service``` and ```sudo systemctl start rrcs-trigger.service``` - Run the following command to see how its booting up. ```watch systemctl status rrcs-triggers.service``` -- Modify the script to have your RRCS Server IP address and port. \ No newline at end of file +- Modify the script to have your RRCS Server IP address and port. + +## Logging + - All logs are printed to journalctl, this includes when the button is pressed. \ No newline at end of file -- 2.49.1 From 1f932b223bf6863d2081fa257ebd1df5a9719ecd Mon Sep 17 00:00:00 2001 From: Ben Nicholson Date: Wed, 19 Nov 2025 21:47:35 +1100 Subject: [PATCH 4/5] added gitignore --- .gitignore | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fb5c92a --- /dev/null +++ b/.gitignore @@ -0,0 +1,74 @@ +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + -- 2.49.1 From 347bc54818c8f12d35c307b407286bdab091ded0 Mon Sep 17 00:00:00 2001 From: Ben Nicholson Date: Fri, 21 Nov 2025 12:20:03 +1100 Subject: [PATCH 5/5] =?UTF-8?q?Renoved=20the=20=C3=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ras_pi_RRCS_BusyLight.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ras_pi_RRCS_BusyLight.py b/ras_pi_RRCS_BusyLight.py index 64b4615..6e0500f 100755 --- a/ras_pi_RRCS_BusyLight.py +++ b/ras_pi_RRCS_BusyLight.py @@ -14,7 +14,7 @@ RESET = "\033[0m" PressVirtKey1OnBench = ''' - PressKeyEx + PressKeyEx C0000000001 64 -- 2.49.1