From e33b82b805d0fcaaf24508db12be3bc602b23923 Mon Sep 17 00:00:00 2001 From: DJ2LS <75909252+DJ2LS@users.noreply.github.com> Date: Sat, 6 Apr 2024 18:03:00 +0200 Subject: [PATCH] first test program --- modem/codec2.py | 16 ++++--- .../create_custom_ofdm_mod.py | 42 +++++++++++++++++++ 2 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 tools/custom_mode_tests/create_custom_ofdm_mod.py diff --git a/modem/codec2.py b/modem/codec2.py index ea6fc1af..24f77e20 100644 --- a/modem/codec2.py +++ b/modem/codec2.py @@ -475,11 +475,11 @@ def create_default_ofdm_config(): nuwbits=40, bad_uw_errors=10, ftwindowwidth=80, - edge_pilots=False, - state_machine=b"data", + edge_pilots=0, + state_machine="data".encode("utf-8"), codename=b"H_1024_2048_4f", tx_uw=uw_sequence, - amp_est_mode=1, + amp_est_mode=True, tx_bpf_en=False, rx_bpf_en=False, foff_limiter=False, @@ -507,7 +507,7 @@ def create_default_ofdm_config(): data_ofdm_500_config = create_default_ofdm_config() -print(data_ofdm_500_config) +#print(data_ofdm_500_config) data_ofdm_500_config.config.contents.ns = 5 data_ofdm_500_config.config.contents.np = 29 data_ofdm_500_config.config.contents.tcp = 0.006 @@ -520,13 +520,17 @@ data_ofdm_500_config.config.contents.amp_est_mode = 1 data_ofdm_500_config.config.contents.amp_scale = 300E3 data_ofdm_500_config.config.contents.codename = b"H_1024_2048_4f" data_ofdm_500_config.config.contents.clip_en = True -data_ofdm_500_config.config.contents.clip_gain1 = 2.7; +data_ofdm_500_config.config.contents.clip_gain1 = 2.2; data_ofdm_500_config.config.contents.clip_gain2 = 0.8; data_ofdm_500_config.config.contents.timing_mx_thresh = 0.10; data_ofdm_500_config.config.contents.tx_bpf_en = False data_ofdm_500_config.config.contents.rx_bpf_en = False # Fill the tx_uw field with the uw_sequence, and pad the rest with zeros if necessary -uw_sequence = [1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0] +uw_sequence = [1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0] +#print(uw_sequence) +#print(len(uw_sequence)) +#uw_sequence.reverse() +#print(uw_sequence) data_ofdm_500_config.tx_uw = (ctypes.c_uint8 * MAX_UW_BITS)(*(uw_sequence + [0]*(MAX_UW_BITS-len(uw_sequence)))) diff --git a/tools/custom_mode_tests/create_custom_ofdm_mod.py b/tools/custom_mode_tests/create_custom_ofdm_mod.py new file mode 100644 index 00000000..edbe6ded --- /dev/null +++ b/tools/custom_mode_tests/create_custom_ofdm_mod.py @@ -0,0 +1,42 @@ +""" + +FreeDATA % python3.11 tools/custom_mode_tests/create_custom_ofdm_mod.py | ./modem/lib/codec2/build_osx/src/freedv_data_raw_rx --vv --framesperburst 1 DATAC1 - /dev/null + + +""" +import sys +sys.path.append('modem') +import numpy as np + +modem_path = '/../../modem' +if modem_path not in sys.path: + sys.path.append(modem_path) + + + +#import modem.codec2 as codec2 +from codec2 import * + +import modulator as modulator +import config as config + +config = config.CONFIG('config.ini') +modulator = modulator.Modulator(config.read()) +#freedv = open_instance(FREEDV_MODE.data_ofdm_2438.value) +#freedv = open_instance(FREEDV_MODE.datac3.value) +freedv = open_instance(FREEDV_MODE.data_ofdm_500.value) + +frames = 10 +txbuffer = bytearray() + +for frame in range(0,frames): + txbuffer = modulator.transmit_add_silence(txbuffer, 1000) + txbuffer = modulator.transmit_add_preamble(txbuffer, freedv) + txbuffer = modulator.transmit_create_frame(txbuffer, freedv, b'123') + txbuffer = modulator.transmit_add_postamble(txbuffer, freedv) + txbuffer = modulator.transmit_add_silence(txbuffer, 1000) + +#print(txbuffer) + +sys.stdout.buffer.write(txbuffer) +sys.stdout.buffer.flush()