Skip to content

Commit 08cc842

Browse files
committed
ctest for parallel Rx, that includes some channel noise and sample clock offset
1 parent c31953c commit 08cc842

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,14 @@ endif(NOT APPLE)
12061206
cat binaryIn.bin | ./demo/freedv_datac1_tx |
12071207
./demo/freedv_datac1_rx > binaryOut.bin;
12081208
diff binaryIn.bin binaryOut.bin")
1209-
1209+
1210+
# test Rx of two modes in parallel, with AWGN noise and sample clock offsets
1211+
add_test(NAME test_demo_datac0c1
1212+
COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR};
1213+
./demo/freedv_datac0c1_tx |
1214+
./src/cohpsk_ch - - -24 -f 20 --Fs 8000 |
1215+
sox -t .s16 -c 1 -r 8000 - -t .s16 -c 1 -r 8008 - |
1216+
./demo/freedv_datac0c1_rx")
1217+
set_tests_properties(test_demo_datac0c1 PROPERTIES PASS_REGULAR_EXPRESSION "DATAC0 Frames: 10 DATAC1 Frames: 10")
12101218

12111219
endif(UNITTEST)

demo/freedv_datac0c1_rx.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@
1010
- the ability to receive signalling as well as payload data frames.
1111
1212
usage:
13+
1314
cd codec2/build_linux
1415
./demo/freedv_datacc01_tx | ./demo/freedv_datac0c1_rx
15-
16+
17+
Give it a hard time with some channel noise, frequency offset, and sample
18+
clock offsets:
19+
20+
./demo/freedv_datac0c1_tx | ./src/cohpsk_ch - - -24 -f 20 --Fs 8000 |
21+
sox -t .s16 -c 1 -r 8000 - -t .s16 -c 1 -r 8008 - |
22+
./demo/freedv_datac0c1_rx
23+
24+
Replace the final line with "aplay -f S16" to listen to the
25+
simulated Rx signal.
26+
1627
\*---------------------------------------------------------------------------*/
1728

1829
/*
@@ -87,8 +98,8 @@ int main(int argc, char *argv[]) {
8798

8899
}
89100

90-
fprintf(stderr, "DATAC0 Frames: %d\n", c0_frames);
91-
fprintf(stderr, "DATAC1 Frames: %d\n", c1_frames);
101+
fprintf(stderr, "DATAC0 Frames: %d DATAC1 Frames: %d\n", c0_frames, c1_frames);
102+
92103
freedv_close(freedv_c0);
93104
freedv_close(freedv_c1);
94105

demo/freedv_datac0c1_tx.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include "freedv_api.h"
3535
#include "ofdm_internal.h"
3636

37+
#define FRAMES 10
38+
3739
void send_burst(struct freedv *freedv);
3840

3941
int main(void) {
@@ -42,9 +44,21 @@ int main(void) {
4244
freedv_c0 = freedv_open(FREEDV_MODE_DATAC0); assert(freedv_c0 != NULL);
4345
freedv_c1 = freedv_open(FREEDV_MODE_DATAC1); assert(freedv_c1 != NULL);
4446

45-
for(int b=0; b<10; b++) {
46-
send_burst(freedv_c0);
47-
send_burst(freedv_c1);
47+
// send frames in different modes in random order
48+
int c0_frames = 0;
49+
int c1_frames = 0;
50+
while ((c0_frames < FRAMES) || (c1_frames < FRAMES)) {
51+
if (rand() & 1) {
52+
if (c0_frames < FRAMES) {
53+
send_burst(freedv_c0);
54+
c0_frames++;
55+
}
56+
} else {
57+
if (c1_frames < FRAMES) {
58+
send_burst(freedv_c1);
59+
c1_frames++;
60+
}
61+
}
4862
}
4963

5064
freedv_close(freedv_c0);

0 commit comments

Comments
 (0)