#!/usr/bin/env bash
# Pos2 full-Dev capture — play one Touch 6 hand, then extract golden 0x20.
#
#   bash ~/EtherGold/sync/_tmp_pos2_full_dev_capture.sh
#   # play Touch 6 on the pos2 cabinet
#   bash ~/EtherGold/sync/_tmp_pos2_extract_touch6.sh
#
set -euo pipefail
cd ~/EtherGold/dev
pkill -f pog422_fixture_bridge 2>/dev/null || true
pkill -f pog422_uartd 2>/dev/null || true
sudo systemctl stop fixture-prod 2>/dev/null || true
sleep 2
mkdir -p ~/EtherGold/logs/lab_gameplay_pilot
export FIXTURE_POS=2
export PI_LABEL=topbox2
export CHANNEL=machine
export FIXTURE_MODE=debug
export FIXTURE_PROD=0
export FIXTURE_DEV_LIGHT=0
export FIXTURE_LOG_MODE=full
export CLEAR_CAPTURE=1
export LAB_GAMEPLAY_SYNTH=0
export VERBOSE=1
LOG=~/EtherGold/logs/lab_gameplay_pilot/pos2_full_dev.log
nohup bash run_bridge_jun11_good.sh >"$LOG" 2>&1 &
echo $! >~/EtherGold/logs/lab_gameplay_pilot/pos2_full_dev.pid
sleep 5
echo "pid=$(cat ~/EtherGold/logs/lab_gameplay_pilot/pos2_full_dev.pid)"
grep -E "session_start|parser_build|FATAL|Dev|packets" "$LOG" | head -20 || true
pgrep -af 'pog422_fixture_bridge' | head -2
echo "Play one Touch 6 on pos2 copper, then run: bash ~/EtherGold/sync/_tmp_pos2_extract_touch6.sh"
