summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgr-digital/examples/ofdm/benchmark_ofdm_rx.py6
-rwxr-xr-xgr-digital/examples/ofdm/benchmark_ofdm_tx.py6
-rw-r--r--gr-digital/examples/ofdm/receive_path.py3
-rw-r--r--gr-digital/examples/ofdm/transmit_path.py3
-rw-r--r--gr-digital/examples/ofdm/uhd_interface.py40
5 files changed, 20 insertions, 38 deletions
diff --git a/gr-digital/examples/ofdm/benchmark_ofdm_rx.py b/gr-digital/examples/ofdm/benchmark_ofdm_rx.py
index 6f8e59d98..f2ed3b8ff 100755
--- a/gr-digital/examples/ofdm/benchmark_ofdm_rx.py
+++ b/gr-digital/examples/ofdm/benchmark_ofdm_rx.py
@@ -38,12 +38,10 @@ class my_top_block(gr.top_block):
gr.top_block.__init__(self)
if(options.rx_freq is not None):
- self.source = uhd_receiver(options.address, options.bitrate,
- options.samples_per_symbol,
+ self.source = uhd_receiver(options.address,
+ options.bandwidth,
options.rx_freq, options.rx_gain,
options.antenna, options.verbose)
- options.samples_per_symbol = self.source._sps
-
elif(options.from_file is not None):
self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file)
else:
diff --git a/gr-digital/examples/ofdm/benchmark_ofdm_tx.py b/gr-digital/examples/ofdm/benchmark_ofdm_tx.py
index fb4d97302..ad3609b52 100755
--- a/gr-digital/examples/ofdm/benchmark_ofdm_tx.py
+++ b/gr-digital/examples/ofdm/benchmark_ofdm_tx.py
@@ -37,12 +37,10 @@ class my_top_block(gr.top_block):
gr.top_block.__init__(self)
if(options.tx_freq is not None):
- self.sink = uhd_transmitter(options.address, options.bitrate,
- options.samples_per_symbol,
+ self.sink = uhd_transmitter(options.address,
+ options.bandwidth,
options.tx_freq, options.tx_gain,
options.antenna, options.verbose)
- options.samples_per_symbol = self.sink._sps
-
elif(options.to_file is not None):
self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file)
else:
diff --git a/gr-digital/examples/ofdm/receive_path.py b/gr-digital/examples/ofdm/receive_path.py
index 8807b0dc2..e1c7868a0 100644
--- a/gr-digital/examples/ofdm/receive_path.py
+++ b/gr-digital/examples/ofdm/receive_path.py
@@ -87,6 +87,9 @@ class receive_path(gr.hier_block2):
"""
Adds receiver-specific options to the Options Parser
"""
+ normal.add_option("-W", "--bandwidth", type="eng_float",
+ default=500e3,
+ help="set symbol bandwidth [default=%default]")
normal.add_option("-v", "--verbose", action="store_true", default=False)
expert.add_option("", "--log", action="store_true", default=False,
help="Log all parts of flow graph to files (CAUTION: lots of data)")
diff --git a/gr-digital/examples/ofdm/transmit_path.py b/gr-digital/examples/ofdm/transmit_path.py
index 6077b28e4..ec357d617 100644
--- a/gr-digital/examples/ofdm/transmit_path.py
+++ b/gr-digital/examples/ofdm/transmit_path.py
@@ -80,6 +80,9 @@ class transmit_path(gr.hier_block2):
normal.add_option("", "--tx-amplitude", type="eng_float",
default=0.1, metavar="AMPL",
help="set transmitter digital amplitude: 0 <= AMPL < 1.0 [default=%default]")
+ normal.add_option("-W", "--bandwidth", type="eng_float",
+ default=500e3,
+ help="set symbol bandwidth [default=%default]")
normal.add_option("-v", "--verbose", action="store_true",
default=False)
expert.add_option("", "--log", action="store_true",
diff --git a/gr-digital/examples/ofdm/uhd_interface.py b/gr-digital/examples/ofdm/uhd_interface.py
index 8420f3eec..d03bd7f46 100644
--- a/gr-digital/examples/ofdm/uhd_interface.py
+++ b/gr-digital/examples/ofdm/uhd_interface.py
@@ -42,7 +42,7 @@ def add_freq_option(parser):
metavar="FREQ")
class uhd_interface:
- def __init__(self, istx, address, bitrate, sps, freq=None,
+ def __init__(self, istx, address, bandwidth, freq=None,
gain=None, antenna=None):
if(istx):
@@ -59,36 +59,16 @@ class uhd_interface:
self._gain = self.set_gain(gain)
self._freq = self.set_freq(freq)
- self._rate, self._sps = self.set_sample_rate(bitrate, sps)
+ self._rate = self.set_sample_rate(bandwidth)
if(antenna):
self.u.set_antenna(antenna, 0)
- def set_sample_rate(self, bitrate, req_sps):
- start_sps = req_sps
- while(True):
- asked_samp_rate = bitrate * req_sps
- self.u.set_samp_rate(asked_samp_rate)
- actual_samp_rate = self.u.get_samp_rate()
-
- sps = actual_samp_rate/bitrate
- if(sps < 2):
- req_sps +=1
- else:
- actual_sps = sps
- break
+ def set_sample_rate(self, bandwidth):
+ self.u.set_samp_rate(bandwidth)
+ actual_bw = self.u.get_samp_rate()
- if(sps != req_sps):
- print "\nBit Rate: %f" % (bitrate)
- print "Requested sps: %f" % (start_sps)
- print "Given sample rate: %f" % (actual_samp_rate)
- print "Actual sps for rate: %f" % (actual_sps)
-
- if(actual_samp_rate != asked_samp_rate):
- print "\nRequested sample rate: %f" % (asked_samp_rate)
- print "Actual sample rate: %f" % (actual_samp_rate)
-
- return (actual_samp_rate, actual_sps)
+ return actual_bw
def get_sample_rate(self):
return self.u.get_samp_rate()
@@ -124,14 +104,14 @@ class uhd_interface:
#-------------------------------------------------------------------#
class uhd_transmitter(uhd_interface, gr.hier_block2):
- def __init__(self, address, bitrate, sps, freq=None, gain=None,
+ def __init__(self, address, bandwidth, freq=None, gain=None,
antenna=None, verbose=False):
gr.hier_block2.__init__(self, "uhd_transmitter",
gr.io_signature(1,1,gr.sizeof_gr_complex),
gr.io_signature(0,0,0))
# Set up the UHD interface as a transmitter
- uhd_interface.__init__(self, True, address, bitrate, sps,
+ uhd_interface.__init__(self, True, address, bandwidth,
freq, gain, antenna)
self.connect(self, self.u)
@@ -174,14 +154,14 @@ class uhd_transmitter(uhd_interface, gr.hier_block2):
class uhd_receiver(uhd_interface, gr.hier_block2):
- def __init__(self, address, bitrate, sps, freq=None, gain=None,
+ def __init__(self, address, bandwidth, freq=None, gain=None,
antenna=None, verbose=False):
gr.hier_block2.__init__(self, "uhd_receiver",
gr.io_signature(0,0,0),
gr.io_signature(1,1,gr.sizeof_gr_complex))
# Set up the UHD interface as a receiver
- uhd_interface.__init__(self, False, address, bitrate, sps,
+ uhd_interface.__init__(self, False, address, bandwidth,
freq, gain, antenna)
self.connect(self.u, self)