File: ofdm_time_sync.sh

package info (click to toggle)
codec2 1.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 121,056 kB
  • sloc: ansic: 414,118; sh: 2,612; objc: 2,574; python: 2,105; cpp: 2,091; asm: 683; makefile: 598
file content (30 lines) | stat: -rwxr-xr-x 1,158 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
# Shell script version of ofdm_time_sync()
# David June 2019
# Tests ofdm modem sync time, using real, off air files

onerun=$(mktemp)
results=$(mktemp)

# bunch of runs at different time offsets into a sample off air file with low SNR and semi-staionary fading
for start_secs in `seq 0 29`;
do
    if [ "$1" = "700D" ]; then
        ofdm_demod --in ../wav/vk2tpm_004.wav --out /dev/null --verbose 2 --ldpc \
                   --start_secs $start_secs --len_secs 5 2>/dev/null > $onerun
    fi;
    if [ "$1" = "2020" ]; then
        ofdm_demod --mode 2020 --in ../wav/david4.wav --out /dev/null --verbose 2 --ldpc \
                   --start_secs $start_secs  --len_secs 5 2>/dev/null > $onerun
    fi;
    [ ! $? -eq 0 ] && { echo "error running ofdm_demod"; exit 1; }
    cat $onerun | sed -n "s/time_to_sync: \([0-9..]*\)/\1/p" >> $results
done
# a pass is we never take longer than 5 secs to sync (mean is much smaller)
python3 -c "
import sys; import numpy as np
x=np.loadtxt(\"$results\")
fails=sum(x == -1)
print(\"fails: %d mean: %5.2f var: %5.2f \" % (fails, np.mean(x), np.var(x)))
sys.exit(0) if fails==0 else sys.exit(1)
"