Files
OmniSocketGo_streaming/robot/v4l2/OmniSocketGo_robot/check-robot-lan.sh
2026-08-09 15:56:20 +08:00

61 lines
1.6 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1091
source "${PROJECT_ROOT}/scripts/dev/load-env.sh"
failed=0
check_empty_relay() {
local name="$1"
local value="${!name:-}"
if [[ -n "${value}" ]]; then
echo "[FAIL] ${name} must be empty, got: ${value}" >&2
failed=1
else
echo "[ OK ] ${name}=<disabled>"
fi
}
check_camera() {
local name="$1"
local device="$2"
if [[ -e "${device}" ]]; then
echo "[ OK ] ${name} camera: ${device} -> $(readlink -f "${device}")"
else
echo "[FAIL] ${name} camera is missing: ${device}" >&2
failed=1
fi
}
echo "Robot video target: ${OMNI_VIDEO_SERVER_ADDR}"
echo "Robot control target: ${OMNI_CONTROL_SERVER_ADDR}"
check_empty_relay ROBOT_SIDE_OMNISOCKET_RELAY_VIA
check_empty_relay OMNI_VIDEO_RELAY_VIA
check_empty_relay OMNI_CONTROL_RELAY_VIA
check_camera head "${OMNI_CAMERA_HEAD_DEVICE}"
check_camera waist "${OMNI_CAMERA_WAIST_DEVICE}"
if pkg-config --exists libavformat libavcodec libavutil libswscale; then
echo "[ OK ] FFmpeg development libraries"
else
echo "[FAIL] FFmpeg development libraries are missing" >&2
failed=1
fi
if [[ -x "${PROJECT_ROOT}/bin/b_side_omnid" ]]; then
echo "[ OK ] bin/b_side_omnid is built"
else
echo "[WARN] bin/b_side_omnid is not built; run: make b_side_omnid"
fi
server_host="${OMNI_VIDEO_SERVER_ADDR%:*}"
if command -v ping >/dev/null 2>&1 && ping -c 1 -W 1 "${server_host}" >/dev/null 2>&1; then
echo "[ OK ] computer is reachable: ${server_host}"
else
echo "[WARN] cannot ping ${server_host}; verify the direct Ethernet addresses"
fi
exit "${failed}"