diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ed0e2a6..ba5d1eda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,7 @@ add_test(NAME 001_highsnr_virtual_P_P PATH=$PATH:${CODEC2_BUILD_DIR}/src; cd ${CMAKE_CURRENT_SOURCE_DIR}/test/001_highsnr_stdio_audio; ./test_virtual.sh") - set_tests_properties(001_highsnr_virtual_P_P PROPERTIES PASS_REGULAR_EXPRESSION "RECEIVED BURSTS: 1 RECEIVED FRAMES: 2") + set_tests_properties(001_highsnr_virtual_P_P PROPERTIES PASS_REGULAR_EXPRESSION "RECEIVED BURSTS: 5 RECEIVED FRAMES: 10 RX_ERRORS: 0") endif() diff --git a/test/001_highsnr_stdio_audio/test_rx.py b/test/001_highsnr_stdio_audio/test_rx.py index 330c9954..6f88ddd9 100644 --- a/test/001_highsnr_stdio_audio/test_rx.py +++ b/test/001_highsnr_stdio_audio/test_rx.py @@ -82,6 +82,7 @@ total_n_bytes = 0 rx_total_frames = 0 rx_frames = 0 rx_bursts = 0 +rx_errors = 0 timeout = time.time() + 10 receive = True @@ -106,8 +107,8 @@ while receive and time.time() < timeout: nbytes = codec2.api.freedv_rawdatarx(freedv, bytes_out, data_in) # demodulate audio total_n_bytes = total_n_bytes + nbytes + rx_status = codec2.api.freedv_get_rx_status(freedv) if DEBUGGING_MODE == True: - rx_status = codec2.api.freedv_get_rx_status(freedv) rx_status_string = codec2.api.rx_sync_flags_to_text[rx_status] print(f"rx_status: {rx_status_string}", file=sys.stderr) @@ -119,12 +120,14 @@ while receive and time.time() < timeout: rx_frames = 0 rx_bursts = rx_bursts + 1 + if rx_status & codec2.api.FREEDV_RX_BIT_ERRORS: + rx_errors = rx_errors + 1 if rx_bursts == N_BURSTS: receive = False -print(f"RECEIVED BURSTS: {rx_bursts} RECEIVED FRAMES: {rx_total_frames}", file=sys.stderr) +print(f"RECEIVED BURSTS: {rx_bursts} RECEIVED FRAMES: {rx_total_frames} RX_ERRORS: {rx_errors}", file=sys.stderr) # and at last check if we had an openend pyaudio instance and close it if AUDIO_INPUT_DEVICE != -1: diff --git a/test/001_highsnr_stdio_audio/test_virtual.sh b/test/001_highsnr_stdio_audio/test_virtual.sh index 6fd08b6d..367fd628 100755 --- a/test/001_highsnr_stdio_audio/test_virtual.sh +++ b/test/001_highsnr_stdio_audio/test_virtual.sh @@ -18,8 +18,8 @@ RX_LOG=$(mktemp) # make sure all child processes are killed when we exit trap 'jobs -p | xargs -r kill' EXIT -python3 test_rx.py --mode datac0 --frames 2 --bursts 1 --audiodev 4 --debug & +python3 test_rx.py --mode datac0 --frames 2 --bursts 5 --audiodev 4 --debug & rx_pid=$! sleep 1 -python3 test_tx.py --mode datac0 --frames 2 --bursts 1 --audiodev 5 +python3 test_tx.py --mode datac0 --frames 2 --bursts 5 --delay 500 --audiodev 5 wait ${rx_pid} diff --git a/test/codec2.py b/test/codec2.py index 7c73922f..4019138d 100644 --- a/test/codec2.py +++ b/test/codec2.py @@ -74,6 +74,12 @@ api.FREEDV_MODE_DATAC1 = 10 api.FREEDV_MODE_DATAC3 = 12 api.FREEDV_MODE_DATAC0 = 14 +# Return code flags for freedv_get_rx_status() function +api.FREEDV_RX_TRIAL_SYNC = 0x1 # demodulator has trial sync +api.FREEDV_RX_SYNC = 0x2 # demodulator has sync +api.FREEDV_RX_BITS = 0x4 # data bits have been returned +api.FREEDV_RX_BIT_ERRORS = 0x8 # FEC may not have corrected all bit errors (not all parity checks OK) + api.rx_sync_flags_to_text = [ "----", "---T",