2022-01-04 14:29:51 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Created on Wed Dec 23 07:04:24 2020
|
|
|
|
|
|
|
|
@author: DJ2LS
|
|
|
|
"""
|
|
|
|
|
|
|
|
import sys
|
2022-05-21 23:04:17 +00:00
|
|
|
|
2022-01-04 22:02:29 +00:00
|
|
|
import codec2
|
2022-05-21 23:04:17 +00:00
|
|
|
import data_handler
|
2022-01-12 06:42:37 +00:00
|
|
|
import modem
|
2022-05-21 23:04:17 +00:00
|
|
|
import pytest
|
|
|
|
import static
|
|
|
|
|
|
|
|
bytes_out = b'{"dt":"f","fn":"zeit.txt","ft":"text\\/plain","d":"data:text\\/plain;base64,MyBtb2Rlcywgb2huZSBjbGFzcwowLjAwMDk2OTQ4MTE4MDk5MTg0MTcKCjIgbW9kZXMsIG9obmUgY2xhc3MKMC4wMDA5NjY1NDUxODkxMjI1Mzk0CgoxIG1vZGUsIG9obmUgY2xhc3MKMC4wMDA5NjY5NzY1NTU4Nzc4MjA5CgMyBtb2Rlcywgb2huZSBjbGFzcwowLjAwMDk2OTQ4MTE4MDk5MTg0MTcKCjIgbW9kZXMsIG9obmUgY2xhc3MKMC4wMDA5NjY1NDUxODkxMjI1Mzk0CgoxIG1vZGUsIG9obmUgY2xhc3MKMC4wMDA5NjY5NzY1NTU4Nzc4MjA5Cg=MyBtb2Rlcywgb2huZSBjbGFzcwowLjAwMDk2OTQ4MTE4MDk5MTg0MTcKCjIgbW9kZXMsIG9obmUgY2xhc3MKMC4wMDA5NjY1NDUxODkxMjI1Mzk0CgoxIG1vZGUsIG9obmUgY2xhc3MKMC4wMDA5NjY5NzY1NTU4Nzc4MjA5CgMyBtb2Rlcywgb2huZSBjbGFzcwowLjAwMDk2OTQ4MTE4MDk5MTg0MTcKCjIgbW9kZXMsIG9obmUgY2xhc3MKMC4wMDA5NjY1NDUxODkxMjI1Mzk0CgoxIG1vZGUsIG9obmUgY2xhc3MKMC4wMDA5NjY5NzY1NTU4Nzc4MjA5CgMyBtb2Rlcywgb2huZSBjbGFzcwowLjAwMDk2OTQ4MTE4MDk5MTg0MTcKCjIgbW9kZXMsIG9obmUgY2xhc3MKMC4wMDA5NjY1NDUxODkxMjI1Mzk0CgoxIG1vZGUsIG9obmUgY2xhc3MKMC4wMDA5NjY5NzY1NTU4Nzc4MjA5Cg=","crc":"123123123"}'
|
2022-01-04 14:29:51 +00:00
|
|
|
|
|
|
|
|
2022-05-21 23:04:17 +00:00
|
|
|
@pytest.mark.parametrize("freedv_mode", ["datac0", "datac1", "datac3"])
|
|
|
|
@pytest.mark.parametrize("n_frames_per_burst", [1, 2, 3])
|
|
|
|
def test_highsnr_arq_short(freedv_mode: str, n_frames_per_burst: int):
|
|
|
|
t_mode = t_repeats = t_repeat_delay = 0
|
|
|
|
t_frames = []
|
2022-01-04 14:29:51 +00:00
|
|
|
|
2022-05-21 23:04:17 +00:00
|
|
|
def t_tx_dummy(mode, repeats, repeat_delay, frames):
|
|
|
|
"""Replacement function for transmit"""
|
|
|
|
print(f"t_tx_dummy: In transmit({mode}, {repeats}, {repeat_delay}, {frames})")
|
|
|
|
nonlocal t_mode, t_repeats, t_repeat_delay, t_frames
|
|
|
|
t_mode = mode
|
|
|
|
t_repeats = repeats
|
|
|
|
t_repeat_delay = repeat_delay
|
|
|
|
t_frames = frames[:]
|
|
|
|
static.TRANSMITTING = False
|
|
|
|
|
|
|
|
# Enable testmode
|
|
|
|
modem.TESTMODE = True
|
|
|
|
# Set some inner variables so the modules don't throw exceptions.
|
|
|
|
modem.RXCHANNEL = "/tmp/rxpipe"
|
|
|
|
modem.TXCHANNEL = "/tmp/txpipe"
|
|
|
|
data_handler.TESTMODE = True
|
|
|
|
static.HAMLIB_RADIOCONTROL = "disabled"
|
|
|
|
|
|
|
|
# start data handler
|
|
|
|
data_handler.DATA()
|
2022-01-04 22:02:29 +00:00
|
|
|
|
2022-05-21 23:04:17 +00:00
|
|
|
# start modem
|
|
|
|
t_modem = modem.RF()
|
2022-01-04 14:29:51 +00:00
|
|
|
|
2022-05-21 23:04:17 +00:00
|
|
|
# Replace transmit routine with our own, an effective No-Op.
|
|
|
|
t_modem.transmit = t_tx_dummy
|
2022-01-12 06:42:37 +00:00
|
|
|
|
2022-05-21 23:04:17 +00:00
|
|
|
mode = codec2.freedv_get_mode_value_by_name(freedv_mode)
|
|
|
|
print(mode)
|
2022-01-12 06:42:37 +00:00
|
|
|
|
2022-05-21 23:04:17 +00:00
|
|
|
# add command to data qeue
|
|
|
|
data_handler.DATA_QUEUE_TRANSMIT.put(
|
|
|
|
["ARQ_FILE", bytes_out, mode, n_frames_per_burst]
|
|
|
|
)
|
2022-01-12 06:42:37 +00:00
|
|
|
|
2022-05-21 23:04:17 +00:00
|
|
|
# This test isn't complete yet, or is obsolete.
|
|
|
|
assert False
|
2022-01-12 06:42:37 +00:00
|
|
|
|
2022-05-23 12:26:14 +00:00
|
|
|
|
2022-05-21 23:04:17 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
# Run pytest with the current script as the filename.
|
|
|
|
ecode = pytest.main(["-v", sys.argv[0]])
|
|
|
|
if ecode == 0:
|
|
|
|
print("errors: 0")
|
|
|
|
else:
|
|
|
|
print(ecode)
|