diff options
-rwxr-xr-x | dpd/iq_file_server.py | 1 | ||||
-rwxr-xr-x | dpd/main.py | 44 | ||||
-rwxr-xr-x | dpd/show_spectrum.py | 11 | ||||
-rw-r--r-- | dpd/src/Measure.py | 16 |
4 files changed, 48 insertions, 24 deletions
diff --git a/dpd/iq_file_server.py b/dpd/iq_file_server.py index 2a38151..7a4e570 100755 --- a/dpd/iq_file_server.py +++ b/dpd/iq_file_server.py @@ -4,7 +4,6 @@ # This example server simulates the ODR-DabMod's # DPD server, taking samples from an IQ file # -# Copyright (C) 2017 Matthias P. Braendli # http://www.opendigitalradio.org # Licence: The MIT License, see notice at the end of this file diff --git a/dpd/main.py b/dpd/main.py index c871879..98eeb84 100755 --- a/dpd/main.py +++ b/dpd/main.py @@ -1,8 +1,14 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -"""This Python script calculates and updates the parameter of the digital -predistortion module of the ODR-DabMod. More precisely the complex -coefficients of the polynom which is used for predistortion.""" +# +# DPD Calculation Engine main file. +# +# http://www.opendigitalradio.org +# Licence: The MIT License, see notice at the end of this file + +"""This Python script is the main file for ODR-DabMod's DPD Computation Engine. +This engine calculates and updates the parameter of the digital +predistortion module of ODR-DabMod.""" import logging logging.basicConfig(format='%(asctime)s - %(module)s - %(levelname)s - %(message)s', @@ -15,12 +21,32 @@ import src.Measure as Measure import src.Model as Model import src.Adapt as Adapt -port = 50055 -port_rc = 9400 -coef_path = "/home/andreas/dab/ODR-DabMod/polyCoefsCustom" -num_req = 10240 +parser = argparse.ArgumentParser(description="DPD Computation Engine for ODR-DabMod") +parser.add_argument('--port', default='50055', + help='port of DPD server to connect to (default: 50055)', + required=False) +parser.add_argument('--rc-port', default='9400', + help='port of ODR-DabMod ZMQ Remote Control to connect to (default: 9400)', + required=False) +parser.add_argument('--samplerate', default='8192000', + help='Sample rate', + required=False) +parser.add_argument('--coefs', default='dpdpoly.coef', + help='File with DPD coefficients, which will be read by ODR-DabMod', + required=False) +parser.add_argument('--samps', default='10240', + help='Number of samples to request from ODR-DabMod', + required=False) + +cli_args = parser.parse_args() + +port = int(cli_args.port) +port_rc = int(cli_args.rc_port) +coef_path = cli_args.coefs +num_req = int(cli_args.samps) +samplerate = int(cli_args.samplerate) -meas = Measure.Measure(port, num_req) +meas = Measure.Measure(samplerate, port, num_req) adapt = Adapt.Adapt(port_rc, coef_path) coefs = adapt.get_coefs() model = Model.Model(coefs) @@ -31,7 +57,7 @@ adapt.set_coefs(coefs) # The MIT License (MIT) # -# Copyright (c) 2017 Andreas Steger +# Copyright (c) 2017 Andreas Steger, Matthias P. Braendli # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/dpd/show_spectrum.py b/dpd/show_spectrum.py index 0ae24c2..95dbef9 100755 --- a/dpd/show_spectrum.py +++ b/dpd/show_spectrum.py @@ -1,16 +1,15 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # -# This is an example tool that shows how to connect to ODR-DabMod's dpd TCP server -# and get samples from there. +# This is an example tool that shows how to connect to ODR-DabMod's dpd TCP +# server and get samples from there. # -# Since the TX and RX samples are not perfectly aligned, the tool has to align them properly, -# which is done in two steps: First on sample-level using a correlation, then with subsample -# accuracy using a FFT approach. +# Since the TX and RX samples are not perfectly aligned, the tool has to align +# them properly, which is done in two steps: First on sample-level using a +# correlation, then with subsample accuracy using a FFT approach. # # It requires SciPy and matplotlib. # -# Copyright (C) 2017 Matthias P. Braendli # http://www.opendigitalradio.org # Licence: The MIT License, see notice at the end of this file diff --git a/dpd/src/Measure.py b/dpd/src/Measure.py index 76f17b2..1b0ac75 100644 --- a/dpd/src/Measure.py +++ b/dpd/src/Measure.py @@ -4,7 +4,7 @@ import sys import socket import struct import numpy as np -import matplotlib.pyplot as pp +import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation import argparse import os @@ -15,16 +15,18 @@ import datetime class Measure: """Collect Measurement from DabMod""" - def __init__(self, port, num_samples_to_request): - """""" + def __init__(self, samplerate, port, num_samples_to_request): logging.info("Instantiate Measure object") + self.samplerate = samplerate self.sizeof_sample = 8 # complex floats self.port = port self.num_samples_to_request = num_samples_to_request def _recv_exact(self, sock, num_bytes): - """Interfaces the socket to receive a byte string - + """Receive an exact number of bytes from a socket. This is + a wrapper around sock.recv() that can return less than the number + of requested bytes. + Args: sock (socket): Socket to receive data from. num_bytes (int): Number of bytes that will be returned. @@ -77,8 +79,6 @@ class Measure: rxframe = np.array([], dtype=np.complex64) if logging.getLogger().getEffectiveLevel() == logging.DEBUG: - import matplotlib.pyplot as plt - txframe_path = ('/tmp/txframe_fft_' + datetime.datetime.now().isoformat() + '.pdf') @@ -108,7 +108,7 @@ class Measure: logging.debug("Disconnecting") s.close() - du = DU.Dab_Util(8192000) + du = DU.Dab_Util(samplerate) txframe_aligned, rxframe_aligned = du.subsample_align(txframe, rxframe) logging.info( |