mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
fix(safety,openxr,dvr,config): harden RC/firmware failsafes, OpenXR lifecycle, DVR StreamCopy, relay & persistent config
This commit is contained in:
1 parent
8028680f07
commit
d82a65d9e6
24 files changed
+2246
-638
No files matched your search
@@ -1,8 +1,9 @@
|
||||
# Règle Udev pour le récepteur Eachine Sphere Link (Radxa Zero 3W / Rockchip RV1106 / RNDIS)
|
||||
# Déclenche l'attribution de l'IP 192.168.1.10/24 dès que le câble USB-C est branché sur le Steam Frame ou PC
|
||||
ACTION=="add", SUBSYSTEM=="net", KERNEL=="usb*|enx*", ATTRS{idVendor}=="1d6b|2207|0525", RUN+="/usr/bin/ip addr add 192.168.1.10/24 dev %k", RUN+="/usr/bin/ip link set dev %k up"
|
||||
# Règle Udev pour le récepteur Eachine Sphere Link (Radxa Zero 3W / Rockchip RV1106 / Linux Gadget RNDIS)
|
||||
# IMPORTANT : ne JAMAIS inclure 1d6b (Linux Foundation USB Root Hub) dans ATTRS{idVendor},
|
||||
# sinon TOUS les adaptateurs Ethernet USB Linux seraient détournés vers 192.168.1.10/24.
|
||||
# On marque aussi NM_UNMANAGED=1 pour éviter que NetworkManager n'écrase l'IP statique par DHCP.
|
||||
ACTION=="add", SUBSYSTEM=="net", KERNEL=="usb*|enx*", ATTRS{idVendor}=="2207|0525", ENV{NM_UNMANAGED}="1", RUN+="/bin/sh -c 'ip addr replace 192.168.1.10/24 dev %k && ip link set dev %k up'"
|
||||
|
||||
# Accès HIDRAW non-root (uaccess) pour le Steam Controller (Ibex 28de:1302..1305) en Mode Gaming SteamOS
|
||||
# Permet la lecture directe des rapports 0x42 et les retours haptiques 0x80 sans sudo ni conflit Lizard Mode
|
||||
KERNEL=="hidraw*", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="1302|1303|1304|1305", MODE="0660", TAG+="uaccess"
|
||||
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="1302|1303|1304|1305", MODE="0660", TAG+="uaccess"
|
||||
@@ -28,12 +28,13 @@ if [ "$ARCH" = "aarch64" ]; then
|
||||
echo "[3/3] Installation locale des lanceurs .desktop (Bureau GPUI + Mode VR Gaming)..."
|
||||
mkdir -p ~/.local/share/applications
|
||||
chmod +x "$DIR/launch.sh" "$DIR/launch_vr.sh"
|
||||
ESCAPED_DIR=$(printf '%s\n' "$DIR" | sed -e 's/[&|\\]/\\&/g')
|
||||
for desktop_file in steamframe-fpv.desktop steamframe-fpv-vr.desktop; do
|
||||
cp "$desktop_file" ~/.local/share/applications/
|
||||
sed -i -E \
|
||||
-e "s|^Exec=.*/(launch(_vr)?\.sh)|Exec=$DIR/\1|g" \
|
||||
-e "s|^Path=.*|Path=$DIR|g" \
|
||||
-e "s|^Icon=.*/assets/|Icon=$DIR/assets/|g" \
|
||||
-e "s|^Exec=.*/(launch(_vr)?\.sh)|Exec=${ESCAPED_DIR}/\1|g" \
|
||||
-e "s|^Path=.*|Path=${ESCAPED_DIR}|g" \
|
||||
-e "s|^Icon=.*/assets/|Icon=${ESCAPED_DIR}/assets/|g" \
|
||||
"$HOME/.local/share/applications/$desktop_file"
|
||||
done
|
||||
|
||||
@@ -41,13 +42,17 @@ if [ "$ARCH" = "aarch64" ]; then
|
||||
echo " Mode Gaming : ajoutez 'SteamFrame FPV (Mode VR)' (launch_vr.sh) en jeu non-Steam."
|
||||
else
|
||||
echo "[!] Exécution sur hôte ${ARCH} (Ubuntu / PC de développement)."
|
||||
echo "[2/3] Compilation Release hôte standard..."
|
||||
cargo build --release
|
||||
if [ "${1:-}" != "--package-only" ]; then
|
||||
echo "[2/3] Compilation Release hôte standard..."
|
||||
cargo build --release
|
||||
else
|
||||
echo "[2/3] Mode --package-only : compilation hôte ignorée."
|
||||
fi
|
||||
|
||||
echo "[3/3] Création de l'archive de déploiement pour le Steam Frame..."
|
||||
mkdir -p dist
|
||||
tar --exclude="target" --exclude=".git" -czf dist/steamframe-fpv-deploy.tar.gz \
|
||||
Cargo.toml Cargo.lock src scripts assets README.md launch.sh launch_vr.sh steamframe-fpv.desktop steamframe-fpv-vr.desktop
|
||||
tar --exclude="target" --exclude=".git" --exclude="__pycache__" -czf dist/steamframe-fpv-deploy.tar.gz \
|
||||
Cargo.toml Cargo.lock src patches scripts assets README.md launch.sh launch_vr.sh steamframe-fpv.desktop steamframe-fpv-vr.desktop
|
||||
|
||||
echo "=== SUCCÈS : Archive de déploiement créée dans $DIR/dist/steamframe-fpv-deploy.tar.gz ==="
|
||||
echo "Pour déployer sur le casque, lancez : ./scripts/deploy_to_steamframe.sh [ip_steamframe]"
|
||||
|
||||
@@ -5,7 +5,7 @@ set -euo pipefail
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null 2>&1 && pwd)"
|
||||
cd "$DIR"
|
||||
|
||||
TARGET_HOST="${1:-deck@192.168.1.15}"
|
||||
TARGET_HOST="${1:-deck@192.168.1.10}"
|
||||
|
||||
echo "=== Déploiement de SteamFrame FPV vers le casque : ${TARGET_HOST} ==="
|
||||
|
||||
@@ -18,16 +18,16 @@ if ! ssh -o ConnectTimeout=3 -o BatchMode=yes "${TARGET_HOST}" "echo 'Connexion
|
||||
fi
|
||||
|
||||
echo "[2/5] Préparation du paquet de déploiement..."
|
||||
./scripts/build_steamframe_arm64.sh
|
||||
./scripts/build_steamframe_arm64.sh --package-only
|
||||
|
||||
echo "[3/5] Transfert des fichiers du projet sur le Steam Frame..."
|
||||
ssh "${TARGET_HOST}" "mkdir -p ~/projects/steamframe_fpv"
|
||||
scp dist/steamframe-fpv-deploy.tar.gz "${TARGET_HOST}:~/projects/steamframe_fpv/"
|
||||
ssh "${TARGET_HOST}" "cd ~/projects/steamframe_fpv && tar -xzf steamframe-fpv-deploy.tar.gz && chmod +x scripts/*.sh launch.sh launch_vr.sh"
|
||||
ssh "${TARGET_HOST}" "cd ~/projects/steamframe_fpv && tar -xzf steamframe-fpv-deploy.tar.gz && rm -f steamframe-fpv-deploy.tar.gz && chmod +x scripts/*.sh launch.sh launch_vr.sh"
|
||||
|
||||
echo "[4/5] Installation de la règle udev USB RNDIS (auto-attribution 192.168.1.10/24)..."
|
||||
scp scripts/99-radxa-vrx-rndis.rules "${TARGET_HOST}:/tmp/"
|
||||
ssh "${TARGET_HOST}" "sudo cp /tmp/99-radxa-vrx-rndis.rules /etc/udev/rules.d/ && sudo udevadm control --reload-rules"
|
||||
echo "[4/5] Installation de la règle udev USB RNDIS & HIDRAW..."
|
||||
scp scripts/99-radxa-vrx-rndis.rules "${TARGET_HOST}:/tmp/99-radxa-vrx-rndis.rules"
|
||||
ssh -t "${TARGET_HOST}" "sudo cp /tmp/99-radxa-vrx-rndis.rules /etc/udev/rules.d/ && rm -f /tmp/99-radxa-vrx-rndis.rules && sudo udevadm control --reload-rules && sudo udevadm trigger --subsystem-match=hidraw --subsystem-match=net"
|
||||
|
||||
echo "[5/5] Compilation Release native ARM64 sur le casque..."
|
||||
ssh "${TARGET_HOST}" "cd ~/projects/steamframe_fpv && ./scripts/build_steamframe_arm64.sh"
|
||||
|
||||
Regular → Executable
File mode changed.
+133
-59
@@ -5,6 +5,8 @@ Relie la Waveshare RP2350 (g29_crsf) au casque Steam Frame (192.168.1.10:14552)
|
||||
via l'interface USB Gadget RNDIS (usb0) sans aucune dépendance externe (stdlib seule).
|
||||
"""
|
||||
|
||||
import errno
|
||||
import fcntl
|
||||
import glob
|
||||
import os
|
||||
import select
|
||||
@@ -18,13 +20,20 @@ BAUD_RATE = termios.B460800
|
||||
BIND_IP = os.environ.get("STEAMFRAME_BIND_IP", "192.168.1.1")
|
||||
CASQUE_IP = os.environ.get("STEAMFRAME_CASQUE_IP", "192.168.1.10")
|
||||
UDP_PORT = int(os.environ.get("STEAMFRAME_G29_PORT", "14552"))
|
||||
MAX_SERIAL_RX_BUF = 4096
|
||||
MAX_SERIAL_TX_BUF = 4096
|
||||
|
||||
# Préfixes autorisés du casque vers la RP2350 (bloque toute commande CLI brute comme B=BOOTSEL ou R=Reset)
|
||||
ALLOWED_INBOUND_PREFIXES = (b"$HT,", b"$RC,", b"$SRC,", b"$GEARS,")
|
||||
|
||||
# Ordre de détection : USB CDC direct puis UART9_M1 (/dev/ttyS9, brochage Radxa Zero 3W documenté)
|
||||
SERIAL_CANDIDATES = (
|
||||
"/dev/ttyACM0",
|
||||
"/dev/ttyACM1",
|
||||
"/dev/ttyS9",
|
||||
"/dev/ttyS4",
|
||||
"/dev/ttyS5",
|
||||
"/dev/ttyS3",
|
||||
"/dev/ttyS9",
|
||||
"/dev/ttyS0",
|
||||
"/dev/ttyAMA0",
|
||||
)
|
||||
@@ -32,24 +41,33 @@ SERIAL_CANDIDATES = (
|
||||
|
||||
def open_serial(dev_path: str) -> int:
|
||||
fd = os.open(dev_path, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
|
||||
attrs = termios.tcgetattr(fd)
|
||||
# Mode raw 8N1 sans contrôle de flux
|
||||
attrs[0] = 0 # iflag
|
||||
attrs[1] = 0 # oflag
|
||||
attrs[2] = termios.CS8 | termios.CREAD | termios.CLOCAL # cflag
|
||||
attrs[3] = 0 # lflag
|
||||
attrs[4] = BAUD_RATE
|
||||
attrs[5] = BAUD_RATE
|
||||
attrs[6][termios.VMIN] = 0
|
||||
attrs[6][termios.VTIME] = 0
|
||||
termios.tcsetattr(fd, termios.TCSANOW, attrs)
|
||||
try:
|
||||
try:
|
||||
fcntl.ioctl(fd, termios.TIOCEXCL)
|
||||
except OSError:
|
||||
pass
|
||||
attrs = termios.tcgetattr(fd)
|
||||
# Mode raw 8N1 sans contrôle de flux
|
||||
attrs[0] = 0 # iflag
|
||||
attrs[1] = 0 # oflag
|
||||
attrs[2] = termios.CS8 | termios.CREAD | termios.CLOCAL # cflag
|
||||
attrs[3] = 0 # lflag
|
||||
attrs[4] = BAUD_RATE
|
||||
attrs[5] = BAUD_RATE
|
||||
attrs[6][termios.VMIN] = 0
|
||||
attrs[6][termios.VTIME] = 0
|
||||
termios.tcsetattr(fd, termios.TCSANOW, attrs)
|
||||
termios.tcflush(fd, termios.TCIOFLUSH)
|
||||
except Exception:
|
||||
os.close(fd)
|
||||
raise
|
||||
return fd
|
||||
|
||||
|
||||
def find_serial_device() -> Optional[str]:
|
||||
forced = os.environ.get("G29_SERIAL_DEV")
|
||||
if forced and os.path.exists(forced):
|
||||
return forced
|
||||
if forced:
|
||||
return forced if os.path.exists(forced) else None
|
||||
for pattern in SERIAL_CANDIDATES:
|
||||
for path in sorted(glob.glob(pattern)):
|
||||
if os.path.exists(path):
|
||||
@@ -57,28 +75,49 @@ def find_serial_device() -> Optional[str]:
|
||||
return None
|
||||
|
||||
|
||||
def main() -> None:
|
||||
def bind_udp_socket() -> tuple[socket.socket, str]:
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
try:
|
||||
sock.bind((BIND_IP, UDP_PORT))
|
||||
bound_ip = BIND_IP
|
||||
except OSError as exc:
|
||||
print(
|
||||
f"[radxa_g29_relay] Bind {BIND_IP}:{UDP_PORT} impossible ({exc}), fallback 0.0.0.0",
|
||||
file=sys.stderr,
|
||||
flush=True,
|
||||
)
|
||||
sock.bind(("0.0.0.0", UDP_PORT))
|
||||
bound_ip = "0.0.0.0"
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
# Attendre brièvement au démarrage que usb0 (192.168.1.1) soit configurée avant fallback
|
||||
for attempt in range(5):
|
||||
try:
|
||||
sock.bind((BIND_IP, UDP_PORT))
|
||||
sock.setblocking(False)
|
||||
return sock, BIND_IP
|
||||
except OSError as exc:
|
||||
if attempt < 4:
|
||||
time.sleep(0.5)
|
||||
else:
|
||||
print(
|
||||
f"[radxa_g29_relay] Bind {BIND_IP}:{UDP_PORT} impossible ({exc}), fallback 0.0.0.0",
|
||||
file=sys.stderr,
|
||||
flush=True,
|
||||
)
|
||||
sock.bind(("0.0.0.0", UDP_PORT))
|
||||
sock.setblocking(False)
|
||||
return sock, "0.0.0.0"
|
||||
|
||||
|
||||
def close_serial(serial_fd: Optional[int]) -> None:
|
||||
if serial_fd is not None:
|
||||
try:
|
||||
os.close(serial_fd)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def main() -> None:
|
||||
sock, bound_ip = bind_udp_socket()
|
||||
print(
|
||||
f"[radxa_g29_relay] UDP {bound_ip}:{UDP_PORT} <-> {CASQUE_IP}:{UDP_PORT} (filtre IP actif)",
|
||||
f"[radxa_g29_relay] UDP {bound_ip}:{UDP_PORT} <-> {CASQUE_IP}:{UDP_PORT} (filtre IP + protocole $ actif)",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
serial_fd: Optional[int] = None
|
||||
serial_buf = bytearray()
|
||||
serial_rx_buf = bytearray()
|
||||
serial_tx_buf = bytearray()
|
||||
last_casque_addr = (CASQUE_IP, UDP_PORT)
|
||||
last_udp_err_log = 0.0
|
||||
|
||||
while True:
|
||||
if serial_fd is None:
|
||||
@@ -86,7 +125,8 @@ def main() -> None:
|
||||
if dev is not None:
|
||||
try:
|
||||
serial_fd = open_serial(dev)
|
||||
serial_buf.clear()
|
||||
serial_rx_buf.clear()
|
||||
serial_tx_buf.clear()
|
||||
print(f"[radxa_g29_relay] Connecté à la RP2350 sur {dev}", flush=True)
|
||||
except OSError as exc:
|
||||
print(f"[radxa_g29_relay] Erreur ouverture {dev}: {exc}", file=sys.stderr, flush=True)
|
||||
@@ -98,51 +138,85 @@ def main() -> None:
|
||||
continue
|
||||
|
||||
rlist = [sock.fileno(), serial_fd]
|
||||
wlist = [serial_fd] if serial_tx_buf else []
|
||||
try:
|
||||
readable, _, _ = select.select(rlist, [], [], 0.25)
|
||||
readable, writable, _ = select.select(rlist, wlist, [], 0.25)
|
||||
except (OSError, ValueError):
|
||||
try:
|
||||
os.close(serial_fd)
|
||||
except OSError:
|
||||
pass
|
||||
close_serial(serial_fd)
|
||||
serial_fd = None
|
||||
continue
|
||||
|
||||
# 1. Réception UDP depuis le casque -> file d'émission UART (filtrée et non-bloquante)
|
||||
if sock.fileno() in readable:
|
||||
try:
|
||||
data, addr = sock.recvfrom(512)
|
||||
while True:
|
||||
try:
|
||||
data, addr = sock.recvfrom(1024)
|
||||
except BlockingIOError:
|
||||
break
|
||||
except OSError:
|
||||
break
|
||||
if addr[0] not in (CASQUE_IP, "127.0.0.1"):
|
||||
continue
|
||||
last_casque_addr = (addr[0], UDP_PORT)
|
||||
if data:
|
||||
os.write(serial_fd, data)
|
||||
except OSError:
|
||||
try:
|
||||
os.close(serial_fd)
|
||||
except OSError:
|
||||
pass
|
||||
serial_fd = None
|
||||
continue
|
||||
for raw_line in data.splitlines():
|
||||
line = raw_line.strip()
|
||||
if not line or not line.startswith(ALLOWED_INBOUND_PREFIXES):
|
||||
continue
|
||||
payload = line + b"\n"
|
||||
if len(serial_tx_buf) + len(payload) > MAX_SERIAL_TX_BUF:
|
||||
# Préférer la trame la plus récente en cas de saturation UART
|
||||
serial_tx_buf.clear()
|
||||
serial_tx_buf.extend(payload)
|
||||
|
||||
if serial_fd in readable:
|
||||
# 2. Vidange non-bloquante de la file TX vers la RP2350 (gère écritures partielles et EAGAIN)
|
||||
if serial_tx_buf and (serial_fd in writable or sock.fileno() in readable):
|
||||
try:
|
||||
written = os.write(serial_fd, serial_tx_buf)
|
||||
if written > 0:
|
||||
del serial_tx_buf[:written]
|
||||
except BlockingIOError:
|
||||
pass
|
||||
except OSError as exc:
|
||||
if exc.errno not in (errno.EAGAIN, errno.EWOULDBLOCK):
|
||||
close_serial(serial_fd)
|
||||
serial_fd = None
|
||||
print(f"[radxa_g29_relay] Erreur écriture RP2350 ({exc}), reconnexion...", flush=True)
|
||||
continue
|
||||
|
||||
# 3. Lecture non-bloquante depuis la RP2350 -> émission UDP vers le casque
|
||||
if serial_fd is not None and serial_fd in readable:
|
||||
try:
|
||||
chunk = os.read(serial_fd, 512)
|
||||
if not chunk:
|
||||
raise OSError("EOF série")
|
||||
serial_buf.extend(chunk)
|
||||
while b"\n" in serial_buf:
|
||||
nl_idx = serial_buf.index(b"\n")
|
||||
line = bytes(serial_buf[: nl_idx + 1]).strip()
|
||||
del serial_buf[: nl_idx + 1]
|
||||
serial_rx_buf.extend(chunk)
|
||||
if len(serial_rx_buf) > MAX_SERIAL_RX_BUF:
|
||||
# Protection anti-OOM si bruit série sans retour à la ligne
|
||||
del serial_rx_buf[:-512]
|
||||
while b"\n" in serial_rx_buf:
|
||||
nl_idx = serial_rx_buf.index(b"\n")
|
||||
line = bytes(serial_rx_buf[: nl_idx + 1]).strip()
|
||||
del serial_rx_buf[: nl_idx + 1]
|
||||
if line.startswith((b"$G29", b"$CRSF")):
|
||||
sock.sendto(line + b"\n", last_casque_addr)
|
||||
except OSError:
|
||||
try:
|
||||
os.close(serial_fd)
|
||||
except OSError:
|
||||
pass
|
||||
serial_fd = None
|
||||
print("[radxa_g29_relay] Liaison RP2350 perdue, attente reconnexion...", flush=True)
|
||||
try:
|
||||
sock.sendto(line + b"\n", last_casque_addr)
|
||||
except OSError as exc:
|
||||
# Une panne réseau usb0 (casque débranché) ne doit JAMAIS fermer le port série RP2350
|
||||
now = time.monotonic()
|
||||
if now - last_udp_err_log >= 5.0:
|
||||
last_udp_err_log = now
|
||||
print(
|
||||
f"[radxa_g29_relay] Casque {last_casque_addr[0]} injoignable ({exc})",
|
||||
file=sys.stderr,
|
||||
flush=True,
|
||||
)
|
||||
except BlockingIOError:
|
||||
pass
|
||||
except OSError as exc:
|
||||
if exc.errno not in (errno.EAGAIN, errno.EWOULDBLOCK):
|
||||
close_serial(serial_fd)
|
||||
serial_fd = None
|
||||
print("[radxa_g29_relay] Liaison RP2350 perdue, attente reconnexion...", flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -21,18 +21,26 @@ if [ -f /boot/dtbo/rk3568-uart9-m1.dtbo.disabled ] && [ ! -f /boot/dtbo/rk3568-u
|
||||
fi
|
||||
if [ -f /boot/dtbo/rk3568-uart9-m1.dtbo ] && [ -f /boot/extlinux/extlinux.conf ]; then
|
||||
if ! grep -q "rk3568-uart9-m1.dtbo" /boot/extlinux/extlinux.conf; then
|
||||
sed -i 's|fdtoverlays \(.*\)|fdtoverlays \1 /boot/dtbo/rk3568-uart9-m1.dtbo|' /boot/extlinux/extlinux.conf
|
||||
echo "[*] Overlay rk3568-uart9-m1.dtbo ajouté dans extlinux.conf (un reboot activera /dev/ttyS9)"
|
||||
cp /boot/extlinux/extlinux.conf /boot/extlinux/extlinux.conf.bak
|
||||
if grep -q "fdtoverlays" /boot/extlinux/extlinux.conf; then
|
||||
sed -i 's|fdtoverlays \(.*\)|fdtoverlays \1 /boot/dtbo/rk3568-uart9-m1.dtbo|' /boot/extlinux/extlinux.conf
|
||||
echo "[*] Overlay rk3568-uart9-m1.dtbo ajouté dans extlinux.conf (sauvegarde .bak créée, reboot requis)"
|
||||
else
|
||||
echo "[!] Aucune directive fdtoverlays trouvée dans /boot/extlinux/extlinux.conf — ajoutez rk3568-uart9-m1.dtbo manuellement."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
cat << 'UNIT' > /etc/systemd/system/steamframe-g29-relay.service
|
||||
[Unit]
|
||||
Description=SteamFrame FPV Unified G29/CRSF <-> USB0 UDP Relay
|
||||
After=network.target
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Environment=G29_SERIAL_DEV=/dev/ttyS9
|
||||
ExecStart=/usr/bin/python3 /usr/local/bin/radxa_g29_relay.py
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Script de validation automatique de la chaîne OpenXR & des Modes de Projection
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
@@ -18,16 +18,33 @@ echo -e "${BLUE}======================================================${NC}"
|
||||
# 1. Vérification du service Monado
|
||||
echo -n "Vérification du service Monado... "
|
||||
STARTED_MONADO=0
|
||||
if pgrep monado-service >/dev/null 2>&1; then
|
||||
MONADO_FIFO=""
|
||||
MONADO_KEEPALIVE_PID=""
|
||||
MONADO_WRAPPER_PID=""
|
||||
|
||||
cleanup() {
|
||||
if [ "$STARTED_MONADO" -eq 1 ]; then
|
||||
[ -n "$MONADO_KEEPALIVE_PID" ] && kill "$MONADO_KEEPALIVE_PID" 2>/dev/null || true
|
||||
[ -n "$MONADO_WRAPPER_PID" ] && kill "$MONADO_WRAPPER_PID" 2>/dev/null || true
|
||||
pkill -x monado-service 2>/dev/null || true
|
||||
[ -n "$MONADO_FIFO" ] && rm -f "$MONADO_FIFO"
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if pgrep -x monado-service >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[OK - Monado est actif]${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}[Démarrage de Monado en arrière-plan...]${NC}"
|
||||
tail -f /dev/null | ./scripts/start_monado_simulated.sh >/tmp/monado_test.log 2>&1 &
|
||||
MONADO_FIFO=$(mktemp -u /tmp/monado_stdin_XXXXXX.fifo)
|
||||
mkfifo "$MONADO_FIFO"
|
||||
sleep infinity > "$MONADO_FIFO" &
|
||||
MONADO_KEEPALIVE_PID=$!
|
||||
./scripts/start_monado_simulated.sh < "$MONADO_FIFO" >/tmp/monado_test.log 2>&1 &
|
||||
MONADO_WRAPPER_PID=$!
|
||||
STARTED_MONADO=1
|
||||
trap 'if [ "$STARTED_MONADO" -eq 1 ]; then pkill -f monado-service 2>/dev/null || true; kill "$MONADO_WRAPPER_PID" 2>/dev/null || true; fi' EXIT
|
||||
sleep 2
|
||||
if pgrep monado-service >/dev/null 2>&1; then
|
||||
if pgrep -x monado-service >/dev/null 2>&1; then
|
||||
echo -e "${GREEN}[OK - Monado démarré]${NC}"
|
||||
else
|
||||
echo -e "${RED}[ERREUR] Impossible de contacter Monado.${NC}"
|
||||
@@ -36,23 +53,25 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
# 2. Test unitaire Rust
|
||||
echo -e "\n${BLUE}--- Étape 1 : Tests unitaires Rust (Maths & Dé-distorsion) ---${NC}"
|
||||
# 2. Test unitaire Rust + compilation du binaire release à jour
|
||||
echo -e "\n${BLUE}--- Étape 1 : Tests unitaires Rust & Compilation Release ---${NC}"
|
||||
cargo test --quiet
|
||||
echo -e "${GREEN}✔ Tous les tests unitaires (DomeWarpLut, ProjectionMode, CRSF/MSP) sont validés.${NC}"
|
||||
cargo build --release --quiet
|
||||
echo -e "${GREEN}✔ Tous les tests unitaires et la compilation Release sont validés.${NC}"
|
||||
|
||||
# Fonction d'exécution d'un test OpenXR
|
||||
run_mode_test() {
|
||||
local mode="$1"
|
||||
local desc="$2"
|
||||
local extra_args="$3"
|
||||
echo -e "\n${BLUE}--- Test Mode : ${desc} (--projection-mode ${mode} ${extra_args}) ---${NC}"
|
||||
local log_tag="$3"
|
||||
shift 3
|
||||
echo -e "\n${BLUE}--- Test Mode : ${desc} (--projection-mode ${mode} $*) ---${NC}"
|
||||
|
||||
local log_file="/tmp/openxr_test_${mode}.log"
|
||||
local log_file="/tmp/openxr_test_${log_tag}.log"
|
||||
rm -f "$log_file"
|
||||
|
||||
# Exécution pendant 3.5 secondes
|
||||
timeout 3.5 ./target/release/steamframe-fpv --no-gui --projection-mode "$mode" $extra_args > "$log_file" 2>&1 || true
|
||||
timeout 3.5 ./target/release/steamframe-fpv --no-gui --projection-mode "$mode" "$@" > "$log_file" 2>&1 || true
|
||||
|
||||
# Vérification des étapes clés dans les logs
|
||||
local has_device=false
|
||||
@@ -62,7 +81,7 @@ run_mode_test() {
|
||||
if grep -q "Casque connecté : Monado" "$log_file"; then
|
||||
has_device=true
|
||||
fi
|
||||
if grep -q "Creation of VkDevice:.*result: VK_SUCCESS" "$log_file" || grep -q "result: VK_SUCCESS" "$log_file"; then
|
||||
if grep -q "Creation of VkDevice:.*result: VK_SUCCESS" "$log_file" || grep -q "Session OpenXR Vulkan" "$log_file"; then
|
||||
has_vulkan=true
|
||||
fi
|
||||
if grep -q "Changement d'état session : FOCUSED" "$log_file"; then
|
||||
@@ -83,12 +102,12 @@ run_mode_test() {
|
||||
}
|
||||
|
||||
# 3. Tests des 3 modes de projection
|
||||
run_mode_test "dome" "Dôme 140° (Equirect2 avec dé-distorsion)" "--lens-k1 -0.14 --lens-k2 0.03"
|
||||
run_mode_test "cylinder" "Cylindre Incurvé 140° (Cylinder layer)" ""
|
||||
run_mode_test "flat" "Quad Plat Virtuel (Quad layer)" ""
|
||||
run_mode_test "dome" "Dôme 140° (Equirect2 avec dé-distorsion)" "dome" --lens-k1 -0.14 --lens-k2 0.03
|
||||
run_mode_test "cylinder" "Cylindre Incurvé 140° (Cylinder layer)" "cylinder"
|
||||
run_mode_test "flat" "Quad Plat Virtuel (Quad layer)" "flat"
|
||||
|
||||
# 4. Test du Mode VR Natif (--vr-only, Mode Gaming SteamOS)
|
||||
run_mode_test "dome" "Mode VR Natif Gaming (--vr-only)" "--vr-only"
|
||||
run_mode_test "dome" "Mode VR Natif Gaming (--vr-only)" "vr_only" --vr-only
|
||||
|
||||
# 5. Test d'initialisation de l'interface graphique GPUI avec OpenXR
|
||||
echo -e "\n${BLUE}--- Étape 2 : Test d'intégration IHM moderne (GPUI + OpenXR) ---${NC}"
|
||||
@@ -98,8 +117,9 @@ timeout 3 ./target/release/steamframe-fpv > "$gpui_log" 2>&1 || true
|
||||
if grep -q "Changement d'état session : FOCUSED" "$gpui_log"; then
|
||||
echo -e "${GREEN}✔ L'interface GPUI se synchronise et alimente parfaitement la session OpenXR FOCUSED.${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}Avertissement GPUI :${NC}"
|
||||
tail -n 10 "$gpui_log"
|
||||
echo -e "${RED}✘ Échec intégration GPUI + OpenXR :${NC}"
|
||||
tail -n 15 "$gpui_log"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "\n${GREEN}======================================================${NC}"
|
||||
|
||||
Reference in new issue
Block a user