From 97abb938c5a9bee63efea4d00568e837ddc21474 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Sat, 25 Apr 2026 05:57:29 -0300 Subject: [PATCH] fix(server): map eye links from distinct capture nodes --- Cargo.lock | 6 +- client/Cargo.toml | 2 +- common/Cargo.toml | 2 +- scripts/install/server.sh | 58 +++++++++---------- server/Cargo.toml | 2 +- .../tests/server_install_script_contract.rs | 16 +++++ 6 files changed, 48 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f96482..efe80d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1642,7 +1642,7 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "lesavka_client" -version = "0.13.15" +version = "0.13.16" dependencies = [ "anyhow", "async-stream", @@ -1676,7 +1676,7 @@ dependencies = [ [[package]] name = "lesavka_common" -version = "0.13.15" +version = "0.13.16" dependencies = [ "anyhow", "base64", @@ -1688,7 +1688,7 @@ dependencies = [ [[package]] name = "lesavka_server" -version = "0.13.15" +version = "0.13.16" dependencies = [ "anyhow", "base64", diff --git a/client/Cargo.toml b/client/Cargo.toml index 9a7cfdf..eadad99 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -4,7 +4,7 @@ path = "src/main.rs" [package] name = "lesavka_client" -version = "0.13.15" +version = "0.13.16" edition = "2024" [dependencies] diff --git a/common/Cargo.toml b/common/Cargo.toml index f8390fb..ad6c487 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lesavka_common" -version = "0.13.15" +version = "0.13.16" edition = "2024" build = "build.rs" diff --git a/scripts/install/server.sh b/scripts/install/server.sh index 9cc3566..a6f284b 100755 --- a/scripts/install/server.sh +++ b/scripts/install/server.sh @@ -320,49 +320,43 @@ if systemctl list-unit-files | grep -q '^relay.service'; then sleep 2 fi -# probe v4l2 devices for GC311s (07ca:3311) -mapfile -t GC_VIDEOS < <( - sudo v4l2-ctl --list-devices 2>/dev/null | - awk '/Live Gamer MINI/{getline; print $1}' +mapfile -t GC_CAPTURE_PAIRS < <( + for dev in /dev/video*; do + props=$(sudo udevadm info -q property -n "$dev" 2>/dev/null || true) + index=$(cat "/sys/class/video4linux/$(basename "$dev")/index" 2>/dev/null || true) + if echo "$props" | grep -q 'ID_VENDOR_ID=07ca' \ + && echo "$props" | grep -q 'ID_MODEL_ID=3311' \ + && [ "$index" = "0" ]; then + tag=$(printf '%s\n' "$props" | awk -F= '/^ID_PATH_TAG=/{print $2}') + if [ -n "$tag" ]; then + printf '%s %s\n' "$tag" "$dev" + fi + fi + done | sort -u ) -# fallback via udev if v4l2-ctl output is empty/partial -if [ "${#GC_VIDEOS[@]}" -ne 2 ]; then - mapfile -t GC_VIDEOS < <( - for dev in /dev/video*; do - props=$(sudo udevadm info -q property -n "$dev" 2>/dev/null || true) - if echo "$props" | grep -q 'ID_VENDOR_ID=07ca' && echo "$props" | grep -q 'ID_MODEL_ID=3311'; then - echo "$dev" - fi - done | sort -u - ) -fi - -if [ "${#GC_VIDEOS[@]}" -ne 2 ]; then +if [ "${#GC_CAPTURE_PAIRS[@]}" -ne 2 ]; then echo "⚠️ GC311 capture cards not fully present; skipping udev eye-link refresh." >&2 - if [ "${#GC_VIDEOS[@]}" -eq 0 ]; then + if [ "${#GC_CAPTURE_PAIRS[@]}" -eq 0 ]; then echo " Detected: none" >&2 else - printf ' Detected: %s\n' "${GC_VIDEOS[@]}" >&2 + printf ' Detected: %s\n' "${GC_CAPTURE_PAIRS[@]}" >&2 fi echo " The server install will continue, and existing /dev/lesavka_* links stay untouched." >&2 else - mapfile -t TAGS < <( - for v in "${GC_VIDEOS[@]}"; do - sudo udevadm info -q property -n "$v" | - awk -F= '/^ID_PATH_TAG=/{print $2}' - done - ) + LEFT_TAG=${GC_CAPTURE_PAIRS[0]%% *} + LEFT_DEV=${GC_CAPTURE_PAIRS[0]#* } + RIGHT_TAG=${GC_CAPTURE_PAIRS[1]%% *} + RIGHT_DEV=${GC_CAPTURE_PAIRS[1]#* } - if [ -z "${TAGS[0]:-}" ] || [ -z "${TAGS[1]:-}" ]; then - echo "⚠️ GC311 cards were detected, but ID_PATH_TAG lookup was incomplete." >&2 + if [ -z "$LEFT_TAG" ] || [ -z "$RIGHT_TAG" ] || [ "$LEFT_TAG" = "$RIGHT_TAG" ]; then + echo "⚠️ GC311 cards were detected, but the capture path tags are incomplete or duplicated." >&2 + printf ' Left candidate: %s\n' "${GC_CAPTURE_PAIRS[0]:-missing}" >&2 + printf ' Right candidate: %s\n' "${GC_CAPTURE_PAIRS[1]:-missing}" >&2 echo " Skipping udev eye-link refresh and preserving any existing /dev/lesavka_* links." >&2 else - printf ' ↪ Left card: %s (%s)\n' "${GC_VIDEOS[0]}" "${TAGS[0]}" - printf ' ↪ Right card: %s (%s)\n' "${GC_VIDEOS[1]}" "${TAGS[1]}" - - LEFT_TAG=${TAGS[0]} - RIGHT_TAG=${TAGS[1]} + printf ' ↪ Left card: %s (%s)\n' "$LEFT_DEV" "$LEFT_TAG" + printf ' ↪ Right card: %s (%s)\n' "$RIGHT_DEV" "$RIGHT_TAG" sudo tee /etc/udev/rules.d/85-gc311.rules >/dev/null <