mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
fixing tests
This commit is contained in:
parent
ef18f4cc04
commit
0ef657945b
7 changed files with 71 additions and 16 deletions
|
@ -38,8 +38,8 @@ class ARQSession:
|
|||
},
|
||||
4: {
|
||||
'mode': codec2.FREEDV_MODE.qam16c2,
|
||||
'min_snr': 10,
|
||||
'duration_per_frame': 2.18,
|
||||
'min_snr': 11,
|
||||
'duration_per_frame': 2.8,
|
||||
'bandwidth': 2100,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -581,7 +581,7 @@ data_ofdm_500_config.config.contents.codename = b"H_4096_8192_3d"
|
|||
data_ofdm_500_config.config.contents.amp_scale = 145E3
|
||||
data_ofdm_500_config.config.contents.tx_uw = create_tx_uw(16, [1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0])
|
||||
|
||||
"""
|
||||
|
||||
# ---------------- OFDM 2438 Hz Bandwidth 16200,9720 ---------------#
|
||||
data_ofdm_2438_config = create_default_ofdm_config()
|
||||
data_ofdm_2438_config.config.contents.ns = 5
|
||||
|
@ -600,8 +600,9 @@ data_ofdm_2438_config.config.contents.clip_gain1 = 2.7
|
|||
data_ofdm_2438_config.config.contents.clip_gain2 = 0.8
|
||||
data_ofdm_2438_config.config.contents.timing_mx_thresh = 0.10
|
||||
data_ofdm_2438_config.config.contents.tx_uw = create_tx_uw(24, [1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1])
|
||||
"""
|
||||
|
||||
# ---------------- OFDM 2438 Hz Bandwidth 8192,4096 ---------------#
|
||||
"""
|
||||
data_ofdm_2438_config = create_default_ofdm_config()
|
||||
data_ofdm_2438_config.config.contents.ns = 5
|
||||
data_ofdm_2438_config.config.contents.np = 27
|
||||
|
@ -619,7 +620,8 @@ data_ofdm_2438_config.config.contents.clip_gain1 = 2.7
|
|||
data_ofdm_2438_config.config.contents.clip_gain2 = 0.8
|
||||
data_ofdm_2438_config.config.contents.timing_mx_thresh = 0.10
|
||||
data_ofdm_2438_config.config.contents.tx_uw = create_tx_uw(16, [1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1])
|
||||
|
||||
"""
|
||||
"""
|
||||
# ---------------- QAM 2438 Hz Bandwidth ---------------#
|
||||
data_qam_2438_config = create_default_ofdm_config()
|
||||
data_qam_2438_config.config.contents.bps = 4
|
||||
|
@ -639,7 +641,7 @@ data_qam_2438_config.config.contents.clip_gain1 = 2.7
|
|||
data_qam_2438_config.config.contents.clip_gain2 = 0.8
|
||||
data_qam_2438_config.config.contents.timing_mx_thresh = 0.10
|
||||
data_qam_2438_config.config.contents.tx_uw = create_tx_uw(162, [1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0])
|
||||
|
||||
"""
|
||||
ofdm_configurations = {
|
||||
FREEDV_MODE.data_ofdm_500.value: data_ofdm_500_config,
|
||||
FREEDV_MODE.data_ofdm_2438.value: data_ofdm_2438_config,
|
||||
|
|
|
@ -50,6 +50,8 @@ class Demodulator():
|
|||
# enable decoding of signalling modes
|
||||
self.MODE_DICT[codec2.FREEDV_MODE.signalling.value]["decode"] = True
|
||||
self.MODE_DICT[codec2.FREEDV_MODE.signalling_ack.value]["decode"] = True
|
||||
self.MODE_DICT[codec2.FREEDV_MODE.data_ofdm_2438.value]["decode"] = True
|
||||
self.MODE_DICT[codec2.FREEDV_MODE.data_ofdm_500.value]["decode"] = True
|
||||
|
||||
|
||||
tci_rx_callback_thread = threading.Thread(
|
||||
|
@ -72,8 +74,6 @@ class Demodulator():
|
|||
|
||||
# create codec2 instance
|
||||
#c2instance = ctypes.cast(
|
||||
# codec2.api.freedv_open(mode), ctypes.c_void_p
|
||||
#)
|
||||
c2instance = codec2.open_instance(mode)
|
||||
|
||||
# get bytes per frame
|
||||
|
|
|
@ -328,7 +328,8 @@ def sock_states(sock):
|
|||
def stop_server():
|
||||
try:
|
||||
app.service_manager.modem_service.put("stop")
|
||||
app.socket_interface_manager.stop_servers()
|
||||
if app.socket_interface_manager:
|
||||
app.socket_interface_manager.stop_servers()
|
||||
|
||||
if app.service_manager.modem:
|
||||
app.service_manager.modem.sd_input_stream.stop
|
||||
|
|
|
@ -48,7 +48,8 @@ class SM:
|
|||
elif cmd in ['restart']:
|
||||
self.stop_modem()
|
||||
self.stop_radio_manager()
|
||||
if self.config['SOCKET_INTERFACE']['enable']:
|
||||
if self.config['SOCKET_INTERFACE']['enable'] and self.socket_interface_manager:
|
||||
|
||||
self.socket_interface_manager.stop_servers()
|
||||
|
||||
# we need to wait a bit for avoiding a portaudio crash
|
||||
|
|
|
@ -105,7 +105,7 @@ class TestARQSession(unittest.TestCase):
|
|||
mode_name = "SIGNALLING_ACK"
|
||||
else:
|
||||
mode_name = None
|
||||
frame_dispatcher.process_data(frame_bytes, None, len(frame_bytes), 15, 0, mode_name=mode_name)
|
||||
frame_dispatcher.process_data(frame_bytes, None, len(frame_bytes), 5, 0, mode_name=mode_name)
|
||||
except queue.Empty:
|
||||
continue
|
||||
self.logger.info(f"[{threading.current_thread().name}] Channel closed.")
|
||||
|
|
|
@ -16,10 +16,59 @@ if modem_path not in sys.path:
|
|||
|
||||
#import modem.codec2 as codec2
|
||||
from codec2 import *
|
||||
|
||||
import threading
|
||||
import modulator as modulator
|
||||
import demodulator as demodulator
|
||||
import config as config
|
||||
|
||||
|
||||
def demod(txbuffer):
|
||||
c2instance = open_instance(FREEDV_MODE.datac3.value)
|
||||
|
||||
# get bytes per frame
|
||||
bytes_per_frame = int(
|
||||
api.freedv_get_bits_per_modem_frame(c2instance) / 8
|
||||
)
|
||||
# create byte out buffer
|
||||
bytes_out = ctypes.create_string_buffer(bytes_per_frame)
|
||||
|
||||
# set initial frames per burst
|
||||
api.freedv_set_frames_per_burst(c2instance, 1)
|
||||
|
||||
# init audio buffer
|
||||
audiobuffer = audio_buffer(len(txbuffer))
|
||||
|
||||
|
||||
# get initial nin
|
||||
nin = api.freedv_nin(c2instance)
|
||||
audiobuffer.push(txbuffer)
|
||||
threading.Event().wait(0.01)
|
||||
|
||||
|
||||
while audiobuffer.nbuffer >= nin:
|
||||
# demodulate audio
|
||||
nbytes = api.freedv_rawdatarx(
|
||||
freedv, bytes_out, audiobuffer.buffer.ctypes
|
||||
)
|
||||
# get current modem states and write to list
|
||||
# 1 trial
|
||||
# 2 sync
|
||||
# 3 trial sync
|
||||
# 6 decoded
|
||||
# 10 error decoding == NACK
|
||||
rx_status = api.freedv_get_rx_status(freedv)
|
||||
print(rx_status)
|
||||
|
||||
# decrement codec traffic counter for making state smoother
|
||||
|
||||
audiobuffer.pop(nin)
|
||||
nin = api.freedv_nin(freedv)
|
||||
if nbytes == bytes_per_frame:
|
||||
print("DECODED!!!!")
|
||||
print("ENDED")
|
||||
print(nin)
|
||||
print(audiobuffer.nbuffer)
|
||||
|
||||
config = config.CONFIG('config.ini')
|
||||
modulator = modulator.Modulator(config.read())
|
||||
#freedv = open_instance(FREEDV_MODE.data_ofdm_2438.value)
|
||||
|
@ -30,7 +79,7 @@ freedv = open_instance(FREEDV_MODE.datac3.value)
|
|||
#freedv = open_instance(FREEDV_MODE.qam16c2.value)
|
||||
|
||||
|
||||
frames = 1
|
||||
frames = 2
|
||||
txbuffer = bytearray()
|
||||
|
||||
for frame in range(0,frames):
|
||||
|
@ -40,6 +89,8 @@ for frame in range(0,frames):
|
|||
txbuffer = modulator.transmit_add_postamble(txbuffer, freedv)
|
||||
txbuffer = modulator.transmit_add_silence(txbuffer, 1000)
|
||||
|
||||
sys.stdout.buffer.flush()
|
||||
sys.stdout.buffer.write(txbuffer)
|
||||
sys.stdout.buffer.flush()
|
||||
#sys.stdout.buffer.flush()
|
||||
#sys.stdout.buffer.write(txbuffer)
|
||||
#sys.stdout.buffer.flush()
|
||||
demod(txbuffer)
|
||||
|
||||
|
|
Loading…
Reference in a new issue