Files
vt1200/harness/badapple/demo.sh
T
arti c166c6fdec fix(badapple): refuse a non-cache --tiles path before the jump
demo.sh loaded (and jumped) the payload before it ever looked at --tiles, so a
wrong path -- the frames directory rather than the cache make_tiles.py writes --
only surfaced after the machine had been handed to a payload that never returns,
forcing a reboot to retry.  It now checks dictionary.bin/stream.bin first, names
the frames-vs-cache confusion when the directory holds raw frames, and exits 2
without touching the network.  The README's failure table gains that row and the
--no-load recovery for an instance that has already been jumped.
2026-10-31 22:05:48 +02:00

89 lines
3.5 KiB
Bash
Executable File

#!/bin/sh
# Play the streaming demo on a RUNNING terminal: wait for its OS network stack,
# deliver the payload over rdebug, then send the clip with the host sender.
#
# The terminal itself is started separately -- `harness/mame/run.sh net` for the
# emulator (its default VR319 monitor already gives the real unit's 1280-px /
# 256-byte framebuffer layout; `VT1200_MONITOR=VR150` reproduces the old derived
# 1024-px view), or a real VT1200 on the network. This script only talks
# to it, so one instance serves one demo: the jump hands the payload the
# remote-debug process and it never returns.
#
# demo.sh # committed 30-frame cache
# demo.sh --tiles /tmp/badapple --frames 3292 --fps 15
# demo.sh --host 192.168.99.2 --iface vt1200
# demo.sh --no-load # send only, payload already running
set -eu
HERE=$(cd "$(dirname "$0")" && pwd)
ROOT=$(cd "$HERE/../.." && pwd)
HOST=192.168.99.2
IFACE=vt1200
TILES=$ROOT/harness/udpstream/tiles
FRAMES=200
FPS=15
LOAD=1
SEND=1
WAIT=180
while [ $# -gt 0 ]; do
case "$1" in
--host) HOST=$2; shift 2 ;;
--iface) IFACE=$2; shift 2 ;;
--tiles) TILES=$2; shift 2 ;;
--frames) FRAMES=$2; shift 2 ;;
--fps) FPS=$2; shift 2 ;;
--wait) WAIT=$2; shift 2 ;;
--no-load) LOAD=0; shift ;;
--no-send) SEND=0; shift ;;
-h|--help) sed -n '2,20p' "$0"; exit 0 ;;
*) echo "demo.sh: unknown option $1" >&2; exit 2 ;;
esac
done
# --- the cache, checked BEFORE anything irreversible ------------------------
# The jump hands the payload the remote-debug process and it never returns, so
# a bad --tiles path discovered afterwards leaves the machine needing a restart
# to try again. Refuse it here instead.
if [ "$SEND" = 1 ]; then
for f in dictionary.bin stream.bin; do
if [ ! -f "$TILES/$f" ]; then
echo "demo.sh: $TILES has no $f -- that is not a tile cache" >&2
if ls "$TILES"/[0-9]*.bin > /dev/null 2>&1; then
echo " it looks like a FRAMES directory (raw 1-bpp frames)." >&2
echo " build the cache from it first:" >&2
echo " python3 harness/udpstream/make_tiles.py --clip $TILES --out $TILES-tiles" >&2
fi
echo " the committed 30-frame cache is harness/udpstream/tiles" >&2
exit 2
fi
done
fi
# --- readiness: an ICMP reply from the terminal's own stack -----------------
start=$(date +%s)
while ! ping -c1 -W1 "$HOST" > /dev/null 2>&1; do
if [ $(( $(date +%s) - start )) -ge "$WAIT" ]; then
echo "demo.sh: $HOST did not answer within ${WAIT}s" >&2
echo " is the terminal booted and on the tap? (harness/mame/run.sh net)" >&2
exit 1
fi
done
echo "demo.sh: $HOST answers ($(( $(date +%s) - start ))s)"
# --- the payload, over the firmware's own remote-debug service --------------
if [ "$LOAD" = 1 ]; then
python3 "$HERE/rdebug_load.py" --host "$HOST"
# The payload takes the LANCE and the remote-debug process with it, so the
# sender is started once the machine has had time to arm its ring.
sleep 3
fi
# --- the clip ---------------------------------------------------------------
if [ "$SEND" = 1 ]; then
echo "demo.sh: sending $FRAMES frame(s) from $TILES at $FPS fps on $IFACE"
sudo -n python3 "$ROOT/harness/udpstream/vidsend.py" --iface "$IFACE" \
--tiles --tiles-dir "$TILES" --frames "$FRAMES" --fps "$FPS"
fi