summaryrefslogtreecommitdiff
path: root/gr-uhd
diff options
context:
space:
mode:
Diffstat (limited to 'gr-uhd')
-rw-r--r--gr-uhd/.gitignore2
-rw-r--r--gr-uhd/Makefile.am29
-rw-r--r--gr-uhd/apps/.gitignore2
-rw-r--r--gr-uhd/apps/Makefile.am22
-rw-r--r--gr-uhd/grc/.gitignore4
-rw-r--r--gr-uhd/grc/Makefile.am55
-rwxr-xr-xgr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py292
-rwxr-xr-xgr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py269
-rw-r--r--gr-uhd/grc/uhd_block_tree.xml16
-rw-r--r--gr-uhd/lib/.gitignore2
-rw-r--r--gr-uhd/lib/Makefile.am49
-rw-r--r--gr-uhd/lib/uhd_multi_usrp_sink.cc188
-rw-r--r--gr-uhd/lib/uhd_multi_usrp_sink.h175
-rw-r--r--gr-uhd/lib/uhd_multi_usrp_source.cc187
-rw-r--r--gr-uhd/lib/uhd_multi_usrp_source.h175
-rw-r--r--gr-uhd/lib/uhd_single_usrp_sink.cc183
-rw-r--r--gr-uhd/lib/uhd_single_usrp_sink.h173
-rw-r--r--gr-uhd/lib/uhd_single_usrp_source.cc182
-rw-r--r--gr-uhd/lib/uhd_single_usrp_source.h177
-rw-r--r--gr-uhd/swig/.gitignore8
-rw-r--r--gr-uhd/swig/Makefile.am84
-rw-r--r--gr-uhd/swig/Makefile.swig.gen145
-rw-r--r--gr-uhd/swig/__init__.py40
-rw-r--r--gr-uhd/swig/gnuradio/.gitignore2
-rw-r--r--gr-uhd/swig/gnuradio/uhd.scm27
-rwxr-xr-xgr-uhd/swig/qa_uhd.py40
-rw-r--r--gr-uhd/swig/run_guile_tests.in14
-rw-r--r--gr-uhd/swig/run_tests.in10
-rw-r--r--gr-uhd/swig/uhd.test37
-rw-r--r--gr-uhd/swig/uhd_swig.i120
30 files changed, 2709 insertions, 0 deletions
diff --git a/gr-uhd/.gitignore b/gr-uhd/.gitignore
new file mode 100644
index 000000000..b336cc7ce
--- /dev/null
+++ b/gr-uhd/.gitignore
@@ -0,0 +1,2 @@
+/Makefile
+/Makefile.in
diff --git a/gr-uhd/Makefile.am b/gr-uhd/Makefile.am
new file mode 100644
index 000000000..83190a1d0
--- /dev/null
+++ b/gr-uhd/Makefile.am
@@ -0,0 +1,29 @@
+#
+# Copyright 2010 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.
+#
+
+include $(top_srcdir)/Makefile.common
+
+SUBDIRS = lib apps
+
+if PYTHON
+SUBDIRS += swig grc
+endif
+
diff --git a/gr-uhd/apps/.gitignore b/gr-uhd/apps/.gitignore
new file mode 100644
index 000000000..b336cc7ce
--- /dev/null
+++ b/gr-uhd/apps/.gitignore
@@ -0,0 +1,2 @@
+/Makefile
+/Makefile.in
diff --git a/gr-uhd/apps/Makefile.am b/gr-uhd/apps/Makefile.am
new file mode 100644
index 000000000..b78d07ee8
--- /dev/null
+++ b/gr-uhd/apps/Makefile.am
@@ -0,0 +1,22 @@
+#
+# Copyright 2010 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.
+#
+
+include $(top_srcdir)/Makefile.common
diff --git a/gr-uhd/grc/.gitignore b/gr-uhd/grc/.gitignore
new file mode 100644
index 000000000..d8ab9bd0c
--- /dev/null
+++ b/gr-uhd/grc/.gitignore
@@ -0,0 +1,4 @@
+/uhd_multi*.xml
+/uhd_single*.xml
+/Makefile
+/Makefile.in
diff --git a/gr-uhd/grc/Makefile.am b/gr-uhd/grc/Makefile.am
new file mode 100644
index 000000000..30061a7ec
--- /dev/null
+++ b/gr-uhd/grc/Makefile.am
@@ -0,0 +1,55 @@
+#
+# Copyright 2010 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.
+#
+
+include $(top_srcdir)/Makefile.common
+
+grcblocksdir = $(grc_blocksdir)
+
+generated_uhd_multi_usrp_blocks = \
+ uhd_multi_usrp_source.xml \
+ uhd_multi_usrp_sink.xml
+
+generated_uhd_single_usrp_blocks = \
+ uhd_single_usrp_source.xml \
+ uhd_single_usrp_sink.xml
+
+BUILT_SOURCES += \
+ $(generated_uhd_multi_usrp_blocks) \
+ $(generated_uhd_single_usrp_blocks)
+
+dist_grcblocks_DATA = \
+ uhd_block_tree.xml \
+ $(BUILT_SOURCES)
+
+########################################################################
+# Rules for generating the source and sink xml wrappers
+########################################################################
+EXTRA_DIST += \
+ $(srcdir)/gen_uhd_multi_usrp_blocks_xml.py \
+ $(srcdir)/gen_uhd_single_usrp_blocks_xml.py
+
+$(generated_uhd_multi_usrp_blocks): $(srcdir)/gen_uhd_multi_usrp_blocks_xml.py
+ @echo "generating $@..."
+ $(PYTHON) $< $@
+
+$(generated_uhd_single_usrp_blocks): $(srcdir)/gen_uhd_single_usrp_blocks_xml.py
+ @echo "generating $@..."
+ $(PYTHON) $< $@
diff --git a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py
new file mode 100755
index 000000000..5902fa855
--- /dev/null
+++ b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py
@@ -0,0 +1,292 @@
+#!/usr/bin/env python
+"""
+Copyright 2010 Free Software Foundation, Inc.
+
+This file is part of GNU Radio
+
+GNU Radio Companion 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 2
+of the License, or (at your option) any later version.
+
+GNU Radio Companion 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 this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+"""
+
+MAIN_TMPL = """\
+<?xml version="1.0"?>
+<block>
+ <name>UHD: Multi USRP $sourk.title()</name>
+ <key>uhd_multi_usrp_$(sourk)</key>
+ <import>from gnuradio import uhd</import>
+ <make>uhd.multi_usrp_$(sourk)(
+ device_addr=\$dev_addr,
+ io_type=uhd.io_type_t.\$type.type,
+ num_channels=\$nchan,
+)
+\#if \$sync()
+_clk_cfg = uhd.clock_config_t()
+_clk_cfg.ref_source = uhd.clock_config_t.REF_SMA
+_clk_cfg.pps_source = uhd.clock_config_t.PPS_SMA
+_clk_cfg.pps_polarity = uhd.clock_config_t.PPS_POS
+self.\$(id).set_clock_config(_clk_cfg, uhd.ALL_MBOARDS);
+self.\$(id).set_time_unknown_pps(uhd.time_spec_t())
+\#end if
+#for $m in range($max_mboards)
+\#if \$num_mboards() > $m and \$sd_spec$(m)()
+self.\$(id).set_subdev_spec(\$sd_spec$(m), $m)
+\#end if
+#end for
+self.\$(id).set_samp_rate(\$samp_rate)
+#for $n in range($max_nchan)
+\#if \$nchan() > $n
+self.\$(id).set_center_freq(\$center_freq$(n), $n)
+self.\$(id).set_gain(\$gain$(n), $n)
+ \#if \$ant$(n)()
+self.\$(id).set_antenna(\$ant$(n), $n)
+ \#end if
+ \#if \$bw$(n)()
+self.\$(id).set_bandwidth(\$bw$(n), $n)
+ \#end if
+\#end if
+#end for
+</make>
+ <callback>set_samp_rate(\$samp_rate)</callback>
+ #for $n in range($max_nchan)
+ <callback>set_center_freq(\$center_freq$(n), $n)</callback>
+ <callback>set_gain(\$gain$(n), $n)</callback>
+ <callback>set_antenna(\$ant$(n), $n)</callback>
+ <callback>set_bandwidth(\$bw$(n), $n)</callback>
+ #end for
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>type:COMPLEX_FLOAT32</opt>
+ <opt>vlen:1</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>type:COMPLEX_INT16</opt>
+ <opt>vlen:2</opt>
+ </option>
+ </param>
+ <param>
+ <name>Device Addr</name>
+ <key>dev_addr</key>
+ <value>addr0=192.168.10.2, addr1=192.168.10.3</value>
+ <type>string</type>
+ <hide>
+ \#if \$dev_addr()
+ none
+ \#else
+ part
+ \#end if
+ </hide>
+ </param>
+ <param>
+ <name>Sync</name>
+ <key>sync</key>
+ <value>sync</value>
+ <type>enum</type>
+ <hide>\#if \$sync() then 'none' else 'part'#</hide>
+ <option>
+ <name>unknown PPS</name>
+ <key>sync</key>
+ </option>
+ <option>
+ <name>don't sync</name>
+ <key></key>
+ </option>
+ </param>
+ <param>
+ <name>Num Mboards</name>
+ <key>num_mboards</key>
+ <value>2</value>
+ <type>int</type>
+ #for $m in range(1, $max_mboards+1)
+ <option>
+ <name>$(m)</name>
+ <key>$m</key>
+ </option>
+ #end for
+ </param>
+ #for $m in range($max_mboards)
+ <param>
+ <name>Mb$(m): Subdev Spec</name>
+ <key>sd_spec$(m)</key>
+ <value></value>
+ <type>string</type>
+ <hide>
+ \#if not \$num_mboards() > $m
+ all
+ \#elif \$sd_spec$(m)()
+ none
+ \#else
+ part
+ \#end if
+ </hide>
+ </param>
+ #end for
+ <param>
+ <name>Num Channels</name>
+ <key>nchan</key>
+ <value>2</value>
+ <type>int</type>
+ #for $n in range(1, $max_nchan+1)
+ <option>
+ <name>$(n)</name>
+ <key>$n</key>
+ </option>
+ #end for
+ </param>
+ <param>
+ <name>Samp Rate (Sps)</name>
+ <key>samp_rate</key>
+ <value>samp_rate</value>
+ <type>real</type>
+ </param>
+ $params
+ <check>$max_nchan >= \$nchan</check>
+ <check>\$nchan > 0</check>
+ <check>$max_mboards >= \$num_mboards</check>
+ <check>\$num_mboards > 0</check>
+ <check>\$nchan >= \$num_mboards</check>
+ <$sourk>
+ <name>$direction</name>
+ <type>\$type</type>
+ <vlen>\$type.vlen</vlen>
+ <nports>\$nchan</nports>
+ </$sourk>
+ <doc>
+The UHD Multi USRP $sourk.title() Block:
+
+Device Address:
+The device address is a delimited string used to locate UHD devices on your system. \\
+Use the device address to specify a list of devices.
+USRP2 Example: addr0=192.168.10.2, addr1=192.168.10.3
+
+Num Motherboards:
+Selects the number of USRP motherboards in this multi-USRP configuration.
+
+Subdevice specification:
+Each motherboard should have its own subdevice specification \\
+and all subdevice specifications should be the same length. \\
+Select the subdevice or subdevices for each channel using a markup string. \\
+The markup string consists of a list of dboard_slot:subdev_name pairs (one pair per channel). \\
+If left blank, the UHD will try to select the first subdevice on your system. \\
+See the application notes for further details.
+Single channel example: :AB
+Dual channel example: :A :B
+
+Num Channels:
+Selects the total number of channels in this multi-USRP configuration.
+Ex: 4 motherboards with 2 channels per board = 8 channels total
+
+Sample rate:
+The sample rate is the number of samples per second input by this block. \\
+The UHD device driver will try its best to match the requested sample rate. \\
+If the requested rate is not possible, the UHD block will print an error at runtime.
+
+Center frequency:
+The center frequency is the overall frequency of the RF chain. \\
+For greater control of how the UHD tunes elements in the RF chain, \\
+pass a tune_request_t object rather than a simple target frequency.
+Tuning with an LO offset example: uhd.tune_request_t(freq, lo_off)
+
+Antenna:
+For subdevices with only one antenna, this may be left blank. \\
+Otherwise, the user should specify one of the possible antenna choices. \\
+See the daughterboard application notes for the possible antenna choices.
+
+Bandwidth:
+To use the default bandwidth filter setting, this should be zero. \\
+Only certain subdevices have configurable bandwidth filters. \\
+See the daughterboard application notes for possible configurations.
+ </doc>
+</block>
+"""
+
+PARAMS_TMPL = """
+ <param>
+ <name>Ch$(n): Center Freq (Hz)</name>
+ <key>center_freq$(n)</key>
+ <value>0</value>
+ <type>real</type>
+ <hide>\#if \$nchan() > $n then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Ch$(n): Gain (dB)</name>
+ <key>gain$(n)</key>
+ <value>0</value>
+ <type>real</type>
+ <hide>\#if \$nchan() > $n then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Ch$(n): Antenna</name>
+ <key>ant$(n)</key>
+ <value></value>
+ <type>string</type>
+ <hide>
+ \#if not \$nchan() > $n
+ all
+ \#elif \$ant$(n)()
+ none
+ \#else
+ part
+ \#end if
+ </hide>
+ </param>
+ <param>
+ <name>Ch$(n): Bandwidth (Hz)</name>
+ <key>bw$(n)</key>
+ <value>0</value>
+ <type>real</type>
+ <hide>
+ \#if not \$nchan() > $n
+ all
+ \#elif \$bw$(n)()
+ none
+ \#else
+ part
+ \#end if
+ </hide>
+ </param>
+"""
+
+def parse_tmpl(_tmpl, **kwargs):
+ from Cheetah import Template
+ return str(Template.Template(_tmpl, kwargs))
+
+max_num_mboards = 4
+max_num_channels = max_num_mboards*4
+
+if __name__ == '__main__':
+ import sys
+ for file in sys.argv[1:]:
+ if 'source' in file:
+ sourk = 'source'
+ direction = 'out'
+ elif 'sink' in file:
+ sourk = 'sink'
+ direction = 'in'
+ else: raise Exception, 'is %s a source or sink?'%file
+
+ params = ''.join([parse_tmpl(PARAMS_TMPL, n=n) for n in range(max_num_channels)])
+ open(file, 'w').write(parse_tmpl(MAIN_TMPL,
+ max_nchan=max_num_channels,
+ max_mboards=max_num_mboards,
+ params=params,
+ sourk=sourk,
+ direction=direction,
+ ))
diff --git a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py
new file mode 100755
index 000000000..66728fe28
--- /dev/null
+++ b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py
@@ -0,0 +1,269 @@
+#!/usr/bin/env python
+"""
+Copyright 2010 Free Software Foundation, Inc.
+
+This file is part of GNU Radio
+
+GNU Radio Companion 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 2
+of the License, or (at your option) any later version.
+
+GNU Radio Companion 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 this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+"""
+
+MAIN_TMPL = """\
+<?xml version="1.0"?>
+<block>
+ <name>UHD: Single USRP $sourk.title()</name>
+ <key>uhd_single_usrp_$(sourk)</key>
+ <import>from gnuradio import uhd</import>
+ <make>uhd.single_usrp_$(sourk)(
+ device_addr=\$dev_addr,
+ io_type=uhd.io_type_t.\$type.type,
+ num_channels=\$nchan,
+)
+\#if \$ref_clk()
+_clk_cfg = uhd.clock_config_t()
+_clk_cfg.ref_source = uhd.clock_config_t.REF_SMA
+_clk_cfg.pps_source = uhd.clock_config_t.PPS_SMA
+_clk_cfg.pps_polarity = uhd.clock_config_t.PPS_POS
+self.\$(id).set_clock_config(_clk_cfg);
+\#end if
+\#if \$sd_spec()
+self.\$(id).set_subdev_spec(\$sd_spec)
+\#end if
+self.\$(id).set_samp_rate(\$samp_rate)
+#for $n in range($max_nchan)
+\#if \$nchan() > $n
+self.\$(id).set_center_freq(\$center_freq$(n), $n)
+self.\$(id).set_gain(\$gain$(n), $n)
+ \#if \$ant$(n)()
+self.\$(id).set_antenna(\$ant$(n), $n)
+ \#end if
+ \#if \$bw$(n)()
+self.\$(id).set_bandwidth(\$bw$(n), $n)
+ \#end if
+\#end if
+#end for
+</make>
+ <callback>set_samp_rate(\$samp_rate)</callback>
+ #for $n in range($max_nchan)
+ <callback>set_center_freq(\$center_freq$(n), $n)</callback>
+ <callback>set_gain(\$gain$(n), $n)</callback>
+ <callback>set_antenna(\$ant$(n), $n)</callback>
+ <callback>set_bandwidth(\$bw$(n), $n)</callback>
+ #end for
+ <param>
+ <name>Input Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>Complex</name>
+ <key>complex</key>
+ <opt>type:COMPLEX_FLOAT32</opt>
+ <opt>vlen:1</opt>
+ </option>
+ <option>
+ <name>Short</name>
+ <key>short</key>
+ <opt>type:COMPLEX_INT16</opt>
+ <opt>vlen:2</opt>
+ </option>
+ </param>
+ <param>
+ <name>Num Channels</name>
+ <key>nchan</key>
+ <value>1</value>
+ <type>int</type>
+ <hide>part</hide>
+ <option>
+ <name>Single Channel</name>
+ <key>1</key>
+ </option>
+ <option>
+ <name>Dual Channel</name>
+ <key>2</key>
+ </option>
+ <option>
+ <name>Quad Channel</name>
+ <key>4</key>
+ </option>
+ </param>
+ <param>
+ <name>Device Addr</name>
+ <key>dev_addr</key>
+ <value>addr=192.168.10.2</value>
+ <type>string</type>
+ <hide>
+ \#if \$dev_addr()
+ none
+ \#else
+ part
+ \#end if
+ </hide>
+ </param>
+ <param>
+ <name>Ref Clock</name>
+ <key>ref_clk</key>
+ <value></value>
+ <type>enum</type>
+ <hide>\#if \$ref_clk() then 'none' else 'part'#</hide>
+ <option>
+ <name>External</name>
+ <key>ext</key>
+ </option>
+ <option>
+ <name>Internal</name>
+ <key></key>
+ </option>
+ </param>
+ <param>
+ <name>Subdev Spec</name>
+ <key>sd_spec</key>
+ <value></value>
+ <type>string</type>
+ <hide>
+ \#if \$sd_spec()
+ none
+ \#else
+ part
+ \#end if
+ </hide>
+ </param>
+ <param>
+ <name>Samp Rate (Sps)</name>
+ <key>samp_rate</key>
+ <value>samp_rate</value>
+ <type>real</type>
+ </param>
+ $params
+ <check>$max_nchan >= \$nchan</check>
+ <check>\$nchan > 0</check>
+ <check>(len((\$sd_spec).split()) or 1) == \$nchan</check>
+ <$sourk>
+ <name>$direction</name>
+ <type>\$type</type>
+ <vlen>\$type.vlen</vlen>
+ <nports>\$nchan</nports>
+ </$sourk>
+ <doc>
+The UHD Single USRP $sourk.title() Block:
+
+Device Address:
+The device address is a delimited string used to locate UHD devices on your system. \\
+If left blank, the first UHD device found will be used. \\
+Use the device address to specify a specific device.
+USRP2 Example: addr=192.168.10.2
+USRP1 Example: serial=12345678
+
+Subdevice specification:
+Select the subdevice or subdevices for each channel using a markup string. \\
+The markup string consists of a list of dboard_slot:subdev_name pairs (one pair per channel). \\
+If left blank, the UHD will try to select the first subdevice on your system. \\
+See the application notes for further details.
+Single channel example: A:AB
+Dual channel example: A:AB B:0
+
+Sample rate:
+The sample rate is the number of samples per second input by this block. \\
+The UHD device driver will try its best to match the requested sample rate. \\
+If the requested rate is not possible, the UHD block will print an error at runtime.
+
+Center frequency:
+The center frequency is the overall frequency of the RF chain. \\
+For greater control of how the UHD tunes elements in the RF chain, \\
+pass a tune_request_t object rather than a simple target frequency.
+Tuning with an LO offset example: uhd.tune_request_t(freq, lo_off)
+
+Antenna:
+For subdevices with only one antenna, this may be left blank. \\
+Otherwise, the user should specify one of the possible antenna choices. \\
+See the daughterboard application notes for the possible antenna choices.
+
+Bandwidth:
+To use the default bandwidth filter setting, this should be zero. \\
+Only certain subdevices have configurable bandwidth filters. \\
+See the daughterboard application notes for possible configurations.
+ </doc>
+</block>
+"""
+
+PARAMS_TMPL = """
+ <param>
+ <name>Ch$(n): Center Freq (Hz)</name>
+ <key>center_freq$(n)</key>
+ <value>0</value>
+ <type>real</type>
+ <hide>\#if \$nchan() > $n then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Ch$(n): Gain (dB)</name>
+ <key>gain$(n)</key>
+ <value>0</value>
+ <type>real</type>
+ <hide>\#if \$nchan() > $n then 'none' else 'all'#</hide>
+ </param>
+ <param>
+ <name>Ch$(n): Antenna</name>
+ <key>ant$(n)</key>
+ <value></value>
+ <type>string</type>
+ <hide>
+ \#if not \$nchan() > $n
+ all
+ \#elif \$ant$(n)()
+ none
+ \#else
+ part
+ \#end if
+ </hide>
+ </param>
+ <param>
+ <name>Ch$(n): Bandwidth (Hz)</name>
+ <key>bw$(n)</key>
+ <value>0</value>
+ <type>real</type>
+ <hide>
+ \#if not \$nchan() > $n
+ all
+ \#elif \$bw$(n)()
+ none
+ \#else
+ part
+ \#end if
+ </hide>
+ </param>
+"""
+
+def parse_tmpl(_tmpl, **kwargs):
+ from Cheetah import Template
+ return str(Template.Template(_tmpl, kwargs))
+
+max_num_channels = 4
+
+if __name__ == '__main__':
+ import sys
+ for file in sys.argv[1:]:
+ if 'source' in file:
+ sourk = 'source'
+ direction = 'out'
+ elif 'sink' in file:
+ sourk = 'sink'
+ direction = 'in'
+ else: raise Exception, 'is %s a source or sink?'%file
+
+ params = ''.join([parse_tmpl(PARAMS_TMPL, n=n) for n in range(max_num_channels)])
+ open(file, 'w').write(parse_tmpl(MAIN_TMPL,
+ max_nchan=max_num_channels,
+ params=params,
+ sourk=sourk,
+ direction=direction,
+ ))
diff --git a/gr-uhd/grc/uhd_block_tree.xml b/gr-uhd/grc/uhd_block_tree.xml
new file mode 100644
index 000000000..f5d42b567
--- /dev/null
+++ b/gr-uhd/grc/uhd_block_tree.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Block Tree for uhd blocks.
+###################################################
+ -->
+<cat>
+ <name></name> <!-- Blank for Root Name -->
+ <cat>
+ <name>UHD</name>
+ <block>uhd_single_usrp_source</block>
+ <block>uhd_single_usrp_sink</block>
+ <block>uhd_multi_usrp_source</block>
+ <block>uhd_multi_usrp_sink</block>
+ </cat>
+</cat>
diff --git a/gr-uhd/lib/.gitignore b/gr-uhd/lib/.gitignore
new file mode 100644
index 000000000..b336cc7ce
--- /dev/null
+++ b/gr-uhd/lib/.gitignore
@@ -0,0 +1,2 @@
+/Makefile
+/Makefile.in
diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am
new file mode 100644
index 000000000..1bcfbbbdc
--- /dev/null
+++ b/gr-uhd/lib/Makefile.am
@@ -0,0 +1,49 @@
+#
+# Copyright 2010 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.
+#
+
+include $(top_srcdir)/Makefile.common
+
+AM_CPPFLAGS = \
+ $(STD_DEFINES_AND_INCLUDES) \
+ $(WITH_INCLUDES) \
+ $(UHD_CPPFLAGS)
+
+lib_LTLIBRARIES = libgnuradio-uhd.la
+
+libgnuradio_uhd_la_SOURCES = \
+ uhd_multi_usrp_source.cc \
+ uhd_multi_usrp_sink.cc \
+ uhd_single_usrp_source.cc \
+ uhd_single_usrp_sink.cc
+
+libgnuradio_uhd_la_LIBADD = \
+ $(GNURADIO_CORE_LA) \
+ $(UHD_LIBS)
+
+libgnuradio_uhd_la_LDFLAGS = $(LTVERSIONFLAGS)
+
+grinclude_HEADERS = \
+ uhd_multi_usrp_source.h \
+ uhd_multi_usrp_sink.h \
+ uhd_single_usrp_source.h \
+ uhd_single_usrp_sink.h
+
+noinst_HEADERS =
diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.cc b/gr-uhd/lib/uhd_multi_usrp_sink.cc
new file mode 100644
index 000000000..ee16e2928
--- /dev/null
+++ b/gr-uhd/lib/uhd_multi_usrp_sink.cc
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2010 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.
+ */
+
+#include <uhd_multi_usrp_sink.h>
+#include <gr_io_signature.h>
+#include <stdexcept>
+
+/***********************************************************************
+ * UHD Multi USRP Sink
+ **********************************************************************/
+uhd_multi_usrp_sink::uhd_multi_usrp_sink(gr_io_signature_sptr sig)
+:gr_sync_block("uhd multi usrp sink", sig, gr_make_io_signature(0, 0, 0)){
+ /* NOP */
+}
+
+/***********************************************************************
+ * UHD Multi USRP Sink Impl
+ **********************************************************************/
+class uhd_multi_usrp_sink_impl : public uhd_multi_usrp_sink{
+public:
+ uhd_multi_usrp_sink_impl(
+ const std::string &device_addr,
+ const uhd::io_type_t &io_type,
+ size_t num_channels
+ ):
+ uhd_multi_usrp_sink(gr_make_io_signature(
+ num_channels, num_channels, io_type.size
+ )),
+ _type(io_type),
+ _nchan(num_channels)
+ {
+ _dev = uhd::usrp::multi_usrp::make(device_addr);
+ }
+
+ void set_subdev_spec(const std::string &spec, size_t mboard){
+ return _dev->set_tx_subdev_spec(spec, mboard);
+ }
+
+ void set_samp_rate(double rate){
+ _dev->set_tx_rate(rate);
+ }
+
+ double get_samp_rate(void){
+ return _dev->get_tx_rate();
+ }
+
+ uhd::tune_result_t set_center_freq(
+ const uhd::tune_request_t tune_request, size_t chan
+ ){
+ return _dev->set_tx_freq(tune_request, chan);
+ }
+
+ uhd::freq_range_t get_freq_range(size_t chan){
+ return _dev->get_tx_freq_range(chan);
+ }
+
+ void set_gain(float gain, size_t chan){
+ return _dev->set_tx_gain(gain, chan);
+ }
+
+ float get_gain(size_t chan){
+ return _dev->get_tx_gain(chan);
+ }
+
+ uhd::gain_range_t get_gain_range(size_t chan){
+ return _dev->get_tx_gain_range(chan);
+ }
+
+ void set_antenna(const std::string &ant, size_t chan){
+ return _dev->set_tx_antenna(ant, chan);
+ }
+
+ std::string get_antenna(size_t chan){
+ return _dev->get_tx_antenna(chan);
+ }
+
+ std::vector<std::string> get_antennas(size_t chan){
+ return _dev->get_tx_antennas(chan);
+ }
+
+ void set_bandwidth(double bandwidth, size_t chan){
+ return _dev->set_tx_bandwidth(bandwidth, chan);
+ }
+
+ void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard){
+ return _dev->set_clock_config(clock_config, mboard);
+ }
+
+ uhd::time_spec_t get_time_now(void){
+ return _dev->get_time_now();
+ }
+
+ void set_time_next_pps(const uhd::time_spec_t &time_spec){
+ return _dev->set_time_next_pps(time_spec);
+ }
+
+ void set_time_unknown_pps(const uhd::time_spec_t &time_spec){
+ return _dev->set_time_unknown_pps(time_spec);
+ }
+
+ uhd::usrp::multi_usrp::sptr get_device(void){
+ return _dev;
+ }
+
+/***********************************************************************
+ * Work
+ **********************************************************************/
+ int work(
+ int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items
+ ){
+ uhd::tx_metadata_t metadata;
+ metadata.start_of_burst = true;
+
+ return _dev->get_device()->send(
+ input_items, noutput_items, metadata,
+ _type, uhd::device::SEND_MODE_FULL_BUFF, 1.0
+ );
+ }
+
+ //Send an empty start-of-burst packet to begin streaming.
+ //Set at a time in the near future so data will be sync'd.
+ bool start(void){
+ uhd::tx_metadata_t metadata;
+ metadata.start_of_burst = true;
+ metadata.has_time_spec = true;
+ //TODO: Time in the near future, must be less than source time in future
+ //because ethernet pause frames with throttle stream commands.
+ //It will be fixed with the invention of host-based flow control.
+ metadata.time_spec = get_time_now() + uhd::time_spec_t(0.05);
+
+ _dev->get_device()->send(
+ gr_vector_const_void_star(_nchan), 0, metadata,
+ _type, uhd::device::SEND_MODE_ONE_PACKET, 1.0
+ );
+ return true;
+ }
+
+ //Send an empty end-of-burst packet to end streaming.
+ //Ending the burst avoids an underflow error on stop.
+ bool stop(void){
+ uhd::tx_metadata_t metadata;
+ metadata.end_of_burst = true;
+
+ _dev->get_device()->send(
+ gr_vector_const_void_star(_nchan), 0, metadata,
+ _type, uhd::device::SEND_MODE_ONE_PACKET, 1.0
+ );
+ return true;
+ }
+
+protected:
+ uhd::usrp::multi_usrp::sptr _dev;
+ const uhd::io_type_t _type;
+ size_t _nchan;
+};
+
+/***********************************************************************
+ * Make UHD Multi USRP Sink
+ **********************************************************************/
+boost::shared_ptr<uhd_multi_usrp_sink> uhd_make_multi_usrp_sink(
+ const std::string &device_addr,
+ const uhd::io_type_t::tid_t &io_type,
+ size_t num_channels
+){
+ return boost::shared_ptr<uhd_multi_usrp_sink>(
+ new uhd_multi_usrp_sink_impl(device_addr, io_type, num_channels)
+ );
+}
diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.h b/gr-uhd/lib/uhd_multi_usrp_sink.h
new file mode 100644
index 000000000..370e59d0e
--- /dev/null
+++ b/gr-uhd/lib/uhd_multi_usrp_sink.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2010 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.
+ */
+
+#ifndef INCLUDED_UHD_MULTI_USRP_SINK_H
+#define INCLUDED_UHD_MULTI_USRP_SINK_H
+
+#include <gr_sync_block.h>
+#include <uhd/usrp/multi_usrp.hpp>
+
+class uhd_multi_usrp_sink;
+
+boost::shared_ptr<uhd_multi_usrp_sink> uhd_make_multi_usrp_sink(
+ const std::string &device_addr,
+ const uhd::io_type_t::tid_t &io_type,
+ size_t num_channels
+);
+
+class uhd_multi_usrp_sink : public gr_sync_block{
+public:
+
+ /*!
+ * Set the IO signature for this block.
+ * \param sig the input signature
+ */
+ uhd_multi_usrp_sink(gr_io_signature_sptr sig);
+
+ /*!
+ * Set the subdevice specification.
+ * \param spec the subdev spec markup string
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_subdev_spec(const std::string &spec, size_t mboard) = 0;
+
+ /*!
+ * Set the sample rate for the usrp device.
+ * \param rate a new rate in Sps
+ */
+ virtual void set_samp_rate(double rate) = 0;
+
+ /*!
+ * Get the sample rate for the usrp device.
+ * This is the actual sample rate and may differ from the rate set.
+ * \return the actual rate in Sps
+ */
+ virtual double get_samp_rate(void) = 0;
+
+ /*!
+ * Tune the usrp device to the desired center frequency.
+ * \param tune_request the tune request instructions
+ * \param chan the channel index 0 to N-1
+ * \return a tune result with the actual frequencies
+ */
+ virtual uhd::tune_result_t set_center_freq(
+ const uhd::tune_request_t tune_request, size_t chan
+ ) = 0;
+
+ /*!
+ * Tune the usrp device to the desired center frequency.
+ * This is a wrapper around set center freq so that in this case,
+ * the user can pass a single frequency in the call through swig.
+ * \param freq the desired frequency in Hz
+ * \param chan the channel index 0 to N-1
+ * \return a tune result with the actual frequencies
+ */
+ uhd::tune_result_t set_center_freq(double freq, size_t chan){
+ return set_center_freq(uhd::tune_request_t(freq), chan);
+ }
+
+ /*!
+ * Get the tunable frequency range.
+ * \param chan the channel index 0 to N-1
+ * \return the frequency range in Hz
+ */
+ virtual uhd::freq_range_t get_freq_range(size_t chan) = 0;
+
+ /*!
+ * Set the gain for the dboard.
+ * \param gain the gain in dB
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_gain(float gain, size_t chan) = 0;
+
+ /*!
+ * Get the actual dboard gain setting.
+ * \param chan the channel index 0 to N-1
+ * \return the actual gain in dB
+ */
+ virtual float get_gain(size_t chan) = 0;
+
+ /*!
+ * Get the settable gain range.
+ * \param chan the channel index 0 to N-1
+ * \return the gain range in dB
+ */
+ virtual uhd::gain_range_t get_gain_range(size_t chan) = 0;
+
+ /*!
+ * Set the antenna to use.
+ * \param ant the antenna string
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_antenna(const std::string &ant, size_t chan) = 0;
+
+ /*!
+ * Get the antenna in use.
+ * \param chan the channel index 0 to N-1
+ * \return the antenna string
+ */
+ virtual std::string get_antenna(size_t chan) = 0;
+
+ /*!
+ * Get a list of possible antennas.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of antenna strings
+ */
+ virtual std::vector<std::string> get_antennas(size_t chan) = 0;
+
+ /*!
+ * Set the subdevice bandpass filter.
+ * \param chan the channel index 0 to N-1
+ * \param bandwidth the filter bandwidth in Hz
+ */
+ virtual void set_bandwidth(double bandwidth, size_t chan) = 0;
+
+ /*!
+ * Set the clock configuration.
+ * \param clock_config the new configuration
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard) = 0;
+
+ /*!
+ * Get the current time registers.
+ * \return the current usrp time
+ */
+ virtual uhd::time_spec_t get_time_now(void) = 0;
+
+ /*!
+ * Set the time registers at the next pps.
+ * \param time_spec the new time
+ */
+ virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0;
+
+ /*!
+ * Sync the time registers with an unknown pps edge.
+ * \param time_spec the new time
+ */
+ virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0;
+
+ /*!
+ * Get access to the underlying uhd device object.
+ * \return the multi usrp device object
+ */
+ virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0;
+};
+
+#endif /* INCLUDED_UHD_MULTI_USRP_SINK_H */
diff --git a/gr-uhd/lib/uhd_multi_usrp_source.cc b/gr-uhd/lib/uhd_multi_usrp_source.cc
new file mode 100644
index 000000000..029a763e3
--- /dev/null
+++ b/gr-uhd/lib/uhd_multi_usrp_source.cc
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2010 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.
+ */
+
+#include <uhd_multi_usrp_source.h>
+#include <gr_io_signature.h>
+#include <stdexcept>
+#include <iostream>
+#include <boost/format.hpp>
+
+/***********************************************************************
+ * UHD Multi USRP Source
+ **********************************************************************/
+uhd_multi_usrp_source::uhd_multi_usrp_source(gr_io_signature_sptr sig)
+:gr_sync_block("uhd multi_usrp source", gr_make_io_signature(0, 0, 0), sig){
+ /* NOP */
+}
+
+/***********************************************************************
+ * UHD Multi USRP Source Impl
+ **********************************************************************/
+class uhd_multi_usrp_source_impl : public uhd_multi_usrp_source{
+public:
+ uhd_multi_usrp_source_impl(
+ const std::string &device_addr,
+ const uhd::io_type_t &io_type,
+ size_t num_channels
+ ):
+ uhd_multi_usrp_source(gr_make_io_signature(
+ num_channels, num_channels, io_type.size
+ )),
+ _type(io_type)
+ {
+ _dev = uhd::usrp::multi_usrp::make(device_addr);
+ }
+
+ void set_subdev_spec(const std::string &spec, size_t mboard){
+ return _dev->set_rx_subdev_spec(spec, mboard);
+ }
+
+ void set_samp_rate(double rate){
+ _dev->set_rx_rate(rate);
+ }
+
+ double get_samp_rate(void){
+ return _dev->get_rx_rate();
+ }
+
+ uhd::tune_result_t set_center_freq(
+ const uhd::tune_request_t tune_request, size_t chan
+ ){
+ return _dev->set_rx_freq(tune_request, chan);
+ }
+
+ uhd::freq_range_t get_freq_range(size_t chan){
+ return _dev->get_rx_freq_range(chan);
+ }
+
+ void set_gain(float gain, size_t chan){
+ return _dev->set_rx_gain(gain, chan);
+ }
+
+ float get_gain(size_t chan){
+ return _dev->get_rx_gain(chan);
+ }
+
+ uhd::gain_range_t get_gain_range(size_t chan){
+ return _dev->get_rx_gain_range(chan);
+ }
+
+ void set_antenna(const std::string &ant, size_t chan){
+ return _dev->set_rx_antenna(ant, chan);
+ }
+
+ std::string get_antenna(size_t chan){
+ return _dev->get_rx_antenna(chan);
+ }
+
+ std::vector<std::string> get_antennas(size_t chan){
+ return _dev->get_rx_antennas(chan);
+ }
+
+ void set_bandwidth(double bandwidth, size_t chan){
+ return _dev->set_rx_bandwidth(bandwidth, chan);
+ }
+
+ void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard){
+ return _dev->set_clock_config(clock_config, mboard);
+ }
+
+ uhd::time_spec_t get_time_now(void){
+ return _dev->get_time_now();
+ }
+
+ void set_time_next_pps(const uhd::time_spec_t &time_spec){
+ return _dev->set_time_next_pps(time_spec);
+ }
+
+ void set_time_unknown_pps(const uhd::time_spec_t &time_spec){
+ return _dev->set_time_unknown_pps(time_spec);
+ }
+
+ uhd::usrp::multi_usrp::sptr get_device(void){
+ return _dev;
+ }
+
+/***********************************************************************
+ * Work
+ **********************************************************************/
+ int work(
+ int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items
+ ){
+ uhd::rx_metadata_t metadata; //not passed out of this block
+
+ size_t num_samps = _dev->get_device()->recv(
+ output_items, noutput_items, metadata,
+ _type, uhd::device::RECV_MODE_FULL_BUFF, 1.0
+ );
+
+ switch(metadata.error_code){
+ case uhd::rx_metadata_t::ERROR_CODE_NONE:
+ return num_samps;
+
+ case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW:
+ //ignore overflows and try work again
+ return work(noutput_items, input_items, output_items);
+
+ default:
+ std::cout << boost::format(
+ "UHD source block got error code 0x%x"
+ ) % metadata.error_code << std::endl;
+ return num_samps;
+ }
+ }
+
+ bool start(void){
+ //setup a stream command that starts streaming slightly in the future
+ static const double reasonable_delay = 0.1; //order of magnitude over RTT
+ uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
+ stream_cmd.stream_now = false;
+ stream_cmd.time_spec = get_time_now() + uhd::time_spec_t(reasonable_delay);
+ _dev->issue_stream_cmd(stream_cmd);
+ return true;
+ }
+
+ bool stop(void){
+ _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
+ return true;
+ }
+
+private:
+ uhd::usrp::multi_usrp::sptr _dev;
+ const uhd::io_type_t _type;
+};
+
+
+/***********************************************************************
+ * Make UHD Multi USRP Source
+ **********************************************************************/
+boost::shared_ptr<uhd_multi_usrp_source> uhd_make_multi_usrp_source(
+ const std::string &device_addr,
+ const uhd::io_type_t::tid_t &io_type,
+ size_t num_channels
+){
+ return boost::shared_ptr<uhd_multi_usrp_source>(
+ new uhd_multi_usrp_source_impl(device_addr, io_type, num_channels)
+ );
+}
diff --git a/gr-uhd/lib/uhd_multi_usrp_source.h b/gr-uhd/lib/uhd_multi_usrp_source.h
new file mode 100644
index 000000000..b3cbdae1f
--- /dev/null
+++ b/gr-uhd/lib/uhd_multi_usrp_source.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2010 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.
+ */
+
+#ifndef INCLUDED_UHD_MULTI_USRP_SOURCE_H
+#define INCLUDED_UHD_MULTI_USRP_SOURCE_H
+
+#include <gr_sync_block.h>
+#include <uhd/usrp/multi_usrp.hpp>
+
+class uhd_multi_usrp_source;
+
+boost::shared_ptr<uhd_multi_usrp_source> uhd_make_multi_usrp_source(
+ const std::string &device_addr,
+ const uhd::io_type_t::tid_t &io_type,
+ size_t num_channels
+);
+
+class uhd_multi_usrp_source : public gr_sync_block{
+public:
+
+ /*!
+ * Set the IO signature for this block.
+ * \param sig the output signature
+ */
+ uhd_multi_usrp_source(gr_io_signature_sptr sig);
+
+ /*!
+ * Set the subdevice specification.
+ * \param spec the subdev spec markup string
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_subdev_spec(const std::string &spec, size_t mboard) = 0;
+
+ /*!
+ * Set the sample rate for the usrp device.
+ * \param rate a new rate in Sps
+ */
+ virtual void set_samp_rate(double rate) = 0;
+
+ /*!
+ * Get the sample rate for the usrp device.
+ * This is the actual sample rate and may differ from the rate set.
+ * \return the actual rate in Sps
+ */
+ virtual double get_samp_rate(void) = 0;
+
+ /*!
+ * Tune the usrp device to the desired center frequency.
+ * \param tune_request the tune request instructions
+ * \param chan the channel index 0 to N-1
+ * \return a tune result with the actual frequencies
+ */
+ virtual uhd::tune_result_t set_center_freq(
+ const uhd::tune_request_t tune_request, size_t chan
+ ) = 0;
+
+ /*!
+ * Tune the usrp device to the desired center frequency.
+ * This is a wrapper around set center freq so that in this case,
+ * the user can pass a single frequency in the call through swig.
+ * \param freq the desired frequency in Hz
+ * \param chan the channel index 0 to N-1
+ * \return a tune result with the actual frequencies
+ */
+ uhd::tune_result_t set_center_freq(double freq, size_t chan){
+ return set_center_freq(uhd::tune_request_t(freq), chan);
+ }
+
+ /*!
+ * Get the tunable frequency range.
+ * \param chan the channel index 0 to N-1
+ * \return the frequency range in Hz
+ */
+ virtual uhd::freq_range_t get_freq_range(size_t chan) = 0;
+
+ /*!
+ * Set the gain for the dboard.
+ * \param gain the gain in dB
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_gain(float gain, size_t chan) = 0;
+
+ /*!
+ * Get the actual dboard gain setting.
+ * \param chan the channel index 0 to N-1
+ * \return the actual gain in dB
+ */
+ virtual float get_gain(size_t chan) = 0;
+
+ /*!
+ * Get the settable gain range.
+ * \param chan the channel index 0 to N-1
+ * \return the gain range in dB
+ */
+ virtual uhd::gain_range_t get_gain_range(size_t chan) = 0;
+
+ /*!
+ * Set the antenna to use.
+ * \param ant the antenna string
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_antenna(const std::string &ant, size_t chan) = 0;
+
+ /*!
+ * Get the antenna in use.
+ * \param chan the channel index 0 to N-1
+ * \return the antenna string
+ */
+ virtual std::string get_antenna(size_t chan) = 0;
+
+ /*!
+ * Get a list of possible antennas.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of antenna strings
+ */
+ virtual std::vector<std::string> get_antennas(size_t chan) = 0;
+
+ /*!
+ * Set the subdevice bandpass filter.
+ * \param bandwidth the filter bandwidth in Hz
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_bandwidth(double bandwidth, size_t chan) = 0;
+
+ /*!
+ * Set the clock configuration.
+ * \param clock_config the new configuration
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard) = 0;
+
+ /*!
+ * Get the current time registers.
+ * \return the current usrp time
+ */
+ virtual uhd::time_spec_t get_time_now(void) = 0;
+
+ /*!
+ * Set the time registers at the next pps.
+ * \param time_spec the new time
+ */
+ virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0;
+
+ /*!
+ * Sync the time registers with an unknown pps edge.
+ * \param time_spec the new time
+ */
+ virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0;
+
+ /*!
+ * Get access to the underlying uhd device object.
+ * \return the multi usrp device object
+ */
+ virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0;
+};
+
+#endif /* INCLUDED_UHD_MULTI_USRP_SOURCE_H */
diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc
new file mode 100644
index 000000000..622f506b5
--- /dev/null
+++ b/gr-uhd/lib/uhd_single_usrp_sink.cc
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2010 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.
+ */
+
+#include <uhd_single_usrp_sink.h>
+#include <gr_io_signature.h>
+#include <stdexcept>
+
+/***********************************************************************
+ * UHD Single USRP Sink
+ **********************************************************************/
+uhd_single_usrp_sink::uhd_single_usrp_sink(gr_io_signature_sptr sig)
+:gr_sync_block("uhd single usrp sink", sig, gr_make_io_signature(0, 0, 0)){
+ /* NOP */
+}
+
+/***********************************************************************
+ * UHD Single USRP Sink Impl
+ **********************************************************************/
+class uhd_single_usrp_sink_impl : public uhd_single_usrp_sink{
+public:
+ uhd_single_usrp_sink_impl(
+ const std::string &device_addr,
+ const uhd::io_type_t &io_type,
+ size_t num_channels
+ ):
+ uhd_single_usrp_sink(gr_make_io_signature(
+ num_channels, num_channels, io_type.size
+ )),
+ _type(io_type),
+ _nchan(num_channels)
+ {
+ _dev = uhd::usrp::single_usrp::make(device_addr);
+ }
+
+ void set_subdev_spec(const std::string &spec){
+ return _dev->set_tx_subdev_spec(spec);
+ }
+
+ void set_samp_rate(double rate){
+ _dev->set_tx_rate(rate);
+ }
+
+ double get_samp_rate(void){
+ return _dev->get_tx_rate();
+ }
+
+ uhd::tune_result_t set_center_freq(
+ const uhd::tune_request_t tune_request, size_t chan
+ ){
+ return _dev->set_tx_freq(tune_request, chan);
+ }
+
+ uhd::freq_range_t get_freq_range(size_t chan){
+ return _dev->get_tx_freq_range(chan);
+ }
+
+ void set_gain(float gain, size_t chan){
+ return _dev->set_tx_gain(gain, chan);
+ }
+
+ float get_gain(size_t chan){
+ return _dev->get_tx_gain(chan);
+ }
+
+ uhd::gain_range_t get_gain_range(size_t chan){
+ return _dev->get_tx_gain_range(chan);
+ }
+
+ void set_antenna(const std::string &ant, size_t chan){
+ return _dev->set_tx_antenna(ant, chan);
+ }
+
+ std::string get_antenna(size_t chan){
+ return _dev->get_tx_antenna(chan);
+ }
+
+ std::vector<std::string> get_antennas(size_t chan){
+ return _dev->get_tx_antennas(chan);
+ }
+
+ void set_bandwidth(double bandwidth, size_t chan){
+ return _dev->set_tx_bandwidth(bandwidth, chan);
+ }
+
+ void set_clock_config(const uhd::clock_config_t &clock_config){
+ return _dev->set_clock_config(clock_config);
+ }
+
+ uhd::time_spec_t get_time_now(void){
+ return _dev->get_time_now();
+ }
+
+ void set_time_now(const uhd::time_spec_t &time_spec){
+ return _dev->set_time_now(time_spec);
+ }
+
+ void set_time_next_pps(const uhd::time_spec_t &time_spec){
+ return _dev->set_time_next_pps(time_spec);
+ }
+
+ uhd::usrp::single_usrp::sptr get_device(void){
+ return _dev;
+ }
+
+/***********************************************************************
+ * Work
+ **********************************************************************/
+ int work(
+ int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items
+ ){
+ uhd::tx_metadata_t metadata;
+ metadata.start_of_burst = true;
+
+ return _dev->get_device()->send(
+ input_items, noutput_items, metadata,
+ _type, uhd::device::SEND_MODE_FULL_BUFF
+ );
+ }
+
+ //Send an empty start-of-burst packet to begin streaming.
+ //This is not necessary since all packets are marked SOB.
+ bool start(void){
+ uhd::tx_metadata_t metadata;
+ metadata.start_of_burst = true;
+
+ _dev->get_device()->send(
+ gr_vector_const_void_star(_nchan), 0, metadata,
+ _type, uhd::device::SEND_MODE_ONE_PACKET
+ );
+ return true;
+ }
+
+ //Send an empty end-of-burst packet to end streaming.
+ //Ending the burst avoids an underflow error on stop.
+ bool stop(void){
+ uhd::tx_metadata_t metadata;
+ metadata.end_of_burst = true;
+
+ _dev->get_device()->send(
+ gr_vector_const_void_star(_nchan), 0, metadata,
+ _type, uhd::device::SEND_MODE_ONE_PACKET
+ );
+ return true;
+ }
+
+protected:
+ uhd::usrp::single_usrp::sptr _dev;
+ const uhd::io_type_t _type;
+ size_t _nchan;
+};
+
+/***********************************************************************
+ * Make UHD Single USRP Sink
+ **********************************************************************/
+boost::shared_ptr<uhd_single_usrp_sink> uhd_make_single_usrp_sink(
+ const std::string &device_addr,
+ const uhd::io_type_t::tid_t &io_type,
+ size_t num_channels
+){
+ return boost::shared_ptr<uhd_single_usrp_sink>(
+ new uhd_single_usrp_sink_impl(device_addr, io_type, num_channels)
+ );
+}
diff --git a/gr-uhd/lib/uhd_single_usrp_sink.h b/gr-uhd/lib/uhd_single_usrp_sink.h
new file mode 100644
index 000000000..a4c4e6452
--- /dev/null
+++ b/gr-uhd/lib/uhd_single_usrp_sink.h
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2010 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.
+ */
+
+#ifndef INCLUDED_UHD_SINGLE_USRP_SINK_H
+#define INCLUDED_UHD_SINGLE_USRP_SINK_H
+
+#include <gr_sync_block.h>
+#include <uhd/usrp/single_usrp.hpp>
+
+class uhd_single_usrp_sink;
+
+boost::shared_ptr<uhd_single_usrp_sink> uhd_make_single_usrp_sink(
+ const std::string &device_addr,
+ const uhd::io_type_t::tid_t &io_type,
+ size_t num_channels = 1
+);
+
+class uhd_single_usrp_sink : public gr_sync_block{
+public:
+
+ /*!
+ * Set the IO signature for this block.
+ * \param sig the input signature
+ */
+ uhd_single_usrp_sink(gr_io_signature_sptr sig);
+
+ /*!
+ * Set the subdevice specification.
+ * \param spec the subdev spec markup string
+ */
+ virtual void set_subdev_spec(const std::string &spec) = 0;
+
+ /*!
+ * Set the sample rate for the usrp device.
+ * \param rate a new rate in Sps
+ */
+ virtual void set_samp_rate(double rate) = 0;
+
+ /*!
+ * Get the sample rate for the usrp device.
+ * This is the actual sample rate and may differ from the rate set.
+ * \return the actual rate in Sps
+ */
+ virtual double get_samp_rate(void) = 0;
+
+ /*!
+ * Tune the usrp device to the desired center frequency.
+ * \param tune_request the tune request instructions
+ * \param chan the channel index 0 to N-1
+ * \return a tune result with the actual frequencies
+ */
+ virtual uhd::tune_result_t set_center_freq(
+ const uhd::tune_request_t tune_request, size_t chan
+ ) = 0;
+
+ /*!
+ * Tune the usrp device to the desired center frequency.
+ * This is a wrapper around set center freq so that in this case,
+ * the user can pass a single frequency in the call through swig.
+ * \param freq the desired frequency in Hz
+ * \param chan the channel index 0 to N-1
+ * \return a tune result with the actual frequencies
+ */
+ uhd::tune_result_t set_center_freq(double freq, size_t chan){
+ return set_center_freq(uhd::tune_request_t(freq), chan);
+ }
+
+ /*!
+ * Get the tunable frequency range.
+ * \param chan the channel index 0 to N-1
+ * \return the frequency range in Hz
+ */
+ virtual uhd::freq_range_t get_freq_range(size_t chan = 0) = 0;
+
+ /*!
+ * Set the gain for the dboard.
+ * \param gain the gain in dB
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_gain(float gain, size_t chan = 0) = 0;
+
+ /*!
+ * Get the actual dboard gain setting.
+ * \param chan the channel index 0 to N-1
+ * \return the actual gain in dB
+ */
+ virtual float get_gain(size_t chan = 0) = 0;
+
+ /*!
+ * Get the settable gain range.
+ * \param chan the channel index 0 to N-1
+ * \return the gain range in dB
+ */
+ virtual uhd::gain_range_t get_gain_range(size_t chan = 0) = 0;
+
+ /*!
+ * Set the antenna to use.
+ * \param ant the antenna string
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0;
+
+ /*!
+ * Get the antenna in use.
+ * \param chan the channel index 0 to N-1
+ * \return the antenna string
+ */
+ virtual std::string get_antenna(size_t chan = 0) = 0;
+
+ /*!
+ * Get a list of possible antennas.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of antenna strings
+ */
+ virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0;
+
+ /*!
+ * Set the subdevice bandpass filter.
+ * \param bandwidth the filter bandwidth in Hz
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0;
+
+ /*!
+ * Set the clock configuration.
+ * \param clock_config the new configuration
+ */
+ virtual void set_clock_config(const uhd::clock_config_t &clock_config) = 0;
+
+ /*!
+ * Get the current time registers.
+ * \return the current usrp time
+ */
+ virtual uhd::time_spec_t get_time_now(void) = 0;
+
+ /*!
+ * Set the time registers asap.
+ * \param time_spec the new time
+ */
+ virtual void set_time_now(const uhd::time_spec_t &time_spec) = 0;
+
+ /*!
+ * Set the time registers at the next pps.
+ * \param time_spec the new time
+ */
+ virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0;
+
+ /*!
+ * Get access to the underlying uhd device object.
+ * \return the single usrp device object
+ */
+ virtual uhd::usrp::single_usrp::sptr get_device(void) = 0;
+};
+
+#endif /* INCLUDED_UHD_SINGLE_USRP_SINK_H */
diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc
new file mode 100644
index 000000000..907e8be54
--- /dev/null
+++ b/gr-uhd/lib/uhd_single_usrp_source.cc
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2010 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.
+ */
+
+#include <uhd_single_usrp_source.h>
+#include <gr_io_signature.h>
+#include <stdexcept>
+#include <iostream>
+#include <boost/format.hpp>
+
+/***********************************************************************
+ * UHD Single USRP Source
+ **********************************************************************/
+uhd_single_usrp_source::uhd_single_usrp_source(gr_io_signature_sptr sig)
+:gr_sync_block("uhd single_usrp source", gr_make_io_signature(0, 0, 0), sig){
+ /* NOP */
+}
+
+/***********************************************************************
+ * UHD Single USRP Source Impl
+ **********************************************************************/
+class uhd_single_usrp_source_impl : public uhd_single_usrp_source{
+public:
+ uhd_single_usrp_source_impl(
+ const std::string &device_addr,
+ const uhd::io_type_t &io_type,
+ size_t num_channels
+ ):
+ uhd_single_usrp_source(gr_make_io_signature(
+ num_channels, num_channels, io_type.size
+ )),
+ _type(io_type)
+ {
+ _dev = uhd::usrp::single_usrp::make(device_addr);
+ }
+
+ void set_subdev_spec(const std::string &spec){
+ return _dev->set_rx_subdev_spec(spec);
+ }
+
+ void set_samp_rate(double rate){
+ _dev->set_rx_rate(rate);
+ }
+
+ double get_samp_rate(void){
+ return _dev->get_rx_rate();
+ }
+
+ uhd::tune_result_t set_center_freq(
+ const uhd::tune_request_t tune_request, size_t chan
+ ){
+ return _dev->set_rx_freq(tune_request, chan);
+ }
+
+ uhd::freq_range_t get_freq_range(size_t chan){
+ return _dev->get_rx_freq_range(chan);
+ }
+
+ void set_gain(float gain, size_t chan){
+ return _dev->set_rx_gain(gain, chan);
+ }
+
+ float get_gain(size_t chan){
+ return _dev->get_rx_gain(chan);
+ }
+
+ uhd::gain_range_t get_gain_range(size_t chan){
+ return _dev->get_rx_gain_range(chan);
+ }
+
+ void set_antenna(const std::string &ant, size_t chan){
+ return _dev->set_rx_antenna(ant, chan);
+ }
+
+ std::string get_antenna(size_t chan){
+ return _dev->get_rx_antenna(chan);
+ }
+
+ std::vector<std::string> get_antennas(size_t chan){
+ return _dev->get_rx_antennas(chan);
+ }
+
+ void set_bandwidth(double bandwidth, size_t chan){
+ return _dev->set_rx_bandwidth(bandwidth, chan);
+ }
+
+ void set_clock_config(const uhd::clock_config_t &clock_config){
+ return _dev->set_clock_config(clock_config);
+ }
+
+ uhd::time_spec_t get_time_now(void){
+ return _dev->get_time_now();
+ }
+
+ void set_time_now(const uhd::time_spec_t &time_spec){
+ return _dev->set_time_now(time_spec);
+ }
+
+ void set_time_next_pps(const uhd::time_spec_t &time_spec){
+ return _dev->set_time_next_pps(time_spec);
+ }
+
+ uhd::usrp::single_usrp::sptr get_device(void){
+ return _dev;
+ }
+
+/***********************************************************************
+ * Work
+ **********************************************************************/
+ int work(
+ int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items
+ ){
+ uhd::rx_metadata_t metadata; //not passed out of this block
+
+ size_t num_samps = _dev->get_device()->recv(
+ output_items, noutput_items, metadata,
+ _type, uhd::device::RECV_MODE_FULL_BUFF
+ );
+
+ switch(metadata.error_code){
+ case uhd::rx_metadata_t::ERROR_CODE_NONE:
+ return num_samps;
+
+ case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW:
+ //ignore overflows and try work again
+ return work(noutput_items, input_items, output_items);
+
+ default:
+ std::cout << boost::format(
+ "UHD source block got error code 0x%x"
+ ) % metadata.error_code << std::endl;
+ return num_samps;
+ }
+ }
+
+ bool start(void){
+ _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
+ return true;
+ }
+
+ bool stop(void){
+ _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
+ return true;
+ }
+
+private:
+ uhd::usrp::single_usrp::sptr _dev;
+ const uhd::io_type_t _type;
+};
+
+
+/***********************************************************************
+ * Make UHD Single USRP Source
+ **********************************************************************/
+boost::shared_ptr<uhd_single_usrp_source> uhd_make_single_usrp_source(
+ const std::string &device_addr,
+ const uhd::io_type_t::tid_t &io_type,
+ size_t num_channels
+){
+ return boost::shared_ptr<uhd_single_usrp_source>(
+ new uhd_single_usrp_source_impl(device_addr, io_type, num_channels)
+ );
+}
diff --git a/gr-uhd/lib/uhd_single_usrp_source.h b/gr-uhd/lib/uhd_single_usrp_source.h
new file mode 100644
index 000000000..2a011b2b3
--- /dev/null
+++ b/gr-uhd/lib/uhd_single_usrp_source.h
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2010 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.
+ */
+
+#ifndef INCLUDED_UHD_SINGLE_USRP_SOURCE_H
+#define INCLUDED_UHD_SINGLE_USRP_SOURCE_H
+
+#include <gr_sync_block.h>
+#include <uhd/usrp/single_usrp.hpp>
+
+class uhd_single_usrp_source;
+
+boost::shared_ptr<uhd_single_usrp_source> uhd_make_single_usrp_source(
+ const std::string &device_addr,
+ const uhd::io_type_t::tid_t &io_type,
+ size_t num_channels = 1
+);
+
+class uhd_single_usrp_source : public gr_sync_block{
+public:
+
+ /*!
+ * Set the IO signature for this block.
+ * \param sig the output signature
+ */
+ uhd_single_usrp_source(gr_io_signature_sptr sig);
+
+ /*!
+ * Set the subdevice specification.
+ * \param spec the subdev spec markup string
+ */
+ virtual void set_subdev_spec(const std::string &spec) = 0;
+
+ /*!
+ * Set the sample rate for the usrp device.
+ * \param rate a new rate in Sps
+ */
+ virtual void set_samp_rate(double rate) = 0;
+
+ /*!
+ * Get the sample rate for the usrp device.
+ * This is the actual sample rate and may differ from the rate set.
+ * \return the actual rate in Sps
+ */
+ virtual double get_samp_rate(void) = 0;
+
+ /*!
+ * Tune the usrp device to the desired center frequency.
+ * \param tune_request the tune request instructions
+ * \param chan the channel index 0 to N-1
+ * \return a tune result with the actual frequencies
+ */
+ virtual uhd::tune_result_t set_center_freq(
+ const uhd::tune_request_t tune_request, size_t chan
+ ) = 0;
+
+ /*!
+ * Tune the usrp device to the desired center frequency.
+ * This is a wrapper around set center freq so that in this case,
+ * the user can pass a single frequency in the call through swig.
+ * \param freq the desired frequency in Hz
+ * \param chan the channel index 0 to N-1
+ * \return a tune result with the actual frequencies
+ */
+ uhd::tune_result_t set_center_freq(double freq, size_t chan){
+ return set_center_freq(uhd::tune_request_t(freq), chan);
+ }
+
+ /*!
+ * Get the tunable frequency range.
+ * \param chan the channel index 0 to N-1
+ * \return the frequency range in Hz
+ */
+ virtual uhd::freq_range_t get_freq_range(size_t chan = 0) = 0;
+
+ /*!
+ * Set the gain for the dboard.
+ * \param gain the gain in dB
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_gain(float gain, size_t chan = 0) = 0;
+
+ /*!
+ * Get the actual dboard gain setting.
+ * \param chan the channel index 0 to N-1
+ * \return the actual gain in dB
+ */
+ virtual float get_gain(size_t chan = 0) = 0;
+
+ /*!
+ * Get the settable gain range.
+ * \param chan the channel index 0 to N-1
+ * \return the gain range in dB
+ */
+ virtual uhd::gain_range_t get_gain_range(size_t chan = 0) = 0;
+
+ /*!
+ * Set the antenna to use.
+ * \param ant the antenna string
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0;
+
+ /*!
+ * Get the antenna in use.
+ * \param chan the channel index 0 to N-1
+ * \return the antenna string
+ */
+ virtual std::string get_antenna(size_t chan = 0) = 0;
+
+ /*!
+ * Get a list of possible antennas.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of antenna strings
+ */
+ virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0;
+
+ /*!
+ * Set the subdevice bandpass filter.
+ * \param bandwidth the filter bandwidth in Hz
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0;
+
+ /*!
+ * Set the clock configuration.
+ * \param clock_config the new configuration
+ */
+ virtual void set_clock_config(const uhd::clock_config_t &clock_config) = 0;
+
+ /*!
+ * Get the current time registers.
+ * \return the current usrp time
+ */
+ virtual uhd::time_spec_t get_time_now(void) = 0;
+
+ /*!
+ * Set the time registers asap.
+ * \param time_spec the new time
+ */
+ virtual void set_time_now(const uhd::time_spec_t &time_spec) = 0;
+
+ /*!
+ * Set the time registers at the next pps.
+ * \param time_spec the new time
+ */
+ virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0;
+
+ /*!
+ * Get access to the underlying uhd device object.
+ * \return the single usrp device object
+ */
+ virtual uhd::usrp::single_usrp::sptr get_device(void) = 0;
+
+ protected:
+ size_t d_num_packet_samps;
+ pmt::pmt_t d_tstamp_pair;
+};
+
+#endif /* INCLUDED_UHD_SINGLE_USRP_SOURCE_H */
diff --git a/gr-uhd/swig/.gitignore b/gr-uhd/swig/.gitignore
new file mode 100644
index 000000000..8afaca254
--- /dev/null
+++ b/gr-uhd/swig/.gitignore
@@ -0,0 +1,8 @@
+/uhd_swig.cc
+/uhd_swig.py
+/Makefile
+/Makefile.in
+/guile
+/python
+/run_guile_tests
+/run_tests
diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am
new file mode 100644
index 000000000..e93571a66
--- /dev/null
+++ b/gr-uhd/swig/Makefile.am
@@ -0,0 +1,84 @@
+#
+# Copyright 2010 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.
+#
+
+include $(top_srcdir)/Makefile.common
+include $(top_srcdir)/Makefile.swig
+
+TESTS =
+EXTRA_DIST += run_tests.in run_guile_tests.in $(nobase_guile_DATA)
+DISTCLEANFILES += run_tests run_guile_tests
+
+noinst_PYTHON = qa_uhd.py
+noinst_GUILE = uhd.test
+
+AM_CPPFLAGS = \
+ $(STD_DEFINES_AND_INCLUDES) \
+ $(PYTHON_CPPFLAGS) \
+ $(UHD_CPPFLAGS) \
+ $(WITH_INCLUDES)
+
+uhd_swig_swig_args = $(UHD_CPPFLAGS)
+
+if GUILE
+nobase_guile_DATA = \
+ gnuradio/uhd.scm
+endif
+
+# ----------------------------------------------------------------
+# The SWIG library
+
+TOP_SWIG_IFILES = \
+ uhd_swig.i
+
+# Install so that they end up available as:
+# import gnuradio.uhd
+# This ends up at:
+# ${prefix}/lib/python${python_version}/site-packages/gnuradio/uhd
+uhd_swig_pythondir_category = \
+ gnuradio/uhd
+
+# additional libraries for linking with the SWIG-generated library
+uhd_swig_la_swig_libadd = \
+ $(top_builddir)/gr-uhd/lib/libgnuradio-uhd.la
+
+# additional Python files to be installed along with the SWIG-generated one
+uhd_swig_python = \
+ __init__.py
+
+# additional SWIG files to be installed
+uhd_swig_swiginclude_headers =
+
+uhd_swig_swig_args = \
+ $(UHD_CFLAGS) \
+ -I$(top_srcdir)/gr-uhd/lib
+
+## If UHD was installed, defined GR_HAVE_UHD for swigging headers
+if GR_DEFINE_HAVE_UHD
+ uhd_swig_swig_args += -DGR_HAVE_UHD
+endif
+
+if PYTHON
+TESTS += run_tests
+endif
+
+if GUILE
+TESTS += run_guile_tests
+endif
diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen
new file mode 100644
index 000000000..b73ccd3c4
--- /dev/null
+++ b/gr-uhd/swig/Makefile.swig.gen
@@ -0,0 +1,145 @@
+# -*- Makefile -*-
+#
+# 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.
+#
+
+# Makefile.swig.gen for uhd_swig.i
+
+## Default install locations for these files:
+##
+## Default location for the Python directory is:
+## ${prefix}/lib/python${python_version}/site-packages/[category]/uhd_swig
+## Default location for the Python exec directory is:
+## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/uhd_swig
+##
+## The following can be overloaded to change the install location, but
+## this has to be done in the including Makefile.am -before-
+## Makefile.swig is included.
+
+uhd_swig_pythondir_category ?= gnuradio/uhd_swig
+uhd_swig_pylibdir_category ?= $(uhd_swig_pythondir_category)
+uhd_swig_pythondir = $(pythondir)/$(uhd_swig_pythondir_category)
+uhd_swig_pylibdir = $(pyexecdir)/$(uhd_swig_pylibdir_category)
+
+# The .so libraries for the guile modules get installed whereever guile
+# is installed, usually /usr/lib/guile/gnuradio/
+# FIXME: determince whether these should be installed with gnuradio.
+uhd_swig_scmlibdir = $(libdir)
+
+# The scm files for the guile modules get installed where ever guile
+# is installed, usually /usr/share/guile/site/uhd_swig
+# FIXME: determince whether these should be installed with gnuradio.
+uhd_swig_scmdir = $(guiledir)
+
+## SWIG headers are always installed into the same directory.
+
+uhd_swig_swigincludedir = $(swigincludedir)
+
+## This is a template file for a "generated" Makefile addition (in
+## this case, "Makefile.swig.gen"). By including the top-level
+## Makefile.swig, this file will be used to generate the SWIG
+## dependencies. Assign the variable TOP_SWIG_FILES to be the list of
+## SWIG .i files to generated wrappings for; there can be more than 1
+## so long as the names are unique (no sorting is done on the
+## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i
+## file will generate .cc, .py, and possibly .h files -- meaning that
+## all of these files will have the same base name (that provided for
+## the SWIG .i file).
+##
+## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the
+## right thing. For more info, see <
+## http://sources.redhat.com/automake/automake.html#Multiple-Outputs >
+
+## Other cleaned files: dependency files generated by SWIG or this Makefile
+
+MOSTLYCLEANFILES += $(DEPDIR)/*.S*
+
+## Various SWIG variables. These can be overloaded in the including
+## Makefile.am by setting the variable value there, then including
+## Makefile.swig .
+
+uhd_swig_swiginclude_HEADERS = \
+ uhd_swig.i \
+ $(uhd_swig_swiginclude_headers)
+
+if PYTHON
+uhd_swig_pylib_LTLIBRARIES = \
+ _uhd_swig.la
+
+_uhd_swig_la_SOURCES = \
+ python/uhd_swig.cc \
+ $(uhd_swig_la_swig_sources)
+
+uhd_swig_python_PYTHON = \
+ uhd_swig.py \
+ $(uhd_swig_python)
+
+_uhd_swig_la_LIBADD = \
+ $(STD_SWIG_LA_LIB_ADD) \
+ $(uhd_swig_la_swig_libadd)
+
+_uhd_swig_la_LDFLAGS = \
+ $(STD_SWIG_LA_LD_FLAGS) \
+ $(uhd_swig_la_swig_ldflags)
+
+_uhd_swig_la_CXXFLAGS = \
+ $(STD_SWIG_CXX_FLAGS) \
+ -I$(top_builddir) \
+ $(uhd_swig_la_swig_cxxflags)
+
+python/uhd_swig.cc: uhd_swig.py
+uhd_swig.py: uhd_swig.i
+
+# Include the python dependencies for this file
+-include python/uhd_swig.d
+
+endif # end of if python
+
+if GUILE
+
+uhd_swig_scmlib_LTLIBRARIES = \
+ libguile-gnuradio-uhd_swig.la
+libguile_gnuradio_uhd_swig_la_SOURCES = \
+ guile/uhd_swig.cc \
+ $(uhd_swig_la_swig_sources)
+nobase_uhd_swig_scm_DATA = \
+ gnuradio/uhd_swig.scm \
+ gnuradio/uhd_swig-primitive.scm
+libguile_gnuradio_uhd_swig_la_LIBADD = \
+ $(STD_SWIG_LA_LIB_ADD) \
+ $(uhd_swig_la_swig_libadd)
+libguile_gnuradio_uhd_swig_la_LDFLAGS = \
+ $(STD_SWIG_LA_LD_FLAGS) \
+ $(uhd_swig_la_swig_ldflags)
+libguile_gnuradio_uhd_swig_la_CXXFLAGS = \
+ $(STD_SWIG_CXX_FLAGS) \
+ -I$(top_builddir) \
+ $(uhd_swig_la_swig_cxxflags)
+
+guile/uhd_swig.cc: gnuradio/uhd_swig.scm
+gnuradio/uhd_swig.scm: uhd_swig.i
+gnuradio/uhd_swig-primitive.scm: gnuradio/uhd_swig.scm
+
+# Include the guile dependencies for this file
+-include guile/uhd_swig.d
+
+endif # end of GUILE
+
+
diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py
new file mode 100644
index 000000000..0fdacb796
--- /dev/null
+++ b/gr-uhd/swig/__init__.py
@@ -0,0 +1,40 @@
+#
+# Copyright 2010 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.
+#
+
+# The presence of this file turns this directory into a Python package
+
+########################################################################
+# Add SWIG generated code to this namespace
+########################################################################
+from uhd_swig import *
+
+########################################################################
+# Add other content from pure-Python modules here
+########################################################################
+
+class tune_request_t(tune_request_t, float):
+ """
+ Make the python tune request object inherit from float
+ so that it can be passed in GRC as a frequency parameter.
+ The type checking in GRC will accept the tune request.
+ """
+ def __new__(self, *args): return float.__new__(self)
+ def __float__(self): return self.target_freq
diff --git a/gr-uhd/swig/gnuradio/.gitignore b/gr-uhd/swig/gnuradio/.gitignore
new file mode 100644
index 000000000..820cedd8c
--- /dev/null
+++ b/gr-uhd/swig/gnuradio/.gitignore
@@ -0,0 +1,2 @@
+uhd_swig-primitive.scm
+uhd_swig.scm
diff --git a/gr-uhd/swig/gnuradio/uhd.scm b/gr-uhd/swig/gnuradio/uhd.scm
new file mode 100644
index 000000000..906aef2a6
--- /dev/null
+++ b/gr-uhd/swig/gnuradio/uhd.scm
@@ -0,0 +1,27 @@
+;;;
+;;; Copyright 2010 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 this program. If not, see <http://www.gnu.org/licenses/>.
+;;;
+
+;;; Semi bogus module that just reexports the uhd_swig module
+
+(define-module (gnuradio uhd)
+ #:use-module (gnuradio export-safely)
+ #:use-module (gnuradio uhd_swig)
+ #:duplicates (merge-generics replace check))
+
+(re-export-all '(gnuradio uhd_swig))
diff --git a/gr-uhd/swig/qa_uhd.py b/gr-uhd/swig/qa_uhd.py
new file mode 100755
index 000000000..2973d04cd
--- /dev/null
+++ b/gr-uhd/swig/qa_uhd.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+#
+# Copyright 2005,2008,2010 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, gr_unittest
+import uhd_swig
+
+class test_uhd(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_000_nop (self):
+ """Just see if we can import the module...
+ They may not have a UHD device connected, etc. Don't try to run anything"""
+ pass
+
+if __name__ == '__main__':
+ gr_unittest.run(test_uhd, "test_uhd.xml")
diff --git a/gr-uhd/swig/run_guile_tests.in b/gr-uhd/swig/run_guile_tests.in
new file mode 100644
index 000000000..5d08b0dd5
--- /dev/null
+++ b/gr-uhd/swig/run_guile_tests.in
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+. @top_builddir@/setup_guile_test_env
+
+# 1st argument is absolute path to hand coded guile source directory
+# 2nd argument is absolute path to component C++ shared library build directory
+# 3nd argument is absolute path to component SWIG build directory
+
+add_local_paths \
+ @srcdir@ \
+ @abs_builddir@ \
+ @abs_builddir@
+
+@GUILE@ -e main -c '(use-modules (gnuradio test-suite guile-test))' -t @srcdir@
diff --git a/gr-uhd/swig/run_tests.in b/gr-uhd/swig/run_tests.in
new file mode 100644
index 000000000..195e71316
--- /dev/null
+++ b/gr-uhd/swig/run_tests.in
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# 1st parameter is absolute path to component source directory
+# 2nd parameter is absolute path to component build directory
+# 3rd parameter is path to Python QA directory
+
+@top_builddir@/run_tests.sh \
+ @abs_top_srcdir@/gr-uhd \
+ @abs_top_builddir@/gr-uhd \
+ @srcdir@
diff --git a/gr-uhd/swig/uhd.test b/gr-uhd/swig/uhd.test
new file mode 100644
index 000000000..adc51c884
--- /dev/null
+++ b/gr-uhd/swig/uhd.test
@@ -0,0 +1,37 @@
+;;; -*- Scheme -*-
+;;;
+;;; Copyright 2010 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 this program. If not, see <http://www.gnu.org/licenses/>.
+;;;
+
+;;; If you're using Emacs's Scheme mode:
+;;; (put 'with-test-prefix 'scheme-indent-function 1)
+
+;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests.
+;;; See also the very end of the file, where the test-equal, test-eqv
+;;; and test-eq macros are defined.
+
+(define-module (test-module)
+ #:use-module (oop goops)
+ #:use-module (gnuradio core)
+ #:use-module (gnuradio test-suite lib)
+ #:duplicates (merge-generics replace check))
+
+;;; Just see if we can import the module...
+;;; They may not have a UHD device attached, powered up etc.
+
+(use-modules (gnuradio uhd))
diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i
new file mode 100644
index 000000000..76f44a491
--- /dev/null
+++ b/gr-uhd/swig/uhd_swig.i
@@ -0,0 +1,120 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010 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.
+ */
+
+// Defined during configure; avoids trying to locate
+// header files if UHD was not installed.
+#ifdef GR_HAVE_UHD
+
+////////////////////////////////////////////////////////////////////////
+// Language independent exception handler
+////////////////////////////////////////////////////////////////////////
+%include exception.i
+
+%exception {
+ try {
+ $action
+ }
+ catch(std::exception &e) {
+ SWIG_exception(SWIG_RuntimeError, e.what());
+ }
+ catch(...) {
+ SWIG_exception(SWIG_RuntimeError, "Unknown exception");
+ }
+
+}
+
+////////////////////////////////////////////////////////////////////////
+// standard includes
+////////////////////////////////////////////////////////////////////////
+%include "gnuradio.i"
+
+namespace std {
+ %template(StringVector) vector<string>;
+}
+
+////////////////////////////////////////////////////////////////////////
+// block headers
+////////////////////////////////////////////////////////////////////////
+%{
+#include <uhd_multi_usrp_source.h>
+#include <uhd_multi_usrp_sink.h>
+#include <uhd_single_usrp_source.h>
+#include <uhd_single_usrp_sink.h>
+%}
+
+////////////////////////////////////////////////////////////////////////
+// used types
+////////////////////////////////////////////////////////////////////////
+%include <uhd/config.hpp>
+%include <uhd/utils/pimpl.hpp>
+%include <uhd/types/ranges.hpp>
+%include <uhd/types/tune_request.hpp>
+%include <uhd/types/tune_result.hpp>
+%include <uhd/types/io_type.hpp>
+%include <uhd/types/time_spec.hpp>
+%include <uhd/types/clock_config.hpp>
+
+//Re-create range typedefs here with %template as they are not imported.
+//Replicate all the levels of templated inheritance so swig understands.
+
+%template(float_range_t) uhd::range_t<float>;
+%template(_float_range_vector_t) std::vector<uhd::range_t<float> >;
+%template(gain_range_t) uhd::meta_range_t<float>;
+
+%template(double_range_t) uhd::range_t<double>;
+%template(_double_range_vector_t) std::vector<uhd::range_t<double> >;
+%template(freq_range_t) uhd::meta_range_t<double>;
+
+////////////////////////////////////////////////////////////////////////
+// block magic
+////////////////////////////////////////////////////////////////////////
+GR_SWIG_BLOCK_MAGIC(uhd,multi_usrp_source)
+%include <uhd_multi_usrp_source.h>
+
+GR_SWIG_BLOCK_MAGIC(uhd,multi_usrp_sink)
+%include <uhd_multi_usrp_sink.h>
+
+GR_SWIG_BLOCK_MAGIC(uhd,single_usrp_source)
+%include <uhd_single_usrp_source.h>
+
+GR_SWIG_BLOCK_MAGIC(uhd,single_usrp_sink)
+%include <uhd_single_usrp_sink.h>
+
+////////////////////////////////////////////////////////////////////////
+// helpful constants
+////////////////////////////////////////////////////////////////////////
+%{
+static const size_t ALL_MBOARDS = uhd::usrp::multi_usrp::ALL_MBOARDS;
+%}
+static const size_t ALL_MBOARDS;
+
+#if SWIGGUILE
+%scheme %{
+(load-extension-global "libguile-gnuradio-uhd_swig" "scm_init_gnuradio_uhd_swig_module")
+%}
+
+%goops %{
+(use-modules (gnuradio gnuradio_core_runtime))
+%}
+#endif /* SWIGGUILE */
+
+#endif /* GR_HAVE_UHD */