Compare commits

..

1 Commits

Author SHA1 Message Date
8785c81248 Merge pull request 'Merging Beta into Main' (#1) from beta into main
Reviewed-on: #1
2025-11-19 11:22:42 +11:00
7 changed files with 6 additions and 368 deletions

74
.gitignore vendored
View File

@@ -1,74 +0,0 @@
### 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

View File

@@ -7,17 +7,4 @@
- Raspian/Debian
- Python 3
- Python 3 Requets
- 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.
- Python 3 RPi.GPIO

View File

@@ -1,39 +0,0 @@
const char Data_PressVirtKey1OnBench_P[] PROGMEM = "<?xml version=\"1.0\"?>\
<methodCall>\
<methodName>PressKeyEx</methodName>\
<params>\
<param><value><string>C0000000001</string></value></param>\
<param><value><i4>64</i4></value></param>\
<param><value><i4>46</i4></value></param>\
<param><value><boolean>0</boolean></value></param>\
<param><value><int>2</int></value></param>\
<param><value><int>0</int></value></param>\
<param><value><int>1</int></value></param>\
<param><value><boolean>1</boolean></value></param>\
<param><value><boolean>1</boolean></value></param>\
<param><value><int>1</int></value></param>\
</params>\
</methodCall>\
";
const char Data_ReleaseVirtKey1OnBench_P[] PROGMEM = "<?xml version=\"1.0\"?>\
<methodCall>\
<methodName>PressKeyEx</methodName>\
<params>\
<param><value><string>C0000000002</string></value></param>\
<param><value><i4>64</i4></value></param>\
<param><value><i4>46</i4></value></param>\
<param><value><boolean>0</boolean></value></param>\
<param><value><int>2</int></value></param>\
<param><value><int>0</int></value></param>\
<param><value><int>1</int></value></param>\
<param><value><boolean>1</boolean></value></param>\
<param><value><boolean>0</boolean></value></param>\
<param><value><int>1</int></value></param>\
</params>\
</methodCall>\
";
__FlashStringHelper* Data_PressVirtKey1OnBench = (__FlashStringHelper*)Data_PressVirtKey1OnBench_P;
__FlashStringHelper* Data_ReleaseVirtKey1OnBench = (__FlashStringHelper*)Data_ReleaseVirtKey1OnBench_P;

View File

@@ -1,210 +0,0 @@
/*
DHCP-based IP printer
This sketch uses the DHCP extensions to the Ethernet library
to get an IP address via DHCP and print the address obtained.
using an Arduino WIZnet Ethernet shield.
Circuit:
Ethernet shield attached to pins 10, 11, 12, 13
created 12 April 2011
modified 9 Apr 2012
by Tom Igoe
modified 02 Sept 2015
by Arturo Guadalupi
*/
#include <SPI.h>
#include <Ethernet.h>
#include "RRCS.h"
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
constexpr int PIN_BTN_MUTE = A2;
constexpr int PIN_LED_RED = A0;
//const uint8_t RRCSServerIP[4] = {10,75,120,147}; // TRUNKNAV VM
//const uint8_t RRCSServerIP[4] = {192,168,192,247}; // Ben's laptop testing
const uint8_t RRCSServerIP[4] = {192,168,192,241}; // Ben's windows VM
const uint16_t RRCSServerPort = 8193;
const uint16_t BlinkMs = 1000;
EthernetClient client;
void ToggleVirtualKey() {
if (client.connect(RRCSServerIP, RRCSServerPort)) {
Serial.println("Connected.");
client.println("POST / HTTP/1.1");
client.print("Host: ");
client.print(RRCSServerIP[0]); client.print(".");
client.print(RRCSServerIP[1]); client.print(".");
client.print(RRCSServerIP[2]); client.print(".");
client.println(RRCSServerIP[3]);
client.println("Content-Type: text/xml"); // Or other content type like application/json
client.println("User-Agent: Ben's Silly Box");
client.println("Connection: close");
client.print("Content-Length: ");
client.println(strlen(Data_PressVirtKey1OnBench_P));
client.println();
client.println(Data_PressVirtKey1OnBench);
client.println(); // End of request
while(client.available()) {
Serial.write((char)client.read());
}
delay(50);
client.stop();
Serial.println();
client.connect(RRCSServerIP, RRCSServerPort);
//delay(20);
client.println("POST / HTTP/1.1");
client.print("Host: ");
client.print(RRCSServerIP[0]); client.print(".");
client.print(RRCSServerIP[1]); client.print(".");
client.print(RRCSServerIP[2]); client.print(".");
client.println(RRCSServerIP[3]);
client.println("Content-Type: text/xml"); // Or other content type like application/json
client.println("User-Agent: Ben's Silly Box");
client.println("Connection: close");
client.print("Content-Length: ");
client.println(strlen(Data_ReleaseVirtKey1OnBench_P));
client.println();
client.println(Data_ReleaseVirtKey1OnBench);
client.println(); // End of request
while(client.available()) {
Serial.write((char)client.read());
}
client.stop();
Serial.println();
Serial.println("Sent.");
} else {
Serial.println("Couldn't reach RRCS Server!");
}
}
bool MuteState = false;
bool EthNoLink = true;
void setup() {
pinMode (PIN_BTN_MUTE, INPUT_PULLUP);
// Blink once on startup
pinMode(PIN_LED_RED, OUTPUT);
digitalWrite(PIN_LED_RED, HIGH);
delay(100);
digitalWrite(PIN_LED_RED, LOW);
// You can use Ethernet.init(pin) to configure the CS pin
Ethernet.init(10); // Most Arduino shields
//Ethernet.init(5); // MKR ETH Shield
//Ethernet.init(0); // Teensy 2.0
//Ethernet.init(20); // Teensy++ 2.0
//Ethernet.init(15); // ESP8266 with Adafruit FeatherWing Ethernet
//Ethernet.init(33); // ESP32 with Adafruit FeatherWing Ethernet
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// start the Ethernet connection:
Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
} else if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
Serial.println("Failed Eth setup. Retrying later.");
} else {
EthNoLink = false;
}
// print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
}
void loop() {
digitalWrite(PIN_LED_RED, MuteState && ((millis() / BlinkMs) % 2));
if (digitalRead(PIN_BTN_MUTE) == LOW) {
// Mute action.
MuteState = !MuteState;
Serial.println(MuteState ? "Muted." : "Unmuted.");
// Lazy debounce is best debounce
delay(50);
while (digitalRead(PIN_BTN_MUTE) == LOW) delay(100);
ToggleVirtualKey();
}
if (EthNoLink) {
Serial.println("Retrying Eth Setup...");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
} else if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
}
Serial.println("Failed Eth Setup.");
} else {
EthNoLink = false;
}
}
switch (Ethernet.maintain()) {
case 1:
//renewed fail
Serial.println("Error: renewed fail");
break;
case 2:
//renewed success
Serial.println("Renewed success");
//print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
digitalWrite(PIN_LED_RED, HIGH);
break;
case 3:
//rebind fail
Serial.println("Error: rebind fail");
break;
case 4:
//rebind success
Serial.println("Rebind success");
//print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
break;
default:
//nothing happened
break;
}
}

16
ras_pi_RRCS_BusyLight.py Executable file → Normal file
View File

@@ -4,15 +4,13 @@ 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"
PressVirtKey1OnBench = '''<?xml version="1.0"?>
BenBusyRRCSdataRising = '''<?xml version="1.0"?>
<methodCall>
<methodName>PressKeyEx</methodName>
<params>
@@ -30,7 +28,7 @@ PressVirtKey1OnBench = '''<?xml version="1.0"?>
</methodCall>
'''
ReleasePressVirtKey1OnBench = '''<?xml version="1.0"?>
BenBusyRRCSdataFalling = '''<?xml version="1.0"?>
<methodCall>
<methodName>PressKeyEx</methodName>
<params>
@@ -51,19 +49,15 @@ ReleasePressVirtKey1OnBench = '''<?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=PressVirtKey1OnBench)
r = requests.post('http://10.75.120.229:8193',headers={'content-type': 'text/xml'},data=BenBusyRRCSdataRising)
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=ReleasePressVirtKey1OnBench)
r = requests.post('http://10.75.120.229:8193',headers={'content-type': 'text/xml'},data=BenBusyRRCSdataFalling)
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)
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")
input("Press enter to quit\n\n")
GPIO.cleanup()

View File

@@ -1,2 +0,0 @@
#!/bin/bash
exec /usr/bin/python3 /usr/local/bin/ras_pi_RRCS_BusyLight.py

View File

@@ -1,18 +0,0 @@
[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