mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
moved ctest from datac0 to datac13
This commit is contained in:
parent
c6fe7d55cc
commit
7b84044ac0
26 changed files with 133 additions and 133 deletions
|
@ -9,7 +9,7 @@ queue used by the daemon process into and out of the TNC.
|
|||
|
||||
Can be invoked from CMake, pytest, coverage or directly.
|
||||
|
||||
Uses util_datac0.py in separate process to perform the data transfer.
|
||||
Uses util_datac13.py in separate process to perform the data transfer.
|
||||
|
||||
@author: N2KIQ
|
||||
"""
|
||||
|
@ -28,9 +28,9 @@ import pytest
|
|||
import structlog
|
||||
|
||||
try:
|
||||
import test.util_datac0 as util
|
||||
import test.util_datac13 as util
|
||||
except ImportError:
|
||||
import util_datac0 as util
|
||||
import util_datac13 as util
|
||||
|
||||
|
||||
STATIONS = ["AA2BB", "ZZ9YY"]
|
||||
|
@ -196,9 +196,9 @@ def analyze_results(station1: list, station2: list, call_list: list):
|
|||
pytest.param("stop", marks=pytest.mark.flaky(reruns=0)),
|
||||
],
|
||||
)
|
||||
def test_datac0(frame_type: str, tmp_path):
|
||||
log_handler.setup_logging(filename=tmp_path / "test_datac0", level="DEBUG")
|
||||
log = structlog.get_logger("test_datac0")
|
||||
def test_datac13(frame_type: str, tmp_path):
|
||||
log_handler.setup_logging(filename=tmp_path / "test_datac13", level="DEBUG")
|
||||
log = structlog.get_logger("test_datac13")
|
||||
|
||||
s1_data = []
|
||||
s2_data = []
|
||||
|
@ -227,7 +227,7 @@ def test_datac0(frame_type: str, tmp_path):
|
|||
from_s2, s2_send = multiprocessing.Pipe()
|
||||
proc = [
|
||||
multiprocessing.Process(
|
||||
target=util.t_datac0_1,
|
||||
target=util.t_datac13_1,
|
||||
args=(
|
||||
s1_send,
|
||||
STATIONS[0],
|
||||
|
@ -238,7 +238,7 @@ def test_datac0(frame_type: str, tmp_path):
|
|||
daemon=True,
|
||||
),
|
||||
multiprocessing.Process(
|
||||
target=util.t_datac0_2,
|
||||
target=util.t_datac13_2,
|
||||
args=(
|
||||
s2_send,
|
||||
STATIONS[1],
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Negative tests for datac0 frames.
|
||||
Negative tests for datac13 frames.
|
||||
|
||||
@author: kronenpj
|
||||
"""
|
||||
|
@ -20,9 +20,9 @@ import pytest
|
|||
import structlog
|
||||
|
||||
try:
|
||||
import test.util_datac0_negative as util
|
||||
import test.util_datac13_negative as util
|
||||
except ImportError:
|
||||
import util_datac0_negative as util
|
||||
import util_datac13_negative as util
|
||||
|
||||
|
||||
STATIONS = ["AA2BB", "ZZ9YY"]
|
||||
|
@ -163,9 +163,9 @@ def analyze_results(station1: list, station2: list, call_list: list):
|
|||
|
||||
# @pytest.mark.parametrize("frame_type", ["beacon", "connect", "ping"])
|
||||
@pytest.mark.parametrize("frame_type", ["ping", "stop"])
|
||||
def test_datac0_negative(frame_type: str, tmp_path):
|
||||
log_handler.setup_logging(filename=tmp_path / "test_datac0", level="DEBUG")
|
||||
log = structlog.get_logger("test_datac0")
|
||||
def test_datac13_negative(frame_type: str, tmp_path):
|
||||
log_handler.setup_logging(filename=tmp_path / "test_datac13", level="DEBUG")
|
||||
log = structlog.get_logger("test_datac13")
|
||||
|
||||
s1_data = []
|
||||
s2_data = []
|
||||
|
@ -194,7 +194,7 @@ def test_datac0_negative(frame_type: str, tmp_path):
|
|||
from_s2, s2_send = multiprocessing.Pipe()
|
||||
proc = [
|
||||
multiprocessing.Process(
|
||||
target=util.t_datac0_1,
|
||||
target=util.t_datac13_1,
|
||||
args=(
|
||||
s1_send,
|
||||
STATIONS[0],
|
||||
|
@ -205,7 +205,7 @@ def test_datac0_negative(frame_type: str, tmp_path):
|
|||
daemon=True,
|
||||
),
|
||||
multiprocessing.Process(
|
||||
target=util.t_datac0_2,
|
||||
target=util.t_datac13_2,
|
||||
args=(
|
||||
s2_send,
|
||||
STATIONS[1],
|
|
@ -49,7 +49,7 @@ def t_HighSNR_C_P_DATACx(
|
|||
bursts: int, frames_per_burst: int, testframes: int, mode: str
|
||||
):
|
||||
"""
|
||||
Test a high signal-to-noise ratio path with DATAC0.
|
||||
Test a high signal-to-noise ratio path with datac13.
|
||||
|
||||
:param bursts: Number of bursts
|
||||
:type bursts: str
|
||||
|
@ -152,7 +152,7 @@ def t_HighSNR_C_P_DATACx(
|
|||
@pytest.mark.parametrize("bursts", [BURSTS])
|
||||
@pytest.mark.parametrize("frames_per_burst", [FRAMESPERBURST])
|
||||
@pytest.mark.parametrize("testframes", [TESTFRAMES])
|
||||
@pytest.mark.parametrize("mode", ["datac0", "datac1", "datac3"])
|
||||
@pytest.mark.parametrize("mode", ["datac13", "datac1", "datac3"])
|
||||
def test_HighSNR_C_P_DATACx(
|
||||
bursts: int, frames_per_burst: int, testframes: int, mode: str
|
||||
):
|
||||
|
|
|
@ -47,7 +47,7 @@ if os.path.exists("test"):
|
|||
|
||||
def t_HighSNR_P_C_DATACx(bursts: int, frames_per_burst: int, mode: str):
|
||||
"""
|
||||
Test a high signal-to-noise ratio path with DATAC0.
|
||||
Test a high signal-to-noise ratio path with datac13.
|
||||
|
||||
:param bursts: Number of bursts
|
||||
:type bursts: str
|
||||
|
@ -154,7 +154,7 @@ def t_HighSNR_P_C_DATACx(bursts: int, frames_per_burst: int, mode: str):
|
|||
# @pytest.mark.parametrize("frames_per_burst", [FRAMESPERBURST, 2, 3])
|
||||
@pytest.mark.parametrize("bursts", [BURSTS])
|
||||
@pytest.mark.parametrize("frames_per_burst", [FRAMESPERBURST])
|
||||
@pytest.mark.parametrize("mode", ["datac0", "datac1", "datac3"])
|
||||
@pytest.mark.parametrize("mode", ["datac13", "datac1", "datac3"])
|
||||
def test_HighSNR_P_C_DATACx(bursts: int, frames_per_burst: int, mode: str):
|
||||
proc = multiprocessing.Process(
|
||||
target=t_HighSNR_P_C_DATACx,
|
||||
|
|
|
@ -115,7 +115,7 @@ def t_HighSNR_P_P_DATACx(bursts: int, frames_per_burst: int, mode: str):
|
|||
# @pytest.mark.parametrize("frames_per_burst", [FRAMESPERBURST, 2, 3])
|
||||
@pytest.mark.parametrize("bursts", [BURSTS])
|
||||
@pytest.mark.parametrize("frames_per_burst", [FRAMESPERBURST])
|
||||
@pytest.mark.parametrize("mode", ["datac0", "datac1", "datac3"])
|
||||
@pytest.mark.parametrize("mode", ["datac13", "datac1", "datac3"])
|
||||
def test_HighSNR_P_P_DATACx(bursts: int, frames_per_burst: int, mode: str):
|
||||
proc = multiprocessing.Process(
|
||||
target=t_HighSNR_P_P_DATACx,
|
||||
|
|
|
@ -46,7 +46,7 @@ if os.path.exists("test"):
|
|||
|
||||
def t_HighSNR_P_P_Multi(bursts: int, frames_per_burst: int):
|
||||
"""
|
||||
Test a high signal-to-noise ratio path with DATAC0, DATAC1 and DATAC3.
|
||||
Test a high signal-to-noise ratio path with datac13, DATAC1 and DATAC3.
|
||||
|
||||
:param bursts: Number of bursts
|
||||
:type bursts: int
|
||||
|
@ -101,7 +101,7 @@ def t_HighSNR_P_P_Multi(bursts: int, frames_per_burst: int):
|
|||
if "DATAC" in str(line, "UTF-8")
|
||||
]
|
||||
)
|
||||
assert f"DATAC0: {bursts}/{frames_per_burst * bursts}" in lastline
|
||||
assert f"datac13: {bursts}/{frames_per_burst * bursts}" in lastline
|
||||
assert f"DATAC1: {bursts}/{frames_per_burst * bursts}" in lastline
|
||||
assert f"DATAC3: {bursts}/{frames_per_burst * bursts}" in lastline
|
||||
print(lastline)
|
||||
|
|
|
@ -9,7 +9,7 @@ queue used by the daemon process into and out of the TNC.
|
|||
|
||||
Can be invoked from CMake, pytest, coverage or directly.
|
||||
|
||||
Uses util_datac0.py in separate process to perform the data transfer.
|
||||
Uses util_datac13.py in separate process to perform the data transfer.
|
||||
|
||||
@author: N2KIQ
|
||||
"""
|
||||
|
|
|
@ -20,8 +20,8 @@ MAX_RUN_TIME=2600
|
|||
# make sure all child processes are killed when we exit
|
||||
trap 'jobs -p | xargs -r kill' EXIT
|
||||
|
||||
arecord --device="plughw:CARD=CHAT2,DEV=0" -r 48000 -f S16_LE -d $MAX_RUN_TIME | python3 util_rx.py --mode datac0 --frames 2 --bursts 5 --debug &
|
||||
arecord --device="plughw:CARD=CHAT2,DEV=0" -r 48000 -f S16_LE -d $MAX_RUN_TIME | python3 util_rx.py --mode datac13 --frames 2 --bursts 5 --debug &
|
||||
rx_pid=$!
|
||||
sleep 1
|
||||
python3 util_tx.py --mode datac0 --frames 2 --bursts 5 --delay 500 | aplay --device="plughw:CARD=CHAT2,DEV=1" -r 48000 -f S16_LE
|
||||
python3 util_tx.py --mode datac13 --frames 2 --bursts 5 --delay 500 | aplay --device="plughw:CARD=CHAT2,DEV=1" -r 48000 -f S16_LE
|
||||
wait ${rx_pid}
|
||||
|
|
|
@ -8,9 +8,9 @@ MAX_RUN_TIME=2600
|
|||
trap 'jobs -p | xargs -r kill' EXIT
|
||||
|
||||
arecord -r 48000 --device="plughw:CARD=CHAT1,DEV=0" -f S16_LE -d $MAX_RUN_TIME | \
|
||||
python3 util_rx.py --mode datac0 --frames 2 --bursts 5 --debug &
|
||||
python3 util_rx.py --mode datac13 --frames 2 --bursts 5 --debug &
|
||||
rx_pid=$!
|
||||
sleep 1
|
||||
python3 util_tx.py --mode datac0 --frames 2 --bursts 5 --delay 500 | \
|
||||
python3 util_tx.py --mode datac13 --frames 2 --bursts 5 --delay 500 | \
|
||||
aplay -r 48000 --device="plughw:CARD=CHAT1,DEV=1" -f S16_LE
|
||||
wait ${rx_pid}
|
||||
|
|
|
@ -8,8 +8,8 @@ MAX_RUN_TIME=2600
|
|||
trap 'jobs -p | xargs -r kill' EXIT
|
||||
|
||||
arecord -r 48000 --device="plughw:CARD=CHAT1,DEV=0" -f S16_LE -d $MAX_RUN_TIME | \
|
||||
python3 util_rx.py --mode datac0 --frames 2 --bursts 5 --debug --timeout 20 &
|
||||
python3 util_rx.py --mode datac13 --frames 2 --bursts 5 --debug --timeout 20 &
|
||||
rx_pid=$!
|
||||
sleep 1
|
||||
python3 util_tx.py --mode datac0 --frames 2 --bursts 5 --delay 2000 --audiodev -2
|
||||
python3 util_tx.py --mode datac13 --frames 2 --bursts 5 --delay 2000 --audiodev -2
|
||||
wait ${rx_pid}
|
||||
|
|
|
@ -7,9 +7,9 @@ MAX_RUN_TIME=2600
|
|||
# make sure all child processes are killed when we exit
|
||||
trap 'jobs -p | xargs -r kill' EXIT
|
||||
|
||||
python3 util_rx.py --mode datac0 --frames 2 --bursts 5 --debug --audiodev -2 &
|
||||
python3 util_rx.py --mode datac13 --frames 2 --bursts 5 --debug --audiodev -2 &
|
||||
rx_pid=$!
|
||||
sleep 1
|
||||
python3 util_tx.py --mode datac0 --frames 2 --bursts 5 | \
|
||||
python3 util_tx.py --mode datac13 --frames 2 --bursts 5 | \
|
||||
aplay -r 48000 --device="plughw:CARD=CHAT1,DEV=1" -f S16_LE
|
||||
wait ${rx_pid}
|
||||
|
|
|
@ -16,8 +16,8 @@ check_alsa_loopback
|
|||
# make sure all child processes are killed when we exit
|
||||
trap 'jobs -p | xargs -r kill' EXIT
|
||||
|
||||
python3 util_callback_rx.py --mode datac0 --frames 2 --bursts 3 --audiodev -2 --debug &
|
||||
python3 util_callback_rx.py --mode datac13 --frames 2 --bursts 3 --audiodev -2 --debug &
|
||||
rx_pid=$!
|
||||
sleep 1
|
||||
python3 util_tx.py --mode datac0 --frames 2 --bursts 3 --audiodev -2
|
||||
python3 util_tx.py --mode datac13 --frames 2 --bursts 3 --audiodev -2
|
||||
wait ${rx_pid}
|
||||
|
|
|
@ -16,8 +16,8 @@ check_alsa_loopback
|
|||
# make sure all child processes are killed when we exit
|
||||
trap 'jobs -p | xargs -r kill' EXIT
|
||||
|
||||
python3 util_callback_rx.py --mode datac0 --frames 2 --bursts 3 --audiodev -2 --debug &
|
||||
python3 util_callback_rx.py --mode datac13 --frames 2 --bursts 3 --audiodev -2 --debug &
|
||||
rx_pid=$!
|
||||
#sleep 1
|
||||
python3 util_tx.py --mode datac0 --frames 2 --bursts 3 --audiodev -2
|
||||
python3 util_tx.py --mode datac13 --frames 2 --bursts 3 --audiodev -2
|
||||
wait ${rx_pid}
|
||||
|
|
|
@ -16,8 +16,8 @@ check_alsa_loopback
|
|||
# make sure all child processes are killed when we exit
|
||||
trap 'jobs -p | xargs -r kill' EXIT
|
||||
|
||||
python3 util_callback_rx_outside.py --mode datac0 --frames 2 --bursts 3 --audiodev -2 --debug &
|
||||
python3 util_callback_rx_outside.py --mode datac13 --frames 2 --bursts 3 --audiodev -2 --debug &
|
||||
rx_pid=$!
|
||||
#sleep 1
|
||||
python3 util_tx.py --mode datac0 --frames 2 --bursts 3 --audiodev -2
|
||||
python3 util_tx.py --mode datac13 --frames 2 --bursts 3 --audiodev -2
|
||||
wait ${rx_pid}
|
||||
|
|
|
@ -112,17 +112,17 @@ class Test:
|
|||
sys.exit()
|
||||
|
||||
# open codec2 instance
|
||||
self.datac0_freedv = ctypes.cast(
|
||||
codec2.api.freedv_open(codec2.FREEDV_MODE.datac0.value), ctypes.c_void_p
|
||||
self.datac13_freedv = ctypes.cast(
|
||||
codec2.api.freedv_open(codec2.FREEDV_MODE.datac13.value), ctypes.c_void_p
|
||||
)
|
||||
self.datac0_bytes_per_frame = int(
|
||||
codec2.api.freedv_get_bits_per_modem_frame(self.datac0_freedv) / 8
|
||||
self.datac13_bytes_per_frame = int(
|
||||
codec2.api.freedv_get_bits_per_modem_frame(self.datac13_freedv) / 8
|
||||
)
|
||||
self.datac0_bytes_out = ctypes.create_string_buffer(self.datac0_bytes_per_frame)
|
||||
self.datac13_bytes_out = ctypes.create_string_buffer(self.datac13_bytes_per_frame)
|
||||
codec2.api.freedv_set_frames_per_burst(
|
||||
self.datac0_freedv, self.N_FRAMES_PER_BURST
|
||||
self.datac13_freedv, self.N_FRAMES_PER_BURST
|
||||
)
|
||||
self.datac0_buffer = codec2.audio_buffer(2 * self.AUDIO_FRAMES_PER_BUFFER)
|
||||
self.datac13_buffer = codec2.audio_buffer(2 * self.AUDIO_FRAMES_PER_BUFFER)
|
||||
|
||||
self.datac1_freedv = ctypes.cast(
|
||||
codec2.api.freedv_open(codec2.FREEDV_MODE.datac1.value), ctypes.c_void_p
|
||||
|
@ -149,9 +149,9 @@ class Test:
|
|||
self.datac3_buffer = codec2.audio_buffer(2 * self.AUDIO_FRAMES_PER_BUFFER)
|
||||
|
||||
# SET COUNTERS
|
||||
self.rx_total_frames_datac0 = 0
|
||||
self.rx_frames_datac0 = 0
|
||||
self.rx_bursts_datac0 = 0
|
||||
self.rx_total_frames_datac13 = 0
|
||||
self.rx_frames_datac13 = 0
|
||||
self.rx_bursts_datac13 = 0
|
||||
|
||||
self.rx_total_frames_datac1 = 0
|
||||
self.rx_frames_datac1 = 0
|
||||
|
@ -173,7 +173,7 @@ class Test:
|
|||
self.frx = open("rx48_callback_multimode.raw", mode="wb")
|
||||
|
||||
# initial nin values
|
||||
self.datac0_nin = codec2.api.freedv_nin(self.datac0_freedv)
|
||||
self.datac13_nin = codec2.api.freedv_nin(self.datac13_freedv)
|
||||
self.datac1_nin = codec2.api.freedv_nin(self.datac1_freedv)
|
||||
self.datac3_nin = codec2.api.freedv_nin(self.datac3_freedv)
|
||||
|
||||
|
@ -187,26 +187,26 @@ class Test:
|
|||
x.tofile(self.frx)
|
||||
x = self.resampler.resample48_to_8(x)
|
||||
|
||||
self.datac0_buffer.push(x)
|
||||
self.datac13_buffer.push(x)
|
||||
self.datac1_buffer.push(x)
|
||||
self.datac3_buffer.push(x)
|
||||
|
||||
while self.datac0_buffer.nbuffer >= self.datac0_nin:
|
||||
while self.datac13_buffer.nbuffer >= self.datac13_nin:
|
||||
# demodulate audio
|
||||
nbytes = codec2.api.freedv_rawdatarx(
|
||||
self.datac0_freedv,
|
||||
self.datac0_bytes_out,
|
||||
self.datac0_buffer.buffer.ctypes,
|
||||
self.datac13_freedv,
|
||||
self.datac13_bytes_out,
|
||||
self.datac13_buffer.buffer.ctypes,
|
||||
)
|
||||
self.datac0_buffer.pop(self.datac0_nin)
|
||||
self.datac0_nin = codec2.api.freedv_nin(self.datac0_freedv)
|
||||
if nbytes == self.datac0_bytes_per_frame:
|
||||
self.rx_total_frames_datac0 = self.rx_total_frames_datac0 + 1
|
||||
self.rx_frames_datac0 = self.rx_frames_datac0 + 1
|
||||
self.datac13_buffer.pop(self.datac13_nin)
|
||||
self.datac13_nin = codec2.api.freedv_nin(self.datac13_freedv)
|
||||
if nbytes == self.datac13_bytes_per_frame:
|
||||
self.rx_total_frames_datac13 = self.rx_total_frames_datac13 + 1
|
||||
self.rx_frames_datac13 = self.rx_frames_datac13 + 1
|
||||
|
||||
if self.rx_frames_datac0 == self.N_FRAMES_PER_BURST:
|
||||
self.rx_frames_datac0 = 0
|
||||
self.rx_bursts_datac0 = self.rx_bursts_datac0 + 1
|
||||
if self.rx_frames_datac13 == self.N_FRAMES_PER_BURST:
|
||||
self.rx_frames_datac13 = 0
|
||||
self.rx_bursts_datac13 = self.rx_bursts_datac13 + 1
|
||||
|
||||
while self.datac1_buffer.nbuffer >= self.datac1_nin:
|
||||
# demodulate audio
|
||||
|
@ -243,7 +243,7 @@ class Test:
|
|||
self.rx_bursts_datac3 = self.rx_bursts_datac3 + 1
|
||||
|
||||
if (
|
||||
self.rx_bursts_datac0 and self.rx_bursts_datac1 and self.rx_bursts_datac3
|
||||
self.rx_bursts_datac13 and self.rx_bursts_datac1 and self.rx_bursts_datac3
|
||||
) == self.N_BURSTS:
|
||||
self.receive = False
|
||||
|
||||
|
@ -253,11 +253,11 @@ class Test:
|
|||
while self.receive:
|
||||
time.sleep(0.01)
|
||||
if self.DEBUGGING_MODE:
|
||||
self.datac0_rxstatus = codec2.api.freedv_get_rx_status(
|
||||
self.datac0_freedv
|
||||
self.datac13_rxstatus = codec2.api.freedv_get_rx_status(
|
||||
self.datac13_freedv
|
||||
)
|
||||
self.datac0_rxstatus = codec2.api.rx_sync_flags_to_text[
|
||||
self.datac0_rxstatus
|
||||
self.datac13_rxstatus = codec2.api.rx_sync_flags_to_text[
|
||||
self.datac13_rxstatus
|
||||
]
|
||||
|
||||
self.datac1_rxstatus = codec2.api.freedv_get_rx_status(
|
||||
|
@ -277,8 +277,8 @@ class Test:
|
|||
print(
|
||||
"NIN0: %5d RX_STATUS0: %4s NIN1: %5d RX_STATUS1: %4s NIN3: %5d RX_STATUS3: %4s"
|
||||
% (
|
||||
self.datac0_nin,
|
||||
self.datac0_rxstatus,
|
||||
self.datac13_nin,
|
||||
self.datac13_rxstatus,
|
||||
self.datac1_nin,
|
||||
self.datac1_rxstatus,
|
||||
self.datac3_nin,
|
||||
|
@ -309,7 +309,7 @@ class Test:
|
|||
)
|
||||
|
||||
print(
|
||||
f"DATAC0: {self.rx_bursts_datac0}/{self.rx_total_frames_datac0} DATAC1: {self.rx_bursts_datac1}/{self.rx_total_frames_datac1} DATAC3: {self.rx_bursts_datac3}/{self.rx_total_frames_datac3}",
|
||||
f"datac13: {self.rx_bursts_datac13}/{self.rx_total_frames_datac13} DATAC1: {self.rx_bursts_datac1}/{self.rx_total_frames_datac1} DATAC3: {self.rx_bursts_datac3}/{self.rx_total_frames_datac3}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
self.frx.close()
|
||||
|
|
|
@ -110,17 +110,17 @@ class Test:
|
|||
sys.exit()
|
||||
|
||||
# open codec2 instance
|
||||
self.datac0_freedv = ctypes.cast(
|
||||
codec2.api.freedv_open(codec2.FREEDV_MODE.datac0.value), ctypes.c_void_p
|
||||
self.datac13_freedv = ctypes.cast(
|
||||
codec2.api.freedv_open(codec2.FREEDV_MODE.datac13.value), ctypes.c_void_p
|
||||
)
|
||||
self.datac0_bytes_per_frame = int(
|
||||
codec2.api.freedv_get_bits_per_modem_frame(self.datac0_freedv) / 8
|
||||
self.datac13_bytes_per_frame = int(
|
||||
codec2.api.freedv_get_bits_per_modem_frame(self.datac13_freedv) / 8
|
||||
)
|
||||
self.datac0_bytes_out = ctypes.create_string_buffer(self.datac0_bytes_per_frame)
|
||||
self.datac13_bytes_out = ctypes.create_string_buffer(self.datac13_bytes_per_frame)
|
||||
codec2.api.freedv_set_frames_per_burst(
|
||||
self.datac0_freedv, self.N_FRAMES_PER_BURST
|
||||
self.datac13_freedv, self.N_FRAMES_PER_BURST
|
||||
)
|
||||
self.datac0_buffer = codec2.audio_buffer(2 * self.AUDIO_FRAMES_PER_BUFFER)
|
||||
self.datac13_buffer = codec2.audio_buffer(2 * self.AUDIO_FRAMES_PER_BUFFER)
|
||||
|
||||
self.datac1_freedv = ctypes.cast(
|
||||
codec2.api.freedv_open(codec2.FREEDV_MODE.datac1.value), ctypes.c_void_p
|
||||
|
@ -147,9 +147,9 @@ class Test:
|
|||
self.datac3_buffer = codec2.audio_buffer(2 * self.AUDIO_FRAMES_PER_BUFFER)
|
||||
|
||||
# SET COUNTERS
|
||||
self.rx_total_frames_datac0 = 0
|
||||
self.rx_frames_datac0 = 0
|
||||
self.rx_bursts_datac0 = 0
|
||||
self.rx_total_frames_datac13 = 0
|
||||
self.rx_frames_datac13 = 0
|
||||
self.rx_bursts_datac13 = 0
|
||||
|
||||
self.rx_total_frames_datac1 = 0
|
||||
self.rx_frames_datac1 = 0
|
||||
|
@ -171,7 +171,7 @@ class Test:
|
|||
self.frx = open("rx48_callback_multimode.raw", mode="wb")
|
||||
|
||||
# initial nin values
|
||||
self.datac0_nin = codec2.api.freedv_nin(self.datac0_freedv)
|
||||
self.datac13_nin = codec2.api.freedv_nin(self.datac13_freedv)
|
||||
self.datac1_nin = codec2.api.freedv_nin(self.datac1_freedv)
|
||||
self.datac3_nin = codec2.api.freedv_nin(self.datac3_freedv)
|
||||
|
||||
|
@ -181,7 +181,7 @@ class Test:
|
|||
x.tofile(self.frx)
|
||||
x = self.resampler.resample48_to_8(x)
|
||||
|
||||
self.datac0_buffer.push(x)
|
||||
self.datac13_buffer.push(x)
|
||||
self.datac1_buffer.push(x)
|
||||
self.datac3_buffer.push(x)
|
||||
|
||||
|
@ -189,9 +189,9 @@ class Test:
|
|||
|
||||
def print_stats(self):
|
||||
if self.DEBUGGING_MODE:
|
||||
self.datac0_rxstatus = codec2.api.freedv_get_rx_status(self.datac0_freedv)
|
||||
self.datac0_rxstatus = codec2.api.rx_sync_flags_to_text[
|
||||
self.datac0_rxstatus
|
||||
self.datac13_rxstatus = codec2.api.freedv_get_rx_status(self.datac13_freedv)
|
||||
self.datac13_rxstatus = codec2.api.rx_sync_flags_to_text[
|
||||
self.datac13_rxstatus
|
||||
]
|
||||
|
||||
self.datac1_rxstatus = codec2.api.freedv_get_rx_status(self.datac1_freedv)
|
||||
|
@ -207,8 +207,8 @@ class Test:
|
|||
print(
|
||||
"NIN0: %5d RX_STATUS0: %4s NIN1: %5d RX_STATUS1: %4s NIN3: %5d RX_STATUS3: %4s"
|
||||
% (
|
||||
self.datac0_nin,
|
||||
self.datac0_rxstatus,
|
||||
self.datac13_nin,
|
||||
self.datac13_rxstatus,
|
||||
self.datac1_nin,
|
||||
self.datac1_rxstatus,
|
||||
self.datac3_nin,
|
||||
|
@ -225,22 +225,22 @@ class Test:
|
|||
print(f"pyAudio error: {e}", file=sys.stderr)
|
||||
|
||||
while self.receive and time.time() < self.timeout:
|
||||
while self.datac0_buffer.nbuffer >= self.datac0_nin:
|
||||
while self.datac13_buffer.nbuffer >= self.datac13_nin:
|
||||
# demodulate audio
|
||||
nbytes = codec2.api.freedv_rawdatarx(
|
||||
self.datac0_freedv,
|
||||
self.datac0_bytes_out,
|
||||
self.datac0_buffer.buffer.ctypes,
|
||||
self.datac13_freedv,
|
||||
self.datac13_bytes_out,
|
||||
self.datac13_buffer.buffer.ctypes,
|
||||
)
|
||||
self.datac0_buffer.pop(self.datac0_nin)
|
||||
self.datac0_nin = codec2.api.freedv_nin(self.datac0_freedv)
|
||||
if nbytes == self.datac0_bytes_per_frame:
|
||||
self.rx_total_frames_datac0 = self.rx_total_frames_datac0 + 1
|
||||
self.rx_frames_datac0 = self.rx_frames_datac0 + 1
|
||||
self.datac13_buffer.pop(self.datac13_nin)
|
||||
self.datac13_nin = codec2.api.freedv_nin(self.datac13_freedv)
|
||||
if nbytes == self.datac13_bytes_per_frame:
|
||||
self.rx_total_frames_datac13 = self.rx_total_frames_datac13 + 1
|
||||
self.rx_frames_datac13 = self.rx_frames_datac13 + 1
|
||||
|
||||
if self.rx_frames_datac0 == self.N_FRAMES_PER_BURST:
|
||||
self.rx_frames_datac0 = 0
|
||||
self.rx_bursts_datac0 = self.rx_bursts_datac0 + 1
|
||||
if self.rx_frames_datac13 == self.N_FRAMES_PER_BURST:
|
||||
self.rx_frames_datac13 = 0
|
||||
self.rx_bursts_datac13 = self.rx_bursts_datac13 + 1
|
||||
self.print_stats()
|
||||
|
||||
while self.datac1_buffer.nbuffer >= self.datac1_nin:
|
||||
|
@ -280,7 +280,7 @@ class Test:
|
|||
self.print_stats()
|
||||
|
||||
if (
|
||||
self.rx_bursts_datac0
|
||||
self.rx_bursts_datac13
|
||||
and self.rx_bursts_datac1
|
||||
and self.rx_bursts_datac3
|
||||
) == self.N_BURSTS:
|
||||
|
@ -297,7 +297,7 @@ class Test:
|
|||
)
|
||||
|
||||
print(
|
||||
f"DATAC0: {self.rx_bursts_datac0}/{self.rx_total_frames_datac0} DATAC1: {self.rx_bursts_datac1}/{self.rx_total_frames_datac1} DATAC3: {self.rx_bursts_datac3}/{self.rx_total_frames_datac3}",
|
||||
f"datac13: {self.rx_bursts_datac13}/{self.rx_total_frames_datac13} DATAC1: {self.rx_bursts_datac1}/{self.rx_total_frames_datac1} DATAC3: {self.rx_bursts_datac3}/{self.rx_total_frames_datac3}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
self.frx.close()
|
||||
|
|
|
@ -158,7 +158,7 @@ class Test:
|
|||
def create_modulation(self):
|
||||
|
||||
modes = [
|
||||
codec2.FREEDV_MODE.datac0.value,
|
||||
codec2.FREEDV_MODE.datac13.value,
|
||||
codec2.FREEDV_MODE.datac1.value,
|
||||
codec2.FREEDV_MODE.datac3.value,
|
||||
]
|
||||
|
|
|
@ -22,7 +22,7 @@ parser = argparse.ArgumentParser(description="FreeDATA audio test")
|
|||
parser.add_argument("--bursts", dest="N_BURSTS", default=1, type=int)
|
||||
parser.add_argument("--framesperburst", dest="N_FRAMES_PER_BURST", default=1, type=int)
|
||||
parser.add_argument(
|
||||
"--mode", dest="FREEDV_MODE", type=str, choices=["datac0", "datac1", "datac3"]
|
||||
"--mode", dest="FREEDV_MODE", type=str, choices=["datac13", "datac1", "datac3"]
|
||||
)
|
||||
parser.add_argument(
|
||||
"--audiodev",
|
||||
|
|
|
@ -22,7 +22,7 @@ parser = argparse.ArgumentParser(description="FreeDATA audio test")
|
|||
parser.add_argument("--bursts", dest="N_BURSTS", default=1, type=int)
|
||||
parser.add_argument("--framesperburst", dest="N_FRAMES_PER_BURST", default=1, type=int)
|
||||
parser.add_argument(
|
||||
"--mode", dest="FREEDV_MODE", type=str, choices=["datac0", "datac1", "datac3"]
|
||||
"--mode", dest="FREEDV_MODE", type=str, choices=["datac13", "datac1", "datac3"]
|
||||
)
|
||||
parser.add_argument(
|
||||
"--audiodev",
|
||||
|
|
|
@ -25,7 +25,7 @@ parser.add_argument("--bursts", dest="N_BURSTS", default=1, type=int)
|
|||
parser.add_argument("--framesperburst", dest="N_FRAMES_PER_BURST", default=1, type=int)
|
||||
parser.add_argument("--delay", dest="DELAY_BETWEEN_BURSTS", default=500, type=int)
|
||||
parser.add_argument(
|
||||
"--mode", dest="FREEDV_MODE", type=str, choices=["datac0", "datac1", "datac3"]
|
||||
"--mode", dest="FREEDV_MODE", type=str, choices=["datac13", "datac1", "datac3"]
|
||||
)
|
||||
parser.add_argument(
|
||||
"--audiodev",
|
||||
|
|
|
@ -7,7 +7,7 @@ Near end-to-end test for sending / receiving control frames through the TNC and
|
|||
and back through on the other station. Data injection initiates from the queue used
|
||||
by the daemon process into and out of the TNC.
|
||||
|
||||
Invoked from test_datac0.py.
|
||||
Invoked from test_datac13.py.
|
||||
|
||||
@author: N2KIQ
|
||||
"""
|
||||
|
@ -83,7 +83,7 @@ def t_setup(
|
|||
return tnc, orig_rx_func, orig_tx_func
|
||||
|
||||
|
||||
def t_datac0_1(
|
||||
def t_datac13_1(
|
||||
parent_pipe,
|
||||
mycall: str,
|
||||
dxcall: str,
|
||||
|
@ -93,7 +93,7 @@ def t_datac0_1(
|
|||
log = structlog.get_logger("station1")
|
||||
orig_tx_func: Callable
|
||||
orig_rx_func: Callable
|
||||
log.debug("t_datac0_1:", TMP_PATH=tmp_path)
|
||||
log.debug("t_datac13_1:", TMP_PATH=tmp_path)
|
||||
|
||||
# Unpack tuple
|
||||
data, timeout_duration, tx_check, _, final_tx_check, _ = config
|
||||
|
@ -143,12 +143,12 @@ def t_datac0_1(
|
|||
tmp_path,
|
||||
)
|
||||
|
||||
log.info("t_datac0_1:", RXCHANNEL=modem.RXCHANNEL)
|
||||
log.info("t_datac0_1:", TXCHANNEL=modem.TXCHANNEL)
|
||||
log.info("t_datac13_1:", RXCHANNEL=modem.RXCHANNEL)
|
||||
log.info("t_datac13_1:", TXCHANNEL=modem.TXCHANNEL)
|
||||
|
||||
time.sleep(0.5)
|
||||
if "stop" in data["command"]:
|
||||
log.debug("t_datac0_1: STOP test, setting TNC state")
|
||||
log.debug("t_datac13_1: STOP test, setting TNC state")
|
||||
static.TNC_STATE = "BUSY"
|
||||
static.ARQ_STATE = True
|
||||
sock.ThreadedTCPRequestHandler.process_tnc_commands(None,json.dumps(data, indent=None))
|
||||
|
@ -199,7 +199,7 @@ def t_datac0_1(
|
|||
log.warning("station1: Exiting!")
|
||||
|
||||
|
||||
def t_datac0_2(
|
||||
def t_datac13_2(
|
||||
parent_pipe,
|
||||
mycall: str,
|
||||
dxcall: str,
|
||||
|
@ -209,7 +209,7 @@ def t_datac0_2(
|
|||
log = structlog.get_logger("station2")
|
||||
orig_tx_func: Callable
|
||||
orig_rx_func: Callable
|
||||
log.debug("t_datac0_2:", TMP_PATH=tmp_path)
|
||||
log.debug("t_datac13_2:", TMP_PATH=tmp_path)
|
||||
|
||||
# Unpack tuple
|
||||
data, timeout_duration, _, rx_check, _, final_rx_check = config
|
||||
|
@ -259,8 +259,8 @@ def t_datac0_2(
|
|||
tmp_path,
|
||||
)
|
||||
|
||||
log.info("t_datac0_2:", RXCHANNEL=modem.RXCHANNEL)
|
||||
log.info("t_datac0_2:", TXCHANNEL=modem.TXCHANNEL)
|
||||
log.info("t_datac13_2:", RXCHANNEL=modem.RXCHANNEL)
|
||||
log.info("t_datac13_2:", TXCHANNEL=modem.TXCHANNEL)
|
||||
|
||||
if "cq" in data:
|
||||
t_data = {"type": "arq", "command": "stop_transmission"}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Negative test utilities for datac0 frames.
|
||||
Negative test utilities for datac13 frames.
|
||||
|
||||
@author: kronenpj
|
||||
"""
|
||||
|
@ -77,7 +77,7 @@ def t_setup(
|
|||
return tnc, orig_rx_func, orig_tx_func
|
||||
|
||||
|
||||
def t_datac0_1(
|
||||
def t_datac13_1(
|
||||
parent_pipe,
|
||||
mycall: str,
|
||||
dxcall: str,
|
||||
|
@ -87,7 +87,7 @@ def t_datac0_1(
|
|||
log = structlog.get_logger("station1")
|
||||
orig_tx_func: Callable
|
||||
orig_rx_func: Callable
|
||||
log.debug("t_datac0_1:", TMP_PATH=tmp_path)
|
||||
log.debug("t_datac13_1:", TMP_PATH=tmp_path)
|
||||
|
||||
# Unpack tuple
|
||||
data, timeout_duration, tx_check, _, final_tx_check, _ = config
|
||||
|
@ -137,14 +137,14 @@ def t_datac0_1(
|
|||
tmp_path,
|
||||
)
|
||||
|
||||
log.info("t_datac0_1:", RXCHANNEL=modem.RXCHANNEL)
|
||||
log.info("t_datac0_1:", TXCHANNEL=modem.TXCHANNEL)
|
||||
log.info("t_datac13_1:", RXCHANNEL=modem.RXCHANNEL)
|
||||
log.info("t_datac13_1:", TXCHANNEL=modem.TXCHANNEL)
|
||||
|
||||
orig_dxcall = static.DXCALLSIGN
|
||||
if "stop" in data["command"]:
|
||||
time.sleep(0.5)
|
||||
log.debug(
|
||||
"t_datac0_1: STOP test, setting TNC state",
|
||||
"t_datac13_1: STOP test, setting TNC state",
|
||||
mycall=static.MYCALLSIGN,
|
||||
dxcall=static.DXCALLSIGN,
|
||||
)
|
||||
|
@ -204,7 +204,7 @@ def t_datac0_1(
|
|||
log.warning("station1: Exiting!")
|
||||
|
||||
|
||||
def t_datac0_2(
|
||||
def t_datac13_2(
|
||||
parent_pipe,
|
||||
mycall: str,
|
||||
dxcall: str,
|
||||
|
@ -214,7 +214,7 @@ def t_datac0_2(
|
|||
log = structlog.get_logger("station2")
|
||||
orig_tx_func: Callable
|
||||
orig_rx_func: Callable
|
||||
log.debug("t_datac0_2:", TMP_PATH=tmp_path)
|
||||
log.debug("t_datac13_2:", TMP_PATH=tmp_path)
|
||||
|
||||
# Unpack tuple
|
||||
data, timeout_duration, _, rx_check, _, final_rx_check = config
|
||||
|
@ -264,9 +264,9 @@ def t_datac0_2(
|
|||
tmp_path,
|
||||
)
|
||||
|
||||
log.info("t_datac0_2:", RXCHANNEL=modem.RXCHANNEL)
|
||||
log.info("t_datac0_2:", TXCHANNEL=modem.TXCHANNEL)
|
||||
log.info("t_datac0_2:", mycall=static.MYCALLSIGN)
|
||||
log.info("t_datac13_2:", RXCHANNEL=modem.RXCHANNEL)
|
||||
log.info("t_datac13_2:", TXCHANNEL=modem.TXCHANNEL)
|
||||
log.info("t_datac13_2:", mycall=static.MYCALLSIGN)
|
||||
|
||||
if "cq" in data:
|
||||
t_data = {"type": "arq", "command": "stop_transmission"}
|
||||
|
|
|
@ -67,7 +67,7 @@ def test_mm_rx():
|
|||
for idx in range(3):
|
||||
datac_freedv.append(
|
||||
ctypes.cast(
|
||||
codec2.api.freedv_open(codec2.FREEDV_MODE.datac0.value), ctypes.c_void_p
|
||||
codec2.api.freedv_open(codec2.FREEDV_MODE.datac13.value), ctypes.c_void_p
|
||||
)
|
||||
)
|
||||
datac_bytes_per_frame.append(
|
||||
|
@ -121,11 +121,11 @@ def test_mm_rx():
|
|||
for idx in range(3):
|
||||
datac_nin[idx] = codec2.api.freedv_nin(datac_freedv[idx])
|
||||
|
||||
def print_stats(time_datac0, time_datac1, time_datac3):
|
||||
def print_stats(time_datac13, time_datac1, time_datac3):
|
||||
if not DEBUGGING_MODE:
|
||||
return
|
||||
|
||||
time_datac = [time_datac0, time_datac1, time_datac3]
|
||||
time_datac = [time_datac13, time_datac1, time_datac3]
|
||||
datac_rxstatus = ["", "", ""]
|
||||
for idx in range(3):
|
||||
datac_rxstatus[idx] = codec2.api.rx_sync_flags_to_text[
|
||||
|
@ -206,7 +206,7 @@ def test_mm_rx():
|
|||
print("TIMEOUT REACHED", file=sys.stderr)
|
||||
|
||||
print(
|
||||
f"DATAC0: {rx_bursts_datac[0]}/{rx_total_frames_datac[0]} "
|
||||
f"datac13: {rx_bursts_datac[0]}/{rx_total_frames_datac[0]} "
|
||||
f"DATAC1: {rx_bursts_datac[1]}/{rx_total_frames_datac[1]} "
|
||||
f"DATAC3: {rx_bursts_datac[2]}/{rx_total_frames_datac[2]}",
|
||||
file=sys.stderr,
|
||||
|
|
|
@ -49,7 +49,7 @@ def test_mm_tx():
|
|||
data_out = b"HELLO WORLD!"
|
||||
|
||||
modes = [
|
||||
codec2.FREEDV_MODE.datac0.value,
|
||||
codec2.FREEDV_MODE.datac13.value,
|
||||
codec2.FREEDV_MODE.datac1.value,
|
||||
codec2.FREEDV_MODE.datac3.value,
|
||||
]
|
||||
|
|
|
@ -221,7 +221,7 @@ def parse_arguments():
|
|||
"--framesperburst", dest="N_FRAMES_PER_BURST", default=1, type=int
|
||||
)
|
||||
parser.add_argument(
|
||||
"--mode", dest="FREEDV_MODE", type=str, choices=["datac0", "datac1", "datac3"]
|
||||
"--mode", dest="FREEDV_MODE", type=str, choices=["datac13", "datac1", "datac3"]
|
||||
)
|
||||
parser.add_argument(
|
||||
"--audiodev",
|
||||
|
|
|
@ -198,7 +198,7 @@ def parse_arguments():
|
|||
help="delay between bursts in ms",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--mode", dest="FREEDV_MODE", type=str, choices=["datac0", "datac1", "datac3"]
|
||||
"--mode", dest="FREEDV_MODE", type=str, choices=["datac13", "datac1", "datac3"]
|
||||
)
|
||||
parser.add_argument(
|
||||
"--audiodev",
|
||||
|
|
Loading…
Reference in a new issue