summaryrefslogtreecommitdiff
path: root/gr-uhd
diff options
context:
space:
mode:
authorJosh Blum2011-02-25 16:11:48 -0800
committerJosh Blum2011-02-25 16:11:48 -0800
commita02bb131f68d5aa66093310c393562671e389778 (patch)
treecc234438359b7e734bb00ac08083c2582b0db86b /gr-uhd
parentda9e63bf4110c06d9a38f2bde3a665f1ae4addae (diff)
parent5bb8acf24e4913d2a969db70476af65c498b032f (diff)
downloadgnuradio-a02bb131f68d5aa66093310c393562671e389778.tar.gz
gnuradio-a02bb131f68d5aa66093310c393562671e389778.tar.bz2
gnuradio-a02bb131f68d5aa66093310c393562671e389778.zip
Merge branch 'gr_uhd_next' into next
Diffstat (limited to 'gr-uhd')
-rw-r--r--gr-uhd/Makefile.am6
-rw-r--r--gr-uhd/grc/.gitignore3
-rw-r--r--gr-uhd/grc/Makefile.am26
-rwxr-xr-xgr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py265
-rw-r--r--[-rwxr-xr-x]gr-uhd/grc/gen_uhd_usrp_blocks.py (renamed from gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py)57
-rw-r--r--gr-uhd/grc/uhd_block_tree.xml6
-rw-r--r--gr-uhd/include/.gitignore (renamed from gr-uhd/apps/.gitignore)0
-rw-r--r--gr-uhd/include/Makefile.am (renamed from gr-uhd/apps/Makefile.am)9
-rw-r--r--gr-uhd/include/gr_uhd_api.h (renamed from gr-uhd/lib/gr_uhd_api.h)2
-rw-r--r--gr-uhd/include/gr_uhd_usrp_sink.h (renamed from gr-uhd/lib/uhd_multi_usrp_sink.h)112
-rw-r--r--gr-uhd/include/gr_uhd_usrp_source.h (renamed from gr-uhd/lib/uhd_multi_usrp_source.h)112
-rw-r--r--gr-uhd/lib/Makefile.am16
-rw-r--r--gr-uhd/lib/gr_uhd_usrp_sink.cc (renamed from gr-uhd/lib/uhd_multi_usrp_sink.cc)62
-rw-r--r--gr-uhd/lib/gr_uhd_usrp_source.cc (renamed from gr-uhd/lib/uhd_multi_usrp_source.cc)62
-rw-r--r--gr-uhd/lib/uhd_single_usrp_sink.cc182
-rw-r--r--gr-uhd/lib/uhd_single_usrp_sink.h174
-rw-r--r--gr-uhd/lib/uhd_single_usrp_source.cc249
-rw-r--r--gr-uhd/lib/uhd_single_usrp_source.h174
-rw-r--r--gr-uhd/swig/Makefile.am6
-rw-r--r--gr-uhd/swig/__init__.py116
-rw-r--r--gr-uhd/swig/uhd_swig.i29
21 files changed, 433 insertions, 1235 deletions
diff --git a/gr-uhd/Makefile.am b/gr-uhd/Makefile.am
index 83190a1d0..2e2d0fbe9 100644
--- a/gr-uhd/Makefile.am
+++ b/gr-uhd/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Free Software Foundation, Inc.
+# Copyright 2010-2011 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -17,11 +17,11 @@
# 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
+SUBDIRS = include lib
if PYTHON
SUBDIRS += swig grc
diff --git a/gr-uhd/grc/.gitignore b/gr-uhd/grc/.gitignore
index d8ab9bd0c..797c54ae7 100644
--- a/gr-uhd/grc/.gitignore
+++ b/gr-uhd/grc/.gitignore
@@ -1,4 +1,3 @@
-/uhd_multi*.xml
-/uhd_single*.xml
+/uhd_usrp*.xml
/Makefile
/Makefile.in
diff --git a/gr-uhd/grc/Makefile.am b/gr-uhd/grc/Makefile.am
index 30061a7ec..7e73a5b39 100644
--- a/gr-uhd/grc/Makefile.am
+++ b/gr-uhd/grc/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Free Software Foundation, Inc.
+# Copyright 2010-2011 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -23,17 +23,11 @@ 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_usrp_blocks = \
+ uhd_usrp_source.xml \
+ uhd_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)
+BUILT_SOURCES += $(generated_uhd_usrp_blocks)
dist_grcblocks_DATA = \
uhd_block_tree.xml \
@@ -42,14 +36,8 @@ dist_grcblocks_DATA = \
########################################################################
# 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) $< $@
+EXTRA_DIST += $(srcdir)/gen_uhd_usrp_blocks.py
-$(generated_uhd_single_usrp_blocks): $(srcdir)/gen_uhd_single_usrp_blocks_xml.py
+$(generated_uhd_usrp_blocks): $(srcdir)/gen_uhd_usrp_blocks.py
@echo "generating $@..."
$(PYTHON) $< $@
diff --git a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py
deleted file mode 100755
index 4de21c989..000000000
--- a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py
+++ /dev/null
@@ -1,265 +0,0 @@
-#!/usr/bin/env python
-"""
-Copyright 2010-2011 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.\$type.type,
- num_channels=\$nchan,
-)
-\#if \$ref_clk()
-self.\$(id).set_clock_config(uhd.clock_config.external());
-\#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 object rather than a simple target frequency.
-Tuning with an LO offset example: uhd.tune_request(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/gen_uhd_multi_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py
index fc44501de..831d69fc4 100755..100644
--- a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py
+++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
"""
Copyright 2010-2011 Free Software Foundation, Inc.
@@ -22,18 +21,23 @@ 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>
+ <name>UHD: USRP $sourk.title()</name>
+ <key>uhd_usrp_$(sourk)</key>
<import>from gnuradio import uhd</import>
- <make>uhd.multi_usrp_$(sourk)(
+ <make>uhd.usrp_$(sourk)(
device_addr=\$dev_addr,
io_type=uhd.io_type.\$type.type,
num_channels=\$nchan,
)
+\#if \$ref_clk()
+self.\$(id).set_clock_config(uhd.clock_config.external(), uhd.ALL_MBOARDS)
+\#end if
\#if \$sync()
-self.\$(id).set_clock_config(uhd.clock_config.external(), uhd.ALL_MBOARDS);
self.\$(id).set_time_unknown_pps(uhd.time_spec())
\#end if
+\#if \$clock_rate()
+self.\$(id).set_clock_rate(\$clock_rate, uhd.ALL_MBOARDS)
+\#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)
@@ -80,7 +84,7 @@ self.\$(id).set_bandwidth(\$bw$(n), $n)
<param>
<name>Device Addr</name>
<key>dev_addr</key>
- <value>addr0=192.168.10.2, addr1=192.168.10.3</value>
+ <value></value>
<type>string</type>
<hide>
\#if \$dev_addr()
@@ -91,9 +95,24 @@ self.\$(id).set_bandwidth(\$bw$(n), $n)
</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>Sync</name>
<key>sync</key>
- <value>sync</value>
+ <value></value>
<type>enum</type>
<hide>\#if \$sync() then 'none' else 'part'#</hide>
<option>
@@ -106,9 +125,20 @@ self.\$(id).set_bandwidth(\$bw$(n), $n)
</option>
</param>
<param>
+ <name>Clock Rate (Hz)</name>
+ <key>clock_rate</key>
+ <value>0.0</value>
+ <type>real</type>
+ <hide>\#if \$clock_rate() then 'none' else 'part'#</hide>
+ <option>
+ <name>Default</name>
+ <key>0.0</key>
+ </option>
+ </param>
+ <param>
<name>Num Mboards</name>
<key>num_mboards</key>
- <value>2</value>
+ <value>1</value>
<type>int</type>
#for $m in range(1, $max_mboards+1)
<option>
@@ -137,7 +167,7 @@ self.\$(id).set_bandwidth(\$bw$(n), $n)
<param>
<name>Num Channels</name>
<key>nchan</key>
- <value>2</value>
+ <value>1</value>
<type>int</type>
#for $n in range(1, $max_nchan+1)
<option>
@@ -165,15 +195,18 @@ self.\$(id).set_bandwidth(\$bw$(n), $n)
<nports>\$nchan</nports>
</$sourk>
<doc>
-The UHD Multi USRP $sourk.title() Block:
+The UHD 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.
+If left blank, the first UHD device found will be used. \\
+Use the device address to specify a specific device or list of devices.
+USRP1 Example: serial=12345678
+USRP2 Example: addr=192.168.10.2
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.
+Selects the number of USRP motherboards in this device configuration.
Subdevice specification:
Each motherboard should have its own subdevice specification \\
diff --git a/gr-uhd/grc/uhd_block_tree.xml b/gr-uhd/grc/uhd_block_tree.xml
index f5d42b567..8a9f62f7c 100644
--- a/gr-uhd/grc/uhd_block_tree.xml
+++ b/gr-uhd/grc/uhd_block_tree.xml
@@ -8,9 +8,7 @@
<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>
+ <block>uhd_usrp_source</block>
+ <block>uhd_usrp_sink</block>
</cat>
</cat>
diff --git a/gr-uhd/apps/.gitignore b/gr-uhd/include/.gitignore
index b336cc7ce..b336cc7ce 100644
--- a/gr-uhd/apps/.gitignore
+++ b/gr-uhd/include/.gitignore
diff --git a/gr-uhd/apps/Makefile.am b/gr-uhd/include/Makefile.am
index b78d07ee8..4a04c98c1 100644
--- a/gr-uhd/apps/Makefile.am
+++ b/gr-uhd/include/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Free Software Foundation, Inc.
+# Copyright 2011 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -17,6 +17,11 @@
# 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
+
+grinclude_HEADERS = \
+ gr_uhd_api.h \
+ gr_uhd_usrp_source.h \
+ gr_uhd_usrp_sink.h
diff --git a/gr-uhd/lib/gr_uhd_api.h b/gr-uhd/include/gr_uhd_api.h
index a9b99fd87..d20b82c99 100644
--- a/gr-uhd/lib/gr_uhd_api.h
+++ b/gr-uhd/include/gr_uhd_api.h
@@ -27,7 +27,7 @@
#ifdef gnuradio_uhd_EXPORTS
# define GR_UHD_API UHD_EXPORT
#else
-# define GR_UHD_API UHD_EXPORT
+# define GR_UHD_API UHD_IMPORT
#endif
#endif /* INCLUDED_GR_UHD_API_H */
diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.h b/gr-uhd/include/gr_uhd_usrp_sink.h
index 4866f2cbb..557cb2cdb 100644
--- a/gr-uhd/lib/uhd_multi_usrp_sink.h
+++ b/gr-uhd/include/gr_uhd_usrp_sink.h
@@ -19,36 +19,36 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef INCLUDED_UHD_MULTI_USRP_SINK_H
-#define INCLUDED_UHD_MULTI_USRP_SINK_H
+#ifndef INCLUDED_GR_UHD_USRP_SINK_H
+#define INCLUDED_GR_UHD_USRP_SINK_H
#include <gr_uhd_api.h>
#include <gr_sync_block.h>
#include <uhd/usrp/multi_usrp.hpp>
-class uhd_multi_usrp_sink;
+class uhd_usrp_sink;
-GR_UHD_API boost::shared_ptr<uhd_multi_usrp_sink> uhd_make_multi_usrp_sink(
+GR_UHD_API boost::shared_ptr<uhd_usrp_sink> uhd_make_usrp_sink(
const uhd::device_addr_t &device_addr,
const uhd::io_type_t &io_type,
size_t num_channels
);
-class GR_UHD_API uhd_multi_usrp_sink : public gr_sync_block{
+class GR_UHD_API uhd_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);
+ uhd_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;
+ virtual void set_subdev_spec(const std::string &spec, size_t mboard = 0) = 0;
/*!
* Set the sample rate for the usrp device.
@@ -70,7 +70,7 @@ public:
* \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
+ const uhd::tune_request_t tune_request, size_t chan = 0
) = 0;
/*!
@@ -81,78 +81,144 @@ public:
* \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){
+ uhd::tune_result_t set_center_freq(double freq, size_t chan = 0){
return set_center_freq(uhd::tune_request_t(freq), chan);
}
/*!
+ * Get the center frequency.
+ * \param chan the channel index 0 to N-1
+ * \return the frequency in Hz
+ */
+ virtual double get_center_freq(size_t chan = 0) = 0;
+
+ /*!
* 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;
+ 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(double gain, size_t chan) = 0;
+ virtual void set_gain(double 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 double get_gain(size_t chan) = 0;
+ virtual double 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;
+ 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;
+ 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;
+ 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;
+ virtual std::vector<std::string> get_antennas(size_t chan = 0) = 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;
+ virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0;
+
+ /*!
+ * Get a daughterboard sensor value.
+ * \param name the name of the sensor
+ * \param chan the channel index 0 to N-1
+ * \return a sensor value object
+ */
+ virtual uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan = 0) = 0;
+
+ /*!
+ * Get a list of possible daughterboard sensor names.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of sensor names
+ */
+ virtual std::vector<std::string> get_dboard_sensor_names(size_t chan = 0) = 0;
+
+ /*!
+ * Get a motherboard sensor value.
+ * \param name the name of the sensor
+ * \param mboard the motherboard index 0 to M-1
+ * \return a sensor value object
+ */
+ virtual uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
+
+ /*!
+ * Get a list of possible motherboard sensor names.
+ * \param mboard the motherboard index 0 to M-1
+ * \return a vector of sensor names
+ */
+ virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 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;
+ virtual void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard = 0) = 0;
+
+ /*!
+ * Get the master clock rate.
+ * \param mboard the motherboard index 0 to M-1
+ * \return the clock rate in Hz
+ */
+ virtual double get_clock_rate(size_t mboard = 0) = 0;
+
+ /*!
+ * Set the master clock rate.
+ * \param rate the new rate in Hz
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_clock_rate(double rate, size_t mboard = 0) = 0;
/*!
* Get the current time registers.
+ * \param mboard the motherboard index 0 to M-1
* \return the current usrp time
*/
- virtual uhd::time_spec_t get_time_now(void) = 0;
+ virtual uhd::time_spec_t get_time_now(size_t mboard = 0) = 0;
+
+ /*!
+ * Get the time when the last pps pulse occured.
+ * \param mboard the motherboard index 0 to M-1
+ * \return the current usrp time
+ */
+ virtual uhd::time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
+
+ /*!
+ * Sets the time registers immediately.
+ * \param time_spec the new time
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_time_now(const uhd::time_spec_t &time_spec, size_t mboard = 0) = 0;
/*!
* Set the time registers at the next pps.
@@ -167,10 +233,16 @@ public:
virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0;
/*!
+ * Get access to the underlying uhd dboard iface object.
+ * \return the dboard_iface object
+ */
+ virtual uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 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 */
+#endif /* INCLUDED_GR_UHD_USRP_SINK_H */
diff --git a/gr-uhd/lib/uhd_multi_usrp_source.h b/gr-uhd/include/gr_uhd_usrp_source.h
index 9cbec52aa..3b36bf45d 100644
--- a/gr-uhd/lib/uhd_multi_usrp_source.h
+++ b/gr-uhd/include/gr_uhd_usrp_source.h
@@ -19,36 +19,36 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef INCLUDED_UHD_MULTI_USRP_SOURCE_H
-#define INCLUDED_UHD_MULTI_USRP_SOURCE_H
+#ifndef INCLUDED_GR_UHD_USRP_SOURCE_H
+#define INCLUDED_GR_UHD_USRP_SOURCE_H
#include <gr_uhd_api.h>
#include <gr_sync_block.h>
#include <uhd/usrp/multi_usrp.hpp>
-class uhd_multi_usrp_source;
+class uhd_usrp_source;
-GR_UHD_API boost::shared_ptr<uhd_multi_usrp_source> uhd_make_multi_usrp_source(
+GR_UHD_API boost::shared_ptr<uhd_usrp_source> uhd_make_usrp_source(
const uhd::device_addr_t &device_addr,
const uhd::io_type_t &io_type,
size_t num_channels
);
-class GR_UHD_API uhd_multi_usrp_source : public gr_sync_block{
+class GR_UHD_API uhd_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);
+ uhd_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;
+ virtual void set_subdev_spec(const std::string &spec, size_t mboard = 0) = 0;
/*!
* Set the sample rate for the usrp device.
@@ -70,7 +70,7 @@ public:
* \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
+ const uhd::tune_request_t tune_request, size_t chan = 0
) = 0;
/*!
@@ -81,78 +81,144 @@ public:
* \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){
+ uhd::tune_result_t set_center_freq(double freq, size_t chan = 0){
return set_center_freq(uhd::tune_request_t(freq), chan);
}
/*!
+ * Get the center frequency.
+ * \param chan the channel index 0 to N-1
+ * \return the frequency in Hz
+ */
+ virtual double get_center_freq(size_t chan = 0) = 0;
+
+ /*!
* 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;
+ 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(double gain, size_t chan) = 0;
+ virtual void set_gain(double 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 double get_gain(size_t chan) = 0;
+ virtual double 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;
+ 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;
+ 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;
+ 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;
+ 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;
+ virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0;
+
+ /*!
+ * Get a daughterboard sensor value.
+ * \param name the name of the sensor
+ * \param chan the channel index 0 to N-1
+ * \return a sensor value object
+ */
+ virtual uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan = 0) = 0;
+
+ /*!
+ * Get a list of possible daughterboard sensor names.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of sensor names
+ */
+ virtual std::vector<std::string> get_dboard_sensor_names(size_t chan = 0) = 0;
+
+ /*!
+ * Get a motherboard sensor value.
+ * \param name the name of the sensor
+ * \param mboard the motherboard index 0 to M-1
+ * \return a sensor value object
+ */
+ virtual uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
+
+ /*!
+ * Get a list of possible motherboard sensor names.
+ * \param mboard the motherboard index 0 to M-1
+ * \return a vector of sensor names
+ */
+ virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 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;
+ virtual void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard = 0) = 0;
+
+ /*!
+ * Get the master clock rate.
+ * \param mboard the motherboard index 0 to M-1
+ * \return the clock rate in Hz
+ */
+ virtual double get_clock_rate(size_t mboard = 0) = 0;
+
+ /*!
+ * Set the master clock rate.
+ * \param rate the new rate in Hz
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_clock_rate(double rate, size_t mboard = 0) = 0;
/*!
* Get the current time registers.
+ * \param mboard the motherboard index 0 to M-1
* \return the current usrp time
*/
- virtual uhd::time_spec_t get_time_now(void) = 0;
+ virtual uhd::time_spec_t get_time_now(size_t mboard = 0) = 0;
+
+ /*!
+ * Get the time when the last pps pulse occured.
+ * \param mboard the motherboard index 0 to M-1
+ * \return the current usrp time
+ */
+ virtual uhd::time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
+
+ /*!
+ * Sets the time registers immediately.
+ * \param time_spec the new time
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_time_now(const uhd::time_spec_t &time_spec, size_t mboard = 0) = 0;
/*!
* Set the time registers at the next pps.
@@ -167,10 +233,16 @@ public:
virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0;
/*!
+ * Get access to the underlying uhd dboard iface object.
+ * \return the dboard_iface object
+ */
+ virtual uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 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 */
+#endif /* INCLUDED_GR_UHD_USRP_SOURCE_H */
diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am
index 7ddb45cb3..d93b243e2 100644
--- a/gr-uhd/lib/Makefile.am
+++ b/gr-uhd/lib/Makefile.am
@@ -24,15 +24,14 @@ include $(top_srcdir)/Makefile.common
AM_CPPFLAGS = \
$(STD_DEFINES_AND_INCLUDES) \
$(WITH_INCLUDES) \
- $(UHD_CPPFLAGS)
+ $(UHD_CPPFLAGS) \
+ -Dgnuradio_uhd_EXPORTS
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
+ gr_uhd_usrp_source.cc \
+ gr_uhd_usrp_sink.cc
libgnuradio_uhd_la_LIBADD = \
$(GNURADIO_CORE_LA) \
@@ -40,11 +39,4 @@ libgnuradio_uhd_la_LIBADD = \
libgnuradio_uhd_la_LDFLAGS = $(LTVERSIONFLAGS)
-grinclude_HEADERS = \
- gr_uhd_api.h \
- 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/gr_uhd_usrp_sink.cc
index 32039e44a..4598e54c2 100644
--- a/gr-uhd/lib/uhd_multi_usrp_sink.cc
+++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc
@@ -19,29 +19,29 @@
* Boston, MA 02110-1301, USA.
*/
-#include <uhd_multi_usrp_sink.h>
+#include <gr_uhd_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)){
+uhd_usrp_sink::uhd_usrp_sink(gr_io_signature_sptr sig)
+:gr_sync_block("gr uhd 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{
+class uhd_usrp_sink_impl : public uhd_usrp_sink{
public:
- uhd_multi_usrp_sink_impl(
+ uhd_usrp_sink_impl(
const uhd::device_addr_t &device_addr,
const uhd::io_type_t &io_type,
size_t num_channels
):
- uhd_multi_usrp_sink(gr_make_io_signature(
+ uhd_usrp_sink(gr_make_io_signature(
num_channels, num_channels, io_type.size
)),
_type(io_type),
@@ -69,6 +69,10 @@ public:
return _dev->set_tx_freq(tune_request, chan);
}
+ double get_center_freq(size_t chan){
+ return _dev->get_tx_freq(chan);
+ }
+
uhd::freq_range_t get_freq_range(size_t chan){
return _dev->get_tx_freq_range(chan);
}
@@ -101,12 +105,44 @@ public:
return _dev->set_tx_bandwidth(bandwidth, chan);
}
+ uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan){
+ return _dev->get_tx_sensor(name, chan);
+ }
+
+ std::vector<std::string> get_dboard_sensor_names(size_t chan){
+ return _dev->get_tx_sensor_names(chan);
+ }
+
+ uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard){
+ return _dev->get_mboard_sensor(name, mboard);
+ }
+
+ std::vector<std::string> get_mboard_sensor_names(size_t mboard){
+ return _dev->get_mboard_sensor_names(mboard);
+ }
+
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();
+ double get_clock_rate(size_t mboard){
+ return _dev->get_master_clock_rate(mboard);
+ }
+
+ void set_clock_rate(double rate, size_t mboard){
+ return _dev->set_master_clock_rate(rate, mboard);
+ }
+
+ uhd::time_spec_t get_time_now(size_t mboard = 0){
+ return _dev->get_time_now(mboard);
+ }
+
+ uhd::time_spec_t get_time_last_pps(size_t mboard){
+ return _dev->get_time_last_pps(mboard);
+ }
+
+ void set_time_now(const uhd::time_spec_t &time_spec, size_t mboard){
+ return _dev->set_time_now(time_spec, mboard);
}
void set_time_next_pps(const uhd::time_spec_t &time_spec){
@@ -117,6 +153,10 @@ public:
return _dev->set_time_unknown_pps(time_spec);
}
+ uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan){
+ return _dev->get_tx_dboard_iface(chan);
+ }
+
uhd::usrp::multi_usrp::sptr get_device(void){
return _dev;
}
@@ -184,12 +224,12 @@ protected:
/***********************************************************************
* Make UHD Multi USRP Sink
**********************************************************************/
-boost::shared_ptr<uhd_multi_usrp_sink> uhd_make_multi_usrp_sink(
+boost::shared_ptr<uhd_usrp_sink> uhd_make_usrp_sink(
const uhd::device_addr_t &device_addr,
const uhd::io_type_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)
+ return boost::shared_ptr<uhd_usrp_sink>(
+ new uhd_usrp_sink_impl(device_addr, io_type, num_channels)
);
}
diff --git a/gr-uhd/lib/uhd_multi_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc
index 181cf1eb4..09cced567 100644
--- a/gr-uhd/lib/uhd_multi_usrp_source.cc
+++ b/gr-uhd/lib/gr_uhd_usrp_source.cc
@@ -19,7 +19,7 @@
* Boston, MA 02110-1301, USA.
*/
-#include <uhd_multi_usrp_source.h>
+#include <gr_uhd_usrp_source.h>
#include <gr_io_signature.h>
#include <stdexcept>
#include <iostream>
@@ -28,22 +28,22 @@
/***********************************************************************
* 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){
+uhd_usrp_source::uhd_usrp_source(gr_io_signature_sptr sig)
+:gr_sync_block("gr uhd 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{
+class uhd_usrp_source_impl : public uhd_usrp_source{
public:
- uhd_multi_usrp_source_impl(
+ uhd_usrp_source_impl(
const uhd::device_addr_t &device_addr,
const uhd::io_type_t &io_type,
size_t num_channels
):
- uhd_multi_usrp_source(gr_make_io_signature(
+ uhd_usrp_source(gr_make_io_signature(
num_channels, num_channels, io_type.size
)),
_type(io_type)
@@ -69,6 +69,10 @@ public:
return _dev->set_rx_freq(tune_request, chan);
}
+ double get_center_freq(size_t chan){
+ return _dev->get_rx_freq(chan);
+ }
+
uhd::freq_range_t get_freq_range(size_t chan){
return _dev->get_rx_freq_range(chan);
}
@@ -101,12 +105,44 @@ public:
return _dev->set_rx_bandwidth(bandwidth, chan);
}
+ uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan){
+ return _dev->get_rx_sensor(name, chan);
+ }
+
+ std::vector<std::string> get_dboard_sensor_names(size_t chan){
+ return _dev->get_rx_sensor_names(chan);
+ }
+
+ uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard){
+ return _dev->get_mboard_sensor(name, mboard);
+ }
+
+ std::vector<std::string> get_mboard_sensor_names(size_t mboard){
+ return _dev->get_mboard_sensor_names(mboard);
+ }
+
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();
+ double get_clock_rate(size_t mboard){
+ return _dev->get_master_clock_rate(mboard);
+ }
+
+ void set_clock_rate(double rate, size_t mboard){
+ return _dev->set_master_clock_rate(rate, mboard);
+ }
+
+ uhd::time_spec_t get_time_now(size_t mboard = 0){
+ return _dev->get_time_now(mboard);
+ }
+
+ uhd::time_spec_t get_time_last_pps(size_t mboard){
+ return _dev->get_time_last_pps(mboard);
+ }
+
+ void set_time_now(const uhd::time_spec_t &time_spec, size_t mboard){
+ return _dev->set_time_now(time_spec, mboard);
}
void set_time_next_pps(const uhd::time_spec_t &time_spec){
@@ -117,6 +153,10 @@ public:
return _dev->set_time_unknown_pps(time_spec);
}
+ uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan){
+ return _dev->get_rx_dboard_iface(chan);
+ }
+
uhd::usrp::multi_usrp::sptr get_device(void){
return _dev;
}
@@ -176,12 +216,12 @@ private:
/***********************************************************************
* Make UHD Multi USRP Source
**********************************************************************/
-boost::shared_ptr<uhd_multi_usrp_source> uhd_make_multi_usrp_source(
+boost::shared_ptr<uhd_usrp_source> uhd_make_usrp_source(
const uhd::device_addr_t &device_addr,
const uhd::io_type_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)
+ return boost::shared_ptr<uhd_usrp_source>(
+ new uhd_usrp_source_impl(device_addr, io_type, num_channels)
);
}
diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc
deleted file mode 100644
index d9aaac893..000000000
--- a/gr-uhd/lib/uhd_single_usrp_sink.cc
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright 2010-2011 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 uhd::device_addr_t &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(double gain, size_t chan){
- return _dev->set_tx_gain(gain, chan);
- }
-
- double 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; //send a mid-burst packet
-
- 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 uhd::device_addr_t &device_addr,
- const uhd::io_type_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
deleted file mode 100644
index 4929d0f13..000000000
--- a/gr-uhd/lib/uhd_single_usrp_sink.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright 2010-2011 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_uhd_api.h>
-#include <gr_sync_block.h>
-#include <uhd/usrp/single_usrp.hpp>
-
-class uhd_single_usrp_sink;
-
-GR_UHD_API boost::shared_ptr<uhd_single_usrp_sink> uhd_make_single_usrp_sink(
- const uhd::device_addr_t &device_addr,
- const uhd::io_type_t &io_type,
- size_t num_channels = 1
-);
-
-class GR_UHD_API 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(double 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 double 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
deleted file mode 100644
index 5a26d44b1..000000000
--- a/gr-uhd/lib/uhd_single_usrp_source.cc
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright 2010-2011 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 uhd::device_addr_t &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(double gain, size_t chan){
- return _dev->set_rx_gain(gain, chan);
- }
-
- double 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
- **********************************************************************/
- virtual 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;
- }
-
-protected:
- uhd::usrp::single_usrp::sptr _dev;
- const uhd::io_type_t _type;
-};
-
-/***********************************************************************
- * UHD Single USRP Source Impl with Tags
- **********************************************************************/
-class uhd_single_usrp_source_impl_with_tags : public uhd_single_usrp_source_impl{
-public:
- uhd_single_usrp_source_impl_with_tags(
- const uhd::device_addr_t &device_addr,
- const uhd::io_type_t &io_type,
- size_t num_channels
- ):
- uhd_single_usrp_source_impl(device_addr, io_type, num_channels)
- {
- d_tag_srcid = pmt::mp("uhd_single_usrp_source");
- }
-
- 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:
- //FIXME in RECV_MODE_FULL_BUFF we are probably get remainders,
- //there is no guarantee of has_time_spec, its random
- if(metadata.has_time_spec) {
- d_tstamp_pair = pmt::mp(pmt::mp(metadata.time_spec.get_full_secs()),
- pmt::mp(metadata.time_spec.get_frac_secs()));
- add_item_tag(0, nitems_written(0),
- //gr_tags::key_time,
- pmt::pmt_string_to_symbol("time"),
- d_tstamp_pair,
- d_tag_srcid);
- }
- 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;
- }
- }
-
-private:
- size_t d_num_packet_samps;
- pmt::pmt_t d_tstamp_pair;
- pmt::pmt_t d_tag_srcid;
-};
-
-
-/***********************************************************************
- * Make UHD Single USRP Source
- **********************************************************************/
-#include <gr_prefs.h>
-boost::shared_ptr<uhd_single_usrp_source> uhd_make_single_usrp_source(
- const uhd::device_addr_t &device_addr,
- const uhd::io_type_t &io_type,
- size_t num_channels
-){
- //use the tags constructor if tags is set to on
- bool tags_enabled = (gr_prefs().get_string("gr-uhd", "tags", "off") == "on");
- if (tags_enabled) return boost::shared_ptr<uhd_single_usrp_source>(
- new uhd_single_usrp_source_impl_with_tags(device_addr, io_type, 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
deleted file mode 100644
index 262f6696c..000000000
--- a/gr-uhd/lib/uhd_single_usrp_source.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright 2010-2011 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_uhd_api.h>
-#include <gr_sync_block.h>
-#include <uhd/usrp/single_usrp.hpp>
-
-class uhd_single_usrp_source;
-
-GR_UHD_API boost::shared_ptr<uhd_single_usrp_source> uhd_make_single_usrp_source(
- const uhd::device_addr_t &device_addr,
- const uhd::io_type_t &io_type,
- size_t num_channels = 1
-);
-
-class GR_UHD_API 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(double 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 double 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_SOURCE_H */
diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am
index e93571a66..035fb2112 100644
--- a/gr-uhd/swig/Makefile.am
+++ b/gr-uhd/swig/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2010 Free Software Foundation, Inc.
+# Copyright 2010-2011 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -66,9 +66,7 @@ uhd_swig_python = \
# additional SWIG files to be installed
uhd_swig_swiginclude_headers =
-uhd_swig_swig_args = \
- $(UHD_CFLAGS) \
- -I$(top_srcdir)/gr-uhd/lib
+uhd_swig_swig_args = $(UHD_CPPFLAGS)
## If UHD was installed, defined GR_HAVE_UHD for swigging headers
if GR_DEFINE_HAVE_UHD
diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py
index 1a9f8358d..7ed689ec0 100644
--- a/gr-uhd/swig/__init__.py
+++ b/gr-uhd/swig/__init__.py
@@ -17,70 +17,72 @@
# 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
+#
########################################################################
-# Create aliases for uhd swig attributes to avoid the "_t"
-# Install the __str__ and __repr__ handlers if applicable
+# Prepare uhd swig module to make it more pythonic
########################################################################
-import uhd_swig
-for attr in dir(uhd_swig):
- myobj = getattr(uhd_swig, attr)
- if hasattr(myobj, 'to_string'): myobj.__repr__ = lambda s: s.to_string().strip()
- if hasattr(myobj, 'to_pp_string'): myobj.__str__ = lambda s: s.to_pp_string().strip()
- if attr.endswith('_t'): setattr(uhd_swig, attr[:-2], myobj)
+def _prepare_uhd_swig():
+ import uhd_swig
-########################################################################
-# Add SWIG generated code to this namespace
-########################################################################
-from uhd_swig import *
+ #some useful typedefs for the user
+ setattr(uhd_swig, 'freq_range_t', uhd_swig.meta_range_t)
+ setattr(uhd_swig, 'gain_range_t', uhd_swig.meta_range_t)
-########################################################################
-# Add other content from pure-Python modules here
-########################################################################
-class freq_range_t(meta_range_t): pass #a typedef for the user
-class gain_range_t(meta_range_t): pass #a typedef for the user
+ #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.
+ class tune_request_t(uhd_swig.tune_request_t, float):
+ def __new__(self, *args): return float.__new__(self)
+ def __float__(self): return self.target_freq
+ setattr(uhd_swig, 'tune_request_t', tune_request_t)
+
+ #Make the python tune request object inherit from string
+ #so that it can be passed in GRC as a string parameter.
+ #The type checking in GRC will accept the device address.
+ #Define the set/get item special methods for dict access.
+ class device_addr_t(uhd_swig.device_addr_t, str):
+ def __new__(self, *args): return str.__new__(self)
+ def __getitem__(self, key): return self.get(key)
+ def __setitem__(self, key, val): self.set(key, val)
+ setattr(uhd_swig, 'device_addr_t', device_addr_t)
-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
+ #handle general things on all uhd_swig attributes
+ #Install the __str__ and __repr__ handlers if applicable
+ #Create aliases for uhd swig attributes to avoid the "_t"
+ for attr in dir(uhd_swig):
+ myobj = getattr(uhd_swig, attr)
+ if hasattr(myobj, 'to_string'): myobj.__repr__ = lambda o: o.to_string().strip()
+ if hasattr(myobj, 'to_pp_string'): myobj.__str__ = lambda o: o.to_pp_string().strip()
+ if hasattr(myobj, 'to_bool'): myobj.__nonzero__ = lambda o: o.to_bool()
+ if hasattr(myobj, 'to_int'): myobj.__int__ = lambda o: o.to_int()
+ if hasattr(myobj, 'to_real'): myobj.__float__ = lambda o: o.to_real()
+ if attr.endswith('_t'): setattr(uhd_swig, attr[:-2], myobj)
-class device_addr_t(device_addr_t, str):
- """
- Make the python tune request object inherit from string
- so that it can be passed in GRC as a string parameter.
- The type checking in GRC will accept the device address.
- Define the set/get item special methods for dict access.
- """
- def __new__(self, *args): return str.__new__(self)
- def __getitem__(self, key): return self.get(key)
- def __setitem__(self, key, val): self.set(key, val)
+ #Cast constructor args (FIXME swig handle overloads?)
+ for attr in ('usrp_source', 'usrp_sink'):
+ def constructor_factory(old_constructor):
+ def constructor_interceptor(*args, **kwargs):
+ args = list(args)
+ kwargs = dict(kwargs)
+ for index, key, cast in (
+ (0, 'device_addr', device_addr),
+ (1, 'io_type', io_type),
+ ):
+ if len(args) > index: args[index] = cast(args[index])
+ if kwargs.has_key(key): kwargs[key] = cast(kwargs[key])
+ return old_constructor(*args, **kwargs)
+ return constructor_interceptor
+ setattr(uhd_swig, attr, constructor_factory(getattr(uhd_swig, attr)))
+
+ #Aliases for deprecated constructors
+ setattr(uhd_swig, 'single_usrp_source', uhd_swig.usrp_source)
+ setattr(uhd_swig, 'single_usrp_sink', uhd_swig.usrp_sink)
+ setattr(uhd_swig, 'multi_usrp_source', uhd_swig.usrp_source)
+ setattr(uhd_swig, 'multi_usrp_sink', uhd_swig.usrp_sink)
########################################################################
-# Cast constructor args (FIXME swig handle overloads?)
+# Initialize this module with the contents of uhd swig
########################################################################
-for attr in (
- 'single_usrp_source', 'single_usrp_sink',
- 'multi_usrp_source', 'multi_usrp_sink'
-):
- def constructor_factory(old_constructor):
- def constructor_interceptor(*args, **kwargs):
- args = list(args)
- kwargs = dict(kwargs)
- for index, key, cast in (
- (0, 'device_addr', device_addr),
- (1, 'io_type', io_type),
- ):
- if len(args) > index: args[index] = cast(args[index])
- if kwargs.has_key(key): kwargs[key] = cast(kwargs[key])
- return old_constructor(*args, **kwargs)
- return constructor_interceptor
- import uhd_swig
- globals()[attr] = constructor_factory(getattr(uhd_swig, attr))
+_prepare_uhd_swig()
+from uhd_swig import *
diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i
index 3c317beb4..b814471b2 100644
--- a/gr-uhd/swig/uhd_swig.i
+++ b/gr-uhd/swig/uhd_swig.i
@@ -53,10 +53,8 @@
// 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>
+#include <gr_uhd_usrp_source.h>
+#include <gr_uhd_usrp_sink.h>
%}
////////////////////////////////////////////////////////////////////////
@@ -93,20 +91,25 @@
%include <uhd/device.hpp>
%template(device_addr_vector_t) std::vector<uhd::device_addr_t>;
+%include <uhd/types/sensors.hpp>
+
////////////////////////////////////////////////////////////////////////
-// block magic
+// swig dboard_iface for python access
////////////////////////////////////////////////////////////////////////
-GR_SWIG_BLOCK_MAGIC(uhd,multi_usrp_source)
-%include <uhd_multi_usrp_source.h>
+%include stdint.i
+%include <uhd/types/serial.hpp>
+%include <uhd/usrp/dboard_iface.hpp>
-GR_SWIG_BLOCK_MAGIC(uhd,multi_usrp_sink)
-%include <uhd_multi_usrp_sink.h>
+%template(dboard_iface_sptr) boost::shared_ptr<uhd::usrp::dboard_iface>;
-GR_SWIG_BLOCK_MAGIC(uhd,single_usrp_source)
-%include <uhd_single_usrp_source.h>
+////////////////////////////////////////////////////////////////////////
+// block magic
+////////////////////////////////////////////////////////////////////////
+GR_SWIG_BLOCK_MAGIC(uhd,usrp_source)
+%include <gr_uhd_usrp_source.h>
-GR_SWIG_BLOCK_MAGIC(uhd,single_usrp_sink)
-%include <uhd_single_usrp_sink.h>
+GR_SWIG_BLOCK_MAGIC(uhd,usrp_sink)
+%include <gr_uhd_usrp_sink.h>
////////////////////////////////////////////////////////////////////////
// helpful constants