hil: single-stream decode+IQ capture, clock-aligned RF TX proof
This commit is contained in:
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# Capture rtl_wmbus decodes AND raw IQ from a SINGLE rtl_sdr stream.
|
||||
#
|
||||
# Why one stream: this dongle's sensitivity drifts by ~17 dB over minutes,
|
||||
# so measurements taken in separate captures at "the same gain" are not
|
||||
# comparable. Decoding meter originals and measuring our own transmissions
|
||||
# in the IQ must therefore share one stream, one gain, one instant.
|
||||
#
|
||||
# Usage: capture_both.sh DURATION_S DECODE_LOG IQ_FILE [GAIN]
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
DUR=$1; OUT=$2; IQ=$3; GAIN=${4:-42.1}
|
||||
|
||||
: > "$OUT"
|
||||
ERR="${OUT%.log}.err"
|
||||
STATS="${OUT%.log}.stats"
|
||||
: > "$ERR"
|
||||
|
||||
health_ok=0
|
||||
for i in 1 2 3; do
|
||||
if ./result-py/bin/python3 hil/sdr_health.py >> "$ERR" 2>&1; then
|
||||
health_ok=1; break
|
||||
fi
|
||||
echo "--- SDR unhealthy; usbreset (try $i)" >> "$ERR"
|
||||
usbreset 0bda:2838 >> "$ERR" 2>&1 || true
|
||||
sleep $((i * 5))
|
||||
done
|
||||
echo "sdr_health_ok=$health_ok" > "${OUT%.log}.health"
|
||||
|
||||
t0=$(date +%s)
|
||||
# tee duplicates the sample stream: one copy to disk, one to the decoder
|
||||
timeout "$DUR" rtl_sdr -f 868950000 -s 1600000 -g "$GAIN" - 2>>"$ERR" \
|
||||
| tee "$IQ" \
|
||||
| rtl_wmbus -f >> "$OUT" 2>/dev/null || true
|
||||
t1=$(date +%s)
|
||||
|
||||
printf 'streamed_seconds=%s\nrequested_seconds=%s\ngain=%s\niq_bytes=%s\n' \
|
||||
"$((t1 - t0))" "$DUR" "$GAIN" "$(stat -c%s "$IQ" 2>/dev/null || echo 0)" \
|
||||
> "$STATS"
|
||||
echo "--- streamed $((t1 - t0))s of ${DUR}s" >> "$ERR"
|
||||
Reference in New Issue
Block a user