54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Check IR listener status on remote system
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
def check_ir_status():
|
|
"""Check if IR listener is running"""
|
|
try:
|
|
# Check if process is running
|
|
result = subprocess.run([
|
|
"ssh", "tulivision@192.168.1.137",
|
|
"ps aux | grep simple_ir_listener_polling | grep -v grep"
|
|
], capture_output=True, text=True)
|
|
|
|
if result.returncode == 0 and result.stdout.strip():
|
|
print("✅ IR Listener is RUNNING")
|
|
print("Process details:")
|
|
print(result.stdout.strip())
|
|
|
|
# Check GPIO status
|
|
gpio_result = subprocess.run([
|
|
"ssh", "tulivision@192.168.1.137",
|
|
"python3 -c 'import RPi.GPIO as GPIO; GPIO.setmode(GPIO.BCM); print(f\"GPIO 18 state: {GPIO.input(18)}\")'"
|
|
], capture_output=True, text=True)
|
|
|
|
if gpio_result.returncode == 0:
|
|
print(f"GPIO Status: {gpio_result.stdout.strip()}")
|
|
|
|
else:
|
|
print("❌ IR Listener is NOT running")
|
|
|
|
# Try to start it
|
|
print("Attempting to start IR listener...")
|
|
start_result = subprocess.run([
|
|
"ssh", "tulivision@192.168.1.137",
|
|
"cd /home/tulivision/rpi-tulivision && nohup python3 simple_ir_listener_polling.py > ir_listener.log 2>&1 &"
|
|
], capture_output=True, text=True)
|
|
|
|
if start_result.returncode == 0:
|
|
print("✅ IR Listener started successfully")
|
|
else:
|
|
print("❌ Failed to start IR listener")
|
|
print(start_result.stderr)
|
|
|
|
except Exception as e:
|
|
print(f"Error checking status: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
check_ir_status()
|
|
|