#!/bin/sh
# Copy the Ch365 A-to-B motion scheduler inputs to the DE25 board.
set -eu

DEST="${1:-terasic@192.168.50.161:~}"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
DATA="$ROOT/sim/data/top_psmct32_raster_demo"
FILES="$ROOT/tools/ps2_sh3_sched.c $DATA/sh3_zs640m28_epochs.txt $DATA/sh3_zs640b24_epochs.txt $DATA/sh3_zs640c24c_epochs.txt"

for k in 0 1 2 3 4 5 6 7 8 9 10 11; do
    FILES="$FILES $DATA/sh3_zs640m28${k}_tex_lpddr.mem $DATA/feeder_sh3_zs640m28${k}.mem"
done

for k in 0 1 2 3 4 5 6 7; do
    FILES="$FILES $DATA/sh3_zs640b24${k}_tex_lpddr.mem $DATA/feeder_sh3_zs640b24${k}.mem"
done

for k in 0 1 2 3 4 5 6 7; do
    FILES="$FILES $DATA/sh3_zs640c24c${k}_tex_lpddr.mem $DATA/feeder_sh3_zs640c24c${k}.mem"
done

for f in $FILES; do
    test -f "$f" || { echo "MISSING: $f" >&2; exit 1; }
done

echo "Copying Ch365 motion host/data files -> $DEST"
# shellcheck disable=SC2086
exec scp $FILES "$DEST"
