#!/bin/sh


usage()
{
    echo "usage: $0 out-dir [tx-power]" 1>&2
    exit 1
}


[ "$1" ] || usage
[ "${1#-}" = "$1" ] || usage
[ "$3" ] && usage
mkdir "$1" || exit
pwr=${2:-2.6}

unset DISPLAY

if [ "${1#/}" = "$1" ]; then
    abs=`pwd`/$1
else
    abs=$1
fi

for a in 0 1 2 3 4 5 6 7 8 9; do
    for b in 0 1 2 3 4 5 6 7 8 9; do
	f=2405
	while [ $f -le 2480 ]; do
	    echo -e $a$b $f MHz '\r'
	    mkdir -p "$1/$f"
	    atrf-txrx -f $f -p $pwr -T +0.5 \
	      "ssh ws usrp2_rx_cfile.py -d 16 -f $f.5M -g 46 -N 1124 \
	         $abs/$f/data$a$b"
	    f=`expr $f + 5`
	done
    done
done