Skip to content

Commit 5e49042

Browse files
committed
first pass at building fade files as part of unittests
1 parent 837495b commit 5e49042

File tree

7 files changed

+36
-47
lines changed

7 files changed

+36
-47
lines changed

CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ endif()
152152
#
153153
option(BUILD_SHARED_LIBS
154154
"Build shared library. Set to OFF for static library." ON)
155-
# Unittest should be on for dev builds and off for releases.
156155
option(UNITTEST "Build unittest binaries." OFF)
157156
option(INSTALL_EXAMPLES "Install example code." OFF)
158157
if(INSTALL_EXAMPLES)
@@ -513,15 +512,15 @@ if(UNITTEST)
513512

514513
add_test(NAME test_OFDM_modem_fading_BER
515514
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
516-
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_fade.sh")
515+
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_fade.sh ${CMAKE_CURRENT_BINARY_DIR}/unittest")
517516

518517
add_test(NAME test_OFDM_modem_phase_est_bw
519518
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
520-
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_phase_est_bw.sh")
519+
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_phase_est_bw.sh ${CMAKE_CURRENT_BINARY_DIR}/unittest")
521520

522521
add_test(NAME test_OFDM_modem_fading_DPSK_BER
523522
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;
524-
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_fade_dpsk.sh")
523+
PATH=$PATH:${CMAKE_CURRENT_BINARY_DIR}/src ./ofdm_fade_dpsk.sh ${CMAKE_CURRENT_BINARY_DIR}/unittest")
525524

526525
add_test(NAME test_OFDM_modem_time_sync_700D
527526
COMMAND sh -c "cd ${CMAKE_CURRENT_SOURCE_DIR}/unittest;

unittest/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,15 @@ ExternalProject_Add(cml
104104
PATCH_COMMAND patch -N -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/../octave/cml.patch || true
105105
BUILD_COMMAND cd ${CMAKE_CURRENT_BINARY_DIR}/../cml/source && CC="${CMAKE_CXX_COMPILER}" CFLAGS="-std=c++11" ${OCTAVE_CMD} -qf --eval "make"
106106
INSTALL_COMMAND true # No installation required
107-
)
107+
)
108+
109+
# Create fading files (used for channel simulation) as part of unit test setup
110+
add_custom_target(fade_files ALL
111+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fast_fading_samples.float
112+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/faster_fading_samples.float
113+
)
114+
add_custom_command(
115+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fast_fading_samples.float
116+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/faster_fading_samples.float
117+
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && ./fade_files.sh ${CMAKE_CURRENT_BINARY_DIR}
118+
)

unittest/fade_files.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash -x
2+
#
3+
# Generate fading files used for channel simulation
4+
5+
output_path=$1
6+
echo "Generating fading files ......"
7+
cmd='cd ../octave; pkg load signal; cohpsk_ch_fading("'${output_path}'/fast_fading_samples.float", 8000, 1.0, 8000*60)'
8+
octave --no-gui -qf --eval "$cmd"
9+
[ ! $? -eq 0 ] && { echo "octave failed to run correctly .... exiting"; exit 1; }
10+
cmd='cd ../octave; pkg load signal; cohpsk_ch_fading("'${output_path}'/faster_fading_samples.float", 8000, 2.0, 8000*60)'
11+
octave --no-gui -qf --eval "$cmd"
12+
[ ! $? -eq 0 ] && { echo "octave failed to run correctly .... exiting"; exit 1; }
13+
exit 0
14+

unittest/ofdm_fade.sh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,9 @@
44
# Tests 700D OFDM modem fading channel performance, using a simulated channel
55

66
results=$(mktemp)
7-
8-
# generate fading file
9-
if [ ! -f ../raw/fast_fading_samples.float ]; then
10-
echo "Generating fading files ......"
11-
cmd='cd ../octave; pkg load signal; cohpsk_ch_fading("../raw/fast_fading_samples.float", 8000, 1.0, 8000*60)'
12-
octave --no-gui -qf --eval "$cmd"
13-
[ ! $? -eq 0 ] && { echo "octave failed to run correctly .... exiting"; exit 1; }
14-
fi
15-
16-
pwd
7+
fade_dir=$1
178
# BER should be around 4% for this test (it's better for larger interleavers but no one uses interleaving in practice)
18-
ofdm_mod --in /dev/zero --ldpc 1 --testframes 60 --txbpf | cohpsk_ch - - -24 --Fs 8000 -f -10 --mpp --raw_dir ../raw | ofdm_demod --out /dev/null --testframes --verbose 2 --ldpc 1 2> $results
9+
ofdm_mod --in /dev/zero --ldpc 1 --testframes 60 --txbpf | cohpsk_ch - - -24 --Fs 8000 -f -10 --mpp --raw_dir $fade_dir | ofdm_demod --out /dev/null --testframes --verbose 2 --ldpc 1 2> $results
1910
cat $results
2011
cber=$(cat $results | sed -n "s/^Coded BER.* \([0-9..]*\) Tbits.*/\1/p")
2112
python3 -c "import sys; sys.exit(0) if $cber<=0.05 else sys.exit(1)"

unittest/ofdm_fade_dpsk.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,9 @@
33
# David Sep 2019
44
# Tests 2020 OFDM modem fading channel performance in DPSK mode, using a simulated faster (2Hz) high SNR fading channel
55

6-
RAW=$PWD/../raw
6+
RAW=$1
77
results=$(mktemp)
88

9-
# generate fading file
10-
if [ ! -f ../raw/faster_fading_samples.float ]; then
11-
echo "Generating fading files ......"
12-
cmd='cd ../octave; pkg load signal; cohpsk_ch_fading("../raw/faster_fading_samples.float", 8000, 2.0, 8000*60)'
13-
octave --no-gui -qf --eval "$cmd"
14-
[ ! $? -eq 0 ] && { echo "octave failed to run correctly .... exiting"; exit 1; }
15-
fi
16-
17-
pwd
18-
199
# Coded BER should be < 1% for this test
2010
ofdm_mod --in /dev/zero --testframes 300 --mode 2020 --ldpc --verbose 1 -p 312 --dpsk | \
2111
cohpsk_ch - - -40 --Fs 8000 -f 10 --ssbfilt 1 --mpd --raw_dir $RAW --multipath_delay 2 | \

unittest/ofdm_phase_est_bw.sh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,10 @@
1414
# $ PATH=$PATH:../build_linux/src ./ofdm_phase_est_bw.sh
1515

1616
results=$(mktemp)
17-
18-
# generate fading file
19-
if [ ! -f ../raw/fast_fading_samples.float ]; then
20-
echo "Generating fading file ......"
21-
cmd='cd ../octave; pkg load signal; cohpsk_ch_fading("../raw/fast_fading_samples.float", 8000, 1.0, 8000*60)'
22-
octave --no-gui -qf --eval "$cmd"
23-
[ ! $? -eq 0 ] && { echo "octave failed to run correctly .... exiting"; exit 1; }
24-
fi
25-
26-
pwd
17+
fade_dir=$1
2718
# BER should be < 5% for this test
2819
ofdm_mod --in /dev/zero --testframes 300 --mode 2020 --ldpc -p 312 --verbose 0 | \
29-
cohpsk_ch - - -40 --Fs 8000 -f 10 --ssbfilt 1 --mpp --raw_dir ../raw | \
20+
cohpsk_ch - - -40 --Fs 8000 -f 10 --ssbfilt 1 --mpp --raw_dir $fade_dir | \
3021
ofdm_demod --out /dev/null --testframes --mode 2020 --verbose 2 --ldpc -p 312 --bandwidth 1 2> $results
3122
cat $results
3223
cber=$(cat $results | sed -n "s/^Coded BER.* \([0-9..]*\) Tbits.*/\1/p")

unittest/reliable_text_fade.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,17 @@ snr=$2
88
min_text_packets=$3
99
clip=$4
1010
build_folder=$5
11+
fade_dir=${build_folder}/../unittest
1112
rx=$build_folder/freedv_rx
1213
tx=$build_folder/freedv_tx
1314

14-
# generate fading file
15-
if [ ! -f ../raw/fast_fading_samples.float ]; then
16-
echo "Generating fading files ......"
17-
cmd='cd ../octave; pkg load signal; cohpsk_ch_fading("../raw/fast_fading_samples.float", 8000, 1.0, 8000*(60+53)'
18-
octave --no-gui -qf --eval "$cmd"
19-
[ ! $? -eq 0 ] && { echo "octave failed to run correctly .... exiting"; exit 1; }
20-
fi
21-
2215
if [ $clip -eq 1 ]; then
2316
clip_args="--txbpf 1 --clip 1"
2417
else
2518
clip_args=
2619
fi
2720

28-
$tx $mode ../raw/ve9qrp.raw - --reliabletext AB1CDEF $clip_args | $build_folder/cohpsk_ch - - $snr --mpp --Fs 8000 -f -5 --raw_dir ../raw/ > $results/reliable_fade.raw
21+
$tx $mode ../raw/ve9qrp.raw - --reliabletext AB1CDEF $clip_args | $build_folder/cohpsk_ch - - $snr --mpp --Fs 8000 -f -5 --raw_dir $fade_dir > $results/reliable_fade.raw
2922
$rx $mode $results/reliable_fade.raw /dev/null --txtrx $results/reliable_fade.txt --reliabletext
3023
if [ `cat $results/reliable_fade.txt | wc -l` -ge $min_text_packets ]; then
3124
exit 0

0 commit comments

Comments
 (0)