Merged r11401:11405 from jblum/digital into trunk. Restores tunnel.py, rx_voice...
authorjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Fri, 10 Jul 2009 00:36:36 +0000 (00:36 +0000)
committerjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Fri, 10 Jul 2009 00:36:36 +0000 (00:36 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11406 221aa14e-8319-0410-a670-987f0aec2ac5

gnuradio-examples/python/digital/Makefile.am
gnuradio-examples/python/digital/benchmark_rx.py
gnuradio-examples/python/digital/benchmark_tx.py
gnuradio-examples/python/digital/generic_usrp.py
gnuradio-examples/python/digital/receive_path.py
gnuradio-examples/python/digital/rx_voice.py
gnuradio-examples/python/digital/tunnel.py
gnuradio-examples/python/digital/tx_voice.py
gnuradio-examples/python/digital/usrp_receive_path.py [new file with mode: 0644]
gnuradio-examples/python/digital/usrp_transmit_path.py [new file with mode: 0644]

index d199c84f70ccfb80d53e1556b24b17cefcfb5332..64ce4ec46625e0d9c6dc51a8ec472bbadad0294c 100644 (file)
@@ -33,7 +33,9 @@ dist_ourdata_DATA =           \
        qt_rx_window.py         \
        receive_path.py         \
        transmit_path.py        \
-       usrp_options.py
+       usrp_options.py \
+       usrp_receive_path.py \
+       usrp_transmit_path.py
 
 dist_ourdata_SCRIPTS =         \
        benchmark_loopback.py   \
index f33b846fe47dedda9d62ce701579ac13e7e5ea3d..ccb0c896338c928cac63474297d4ed379be4b08e 100755 (executable)
@@ -31,9 +31,7 @@ import struct
 import sys
 
 # from current dir
-from receive_path import receive_path
-from pick_bitrate import pick_rx_bitrate
-import usrp_options
+import usrp_receive_path
 
 #import os
 #print os.getpid()
@@ -43,111 +41,10 @@ class my_top_block(gr.top_block):
     def __init__(self, demodulator, rx_callback, options):
         gr.top_block.__init__(self)
 
-        self._rx_freq            = options.rx_freq         # receiver's center frequency
-        self._rx_gain            = options.rx_gain         # receiver's gain
-        self._decim              = options.decim           # Decimating rate for the USRP (prelim)
-        self._bitrate            = options.bitrate
-        self._samples_per_symbol = options.samples_per_symbol
-        self._demod_class        = demodulator
-
-        if self._rx_freq is None:
-            sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
-            raise SystemExit
-
-        # Set up USRP source
-        self._setup_usrp_source(options)
-
-        # copy the final answers back into options for use by demodulator
-        options.samples_per_symbol = self._samples_per_symbol
-        options.bitrate = self._bitrate
-        options.decim = self._decim
-
-        ok = self.set_freq(self._rx_freq)
-        if not ok:
-            print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(self._rx_freq))
-            raise ValueError, eng_notation.num_to_str(self._rx_freq)
-
-        self.set_gain(options.rx_gain)
-        self.set_auto_tr(True)                 # enable Auto Transmit/Receive switching
-
         # Set up receive path
-        self.rxpath = receive_path(demodulator, rx_callback, options) 
-
-        self.connect(self.u, self.rxpath)
-        
-    def _setup_usrp_source(self, options):
-        self.u = usrp_options.create_usrp_source(options)
-        adc_rate = self.u.adc_rate()
-
-        self.u.set_decim(self._decim)
-
-        (self._bitrate, self._samples_per_symbol, self._decim) = \
-                        pick_rx_bitrate(self._bitrate, self._demod_class.bits_per_symbol(), \
-                                        self._samples_per_symbol, self._decim, adc_rate,  \
-                                        self.u.get_decim_rates())
-
-        self.u.set_decim(self._decim)
-
-
-    def set_freq(self, target_freq):
-        """
-        Set the center frequency we're interested in.
-
-        @param target_freq: frequency in Hz
-        @rypte: bool
-
-        Tuning is a two step process.  First we ask the front-end to
-        tune as close to the desired frequency as it can.  Then we use
-        the result of that operation and our target_frequency to
-        determine the value for the digital up converter.
-        """
-        return self.u.set_center_freq(target_freq)
-
-    def set_gain(self, gain):
-        """
-        Sets the analog gain in the USRP
-        """
-        if gain is None:
-            r = self.u.gain_range()
-            gain = (r[0] + r[1])/2               # set gain to midpoint
-        self.gain = gain
-        return self.u.set_gain(gain)
-
-    def set_auto_tr(self, enable):
-        return self.u.set_auto_tr(enable)
-
-    def decim(self):
-        return self._decim
-
-    def add_options(normal, expert):
-        """
-        Adds usrp-specific options to the Options Parser
-        """
-        add_freq_option(normal)
-        normal.add_option("-v", "--verbose", action="store_true", default=False)
-
-        expert.add_option("", "--rx-freq", type="eng_float", default=None,
-                          help="set Rx frequency to FREQ [default=%default]", metavar="FREQ")
-   
-
-    # Make a static method to call before instantiation
-    add_options = staticmethod(add_options)
-
-
-def add_freq_option(parser):
-    """
-    Hackery that has the -f / --freq option set both tx_freq and rx_freq
-    """
-    def freq_callback(option, opt_str, value, parser):
-        parser.values.rx_freq = value
-        parser.values.tx_freq = value
-
-    if not parser.has_option('--freq'):
-        parser.add_option('-f', '--freq', type="eng_float",
-                          action="callback", callback=freq_callback,
-                          help="set Tx and/or Rx frequency to FREQ [default=%default]",
-                          metavar="FREQ")
+        self.rxpath = usrp_receive_path.usrp_receive_path(demodulator, rx_callback, options) 
 
+        self.connect(self.rxpath)
 
 # /////////////////////////////////////////////////////////////////////////////
 #                                   main
@@ -183,9 +80,7 @@ def main():
                       help="Select modulation from: %s [default=%%default]"
                             % (', '.join(demods.keys()),))
 
-    my_top_block.add_options(parser, expert_grp)
-    receive_path.add_options(parser, expert_grp)
-    usrp_options.add_rx_options(parser)
+    usrp_receive_path.add_options(parser, expert_grp)
 
     for mod in demods.values():
         mod.add_options(expert_grp)
index 225d103865bc4bd8f69fdfcc290c19d7f916fb82..73c4a3901547cde7229149ed54c628e16eb31b30 100755 (executable)
@@ -29,9 +29,7 @@ from optparse import OptionParser
 import random, time, struct, sys
 
 # from current dir
-from transmit_path import transmit_path
-from pick_bitrate import pick_tx_bitrate
-import usrp_options
+import usrp_transmit_path
 
 #import os 
 #print os.getpid()
@@ -41,124 +39,9 @@ class my_top_block(gr.top_block):
     def __init__(self, modulator, options):
         gr.top_block.__init__(self)
 
-        self._tx_freq            = options.tx_freq         # tranmitter's center frequency
-        self._interp             = options.interp          # interpolating rate for the USRP (prelim)
-        self._bitrate            = options.bitrate
-        self._samples_per_symbol = options.samples_per_symbol
-        self._modulator_class    = modulator
-
-        if self._tx_freq is None:
-            sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n")
-            raise SystemExit
-
-        # Set up USRP sink; also adjusts interp, and bitrate
-        self._setup_usrp_sink(options)
-
-        # copy the final answers back into options for use by modulator
-        options.samples_per_symbol = self._samples_per_symbol
-        options.bitrate = self._bitrate
-        options.interp = self._interp
-
-        # Set center frequency of USRP
-        ok = self.set_freq(self._tx_freq)
-        if not ok:
-            print "Failed to set Tx frequency to %s" % (eng_notation.num_to_str(self._tx_freq),)
-            raise ValueError
-
-        # Set the USRP for maximum transmit gain
-        # (Note that on the RFX cards this is a nop.)
-        self.set_gain(self.u.gain_range()[1])
-
-        self.txpath = transmit_path(modulator, options)
-
-        self.connect(self.txpath, self.u)
-
-    def _setup_usrp_sink(self, options):
-        """
-        Creates a USRP sink, determines the settings for best bitrate,
-        and attaches to the transmitter's subdevice.
-        """
-        self.u = usrp_options.create_usrp_sink(options)
-        dac_rate = self.u.dac_rate()
-
-        (self._bitrate, self._samples_per_symbol, self._interp) = \
-                        pick_tx_bitrate(self._bitrate, self._modulator_class.bits_per_symbol(), \
-                                        self._samples_per_symbol, self._interp, dac_rate, \
-                                        self.u.get_interp_rates())
-
-        self.u.set_interp(self._interp)
-        self.set_auto_tr(True)                 # enable Auto Transmit/Receive switching
-
-    def set_freq(self, target_freq):
-        """
-        Set the center frequency we're interested in.
-
-        @param target_freq: frequency in Hz
-        @rypte: bool
-
-        Tuning is a two step process.  First we ask the front-end to
-        tune as close to the desired frequency as it can.  Then we use
-        the result of that operation and our target_frequency to
-        determine the value for the digital up converter.
-        """
-        return self.u.set_center_freq(target_freq)
-
-    def set_gain(self, gain):
-        """
-        Sets the analog gain in the USRP
-        """
-        self.gain = gain
-        self.u.set_gain(gain)
-
-    def set_auto_tr(self, enable):
-        """
-        Turns on auto transmit/receive of USRP daughterboard (if exits; else ignored)
-        """
-        return self.u.set_auto_tr(enable)
-        
-    def interp(self):
-        return self._interp
-
-    def add_options(normal, expert):
-        """
-        Adds usrp-specific options to the Options Parser
-        """
-        add_freq_option(normal)
-        normal.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
-                          help="select USRP Tx side A or B")
-        normal.add_option("-v", "--verbose", action="store_true", default=False)
-
-        expert.add_option("", "--tx-freq", type="eng_float", default=None,
-                          help="set transmit frequency to FREQ [default=%default]", metavar="FREQ")
-        expert.add_option("-i", "--interp", type="intx", default=256,
-                          help="set fpga interpolation rate to INTERP [default=%default]")
-    # Make a static method to call before instantiation
-    add_options = staticmethod(add_options)
-
-    def _print_verbage(self):
-        """
-        Prints information about the transmit path
-        """
-        print "Using TX d'board %s"    % (self.subdev.side_and_name(),)
-        print "modulation:      %s"    % (self._modulator_class.__name__)
-        print "interp:          %3d"   % (self._interp)
-        print "Tx Frequency:    %s"    % (eng_notation.num_to_str(self._tx_freq))
-        
-
-def add_freq_option(parser):
-    """
-    Hackery that has the -f / --freq option set both tx_freq and rx_freq
-    """
-    def freq_callback(option, opt_str, value, parser):
-        parser.values.rx_freq = value
-        parser.values.tx_freq = value
-
-    if not parser.has_option('--freq'):
-        parser.add_option('-f', '--freq', type="eng_float",
-                          action="callback", callback=freq_callback,
-                          help="set Tx and/or Rx frequency to FREQ [default=%default]",
-                          metavar="FREQ")
+        self.txpath = usrp_transmit_path.usrp_transmit_path(modulator, options)
 
+        self.connect(self.txpath)
 
 # /////////////////////////////////////////////////////////////////////////////
 #                                   main
@@ -191,9 +74,7 @@ def main():
     parser.add_option("","--from-file", default=None,
                       help="use file for packet contents")
 
-    my_top_block.add_options(parser, expert_grp)
-    transmit_path.add_options(parser, expert_grp)
-    usrp_options.add_tx_options(parser)
+    usrp_transmit_path.add_options(parser, expert_grp)
 
     for mod in mods.values():
         mod.add_options(expert_grp)
index 7f062f3c72b83b1aa6fe512fc54d3aeb9a9bcd7e..c7ccbe53c56b1e5e1c15b66df8287b6cbafcae04 100644 (file)
@@ -99,7 +99,7 @@ class _generic_usrp_base(object):
     def gain_range(self):
         if self._type == USRP1_TYPE: return self._subdev.gain_range()
         elif self._type == USRP2_TYPE: return self._u.gain_range()
-        elif self._type == DUMMY_TYPE: return (0, 0)
+        elif self._type == DUMMY_TYPE: return (0, 0, 0)
 
     def set_center_freq(self, target_freq):
         if self._type == USRP1_TYPE:
index a6bffeeac4c942a69c74b0c96770a69d30be03fc..c229aa9e4784c9f6d848d893b0d42c520d52d87c 100644 (file)
@@ -118,8 +118,6 @@ class receive_path(gr.hier_block2):
         if not normal.has_option("--bitrate"):
             normal.add_option("-r", "--bitrate", type="eng_float", default=100e3,
                               help="specify bitrate [default=%default].")
-        normal.add_option("", "--show-rx-gain-range", action="store_true", default=False, 
-                          help="print min and max Rx gain available on selected daughterboard")
         normal.add_option("-v", "--verbose", action="store_true", default=False)
         expert.add_option("-S", "--samples-per-symbol", type="int", default=2,
                           help="set samples/symbol [default=%default]")
index fa9e50b8e4e042af71e86ff8be835545b8ca2158..1aad1ff8e6a42c7e64af9de66df7ff52cd6742f7 100755 (executable)
@@ -34,7 +34,7 @@ import struct
 import sys
 
 # from current dir
-from receive_path import receive_path
+import usrp_receive_path
 
 #import os
 #print os.getpid()
@@ -61,7 +61,7 @@ class audio_tx(gr.hier_block2):
 class my_top_block(gr.top_block):
     def __init__(self, demod_class, rx_callback, options):
         gr.top_block.__init__(self)
-        self.rxpath = receive_path(demod_class, rx_callback, options)
+        self.rxpath = usrp_receive_path.usrp_receive_path(demod_class, rx_callback, options)
         self.audio_tx = audio_tx(options.audio_output)
        self.connect(self.rxpath)
        self.connect(self.audio_tx)        
@@ -101,8 +101,7 @@ def main():
                             % (', '.join(demods.keys()),))
     parser.add_option("-O", "--audio-output", type="string", default="",
                       help="pcm output device name.  E.g., hw:0,0 or /dev/dsp")
-
-    receive_path.add_options(parser, expert_grp)
+    usrp_receive_path.add_options(parser, expert_grp)
 
     for mod in demods.values():
         mod.add_options(expert_grp)
index dd4bd3df61d251c11299cea91323ad7d42199027..b0af721da1ddc87a4d71ec01f17f7aa5f8cba263 100755 (executable)
@@ -46,8 +46,8 @@ import sys
 import os
 
 # from current dir
-from transmit_path import transmit_path
-from receive_path import receive_path
+import usrp_transmit_path
+import usrp_receive_path
 
 #print os.getpid()
 #raw_input('Attach and press enter')
@@ -91,11 +91,11 @@ class my_top_block(gr.top_block):
                  rx_callback, options):
 
         gr.top_block.__init__(self)
-        self.txpath = transmit_path(mod_class, options)
-        self.rxpath = receive_path(demod_class, rx_callback, options)
-       self.connect(self.txpath);
-       self.connect(self.rxpath);
-       
+        self.txpath = usrp_transmit_path.usrp_transmit_path(mod_class, options)
+        self.rxpath = usrp_receive_path.usrp_receive_path(demod_class, rx_callback, options)
+        self.connect(self.txpath)
+        self.connect(self.rxpath)
+
     def send_pkt(self, payload='', eof=False):
         return self.txpath.send_pkt(payload, eof)
 
@@ -180,7 +180,10 @@ def main():
 
     parser = OptionParser (option_class=eng_option, conflict_handler="resolve")
     expert_grp = parser.add_option_group("Expert")
-
+    expert_grp.add_option("", "--rx-freq", type="eng_float", default=None,
+                          help="set Rx frequency to FREQ [default=%default]", metavar="FREQ")
+    expert_grp.add_option("", "--tx-freq", type="eng_float", default=None,
+                          help="set transmit frequency to FREQ [default=%default]", metavar="FREQ")
     parser.add_option("-m", "--modulation", type="choice", choices=mods.keys(),
                       default='gmsk',
                       help="Select modulation from: %s [default=%%default]"
@@ -192,8 +195,8 @@ def main():
     expert_grp.add_option("","--tun-device-filename", default="/dev/net/tun",
                           help="path to tun device file [default=%default]")
 
-    transmit_path.add_options(parser, expert_grp)
-    receive_path.add_options(parser, expert_grp)
+    usrp_transmit_path.add_options(parser, expert_grp)
+    usrp_receive_path.add_options(parser, expert_grp)
 
     for mod in mods.values():
         mod.add_options(expert_grp)
@@ -206,11 +209,6 @@ def main():
         parser.print_help(sys.stderr)
         sys.exit(1)
 
-    if options.rx_freq is None or options.tx_freq is None:
-        sys.stderr.write("You must specify -f FREQ or --freq FREQ\n")
-        parser.print_help(sys.stderr)
-        sys.exit(1)
-
     # open the TUN/TAP interface
     (tun_fd, tun_ifname) = open_tun_interface(options.tun_device_filename)
 
index 146f6e7e245b7a148db75cfe2c4eabb88caa61cd..d8692beb40ebebb57efdc4f6ae0a3fd562dd758c 100755 (executable)
@@ -35,7 +35,7 @@ import struct
 import sys
 
 # from current dir
-from transmit_path import transmit_path
+import usrp_transmit_path
 
 #import os
 #print os.getpid()
@@ -64,7 +64,7 @@ class my_top_block(gr.top_block):
 
     def __init__(self, modulator_class, options):
         gr.top_block.__init__(self)
-        self.txpath = transmit_path(modulator_class, options)
+        self.txpath = usrp_transmit_path.usrp_transmit_path(modulator_class, options)
         self.audio_rx = audio_rx(options.audio_input)
        self.connect(self.txpath)
        self.connect(self.audio_rx)
@@ -95,8 +95,7 @@ def main():
                       help="set megabytes to transmit [default=inf]")
     parser.add_option("-I", "--audio-input", type="string", default="",
                       help="pcm input device name.  E.g., hw:0,0 or /dev/dsp")
-
-    transmit_path.add_options(parser, expert_grp)
+    usrp_transmit_path.add_options(parser, expert_grp)
 
     for mod in mods.values():
         mod.add_options(expert_grp)
diff --git a/gnuradio-examples/python/digital/usrp_receive_path.py b/gnuradio-examples/python/digital/usrp_receive_path.py
new file mode 100644 (file)
index 0000000..fd47c27
--- /dev/null
@@ -0,0 +1,86 @@
+#
+# Copyright 2009 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+
+from gnuradio import gr
+import usrp_options
+import receive_path
+from pick_bitrate import pick_rx_bitrate
+from gnuradio import eng_notation
+
+def add_freq_option(parser):
+    """
+    Hackery that has the -f / --freq option set both tx_freq and rx_freq
+    """
+    def freq_callback(option, opt_str, value, parser):
+        parser.values.rx_freq = value
+        parser.values.tx_freq = value
+
+    if not parser.has_option('--freq'):
+        parser.add_option('-f', '--freq', type="eng_float",
+                          action="callback", callback=freq_callback,
+                          help="set Tx and/or Rx frequency to FREQ [default=%default]",
+                          metavar="FREQ")
+
+def add_options(parser, expert):
+    add_freq_option(parser)
+    usrp_options.add_rx_options(parser)
+    receive_path.receive_path.add_options(parser, expert)
+    expert.add_option("", "--rx-freq", type="eng_float", default=None,
+                          help="set Rx frequency to FREQ [default=%default]", metavar="FREQ")
+    parser.add_option("-v", "--verbose", action="store_true", default=False)
+
+class usrp_receive_path(gr.hier_block2):
+
+    def __init__(self, demod_class, rx_callback, options):
+        '''
+        See below for what options should hold
+        '''
+        gr.hier_block2.__init__(self, "usrp_receive_path",
+                gr.io_signature(0, 0, 0),                    # Input signature
+                gr.io_signature(0, 0, 0)) # Output signature
+        if options.rx_freq is None:
+            sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
+            raise SystemExit
+        rx_path = receive_path.receive_path(demod_class, rx_callback, options)
+        for attr in dir(rx_path): #forward the methods
+            if not attr.startswith('_') and not hasattr(self, attr):
+                setattr(self, attr, getattr(rx_path, attr))
+        #setup usrp
+        self._demod_class = demod_class
+        self._setup_usrp_source(options)
+        #connect
+        self.connect(self.u, rx_path)
+
+    def _setup_usrp_source(self, options):
+        self.u = usrp_options.create_usrp_source(options)
+        adc_rate = self.u.adc_rate()
+        if options.verbose:
+            print 'USRP Source:', self.u
+        (self._bitrate, self._samples_per_symbol, self._decim) = \
+                        pick_rx_bitrate(options.bitrate, self._demod_class.bits_per_symbol(), \
+                                        options.samples_per_symbol, options.decim, adc_rate,  \
+                                        self.u.get_decim_rates())
+
+        self.u.set_decim(self._decim)
+
+        if not self.u.set_center_freq(options.rx_freq):
+            print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(options.rx_freq))
+            raise ValueError, eng_notation.num_to_str(options.rx_freq)
diff --git a/gnuradio-examples/python/digital/usrp_transmit_path.py b/gnuradio-examples/python/digital/usrp_transmit_path.py
new file mode 100644 (file)
index 0000000..ed2603f
--- /dev/null
@@ -0,0 +1,90 @@
+#
+# Copyright 2009 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+
+from gnuradio import gr
+import usrp_options
+import transmit_path
+from pick_bitrate import pick_tx_bitrate
+from gnuradio import eng_notation
+
+def add_freq_option(parser):
+    """
+    Hackery that has the -f / --freq option set both tx_freq and rx_freq
+    """
+    def freq_callback(option, opt_str, value, parser):
+        parser.values.rx_freq = value
+        parser.values.tx_freq = value
+
+    if not parser.has_option('--freq'):
+        parser.add_option('-f', '--freq', type="eng_float",
+                          action="callback", callback=freq_callback,
+                          help="set Tx and/or Rx frequency to FREQ [default=%default]",
+                          metavar="FREQ")
+
+def add_options(parser, expert):
+    add_freq_option(parser)
+    usrp_options.add_tx_options(parser)
+    transmit_path.transmit_path.add_options(parser, expert)
+    expert.add_option("", "--tx-freq", type="eng_float", default=None,
+                          help="set transmit frequency to FREQ [default=%default]", metavar="FREQ")
+    parser.add_option("-v", "--verbose", action="store_true", default=False)
+
+class usrp_transmit_path(gr.hier_block2):
+    def __init__(self, modulator_class, options):
+        '''
+        See below for what options should hold
+        '''
+        gr.hier_block2.__init__(self, "usrp_transmit_path",
+                gr.io_signature(0, 0, 0),                    # Input signature
+                gr.io_signature(0, 0, 0)) # Output signature
+        if options.tx_freq is None:
+            sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n")
+            raise SystemExit
+        tx_path = transmit_path.transmit_path(modulator_class, options)
+        for attr in dir(tx_path): #forward the methods
+            if not attr.startswith('_') and not hasattr(self, attr):
+                setattr(self, attr, getattr(tx_path, attr))
+        #setup usrp
+        self._modulator_class = modulator_class
+        self._setup_usrp_sink(options)
+        #connect
+        self.connect(tx_path, self.u)
+
+    def _setup_usrp_sink(self, options):
+        """
+        Creates a USRP sink, determines the settings for best bitrate,
+        and attaches to the transmitter's subdevice.
+        """
+        self.u = usrp_options.create_usrp_sink(options)
+        dac_rate = self.u.dac_rate()
+        if options.verbose:
+            print 'USRP Sink:', self.u
+        (self._bitrate, self._samples_per_symbol, self._interp) = \
+                        pick_tx_bitrate(options.bitrate, self._modulator_class.bits_per_symbol(), \
+                                        options.samples_per_symbol, options.interp, dac_rate, \
+                                        self.u.get_interp_rates())
+
+        self.u.set_interp(self._interp)
+        self.u.set_auto_tr(True)
+
+        if not self.u.set_center_freq(options.tx_freq):
+            print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(options.tx_freq))
+            raise ValueError, eng_notation.num_to_str(options.tx_freq)