diff options
| author | drowe67 <[email protected]> | 2023-07-13 10:50:29 +0930 |
|---|---|---|
| committer | David Rowe <[email protected]> | 2023-07-13 10:50:29 +0930 |
| commit | 9f818a0dce90067e321ee605319136119aa7f1d4 (patch) | |
| tree | 3d02943a790eca5ba79a52ca127e8707779da926 /unittest | |
| parent | 6a7f3772824a4a54df4237f124a4956dcaebe49f (diff) | |
rm-ed unused unittest/*.sh
Diffstat (limited to 'unittest')
| -rwxr-xr-x | unittest/ofdm_fade_dpsk.sh | 15 | ||||
| -rwxr-xr-x | unittest/ota_auto.sh | 15 | ||||
| -rwxr-xr-x | unittest/ota_last.sh | 70 | ||||
| -rwxr-xr-x | unittest/ota_summary.sh | 55 | ||||
| -rwxr-xr-x | unittest/ota_test.sh | 161 | ||||
| -rwxr-xr-x | unittest/ota_voice_auto.sh | 23 | ||||
| -rwxr-xr-x | unittest/ota_voice_summary.sh | 80 | ||||
| -rwxr-xr-x | unittest/ota_voice_test.sh | 309 | ||||
| -rwxr-xr-x | unittest/spectrogram.sh | 17 | ||||
| -rwxr-xr-x | unittest/tnc1_high_snr.sh | 103 | ||||
| -rwxr-xr-x | unittest/tnc4_high_snr_ping.sh | 114 |
11 files changed, 0 insertions, 962 deletions
diff --git a/unittest/ofdm_fade_dpsk.sh b/unittest/ofdm_fade_dpsk.sh deleted file mode 100755 index 18e38bb..0000000 --- a/unittest/ofdm_fade_dpsk.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -# -# David Sep 2019 -# Tests 2020 OFDM modem fading channel performance in DPSK mode, using a simulated faster (2Hz) high SNR fading channel - -fading_dir=$1 -results=$(mktemp) - -# Coded BER should be < 1% for this test -ofdm_mod --in /dev/zero --testframes 300 --mode 2020 --ldpc --verbose 1 --dpsk | \ -ch - - --No -40 -f 10 --ssbfilt 1 --mpd --fading_dir $fading_dir --multipath_delay 2 | \ -ofdm_demod --out /dev/null --testframes --mode 2020 --verbose 1 --ldpc --dpsk 2> $results -cat $results -cber=$(cat $results | sed -n "s/^Coded BER.* \([0-9..]*\) Tbits.*/\1/p") -python3 -c "import sys; sys.exit(0) if $cber<=0.05 else sys.exit(1)" diff --git a/unittest/ota_auto.sh b/unittest/ota_auto.sh deleted file mode 100755 index b6355ba..0000000 --- a/unittest/ota_auto.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -# ota_auto.sh -# -# Run a single automated test and log results - -timestamp=$(date +"%F-%T") -mkdir -p $timestamp -start_dir=$(pwd) -cd $timestamp -../ota_test.sh "$@" >> log.txt 2>&1 -cd $start_dir -kiwi_sdr=$(head -n 1 ${timestamp}/log.txt) -mode=$(head -n 2 ${timestamp}/log.txt | tail -n 1) -result=$(awk '/FrmGd/{getline; print}' ${timestamp}/log.txt) -printf "%s %-25s %s %s\n" $timestamp $kiwi_sdr $mode "$result" >> log.txt diff --git a/unittest/ota_last.sh b/unittest/ota_last.sh deleted file mode 100755 index 31efa1c..0000000 --- a/unittest/ota_last.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash -# -# Present summary info from the n-th latest OTA HF data test - -function print_help { - echo - echo "Summary of last automated Over The Air (OTA) test" - echo - echo " usage ./ota_last.sh [options]" - echo - echo " -a show scatter diagram" - echo " -p play the received wave file" - echo " -n N select N-th from last file" - echo " -s display spectrogram" -} - -show_spec=0 -show_scatter=0 -play_file=0 -N=1 - -while [[ $# -gt 0 ]] -do -key="$1" -case $key in - -n) - N="$2" - shift - shift - ;; - -a) - show_scatter=1 - shift - ;; - -s) - show_spec=1 - shift - ;; - -p) - play_file=1 - shift - ;; - -h) - print_help - ;; -esac -done - -# cat the log from the selected test -directory=$(ls -td 2021* | head -n ${N} | tail -n 1) -echo ${directory} -cat ${directory}/log.txt - -# optionally show a few plots - -if [ $show_spec -eq 1 ]; then - if [ -f ${directory}/spec.png ]; then - eog ${directory}/spec.png - else - eog ${directory}/spec.jpg - fi -fi - -if [ $show_scatter -eq 1 ]; then - eog ${directory}/scatter.png -fi - -if [ $play_file -eq 1 ]; then - play ${directory}/rx.wav -fi diff --git a/unittest/ota_summary.sh b/unittest/ota_summary.sh deleted file mode 100755 index 5e028e3..0000000 --- a/unittest/ota_summary.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -# -# Summarise tests to date - -CODEC2=${HOME}/codec2 - -function print_help { - echo - echo "Automated Over The Air (OTA) data test for FreeDV OFDM HF data modems" - echo - echo " usage ./ota_summary.sh [-t]" - echo - echo " -t create/update thumbnail directory" - exit 0 -} - -thumbnails=0 -while [[ $# -gt 0 ]] -do -key="$1" -case $key in - -t) - thumbnails=1 - shift - ;; - -h) - print_help - ;; -esac -done - -total_bytes=$(cat log.txt | tr -s ' ' | cut -f6 -d' ' | awk '$0==($0+0)' | paste -sd+ | bc) -printf "total bytes: %'d\n" ${total_bytes} - -# collect SNR averages from log.txt and generate a histogram -ota_snrs=mktemp -cat log.txt | tr -s ' ' | cut -f7 -d' ' | awk '$0==($0+0)'| sed '/-nan/d' > ${ota_snrs} -echo "warning('off', 'all'); \ - snr=load('${ota_snrs}'); \ - hist(snr); \ - print('snr_hist.png','-dpng'); \ - quit" | octave-cli -qf > /dev/null - -# option to put small versions of spec/scatter in one dir - -if [ $thumbnails -ne 0 ]; then - mkdir -p thumbnails - spec_files=$(find . -name spec.jpg -o -name spec.png) - for f in $spec_files - do - d=$(echo $f | sed -r 's/\.(.*)\//\1_/') - echo $f thumbnails${d} - cp $f thumbnails${d} - done -fi diff --git a/unittest/ota_test.sh b/unittest/ota_test.sh deleted file mode 100755 index 37b6ac0..0000000 --- a/unittest/ota_test.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env bash -# ota_test.sh -# -# Automated Over The Air (OTA) data test for FreeDV OFDM HF data modems -# -# 1. Build codec2 -# 2. Install kiwclient: -# cd ~ && git clone [email protected]:jks-prv/kiwiclient.git -# 3. Install Hamlib cli tools - -PATH=${PATH}:${HOME}/codec2/build_linux/src:${HOME}/kiwiclient -CODEC2=${HOME}/codec2 - -kiwi_url="" -port=8073 -freq_kHz="7177" -tx_only=0 -Nbursts=5 -mode="datac0" -model=361 - -function print_help { - echo - echo "Automated Over The Air (OTA) data test for FreeDV OFDM HF data modems" - echo - echo " usage ./ota_test.sh [-d] [-f freq_kHz] [-t] [-n Nbursts] [-o model] [-p port] kiwi_url" - echo - echo " -d debug mode; trace script execution" - echo " -o model select radio model number ('rigctl -l' to list)" - echo " -m mode datac0|datac1|datac3" - echo " -t Tx only, useful for manually observing SDRs which block multiple sessions from one IP" - echo - exit -} - -function run_rigctl { - command=$1 - model=$2 - echo $command | rigctl -m $model -r /dev/ttyUSB0 > /dev/null - if [ $? -ne 0 ]; then - echo "Can't talk to Tx" - exit 1 - fi -} - -POSITIONAL=() -while [[ $# -gt 0 ]] -do -key="$1" -case $key in - -d) - set -x - shift - ;; - -f) - freq_kHz="$2" - shift - shift - ;; - -o) - model="$2" - shift - shift - ;; - -m) - mode="$2" - shift - shift - ;; - -n) - Nbursts="$2" - shift - shift - ;; - -p) - port="$2" - shift - shift - ;; - -t) - tx_only=1 - shift - ;; - -h) - print_help - ;; - *) - POSITIONAL+=("$1") # save it in an array for later - shift - ;; -esac -done -set -- "${POSITIONAL[@]}" # restore positional parameters - -if [ $tx_only -eq 0 ]; then - if [ $# -lt 1 ]; then - print_help - fi - kiwi_url="$1" - echo $kiwi_url -fi - -# create test Tx file -echo $mode -freedv_data_raw_tx -q --framesperburst 1 --bursts ${Nbursts} --testframes ${Nbursts} ${mode} /dev/zero test_datac0.raw - -usb_lsb=$(python3 -c "print('usb') if ${freq_kHz} >= 10000 else print('lsb')") - -if [ $tx_only -eq 0 ]; then - echo -n "waiting for KiwiSDR " - # start recording from remote kiwisdr - kiwi_stdout=$(mktemp) - kiwirecorder.py -s $kiwi_url -p ${port} -f $freq_kHz -m ${usb_lsb} -r 8000 --filename=rx --time-limit=300 >$kiwi_stdout & - kiwi_pid=$! - - # wait for kiwi to start recording - timeout_counter=0 - until grep -q -i 'Block: ' $kiwi_stdout - do - timeout_counter=$((timeout_counter+1)) - if [ $timeout_counter -eq 10 ]; then - echo "can't connect to ${kiwi_url}" - exit 1 - fi - echo -n "." - sleep 1 - done - echo -fi - -# transmit using local SSB radio -echo "Tx data signal" -freq_Hz=$((freq_kHz*1000)) -usb_lsb_upper=$(echo ${usb_lsb} | awk '{print toupper($0)}') -run_rigctl "\\set_mode PKT${usb_lsb_upper} 0" $model -run_rigctl "\\set_freq ${freq_Hz}" $model -run_rigctl "\\set_ptt 1" $model -aplay --device="plughw:CARD=CODEC,DEV=0" -f S16_LE test_datac0.raw 2>/dev/null -run_rigctl "\\set_ptt 0" $model - -if [ $tx_only -eq 0 ]; then - sleep 2 - echo "Stopping KiwiSDR" - kill ${kiwi_pid} - wait ${kiwi_pid} 2>/dev/null - - echo "Process receiver sample" - # generate spectrogram - echo "pkg load signal; warning('off', 'all'); \ - s=load_raw('rx.wav'); \ - plot_specgram(s, 8000, 500, 2500); print('spec.jpg', '-djpg'); \ - quit" | octave-cli -p ${CODEC2}/octave -qf > /dev/null - # attempt to demodulate - freedv_data_raw_rx -q --framesperburst 1 --testframes ${mode} -v --scatter scatter.txt --singleline rx.wav /dev/null - # render scatter plot (if we get any frames) - scatter_sz=$(ls -l scatter.txt | cut -f 5 -d' ') - if [ $scatter_sz -ne 0 ]; then - echo "pkg load signal; warning('off', 'all'); pl_scatter('scatter.txt'); quit" | octave-cli -p ${CODEC2}/octave -qf > /dev/null - fi -fi - diff --git a/unittest/ota_voice_auto.sh b/unittest/ota_voice_auto.sh deleted file mode 100755 index c741f2d..0000000 --- a/unittest/ota_voice_auto.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -# ota_voice_auto.sh -# -# Run a single automated voice test, files are put in a time stamped -# directory, and summarised in single line in the log file -# log_voice.txt. Designed to be used from cron. - -# use crontab -e to edit cron for current user, sample entry: - -# m h dom mon dow command -# */10 6-12 24 4 * cd codec2/unittest; ./ota_voice_auto.sh ~/your_speech_file.s16 your.kiwi.sdr - -timestamp=$(date +"%F-%T") -mkdir -p $timestamp -start_dir=$(pwd) -cd $timestamp -../ota_voice_test.sh "$@" > log.txt 2>&1 -cd $start_dir -kiwi_sdr=$(head -n 1 ${timestamp}/log.txt) -mode=$(head -n 2 ${timestamp}/log.txt | tail -n 1) -Nsync=$(cat ${timestamp}/log.txt | grep Nsync | tr -s ' ' | cut -d' ' -f2) -SNRav=$(cat ${timestamp}/log.txt | grep SNRav | tr -s ' ' | cut -d' ' -f2) -printf "%s %-25s %s %3d %5.2f\n" $timestamp $kiwi_sdr $mode $Nsync $SNRav >> log_voice.txt diff --git a/unittest/ota_voice_summary.sh b/unittest/ota_voice_summary.sh deleted file mode 100755 index 62014fd..0000000 --- a/unittest/ota_voice_summary.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash -# -# Summarise tests to date into one directory to allow easy browsing - -src=/home/david/Downloads/speech_orig_16k.wav -length_src=$(sox $src -n stat 2>&1 | grep Length | sed -r 's/.*\:\s*//') - -dir=voice_summary -mkdir -p ${dir} -time_snr_files=$(find . -name time_snr.jpg | sort) -p=$(pwd) -serial=0 - -echo "<table>" -echo "<tr>" -echo "<th>Serial</th><th>Mode</th><th>KiwiSDR</th><th>Rx</th><th>AnDV</th><th>DV</th><th>Spectrogram</th><th>SNR</th>" -echo "</tr>" - -for f in $time_snr_files -do - d=$(echo $f | sed -r 's/\.\/(.*)\/time_snr.jpg/\1/') - sdr_url=$(head ${d}/log.txt -n 1) - sdr="unk" - case $sdr_url in - "kiwisdr.areg.org.au") - sdr="areg" - ;; - "sdr-amradioantennas.com") - sdr="am" - ;; - "vk6qs.proxy.kiwisdr.com") - sdr="vk6qs" - ;; - "sdr.ironstonerange.com") - sdr="iron" - ;; - "kk6pr.ddns.net") - sdr="kk6pr" - ;; - "kiwisdr.owdjim.gen.nz") - sdr="marahau" - ;; - "kiwisdrzl1kfm.ddns.net") - sdr="zl1kfm" - ;; - *) - echo "Unknown Kiwi SDR" - ;; - esac - mode=$(head ${d}/log.txt -n 2 | tail -n 1) - serial_str=$(printf "%04d" $serial) - #echo $serial_str $d $sdr $mode - echo "<tr>" - echo "<td>$serial</td>" - echo "<td>$mode</td>" - echo "<td>$sdr</td>" - - f=${dir}/${serial_str}_${d}_${sdr}_${mode} - f1=${serial_str}_${d}_${sdr}_${mode} - - cp ${d}/rx.wav ${f}_rx.wav - echo "<td><a href=\"${f1}_rx.wav\">Rx</td>" - - cp ${d}/rx_freedv.wav ${f}_rx_freedv.wav - echo "<td><a href=\"${f1}_rx_freedv.wav\">AnDV</td>" - - length_f=$(sox ${f}_rx_freedv.wav -n stat 2>&1 | grep Length | sed -r 's/.*\:\s*//') - start_dv=$(python -c "print(${length_f}-${length_src}-2)") - sox ${d}/rx_freedv.wav ${f}_rx_freedv_dv.wav trim $start_dv $length_src - echo "<td><a href=\"${f1}_rx_freedv_dv.wav\">DV</td>" - - cp ${d}/spec.jpg ${f}_spec.jpg - echo "<td><img src=\"${f1}_spec.jpg\" width="200" height="200" /></td>" - cp ${d}/time_snr.jpg ${f}_time_snr.jpg - echo "<td><img src=\"${f1}_time_snr.jpg\" width="200" height="200" /></td>" - echo "</tr>" - serial=$((serial + 1)) -done - -echo "</table>" diff --git a/unittest/ota_voice_test.sh b/unittest/ota_voice_test.sh deleted file mode 100755 index 4f502ec..0000000 --- a/unittest/ota_voice_test.sh +++ /dev/null @@ -1,309 +0,0 @@ -#!/usr/bin/env bash -# ota_voice_test.sh -# -# Automated Over The Air (OTA) voice test for FreeDV HF voice modes -# -# 1. Build codec2 -# 2. Install kiwclient: -# cd ~ && git clone [email protected]:jks-prv/kiwiclient.git -# 3. Install Hamlib cli tools, and add user to dialout group: -# sudo adduser david dialout -# 4. To test rigctl: -# echo "m" | rigctl -m 361 -r /dev/ttyUSB0 -# 5. Adjust Tx drive so ALC is just being tickled, set desired RF power: -# ../build_linux/src/freedv_tx 2020 ~/Downloads/speech_orig_16k.wav - | aplay -f S16_LE --device="plughw:CARD=CODEC,DEV=0" -# 6. Sample command line: -# ./ota_voice_test.sh ~/Downloads/speech_orig_16k.wav -m 700E -i ~/Downloads/vk5dgr_testing_8k.wav sdr.ironstonerange.com -p 8074 - -MY_PATH=`dirname $0` -BUILD_PATH=`echo $MY_PATH/../build_*/src` -PATH=${PATH}:${BUILD_PATH}:${HOME}/kiwiclient -CODEC2=${MY_PATH}/.. - -kiwi_url="" -port=8074 -freq_kHz="7177" -tx_only=0 -Nbursts=5 -mode="700D" -model=361 -gain=6 -serialPort="/dev/ttyUSB0" -rxwavefile=0 -soundDevice="plughw:CARD=CODEC,DEV=0" -txstats=0 -stationid="" - -function print_help { - echo - echo "Automated Over The Air (OTA) voice test for FreeDV HF voice modes" - echo - echo " usage ./ota_voice_test.sh [options] SpeechWaveFile [kiwi_url]" - echo " or:" - echo " usage ./ota_voice_test.sh -r rxWaveFile" - echo - echo " -c dev The sound device (in ALSA format on Linux, CoreAudio for macOS)" - echo " -d debug mode; trace script execution" - echo " -f Frequency (kHz)" - echo " -g SSB (analog) compressor gain" - echo " -i StationIDWaveFile Prepend this file to identify transmission (should be 8KHz mono)" - echo " -m mode 700c|700d|700e" - echo " -o model select radio model number ('rigctl -l' to list)" - echo " -p port kiwi_url port to use (default 8073)." - echo " -r Rx wave file mode: Rx process supplied rx wave file" - echo " -s SerialPort The serial port (or hostname:port) to control SSB radio," - echo " default /dev/ttyUSB0" - echo " -t Tx only, useful for manually observing SDRs" - echo " -x Generate tx.wav file and exit" - echo - exit -} - -# Approximation of Hilbert clipper type compressor. Could do with some HF boost -function analog_compressor { - input_file=$1 - output_file=$2 - gain=$3 - cat $input_file | ch - - 2>/dev/null | \ - ch - - --No -100 --clip 16384 --gain $gain 2>/dev/null | \ - # final line prints peak and CPAPR for SSB - ch - - --clip 16384 | - # manually adjusted to get similar peak levels for SSB and FreeDV - sox -t .s16 -r 8000 -c 1 -v 0.85 - -t .s16 $output_file -} - -function run_rigctl { - command=$1 - model=$2 - echo $command | rigctl -m $model -r $serialPort > /dev/null - if [ $? -ne 0 ]; then - echo "Can't talk to Tx" - clean_up - exit 1 - fi -} - -function clean_up { - echo "killing KiwiSDR process" - kill ${kiwi_pid} - wait ${kiwi_pid} 2>/dev/null - exit 1 -} - -function process_rx { - echo "Process receiver sample" - rx=$1 - # generate spectrogram - echo "pkg load signal; warning('off', 'all'); \ - s=load_raw('${rx}'); \ - plot_specgram(s, 8000, 200, 3000); print('spec.jpg', '-djpg'); \ - quit" | octave-cli -p ${CODEC2}/octave -qf > /dev/null - # attempt to decode - freedv_rx ${mode} ${rx} - -v --passthroughgain 1.0 2>rx_stats.txt | sox -t .s16 -r $speechFs -c 1 - rx_freedv.wav - cat rx_stats.txt | tr -s ' ' | cut -f5 -d' ' | awk '$0==($0+0)' > sync.txt - cat rx_stats.txt | tr -s ' ' | cut -f10 -d' ' | awk '$0==($0+0)' > snr.txt - # time domain plot of output speech, SNR, and sync - echo "pkg load signal; warning('off', 'all'); \ - s=load_raw('rx_freedv.wav'); snr=load('snr.txt'); sync=load('sync.txt'); \ - subplot(211); plot(s); subplot(212); x=1:length(sync); plotyy(x,snr,x,sync); \ - ylim([-5 15]); ylabel('SNR (dB)'); grid; \ - print('time_snr.jpg', '-djpg'); \ - printf('Nsync: %3d\n', sum(sync)); \ - snr_valid = snr(find(snr != -5.0)); \ - if length(snr_valid) printf('SNRav: %5.2f\n', mean(snr_valid)); else printf('SNRav: %5.2f\n', -5); end; - quit" | octave-cli -p ${CODEC2}/octave -qf -} - -POSITIONAL=() -while [[ $# -gt 0 ]] -do -key="$1" -case $key in - -d) - set -x - shift - ;; - -f) - freq_kHz="$2" - shift - shift - ;; - -g) - gain="$2" - shift - shift - ;; - -i) - stationid="$2" - shift - shift - ;; - -o) - model="$2" - shift - shift - ;; - -m) - mode="$2" - shift - shift - ;; - -p) - port="$2" - shift - shift - ;; - -t) - tx_only=1 - shift - ;; - -r) - rxwavefile=1 - shift - ;; - -x) - txstats=1 - shift - ;; - -c) - soundDevice="$2" - shift - shift - ;; - -s) - serialPort="$2" - shift - shift - ;; - -h) - print_help - ;; - *) - POSITIONAL+=("$1") # save it in an array for later - shift - ;; -esac -done -set -- "${POSITIONAL[@]}" # restore positional parameters - -# determine sample rate of freedv_tx/freedv_rx -speechFs=8000 -if [ "$mode" == "2020" ] || [ "$mode" == "2020B" ] || [ "$mode" == "2020C" ]; then - speechFs=16000 -fi - -if [ $rxwavefile -eq 1 ]; then - process_rx $1 - exit 0 -fi - -speechfile="$1" -if [ ! -f $speechfile ]; then - echo "Can't find input speech wave file: ${speechfile}!" - exit 1 -fi - -if [ $tx_only -eq 0 ]; then - if [ $# -lt 1 ]; then - print_help - fi - kiwi_url="$2" - echo $kiwi_url -fi - -# create Tx file ------------------------ -echo $mode - -# create compressed analog -speechfile_raw_8k=$(mktemp) -comp_in=$(mktemp) -speech_comp=$(mktemp) -speech_freedv=$(mktemp) -# If 16kHz input files for 2020x, we need an 8kHz version for SSB -sox $speechfile -r 8000 -t .s16 -c 1 $speechfile_raw_8k -if [ -z $stationid ]; then - cp $speechfile_raw_8k $comp_in -else - # append station ID and apply analog compression - stationid_raw_8k=$(mktemp) - sox $stationid -r 8000 -t .s16 -c 1 $stationid_raw_8k - cat $stationid_raw_8k $speechfile_raw_8k> $comp_in -fi -analog_compressor $comp_in $speech_comp $gain - -# create modulated FreeDV, with compressor enabled -sox $speechfile -t .s16 -r $speechFs - | freedv_tx $mode - $speech_freedv --clip 1 -cat $speech_comp $speech_freedv > tx.raw -sox -t .s16 -r 8000 -c 1 tx.raw tx.wav - -if [ $txstats -eq 1 ]; then - # ch just used to monitor observe peak and RMS level - ch $speech_freedv /dev/null - # time domain plot of tx signal - echo "pkg load signal; warning('off', 'all'); \ - s=load_raw('tx.raw'); plot(s); \ - print('tx.jpg', '-djpg'); \ - quit" | octave-cli -p ${CODEC2}/octave -qf > /dev/null - exit 0 -fi - -# kick off KiwiSDR ---------------------------- - -usb_lsb=$(python3 -c "print('usb') if ${freq_kHz} >= 10000 else print('lsb')") -if [ $tx_only -eq 0 ]; then - # clean up any kiwiSDR processes if we get a ctrl-C - trap clean_up SIGHUP SIGINT SIGTERM - - echo -n "waiting for KiwiSDR " - # start recording from remote kiwisdr - kiwi_stdout=$(mktemp) - kiwirecorder.py -s $kiwi_url -p ${port} -f $freq_kHz -m ${usb_lsb} -r 8000 --filename=rx --time-limit=300 >$kiwi_stdout & - kiwi_pid=$! - - # wait for kiwi to start recording - timeout_counter=0 - until grep -q -i 'Block: ' $kiwi_stdout - do - timeout_counter=$((timeout_counter+1)) - if [ $timeout_counter -eq 10 ]; then - echo "can't connect to ${kiwi_url}" - kill ${kiwi_pid} - wait ${kiwi_pid} 2>/dev/null - exit 1 - fi - echo -n "." - sleep 1 - done - echo -fi - -# transmit using local SSB radio -echo "Tx data signal" -freq_Hz=$((freq_kHz*1000)) -usb_lsb_upper=$(echo ${usb_lsb} | awk '{print toupper($0)}') -run_rigctl "\\set_mode PKT${usb_lsb_upper} 0" $model -run_rigctl "\\set_freq ${freq_Hz}" $model -run_rigctl "\\set_ptt 1" $model -if [ `uname` == "Darwin" ]; then - AUDIODEV="${soundDevice}" play -t raw -b 16 -c 1 -r 8000 -e signed-integer --endian little tx.raw -else - aplay --device="${soundDevice}" -f S16_LE tx.raw 2>/dev/null -fi -if [ $? -ne 0 ]; then - run_rigctl "\\set_ptt 0" $model - clean_up - echo "Problem running aplay!" - echo "Is ${soundDevice} configured as the default sound device in Settings-Sound?" - exit 1 -fi -run_rigctl "\\set_ptt 0" $model - -if [ $tx_only -eq 0 ]; then - sleep 2 - echo "Stopping KiwiSDR" - kill ${kiwi_pid} - wait ${kiwi_pid} 2>/dev/null - - process_rx rx.wav -fi - diff --git a/unittest/spectrogram.sh b/unittest/spectrogram.sh deleted file mode 100755 index 87d3fa2..0000000 --- a/unittest/spectrogram.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -# spectrogram.sh -# -# Render a spectrogram from a wave file. - -PATH=${PATH}:${HOME}/codec2/build_linux/src -CODEC2=${HOME}/codec2 - -fullfile=$1 -filename=$(basename -- "$fullfile") -extension="${filename##*.}" -filename="${filename%.*}" - -echo "pkg load signal; warning('off', 'all'); \ - s=load_raw('${fullfile}'); \ - plot_specgram(s, 8000, 500, 2500); print('${filename}.jpg', '-djpg'); \ - quit" | octave-cli -p ${CODEC2}/octave -qf > /dev/null diff --git a/unittest/tnc1_high_snr.sh b/unittest/tnc1_high_snr.sh deleted file mode 100755 index e9a028a..0000000 --- a/unittest/tnc1_high_snr.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env bash -# tnc1_high_snr.sh -# -# HF TNC use case test 1 -# + Send unidirectional frames at high SNR over an alsa loopback virtual sound card -# + Using the sound card can take some time, so implemented as a service to run automatically in background - -NAME=tnc1 -CODEC2_PATH=${HOME}/codec2 -PIDFILE_TX=/tmp/${NAME}_tx.pid -PIDFILE_RX=/tmp/${NAME}_rx.pid -LOGFILE=${NAME}.log -PATH=${CODEC2_PATH}/build_linux/src:${PATH} -DELAY="${DELAY:-500}" -MAX_RUN_TIME=3600 -# we use single frame bursts, so BURSTS==FRAME -BURSTS=$2 - -function run_tx { - bursts=$1 - delay=$2 - freedv_data_raw_tx DATAC0 /dev/zero - --testframes ${bursts} --bursts ${bursts} --delay ${delay} | aplay --device="plughw:CARD=CHAT2,DEV=1" -f S16_LE -} - -function start_rx_background { - arecord --device="plughw:CARD=CHAT2,DEV=0" -f S16_LE -d $MAX_RUN_TIME | freedv_data_raw_rx DATAC0 - /dev/null --framesperburst 1 --vv --testframes & - echo $!>${PIDFILE_RX} -} - -function stop_service { - echo "service stopping - bye!" 1>&2 - if [ -e ${PIDFILE_RX} ]; then - pid_rx=$(cat ${PIDFILE_RX}) - rm ${PIDFILE_RX} - kill ${pid_rx} - fi - - if [ -e ${PIDFILE_TX} ]; then - pid_tx=$(cat ${PIDFILE_TX}) - rm ${PIDFILE_TX} - kill ${pid_tx} - fi -} - -function check_running { - if [ -e ${PIDFILE_TX} ]; then - echo "Tx already running... pid: ${PIDFILE_TX}" - exit 1 - fi - if [ -e ${PIDFILE_RX} ]; then - echo "Rx already running... pid: ${PIDFILE_RX}" - exit 1 - fi -} - -function check_alsa_loopback { - lsmod | grep snd_aloop >> /dev/null - if [ $? -eq 1 ]; then - echo "ALSA loopback device not present. Please install with:" - echo - echo " sudo modprobe snd-aloop index=1,2 enable=1,1 pcm_substreams=1,1 id=CHAT1,CHAT2" - exit 1 - fi -} - -case "$1" in - start) - check_running - check_alsa_loopback - ( start_rx_background && sleep 1 && run_tx ${BURSTS} ${DELAY} && stop_service ) 2>${LOGFILE} & - echo $!>${PIDFILE_TX} - echo "Results in ${LOGFILE}" - ;; - start_verbose) - set -x - check_running - check_alsa_loopback - # Show all outputs and log output to stderr rather than logfile - verbose=1 - start_rx_background && sleep 1 && run_tx ${BURSTS} ${DELAY} && stop_service - ;; - stop) - stop_service - ;; - restart) - $0 stop - $0 start - ;; - status) - if [ -e ${PIDFILE_TX} ]; then - echo ${NAME} is running, pid=`cat ${PIDFILE_TX}` - else - echo ${NAME} is NOT running - exit 1 - fi - ;; - *) - echo "Usage: $0 {start|start_verbose|stop|restart|status} NumFrames" - echo " $0 start_verbose 1 - 1 frame packet verbose, logs to stderr" - echo " $0 start 5 - 5 frames, run as service in background, logs sent to ${LOGFILE}" -esac - -exit 0 diff --git a/unittest/tnc4_high_snr_ping.sh b/unittest/tnc4_high_snr_ping.sh deleted file mode 100755 index d9bee07..0000000 --- a/unittest/tnc4_high_snr_ping.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env bash -# tnc4_high_snr_ping.sh -# -# HF TNC use case test 4 -# + Terminal 1 sends frames to Terminal 2 -# + Terminal 2 receives frames and re-transmits them back to Terminal 1 -# + Terminal 1 and 2 count number of frames received (see logfiles) -# + The modem samples are sent over virtual sound cards, this runs in real time, which -# can be slow for tests involving many packets. Therefore this test is implemented as a -# service script. - -NAME=tnc4 -CODEC2_PATH=${HOME}/codec2 -PIDFILE_TX1=/tmp/${NAME}_tx1.pid -PIDFILE_RX1=/tmp/${NAME}_rx1.pid -PIDFILE_RX2=/tmp/${NAME}_rx2.pid -LOGFILE1=${NAME}_1.log -LOGFILE2=${NAME}_2.log -PATH=${CODEC2_PATH}/build_linux/src:${PATH} -DELAY="${DELAY:-500}" -MAX_RUN_TIME=3600 -# in this version we use single frame bursts, so BURSTS==FRAMES -BURSTS=$2 -MODE=DATAC0 - -function tx1 { - freedv_data_raw_tx ${MODE} /dev/zero - --testframes ${BURSTS} --bursts ${BURSTS} --delay ${DELAY} | aplay --device="plughw:CARD=CHAT2,DEV=1" -f S16_LE -} - -function rx2_background { - # re-transmit any frames we receive - ( arecord --device="plughw:CARD=CHAT2,DEV=0" -f S16_LE -d $MAX_RUN_TIME | \ - freedv_data_raw_rx ${MODE} - - --framesperburst 1 --vv --testframes | \ - freedv_data_raw_tx ${MODE} - - --delay ${DELAY} | \ - aplay --device="plughw:CARD=CHAT1,DEV=1" -f S16_LE ) 2>${LOGFILE2} & - # killing arecord kills the entire pipeline - echo $(pidof arecord)>${PIDFILE_RX2} -} - -function rx1_background { - arecord --device="plughw:CARD=CHAT1,DEV=0" -f S16_LE -d $MAX_RUN_TIME | freedv_data_raw_rx ${MODE} - /dev/null --framesperburst 1 --vv --testframes & - echo $!>${PIDFILE_RX1} -} - -function stop_process { - if [ -e ${1} ]; then - pid=$(cat ${1}) - rm ${1} - kill ${pid} - fi -} - -function stop_service { - echo "service stopping - bye!" 1>&2 - stop_process ${PIDFILE_RX1} - stop_process ${PIDFILE_RX2} - stop_process ${PIDFILE_TX1} -} - -function check_running { - if [ -e ${PIDFILE_TX1} ]; then - echo "Tx already running... pid: ${PIDFILE_TX1}" - exit 1 - fi - if [ -e ${PIDFILE_RX1} ]; then - echo "Rx1 already running... pid: ${PIDFILE_RX1}" - exit 1 - fi - if [ -e ${PIDFILE_RX2} ]; then - echo "Rx2 already running... pid: ${PIDFILE_RX2}" - exit 1 - fi -} - -function check_alsa_loopback { - lsmod | grep snd_aloop >> /dev/null - if [ $? -eq 1 ]; then - echo "ALSA loopback device not present. Please install with:" - echo - echo " sudo modprobe snd-aloop index=1,2 enable=1,1 pcm_substreams=1,1 id=CHAT1,CHAT2" - exit 1 - fi -} - -case "$1" in - start) - check_running - check_alsa_loopback - rx2_background - ( rx1_background && sleep 1 && tx1 && sleep 5 && stop_service ) 2>${LOGFILE1} & - echo $!>${PIDFILE_TX1} - echo "Results for terminal 1 in ${LOGFILE1} and terminal 2 in ${LOGFILE2}" - ;; - stop) - stop_service - ;; - restart) - $0 stop - $0 start - ;; - status) - if [ -e ${PIDFILE_TX1} ]; then - echo ${NAME} is running, pid=`cat ${PIDFILE_TX1}` - else - echo ${NAME} is NOT running - exit 1 - fi - ;; - *) - echo "Usage: $0 {start|start_verbose|stop|restart|status} NumFrames" - echo " $0 start 5 - test ping over 5 frames; logs sent to ${LOGFILE1} and ${LOGFILE2}" -esac - -exit 0 |
