Merge pull request 'beta -> main' (#3) from beta into main
Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
74
.gitignore
vendored
Normal file
74
.gitignore
vendored
Normal file
@@ -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
|
||||||
|
|
||||||
15
README.md
15
README.md
@@ -7,4 +7,17 @@
|
|||||||
- Raspian/Debian
|
- Raspian/Debian
|
||||||
- Python 3
|
- Python 3
|
||||||
- Python 3 Requets
|
- Python 3 Requets
|
||||||
- Python 3 RPi.GPIO
|
- 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.
|
||||||
|
|
||||||
|
## Logging
|
||||||
|
- All logs are printed to journalctl, this includes when the button is pressed.
|
||||||
16
ras_pi_RRCS_BusyLight.py
Normal file → Executable file
16
ras_pi_RRCS_BusyLight.py
Normal file → Executable file
@@ -4,13 +4,15 @@ os.environ['RPI_LGPIO_REVISION'] = "800012"
|
|||||||
import time
|
import time
|
||||||
import requests
|
import requests
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
|
import socket
|
||||||
|
|
||||||
|
|
||||||
RED = "\033[91m"
|
RED = "\033[91m"
|
||||||
GREEN = "\033[92m"
|
GREEN = "\033[92m"
|
||||||
RESET = "\033[0m"
|
RESET = "\033[0m"
|
||||||
|
|
||||||
|
|
||||||
BenBusyRRCSdataRising = '''<?xml version="1.0"?>
|
PressVirtKey1OnBench = '''<?xml version="1.0"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>PressKeyEx</methodName>
|
<methodName>PressKeyEx</methodName>
|
||||||
<params>
|
<params>
|
||||||
@@ -28,7 +30,7 @@ BenBusyRRCSdataRising = '''<?xml version="1.0"?>
|
|||||||
</methodCall>
|
</methodCall>
|
||||||
'''
|
'''
|
||||||
|
|
||||||
BenBusyRRCSdataFalling = '''<?xml version="1.0"?>
|
ReleasePressVirtKey1OnBench = '''<?xml version="1.0"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>PressKeyEx</methodName>
|
<methodName>PressKeyEx</methodName>
|
||||||
<params>
|
<params>
|
||||||
@@ -49,15 +51,19 @@ BenBusyRRCSdataFalling = '''<?xml version="1.0"?>
|
|||||||
def button_callback(channel):
|
def button_callback(channel):
|
||||||
if GPIO.input(channel):
|
if GPIO.input(channel):
|
||||||
print(f"{RED}Button pressed{RESET}")
|
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)
|
time.sleep(0.05)
|
||||||
print(f"{GREEN}Button released{RESET}")
|
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.setwarnings(False)
|
||||||
GPIO.setmode(GPIO.BOARD)
|
GPIO.setmode(GPIO.BOARD)
|
||||||
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||||
|
|
||||||
GPIO.add_event_detect(12, GPIO.RISING, callback=button_callback, bouncetime=200)
|
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()
|
GPIO.cleanup()
|
||||||
2
rrcs-trigger
Executable file
2
rrcs-trigger
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
exec /usr/bin/python3 /usr/local/bin/ras_pi_RRCS_BusyLight.py
|
||||||
18
rrcs-trigger.service
Executable file
18
rrcs-trigger.service
Executable file
@@ -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
|
||||||
Reference in New Issue
Block a user