From 7e985e7f553a863df37cf39bfd2bd958d82ea46c Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Wed, 19 Oct 2011 09:58:03 -0700
Subject: digital: fixed digital narrowband examples to use args instead of
 address and better default.

---
 gr-digital/examples/narrowband/benchmark_rx.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'gr-digital/examples/narrowband/benchmark_rx.py')

diff --git a/gr-digital/examples/narrowband/benchmark_rx.py b/gr-digital/examples/narrowband/benchmark_rx.py
index 65aac3638c..19c242ec5b 100755
--- a/gr-digital/examples/narrowband/benchmark_rx.py
+++ b/gr-digital/examples/narrowband/benchmark_rx.py
@@ -44,7 +44,7 @@ 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,
+            self.source = uhd_receiver(options.args, options.bitrate,
                                        options.samples_per_symbol,
                                        options.rx_freq, options.rx_gain,
                                        options.antenna, options.verbose)
-- 
cgit v1.2.3


From b35d84eb447f44b547d928e5741feab7660c39e6 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Wed, 19 Oct 2011 10:23:53 -0700
Subject: digital: fixed digital narrowband examples to set the sample rate
 based on the symbol rate, not the bitrate, of the modulation.

---
 gr-digital/examples/narrowband/benchmark_rx.py  |  6 +++++-
 gr-digital/examples/narrowband/benchmark_tx.py  |  6 +++++-
 gr-digital/examples/narrowband/tunnel.py        |  8 ++++++--
 gr-digital/examples/narrowband/uhd_interface.py | 20 ++++++++++----------
 4 files changed, 26 insertions(+), 14 deletions(-)

(limited to 'gr-digital/examples/narrowband/benchmark_rx.py')

diff --git a/gr-digital/examples/narrowband/benchmark_rx.py b/gr-digital/examples/narrowband/benchmark_rx.py
index 19c242ec5b..32c3222aeb 100755
--- a/gr-digital/examples/narrowband/benchmark_rx.py
+++ b/gr-digital/examples/narrowband/benchmark_rx.py
@@ -44,7 +44,11 @@ class my_top_block(gr.top_block):
         gr.top_block.__init__(self)
 
         if(options.rx_freq is not None):
-            self.source = uhd_receiver(options.args, options.bitrate,
+            # Work-around to get the modulation's bits_per_symbol
+            args = demodulator.extract_kwargs_from_options(options)
+            symbol_rate = options.bitrate / demodulator(**args).bits_per_symbol()
+
+            self.source = uhd_receiver(options.args, symbol_rate,
                                        options.samples_per_symbol,
                                        options.rx_freq, options.rx_gain,
                                        options.antenna, options.verbose)
diff --git a/gr-digital/examples/narrowband/benchmark_tx.py b/gr-digital/examples/narrowband/benchmark_tx.py
index cc077bb28e..25ed355daf 100755
--- a/gr-digital/examples/narrowband/benchmark_tx.py
+++ b/gr-digital/examples/narrowband/benchmark_tx.py
@@ -43,7 +43,11 @@ class my_top_block(gr.top_block):
         gr.top_block.__init__(self)
 
         if(options.tx_freq is not None):
-            self.sink = uhd_transmitter(options.args, options.bitrate,
+            # Work-around to get the modulation's bits_per_symbol
+            args = modulator.extract_kwargs_from_options(options)
+            symbol_rate = options.bitrate / modulator(**args).bits_per_symbol()
+
+            self.sink = uhd_transmitter(options.args, symbol_rate,
                                         options.samples_per_symbol,
                                         options.tx_freq, options.tx_gain,
                                         options.antenna, options.verbose)
diff --git a/gr-digital/examples/narrowband/tunnel.py b/gr-digital/examples/narrowband/tunnel.py
index 7f40bb1c36..7414a7227a 100755
--- a/gr-digital/examples/narrowband/tunnel.py
+++ b/gr-digital/examples/narrowband/tunnel.py
@@ -92,12 +92,16 @@ class my_top_block(gr.top_block):
 
         gr.top_block.__init__(self)
 
-        self.source = uhd_receiver(options.address, options.bitrate,
+        # Get the modulation's bits_per_symbol
+        args = mod_class.extract_kwargs_from_options(options)
+        symbol_rate = options.bitrate / mod_class(**args).bits_per_symbol()
+
+        self.source = uhd_receiver(options.args, symbol_rate,
                                    options.samples_per_symbol,
                                    options.rx_freq, options.rx_gain,
                                    options.antenna, options.verbose)
 
-        self.sink = uhd_transmitter(options.address, options.bitrate,
+        self.sink = uhd_transmitter(options.args, symbol_rate,
                                     options.samples_per_symbol,
                                     options.tx_freq, options.tx_gain,
                                     options.antenna, options.verbose)
diff --git a/gr-digital/examples/narrowband/uhd_interface.py b/gr-digital/examples/narrowband/uhd_interface.py
index 5dffe46e04..a0be516ec4 100644
--- a/gr-digital/examples/narrowband/uhd_interface.py
+++ b/gr-digital/examples/narrowband/uhd_interface.py
@@ -42,7 +42,7 @@ def add_freq_option(parser):
                           metavar="FREQ")
 
 class uhd_interface:
-    def __init__(self, istx, args, bitrate, sps, freq=None,
+    def __init__(self, istx, args, sym_rate, sps, freq=None,
                  gain=None, antenna=None):
         
         if(istx):
@@ -59,19 +59,19 @@ 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._sps = self.set_sample_rate(sym_rate, sps)
 
         if(antenna):
             self.u.set_antenna(antenna, 0)
         
-    def set_sample_rate(self, bitrate, req_sps):
+    def set_sample_rate(self, sym_rate, req_sps):
         start_sps = req_sps
         while(True):
-            asked_samp_rate = bitrate * req_sps
+            asked_samp_rate = sym_rate * req_sps
             self.u.set_samp_rate(asked_samp_rate)
             actual_samp_rate = self.u.get_samp_rate()
 
-            sps = actual_samp_rate/bitrate
+            sps = actual_samp_rate/sym_rate
             if(sps < 2):
                 req_sps +=1
             else:
@@ -79,7 +79,7 @@ class uhd_interface:
                 break
         
         if(sps != req_sps):
-            print "\nBit Rate:            %f" % (bitrate)
+            print "\nSymbol Rate:         %f" % (sym_rate)
             print "Requested sps:       %f" % (start_sps)
             print "Given sample rate:   %f" % (actual_samp_rate)
             print "Actual sps for rate: %f" % (actual_sps)
@@ -124,14 +124,14 @@ class uhd_interface:
 #-------------------------------------------------------------------#
 
 class uhd_transmitter(uhd_interface, gr.hier_block2):
-    def __init__(self, args, bitrate, sps, freq=None, gain=None,
+    def __init__(self, args, sym_rate, sps, 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, args, bitrate, sps,
+        uhd_interface.__init__(self, True, args, sym_rate, sps,
                                freq, gain, antenna)
 
         self.connect(self, self.u)
@@ -174,14 +174,14 @@ class uhd_transmitter(uhd_interface, gr.hier_block2):
 
 
 class uhd_receiver(uhd_interface, gr.hier_block2):
-    def __init__(self, args, bitrate, sps, freq=None, gain=None,
+    def __init__(self, args, sym_rate, sps, 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, args, bitrate, sps,
+        uhd_interface.__init__(self, False, args, sym_rate, sps,
                                freq, gain, antenna)
 
         self.connect(self.u, self)
-- 
cgit v1.2.3