From 8afa393725c2bfda7c341b7202acfa40cc3245d2 Mon Sep 17 00:00:00 2001 From: Jason Abele Date: Fri, 21 Jan 2011 19:24:33 -0800 Subject: Added first pass at swigging dboard iface --- gr-uhd/lib/uhd_multi_usrp_sink.cc | 4 ++++ gr-uhd/lib/uhd_multi_usrp_sink.h | 6 ++++++ gr-uhd/lib/uhd_multi_usrp_source.cc | 4 ++++ gr-uhd/lib/uhd_multi_usrp_source.h | 6 ++++++ gr-uhd/lib/uhd_single_usrp_sink.cc | 4 ++++ gr-uhd/lib/uhd_single_usrp_sink.h | 6 ++++++ gr-uhd/lib/uhd_single_usrp_source.cc | 4 ++++ gr-uhd/lib/uhd_single_usrp_source.h | 6 ++++++ gr-uhd/swig/uhd_swig.i | 9 +++++++++ 9 files changed, 49 insertions(+) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.cc b/gr-uhd/lib/uhd_multi_usrp_sink.cc index 32039e44a..126d006d6 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.cc +++ b/gr-uhd/lib/uhd_multi_usrp_sink.cc @@ -117,6 +117,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; } diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.h b/gr-uhd/lib/uhd_multi_usrp_sink.h index 4866f2cbb..b15339eb7 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.h +++ b/gr-uhd/lib/uhd_multi_usrp_sink.h @@ -166,6 +166,12 @@ 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; + /*! * Get access to the underlying uhd device object. * \return the multi usrp device object diff --git a/gr-uhd/lib/uhd_multi_usrp_source.cc b/gr-uhd/lib/uhd_multi_usrp_source.cc index 181cf1eb4..affcfce75 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.cc +++ b/gr-uhd/lib/uhd_multi_usrp_source.cc @@ -117,6 +117,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; } diff --git a/gr-uhd/lib/uhd_multi_usrp_source.h b/gr-uhd/lib/uhd_multi_usrp_source.h index 9cbec52aa..0f26c9457 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.h +++ b/gr-uhd/lib/uhd_multi_usrp_source.h @@ -166,6 +166,12 @@ 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; + /*! * Get access to the underlying uhd device object. * \return the multi usrp device object diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc index d9aaac893..88b2479a9 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -116,6 +116,10 @@ public: return _dev->set_time_next_pps(time_spec); } + uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan){ + return _dev->get_tx_dboard_iface(chan); + } + uhd::usrp::single_usrp::sptr get_device(void){ return _dev; } diff --git a/gr-uhd/lib/uhd_single_usrp_sink.h b/gr-uhd/lib/uhd_single_usrp_sink.h index 4929d0f13..23342570d 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.h +++ b/gr-uhd/lib/uhd_single_usrp_sink.h @@ -164,6 +164,12 @@ public: */ virtual void set_time_next_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; + /*! * Get access to the underlying uhd device object. * \return the single usrp device object diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index 5a26d44b1..4495ea048 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -117,6 +117,10 @@ public: return _dev->set_time_next_pps(time_spec); } + uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan){ + return _dev->get_rx_dboard_iface(chan); + } + uhd::usrp::single_usrp::sptr get_device(void){ return _dev; } diff --git a/gr-uhd/lib/uhd_single_usrp_source.h b/gr-uhd/lib/uhd_single_usrp_source.h index 262f6696c..425108828 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.h +++ b/gr-uhd/lib/uhd_single_usrp_source.h @@ -164,6 +164,12 @@ public: */ virtual void set_time_next_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; + /*! * Get access to the underlying uhd device object. * \return the single usrp device object diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 3c317beb4..e90f850bd 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -93,6 +93,15 @@ %include %template(device_addr_vector_t) std::vector; +//////////////////////////////////////////////////////////////////////// +// swig dboard_iface for python access +//////////////////////////////////////////////////////////////////////// +%include stdint.i +%include +%include + +%template(dboard_iface_sptr) boost::shared_ptr; + //////////////////////////////////////////////////////////////////////// // block magic //////////////////////////////////////////////////////////////////////// -- cgit From 222465e2bc9ffc7f378c698876f44b3f722e0d37 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 26 Jan 2011 13:32:56 -0800 Subject: uhd: channel = 0 defaults for single interfaces get_dboard_iface --- gr-uhd/lib/uhd_single_usrp_sink.h | 2 +- gr-uhd/lib/uhd_single_usrp_source.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_single_usrp_sink.h b/gr-uhd/lib/uhd_single_usrp_sink.h index 23342570d..f8b8479aa 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.h +++ b/gr-uhd/lib/uhd_single_usrp_sink.h @@ -168,7 +168,7 @@ public: * 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; + virtual uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 0; /*! * Get access to the underlying uhd device object. diff --git a/gr-uhd/lib/uhd_single_usrp_source.h b/gr-uhd/lib/uhd_single_usrp_source.h index 425108828..2808e8563 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.h +++ b/gr-uhd/lib/uhd_single_usrp_source.h @@ -168,7 +168,7 @@ public: * 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; + virtual uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 0; /*! * Get access to the underlying uhd device object. -- cgit From 7787d1fc1aecc7b59e476c31865b4f32348cb729 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 10 Feb 2011 00:56:55 -0800 Subject: uhd: replaced multi/single usrp stuff with just one usrp wrapper --- gr-uhd/Makefile.am | 6 +- gr-uhd/apps/.gitignore | 2 - gr-uhd/apps/Makefile.am | 22 - gr-uhd/grc/Makefile.am | 26 +- gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py | 288 ------ gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py | 265 ------ gr-uhd/grc/gen_uhd_usrp_blocks.py | 307 +++++++ gr-uhd/grc/uhd_block_tree.xml | 6 +- gr-uhd/grc/uhd_usrp_sink.xml | 1255 ++++++++++++++++++++++++++ gr-uhd/grc/uhd_usrp_source.xml | 1255 ++++++++++++++++++++++++++ gr-uhd/include/.gitignore | 2 + gr-uhd/include/Makefile.am | 27 + gr-uhd/include/gr_uhd_api.h | 33 + gr-uhd/include/gr_uhd_usrp_sink.h | 196 ++++ gr-uhd/include/gr_uhd_usrp_source.h | 196 ++++ gr-uhd/lib/Makefile.am | 13 +- gr-uhd/lib/gr_uhd_api.h | 33 - gr-uhd/lib/gr_uhd_usrp_sink.cc | 207 +++++ gr-uhd/lib/gr_uhd_usrp_source.cc | 199 ++++ gr-uhd/lib/uhd_multi_usrp_sink.cc | 199 ---- gr-uhd/lib/uhd_multi_usrp_sink.h | 182 ---- gr-uhd/lib/uhd_multi_usrp_source.cc | 191 ---- gr-uhd/lib/uhd_multi_usrp_source.h | 182 ---- gr-uhd/lib/uhd_single_usrp_sink.cc | 186 ---- gr-uhd/lib/uhd_single_usrp_sink.h | 180 ---- gr-uhd/lib/uhd_single_usrp_source.cc | 253 ------ gr-uhd/lib/uhd_single_usrp_source.h | 180 ---- gr-uhd/swig/Makefile.am | 6 +- gr-uhd/swig/__init__.py | 13 +- gr-uhd/swig/uhd_swig.i | 20 +- 30 files changed, 3708 insertions(+), 2222 deletions(-) delete mode 100644 gr-uhd/apps/.gitignore delete mode 100644 gr-uhd/apps/Makefile.am delete mode 100755 gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py delete mode 100755 gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py create mode 100644 gr-uhd/grc/gen_uhd_usrp_blocks.py create mode 100644 gr-uhd/grc/uhd_usrp_sink.xml create mode 100644 gr-uhd/grc/uhd_usrp_source.xml create mode 100644 gr-uhd/include/.gitignore create mode 100644 gr-uhd/include/Makefile.am create mode 100644 gr-uhd/include/gr_uhd_api.h create mode 100644 gr-uhd/include/gr_uhd_usrp_sink.h create mode 100644 gr-uhd/include/gr_uhd_usrp_source.h delete mode 100644 gr-uhd/lib/gr_uhd_api.h create mode 100644 gr-uhd/lib/gr_uhd_usrp_sink.cc create mode 100644 gr-uhd/lib/gr_uhd_usrp_source.cc delete mode 100644 gr-uhd/lib/uhd_multi_usrp_sink.cc delete mode 100644 gr-uhd/lib/uhd_multi_usrp_sink.h delete mode 100644 gr-uhd/lib/uhd_multi_usrp_source.cc delete mode 100644 gr-uhd/lib/uhd_multi_usrp_source.h delete mode 100644 gr-uhd/lib/uhd_single_usrp_sink.cc delete mode 100644 gr-uhd/lib/uhd_single_usrp_sink.h delete mode 100644 gr-uhd/lib/uhd_single_usrp_source.cc delete mode 100644 gr-uhd/lib/uhd_single_usrp_source.h (limited to 'gr-uhd') 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/apps/.gitignore b/gr-uhd/apps/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/gr-uhd/apps/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/gr-uhd/apps/Makefile.am b/gr-uhd/apps/Makefile.am deleted file mode 100644 index b78d07ee8..000000000 --- a/gr-uhd/apps/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -# -# 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/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_multi_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py deleted file mode 100755 index fc44501de..000000000 --- a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py +++ /dev/null @@ -1,288 +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 = """\ - - - UHD: Multi USRP $sourk.title() - uhd_multi_usrp_$(sourk) - from gnuradio import uhd - uhd.multi_usrp_$(sourk)( - device_addr=\$dev_addr, - io_type=uhd.io_type.\$type.type, - num_channels=\$nchan, -) -\#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 -#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 - - set_samp_rate(\$samp_rate) - #for $n in range($max_nchan) - set_center_freq(\$center_freq$(n), $n) - set_gain(\$gain$(n), $n) - set_antenna(\$ant$(n), $n) - set_bandwidth(\$bw$(n), $n) - #end for - - Input Type - type - enum - - - - - Device Addr - dev_addr - addr0=192.168.10.2, addr1=192.168.10.3 - string - - \#if \$dev_addr() - none - \#else - part - \#end if - - - - Sync - sync - sync - enum - \#if \$sync() then 'none' else 'part'# - - - - - Num Mboards - num_mboards - 2 - int - #for $m in range(1, $max_mboards+1) - - #end for - - #for $m in range($max_mboards) - - Mb$(m): Subdev Spec - sd_spec$(m) - - string - - \#if not \$num_mboards() > $m - all - \#elif \$sd_spec$(m)() - none - \#else - part - \#end if - - - #end for - - Num Channels - nchan - 2 - int - #for $n in range(1, $max_nchan+1) - - #end for - - - Samp Rate (Sps) - samp_rate - samp_rate - real - - $params - $max_nchan >= \$nchan - \$nchan > 0 - $max_mboards >= \$num_mboards - \$num_mboards > 0 - \$nchan >= \$num_mboards - <$sourk> - $direction - \$type - \$type.vlen - \$nchan - - -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 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. - - -""" - -PARAMS_TMPL = """ - - Ch$(n): Center Freq (Hz) - center_freq$(n) - 0 - real - \#if \$nchan() > $n then 'none' else 'all'# - - - Ch$(n): Gain (dB) - gain$(n) - 0 - real - \#if \$nchan() > $n then 'none' else 'all'# - - - Ch$(n): Antenna - ant$(n) - - string - - \#if not \$nchan() > $n - all - \#elif \$ant$(n)() - none - \#else - part - \#end if - - - - Ch$(n): Bandwidth (Hz) - bw$(n) - 0 - real - - \#if not \$nchan() > $n - all - \#elif \$bw$(n)() - none - \#else - part - \#end if - - -""" - -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 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 = """\ - - - UHD: Single USRP $sourk.title() - uhd_single_usrp_$(sourk) - from gnuradio import uhd - 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 - - set_samp_rate(\$samp_rate) - #for $n in range($max_nchan) - set_center_freq(\$center_freq$(n), $n) - set_gain(\$gain$(n), $n) - set_antenna(\$ant$(n), $n) - set_bandwidth(\$bw$(n), $n) - #end for - - Input Type - type - enum - - - - - Num Channels - nchan - 1 - int - part - - - - - - Device Addr - dev_addr - addr=192.168.10.2 - string - - \#if \$dev_addr() - none - \#else - part - \#end if - - - - Ref Clock - ref_clk - - enum - \#if \$ref_clk() then 'none' else 'part'# - - - - - Subdev Spec - sd_spec - - string - - \#if \$sd_spec() - none - \#else - part - \#end if - - - - Samp Rate (Sps) - samp_rate - samp_rate - real - - $params - $max_nchan >= \$nchan - \$nchan > 0 - (len((\$sd_spec).split()) or 1) == \$nchan - <$sourk> - $direction - \$type - \$type.vlen - \$nchan - - -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. - - -""" - -PARAMS_TMPL = """ - - Ch$(n): Center Freq (Hz) - center_freq$(n) - 0 - real - \#if \$nchan() > $n then 'none' else 'all'# - - - Ch$(n): Gain (dB) - gain$(n) - 0 - real - \#if \$nchan() > $n then 'none' else 'all'# - - - Ch$(n): Antenna - ant$(n) - - string - - \#if not \$nchan() > $n - all - \#elif \$ant$(n)() - none - \#else - part - \#end if - - - - Ch$(n): Bandwidth (Hz) - bw$(n) - 0 - real - - \#if not \$nchan() > $n - all - \#elif \$bw$(n)() - none - \#else - part - \#end if - - -""" - -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_usrp_blocks.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py new file mode 100644 index 000000000..ec4633427 --- /dev/null +++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py @@ -0,0 +1,307 @@ +""" +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 = """\ + + + UHD: USRP $sourk.title() + uhd_usrp_$(sourk) + from gnuradio import uhd + 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_time_unknown_pps(uhd.time_spec()) +\#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 + + set_samp_rate(\$samp_rate) + #for $n in range($max_nchan) + set_center_freq(\$center_freq$(n), $n) + set_gain(\$gain$(n), $n) + set_antenna(\$ant$(n), $n) + set_bandwidth(\$bw$(n), $n) + #end for + + Input Type + type + enum + + + + + Device Addr + dev_addr + + string + + \#if \$dev_addr() + none + \#else + part + \#end if + + + + Ref Clock + ref_clk + + enum + \#if \$ref_clk() then 'none' else 'part'# + + + + + Sync + sync + sync + enum + \#if \$sync() then 'none' else 'part'# + + + + + Num Mboards + num_mboards + 1 + int + #for $m in range(1, $max_mboards+1) + + #end for + + #for $m in range($max_mboards) + + Mb$(m): Subdev Spec + sd_spec$(m) + + string + + \#if not \$num_mboards() > $m + all + \#elif \$sd_spec$(m)() + none + \#else + part + \#end if + + + #end for + + Num Channels + nchan + 2 + int + #for $n in range(1, $max_nchan+1) + + #end for + + + Samp Rate (Sps) + samp_rate + samp_rate + real + + $params + $max_nchan >= \$nchan + \$nchan > 0 + $max_mboards >= \$num_mboards + \$num_mboards > 0 + \$nchan >= \$num_mboards + <$sourk> + $direction + \$type + \$type.vlen + \$nchan + + +The UHD 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 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 device 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 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. + + +""" + +PARAMS_TMPL = """ + + Ch$(n): Center Freq (Hz) + center_freq$(n) + 0 + real + \#if \$nchan() > $n then 'none' else 'all'# + + + Ch$(n): Gain (dB) + gain$(n) + 0 + real + \#if \$nchan() > $n then 'none' else 'all'# + + + Ch$(n): Antenna + ant$(n) + + string + + \#if not \$nchan() > $n + all + \#elif \$ant$(n)() + none + \#else + part + \#end if + + + + Ch$(n): Bandwidth (Hz) + bw$(n) + 0 + real + + \#if not \$nchan() > $n + all + \#elif \$bw$(n)() + none + \#else + part + \#end if + + +""" + +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/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 @@ UHD - uhd_single_usrp_source - uhd_single_usrp_sink - uhd_multi_usrp_source - uhd_multi_usrp_sink + uhd_usrp_source + uhd_usrp_sink diff --git a/gr-uhd/grc/uhd_usrp_sink.xml b/gr-uhd/grc/uhd_usrp_sink.xml new file mode 100644 index 000000000..219504ecd --- /dev/null +++ b/gr-uhd/grc/uhd_usrp_sink.xml @@ -0,0 +1,1255 @@ + + + UHD: USRP Sink + uhd_usrp_sink + from gnuradio import uhd + uhd.multi_usrp_sink( + 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_time_unknown_pps(uhd.time_spec()) +#end if +#if $num_mboards() > 0 and $sd_spec0() +self.$(id).set_subdev_spec($sd_spec0, 0) +#end if +#if $num_mboards() > 1 and $sd_spec1() +self.$(id).set_subdev_spec($sd_spec1, 1) +#end if +#if $num_mboards() > 2 and $sd_spec2() +self.$(id).set_subdev_spec($sd_spec2, 2) +#end if +#if $num_mboards() > 3 and $sd_spec3() +self.$(id).set_subdev_spec($sd_spec3, 3) +#end if +self.$(id).set_samp_rate($samp_rate) +#if $nchan() > 0 +self.$(id).set_center_freq($center_freq0, 0) +self.$(id).set_gain($gain0, 0) + #if $ant0() +self.$(id).set_antenna($ant0, 0) + #end if + #if $bw0() +self.$(id).set_bandwidth($bw0, 0) + #end if +#end if +#if $nchan() > 1 +self.$(id).set_center_freq($center_freq1, 1) +self.$(id).set_gain($gain1, 1) + #if $ant1() +self.$(id).set_antenna($ant1, 1) + #end if + #if $bw1() +self.$(id).set_bandwidth($bw1, 1) + #end if +#end if +#if $nchan() > 2 +self.$(id).set_center_freq($center_freq2, 2) +self.$(id).set_gain($gain2, 2) + #if $ant2() +self.$(id).set_antenna($ant2, 2) + #end if + #if $bw2() +self.$(id).set_bandwidth($bw2, 2) + #end if +#end if +#if $nchan() > 3 +self.$(id).set_center_freq($center_freq3, 3) +self.$(id).set_gain($gain3, 3) + #if $ant3() +self.$(id).set_antenna($ant3, 3) + #end if + #if $bw3() +self.$(id).set_bandwidth($bw3, 3) + #end if +#end if +#if $nchan() > 4 +self.$(id).set_center_freq($center_freq4, 4) +self.$(id).set_gain($gain4, 4) + #if $ant4() +self.$(id).set_antenna($ant4, 4) + #end if + #if $bw4() +self.$(id).set_bandwidth($bw4, 4) + #end if +#end if +#if $nchan() > 5 +self.$(id).set_center_freq($center_freq5, 5) +self.$(id).set_gain($gain5, 5) + #if $ant5() +self.$(id).set_antenna($ant5, 5) + #end if + #if $bw5() +self.$(id).set_bandwidth($bw5, 5) + #end if +#end if +#if $nchan() > 6 +self.$(id).set_center_freq($center_freq6, 6) +self.$(id).set_gain($gain6, 6) + #if $ant6() +self.$(id).set_antenna($ant6, 6) + #end if + #if $bw6() +self.$(id).set_bandwidth($bw6, 6) + #end if +#end if +#if $nchan() > 7 +self.$(id).set_center_freq($center_freq7, 7) +self.$(id).set_gain($gain7, 7) + #if $ant7() +self.$(id).set_antenna($ant7, 7) + #end if + #if $bw7() +self.$(id).set_bandwidth($bw7, 7) + #end if +#end if +#if $nchan() > 8 +self.$(id).set_center_freq($center_freq8, 8) +self.$(id).set_gain($gain8, 8) + #if $ant8() +self.$(id).set_antenna($ant8, 8) + #end if + #if $bw8() +self.$(id).set_bandwidth($bw8, 8) + #end if +#end if +#if $nchan() > 9 +self.$(id).set_center_freq($center_freq9, 9) +self.$(id).set_gain($gain9, 9) + #if $ant9() +self.$(id).set_antenna($ant9, 9) + #end if + #if $bw9() +self.$(id).set_bandwidth($bw9, 9) + #end if +#end if +#if $nchan() > 10 +self.$(id).set_center_freq($center_freq10, 10) +self.$(id).set_gain($gain10, 10) + #if $ant10() +self.$(id).set_antenna($ant10, 10) + #end if + #if $bw10() +self.$(id).set_bandwidth($bw10, 10) + #end if +#end if +#if $nchan() > 11 +self.$(id).set_center_freq($center_freq11, 11) +self.$(id).set_gain($gain11, 11) + #if $ant11() +self.$(id).set_antenna($ant11, 11) + #end if + #if $bw11() +self.$(id).set_bandwidth($bw11, 11) + #end if +#end if +#if $nchan() > 12 +self.$(id).set_center_freq($center_freq12, 12) +self.$(id).set_gain($gain12, 12) + #if $ant12() +self.$(id).set_antenna($ant12, 12) + #end if + #if $bw12() +self.$(id).set_bandwidth($bw12, 12) + #end if +#end if +#if $nchan() > 13 +self.$(id).set_center_freq($center_freq13, 13) +self.$(id).set_gain($gain13, 13) + #if $ant13() +self.$(id).set_antenna($ant13, 13) + #end if + #if $bw13() +self.$(id).set_bandwidth($bw13, 13) + #end if +#end if +#if $nchan() > 14 +self.$(id).set_center_freq($center_freq14, 14) +self.$(id).set_gain($gain14, 14) + #if $ant14() +self.$(id).set_antenna($ant14, 14) + #end if + #if $bw14() +self.$(id).set_bandwidth($bw14, 14) + #end if +#end if +#if $nchan() > 15 +self.$(id).set_center_freq($center_freq15, 15) +self.$(id).set_gain($gain15, 15) + #if $ant15() +self.$(id).set_antenna($ant15, 15) + #end if + #if $bw15() +self.$(id).set_bandwidth($bw15, 15) + #end if +#end if + + set_samp_rate($samp_rate) + set_center_freq($center_freq0, 0) + set_gain($gain0, 0) + set_antenna($ant0, 0) + set_bandwidth($bw0, 0) + set_center_freq($center_freq1, 1) + set_gain($gain1, 1) + set_antenna($ant1, 1) + set_bandwidth($bw1, 1) + set_center_freq($center_freq2, 2) + set_gain($gain2, 2) + set_antenna($ant2, 2) + set_bandwidth($bw2, 2) + set_center_freq($center_freq3, 3) + set_gain($gain3, 3) + set_antenna($ant3, 3) + set_bandwidth($bw3, 3) + set_center_freq($center_freq4, 4) + set_gain($gain4, 4) + set_antenna($ant4, 4) + set_bandwidth($bw4, 4) + set_center_freq($center_freq5, 5) + set_gain($gain5, 5) + set_antenna($ant5, 5) + set_bandwidth($bw5, 5) + set_center_freq($center_freq6, 6) + set_gain($gain6, 6) + set_antenna($ant6, 6) + set_bandwidth($bw6, 6) + set_center_freq($center_freq7, 7) + set_gain($gain7, 7) + set_antenna($ant7, 7) + set_bandwidth($bw7, 7) + set_center_freq($center_freq8, 8) + set_gain($gain8, 8) + set_antenna($ant8, 8) + set_bandwidth($bw8, 8) + set_center_freq($center_freq9, 9) + set_gain($gain9, 9) + set_antenna($ant9, 9) + set_bandwidth($bw9, 9) + set_center_freq($center_freq10, 10) + set_gain($gain10, 10) + set_antenna($ant10, 10) + set_bandwidth($bw10, 10) + set_center_freq($center_freq11, 11) + set_gain($gain11, 11) + set_antenna($ant11, 11) + set_bandwidth($bw11, 11) + set_center_freq($center_freq12, 12) + set_gain($gain12, 12) + set_antenna($ant12, 12) + set_bandwidth($bw12, 12) + set_center_freq($center_freq13, 13) + set_gain($gain13, 13) + set_antenna($ant13, 13) + set_bandwidth($bw13, 13) + set_center_freq($center_freq14, 14) + set_gain($gain14, 14) + set_antenna($ant14, 14) + set_bandwidth($bw14, 14) + set_center_freq($center_freq15, 15) + set_gain($gain15, 15) + set_antenna($ant15, 15) + set_bandwidth($bw15, 15) + + Input Type + type + enum + + + + + Device Addr + dev_addr + + string + + #if $dev_addr() + none + #else + part + #end if + + + + Ref Clock + ref_clk + + enum + #if $ref_clk() then 'none' else 'part'# + + + + + Sync + sync + sync + enum + #if $sync() then 'none' else 'part'# + + + + + Num Mboards + num_mboards + 1 + int + + + + + + + Mb0: Subdev Spec + sd_spec0 + + string + + #if not $num_mboards() > 0 + all + #elif $sd_spec0() + none + #else + part + #end if + + + + Mb1: Subdev Spec + sd_spec1 + + string + + #if not $num_mboards() > 1 + all + #elif $sd_spec1() + none + #else + part + #end if + + + + Mb2: Subdev Spec + sd_spec2 + + string + + #if not $num_mboards() > 2 + all + #elif $sd_spec2() + none + #else + part + #end if + + + + Mb3: Subdev Spec + sd_spec3 + + string + + #if not $num_mboards() > 3 + all + #elif $sd_spec3() + none + #else + part + #end if + + + + Num Channels + nchan + 2 + int + + + + + + + + + + + + + + + + + + + Samp Rate (Sps) + samp_rate + samp_rate + real + + + + Ch0: Center Freq (Hz) + center_freq0 + 0 + real + #if $nchan() > 0 then 'none' else 'all'# + + + Ch0: Gain (dB) + gain0 + 0 + real + #if $nchan() > 0 then 'none' else 'all'# + + + Ch0: Antenna + ant0 + + string + + #if not $nchan() > 0 + all + #elif $ant0() + none + #else + part + #end if + + + + Ch0: Bandwidth (Hz) + bw0 + 0 + real + + #if not $nchan() > 0 + all + #elif $bw0() + none + #else + part + #end if + + + + + Ch1: Center Freq (Hz) + center_freq1 + 0 + real + #if $nchan() > 1 then 'none' else 'all'# + + + Ch1: Gain (dB) + gain1 + 0 + real + #if $nchan() > 1 then 'none' else 'all'# + + + Ch1: Antenna + ant1 + + string + + #if not $nchan() > 1 + all + #elif $ant1() + none + #else + part + #end if + + + + Ch1: Bandwidth (Hz) + bw1 + 0 + real + + #if not $nchan() > 1 + all + #elif $bw1() + none + #else + part + #end if + + + + + Ch2: Center Freq (Hz) + center_freq2 + 0 + real + #if $nchan() > 2 then 'none' else 'all'# + + + Ch2: Gain (dB) + gain2 + 0 + real + #if $nchan() > 2 then 'none' else 'all'# + + + Ch2: Antenna + ant2 + + string + + #if not $nchan() > 2 + all + #elif $ant2() + none + #else + part + #end if + + + + Ch2: Bandwidth (Hz) + bw2 + 0 + real + + #if not $nchan() > 2 + all + #elif $bw2() + none + #else + part + #end if + + + + + Ch3: Center Freq (Hz) + center_freq3 + 0 + real + #if $nchan() > 3 then 'none' else 'all'# + + + Ch3: Gain (dB) + gain3 + 0 + real + #if $nchan() > 3 then 'none' else 'all'# + + + Ch3: Antenna + ant3 + + string + + #if not $nchan() > 3 + all + #elif $ant3() + none + #else + part + #end if + + + + Ch3: Bandwidth (Hz) + bw3 + 0 + real + + #if not $nchan() > 3 + all + #elif $bw3() + none + #else + part + #end if + + + + + Ch4: Center Freq (Hz) + center_freq4 + 0 + real + #if $nchan() > 4 then 'none' else 'all'# + + + Ch4: Gain (dB) + gain4 + 0 + real + #if $nchan() > 4 then 'none' else 'all'# + + + Ch4: Antenna + ant4 + + string + + #if not $nchan() > 4 + all + #elif $ant4() + none + #else + part + #end if + + + + Ch4: Bandwidth (Hz) + bw4 + 0 + real + + #if not $nchan() > 4 + all + #elif $bw4() + none + #else + part + #end if + + + + + Ch5: Center Freq (Hz) + center_freq5 + 0 + real + #if $nchan() > 5 then 'none' else 'all'# + + + Ch5: Gain (dB) + gain5 + 0 + real + #if $nchan() > 5 then 'none' else 'all'# + + + Ch5: Antenna + ant5 + + string + + #if not $nchan() > 5 + all + #elif $ant5() + none + #else + part + #end if + + + + Ch5: Bandwidth (Hz) + bw5 + 0 + real + + #if not $nchan() > 5 + all + #elif $bw5() + none + #else + part + #end if + + + + + Ch6: Center Freq (Hz) + center_freq6 + 0 + real + #if $nchan() > 6 then 'none' else 'all'# + + + Ch6: Gain (dB) + gain6 + 0 + real + #if $nchan() > 6 then 'none' else 'all'# + + + Ch6: Antenna + ant6 + + string + + #if not $nchan() > 6 + all + #elif $ant6() + none + #else + part + #end if + + + + Ch6: Bandwidth (Hz) + bw6 + 0 + real + + #if not $nchan() > 6 + all + #elif $bw6() + none + #else + part + #end if + + + + + Ch7: Center Freq (Hz) + center_freq7 + 0 + real + #if $nchan() > 7 then 'none' else 'all'# + + + Ch7: Gain (dB) + gain7 + 0 + real + #if $nchan() > 7 then 'none' else 'all'# + + + Ch7: Antenna + ant7 + + string + + #if not $nchan() > 7 + all + #elif $ant7() + none + #else + part + #end if + + + + Ch7: Bandwidth (Hz) + bw7 + 0 + real + + #if not $nchan() > 7 + all + #elif $bw7() + none + #else + part + #end if + + + + + Ch8: Center Freq (Hz) + center_freq8 + 0 + real + #if $nchan() > 8 then 'none' else 'all'# + + + Ch8: Gain (dB) + gain8 + 0 + real + #if $nchan() > 8 then 'none' else 'all'# + + + Ch8: Antenna + ant8 + + string + + #if not $nchan() > 8 + all + #elif $ant8() + none + #else + part + #end if + + + + Ch8: Bandwidth (Hz) + bw8 + 0 + real + + #if not $nchan() > 8 + all + #elif $bw8() + none + #else + part + #end if + + + + + Ch9: Center Freq (Hz) + center_freq9 + 0 + real + #if $nchan() > 9 then 'none' else 'all'# + + + Ch9: Gain (dB) + gain9 + 0 + real + #if $nchan() > 9 then 'none' else 'all'# + + + Ch9: Antenna + ant9 + + string + + #if not $nchan() > 9 + all + #elif $ant9() + none + #else + part + #end if + + + + Ch9: Bandwidth (Hz) + bw9 + 0 + real + + #if not $nchan() > 9 + all + #elif $bw9() + none + #else + part + #end if + + + + + Ch10: Center Freq (Hz) + center_freq10 + 0 + real + #if $nchan() > 10 then 'none' else 'all'# + + + Ch10: Gain (dB) + gain10 + 0 + real + #if $nchan() > 10 then 'none' else 'all'# + + + Ch10: Antenna + ant10 + + string + + #if not $nchan() > 10 + all + #elif $ant10() + none + #else + part + #end if + + + + Ch10: Bandwidth (Hz) + bw10 + 0 + real + + #if not $nchan() > 10 + all + #elif $bw10() + none + #else + part + #end if + + + + + Ch11: Center Freq (Hz) + center_freq11 + 0 + real + #if $nchan() > 11 then 'none' else 'all'# + + + Ch11: Gain (dB) + gain11 + 0 + real + #if $nchan() > 11 then 'none' else 'all'# + + + Ch11: Antenna + ant11 + + string + + #if not $nchan() > 11 + all + #elif $ant11() + none + #else + part + #end if + + + + Ch11: Bandwidth (Hz) + bw11 + 0 + real + + #if not $nchan() > 11 + all + #elif $bw11() + none + #else + part + #end if + + + + + Ch12: Center Freq (Hz) + center_freq12 + 0 + real + #if $nchan() > 12 then 'none' else 'all'# + + + Ch12: Gain (dB) + gain12 + 0 + real + #if $nchan() > 12 then 'none' else 'all'# + + + Ch12: Antenna + ant12 + + string + + #if not $nchan() > 12 + all + #elif $ant12() + none + #else + part + #end if + + + + Ch12: Bandwidth (Hz) + bw12 + 0 + real + + #if not $nchan() > 12 + all + #elif $bw12() + none + #else + part + #end if + + + + + Ch13: Center Freq (Hz) + center_freq13 + 0 + real + #if $nchan() > 13 then 'none' else 'all'# + + + Ch13: Gain (dB) + gain13 + 0 + real + #if $nchan() > 13 then 'none' else 'all'# + + + Ch13: Antenna + ant13 + + string + + #if not $nchan() > 13 + all + #elif $ant13() + none + #else + part + #end if + + + + Ch13: Bandwidth (Hz) + bw13 + 0 + real + + #if not $nchan() > 13 + all + #elif $bw13() + none + #else + part + #end if + + + + + Ch14: Center Freq (Hz) + center_freq14 + 0 + real + #if $nchan() > 14 then 'none' else 'all'# + + + Ch14: Gain (dB) + gain14 + 0 + real + #if $nchan() > 14 then 'none' else 'all'# + + + Ch14: Antenna + ant14 + + string + + #if not $nchan() > 14 + all + #elif $ant14() + none + #else + part + #end if + + + + Ch14: Bandwidth (Hz) + bw14 + 0 + real + + #if not $nchan() > 14 + all + #elif $bw14() + none + #else + part + #end if + + + + + Ch15: Center Freq (Hz) + center_freq15 + 0 + real + #if $nchan() > 15 then 'none' else 'all'# + + + Ch15: Gain (dB) + gain15 + 0 + real + #if $nchan() > 15 then 'none' else 'all'# + + + Ch15: Antenna + ant15 + + string + + #if not $nchan() > 15 + all + #elif $ant15() + none + #else + part + #end if + + + + Ch15: Bandwidth (Hz) + bw15 + 0 + real + + #if not $nchan() > 15 + all + #elif $bw15() + none + #else + part + #end if + + + + 16 >= $nchan + $nchan > 0 + 4 >= $num_mboards + $num_mboards > 0 + $nchan >= $num_mboards + + in + $type + $type.vlen + $nchan + + +The UHD USRP Sink 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 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 device 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 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. + + diff --git a/gr-uhd/grc/uhd_usrp_source.xml b/gr-uhd/grc/uhd_usrp_source.xml new file mode 100644 index 000000000..d90bda993 --- /dev/null +++ b/gr-uhd/grc/uhd_usrp_source.xml @@ -0,0 +1,1255 @@ + + + UHD: USRP Source + uhd_usrp_source + from gnuradio import uhd + uhd.multi_usrp_source( + 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_time_unknown_pps(uhd.time_spec()) +#end if +#if $num_mboards() > 0 and $sd_spec0() +self.$(id).set_subdev_spec($sd_spec0, 0) +#end if +#if $num_mboards() > 1 and $sd_spec1() +self.$(id).set_subdev_spec($sd_spec1, 1) +#end if +#if $num_mboards() > 2 and $sd_spec2() +self.$(id).set_subdev_spec($sd_spec2, 2) +#end if +#if $num_mboards() > 3 and $sd_spec3() +self.$(id).set_subdev_spec($sd_spec3, 3) +#end if +self.$(id).set_samp_rate($samp_rate) +#if $nchan() > 0 +self.$(id).set_center_freq($center_freq0, 0) +self.$(id).set_gain($gain0, 0) + #if $ant0() +self.$(id).set_antenna($ant0, 0) + #end if + #if $bw0() +self.$(id).set_bandwidth($bw0, 0) + #end if +#end if +#if $nchan() > 1 +self.$(id).set_center_freq($center_freq1, 1) +self.$(id).set_gain($gain1, 1) + #if $ant1() +self.$(id).set_antenna($ant1, 1) + #end if + #if $bw1() +self.$(id).set_bandwidth($bw1, 1) + #end if +#end if +#if $nchan() > 2 +self.$(id).set_center_freq($center_freq2, 2) +self.$(id).set_gain($gain2, 2) + #if $ant2() +self.$(id).set_antenna($ant2, 2) + #end if + #if $bw2() +self.$(id).set_bandwidth($bw2, 2) + #end if +#end if +#if $nchan() > 3 +self.$(id).set_center_freq($center_freq3, 3) +self.$(id).set_gain($gain3, 3) + #if $ant3() +self.$(id).set_antenna($ant3, 3) + #end if + #if $bw3() +self.$(id).set_bandwidth($bw3, 3) + #end if +#end if +#if $nchan() > 4 +self.$(id).set_center_freq($center_freq4, 4) +self.$(id).set_gain($gain4, 4) + #if $ant4() +self.$(id).set_antenna($ant4, 4) + #end if + #if $bw4() +self.$(id).set_bandwidth($bw4, 4) + #end if +#end if +#if $nchan() > 5 +self.$(id).set_center_freq($center_freq5, 5) +self.$(id).set_gain($gain5, 5) + #if $ant5() +self.$(id).set_antenna($ant5, 5) + #end if + #if $bw5() +self.$(id).set_bandwidth($bw5, 5) + #end if +#end if +#if $nchan() > 6 +self.$(id).set_center_freq($center_freq6, 6) +self.$(id).set_gain($gain6, 6) + #if $ant6() +self.$(id).set_antenna($ant6, 6) + #end if + #if $bw6() +self.$(id).set_bandwidth($bw6, 6) + #end if +#end if +#if $nchan() > 7 +self.$(id).set_center_freq($center_freq7, 7) +self.$(id).set_gain($gain7, 7) + #if $ant7() +self.$(id).set_antenna($ant7, 7) + #end if + #if $bw7() +self.$(id).set_bandwidth($bw7, 7) + #end if +#end if +#if $nchan() > 8 +self.$(id).set_center_freq($center_freq8, 8) +self.$(id).set_gain($gain8, 8) + #if $ant8() +self.$(id).set_antenna($ant8, 8) + #end if + #if $bw8() +self.$(id).set_bandwidth($bw8, 8) + #end if +#end if +#if $nchan() > 9 +self.$(id).set_center_freq($center_freq9, 9) +self.$(id).set_gain($gain9, 9) + #if $ant9() +self.$(id).set_antenna($ant9, 9) + #end if + #if $bw9() +self.$(id).set_bandwidth($bw9, 9) + #end if +#end if +#if $nchan() > 10 +self.$(id).set_center_freq($center_freq10, 10) +self.$(id).set_gain($gain10, 10) + #if $ant10() +self.$(id).set_antenna($ant10, 10) + #end if + #if $bw10() +self.$(id).set_bandwidth($bw10, 10) + #end if +#end if +#if $nchan() > 11 +self.$(id).set_center_freq($center_freq11, 11) +self.$(id).set_gain($gain11, 11) + #if $ant11() +self.$(id).set_antenna($ant11, 11) + #end if + #if $bw11() +self.$(id).set_bandwidth($bw11, 11) + #end if +#end if +#if $nchan() > 12 +self.$(id).set_center_freq($center_freq12, 12) +self.$(id).set_gain($gain12, 12) + #if $ant12() +self.$(id).set_antenna($ant12, 12) + #end if + #if $bw12() +self.$(id).set_bandwidth($bw12, 12) + #end if +#end if +#if $nchan() > 13 +self.$(id).set_center_freq($center_freq13, 13) +self.$(id).set_gain($gain13, 13) + #if $ant13() +self.$(id).set_antenna($ant13, 13) + #end if + #if $bw13() +self.$(id).set_bandwidth($bw13, 13) + #end if +#end if +#if $nchan() > 14 +self.$(id).set_center_freq($center_freq14, 14) +self.$(id).set_gain($gain14, 14) + #if $ant14() +self.$(id).set_antenna($ant14, 14) + #end if + #if $bw14() +self.$(id).set_bandwidth($bw14, 14) + #end if +#end if +#if $nchan() > 15 +self.$(id).set_center_freq($center_freq15, 15) +self.$(id).set_gain($gain15, 15) + #if $ant15() +self.$(id).set_antenna($ant15, 15) + #end if + #if $bw15() +self.$(id).set_bandwidth($bw15, 15) + #end if +#end if + + set_samp_rate($samp_rate) + set_center_freq($center_freq0, 0) + set_gain($gain0, 0) + set_antenna($ant0, 0) + set_bandwidth($bw0, 0) + set_center_freq($center_freq1, 1) + set_gain($gain1, 1) + set_antenna($ant1, 1) + set_bandwidth($bw1, 1) + set_center_freq($center_freq2, 2) + set_gain($gain2, 2) + set_antenna($ant2, 2) + set_bandwidth($bw2, 2) + set_center_freq($center_freq3, 3) + set_gain($gain3, 3) + set_antenna($ant3, 3) + set_bandwidth($bw3, 3) + set_center_freq($center_freq4, 4) + set_gain($gain4, 4) + set_antenna($ant4, 4) + set_bandwidth($bw4, 4) + set_center_freq($center_freq5, 5) + set_gain($gain5, 5) + set_antenna($ant5, 5) + set_bandwidth($bw5, 5) + set_center_freq($center_freq6, 6) + set_gain($gain6, 6) + set_antenna($ant6, 6) + set_bandwidth($bw6, 6) + set_center_freq($center_freq7, 7) + set_gain($gain7, 7) + set_antenna($ant7, 7) + set_bandwidth($bw7, 7) + set_center_freq($center_freq8, 8) + set_gain($gain8, 8) + set_antenna($ant8, 8) + set_bandwidth($bw8, 8) + set_center_freq($center_freq9, 9) + set_gain($gain9, 9) + set_antenna($ant9, 9) + set_bandwidth($bw9, 9) + set_center_freq($center_freq10, 10) + set_gain($gain10, 10) + set_antenna($ant10, 10) + set_bandwidth($bw10, 10) + set_center_freq($center_freq11, 11) + set_gain($gain11, 11) + set_antenna($ant11, 11) + set_bandwidth($bw11, 11) + set_center_freq($center_freq12, 12) + set_gain($gain12, 12) + set_antenna($ant12, 12) + set_bandwidth($bw12, 12) + set_center_freq($center_freq13, 13) + set_gain($gain13, 13) + set_antenna($ant13, 13) + set_bandwidth($bw13, 13) + set_center_freq($center_freq14, 14) + set_gain($gain14, 14) + set_antenna($ant14, 14) + set_bandwidth($bw14, 14) + set_center_freq($center_freq15, 15) + set_gain($gain15, 15) + set_antenna($ant15, 15) + set_bandwidth($bw15, 15) + + Input Type + type + enum + + + + + Device Addr + dev_addr + + string + + #if $dev_addr() + none + #else + part + #end if + + + + Ref Clock + ref_clk + + enum + #if $ref_clk() then 'none' else 'part'# + + + + + Sync + sync + sync + enum + #if $sync() then 'none' else 'part'# + + + + + Num Mboards + num_mboards + 1 + int + + + + + + + Mb0: Subdev Spec + sd_spec0 + + string + + #if not $num_mboards() > 0 + all + #elif $sd_spec0() + none + #else + part + #end if + + + + Mb1: Subdev Spec + sd_spec1 + + string + + #if not $num_mboards() > 1 + all + #elif $sd_spec1() + none + #else + part + #end if + + + + Mb2: Subdev Spec + sd_spec2 + + string + + #if not $num_mboards() > 2 + all + #elif $sd_spec2() + none + #else + part + #end if + + + + Mb3: Subdev Spec + sd_spec3 + + string + + #if not $num_mboards() > 3 + all + #elif $sd_spec3() + none + #else + part + #end if + + + + Num Channels + nchan + 2 + int + + + + + + + + + + + + + + + + + + + Samp Rate (Sps) + samp_rate + samp_rate + real + + + + Ch0: Center Freq (Hz) + center_freq0 + 0 + real + #if $nchan() > 0 then 'none' else 'all'# + + + Ch0: Gain (dB) + gain0 + 0 + real + #if $nchan() > 0 then 'none' else 'all'# + + + Ch0: Antenna + ant0 + + string + + #if not $nchan() > 0 + all + #elif $ant0() + none + #else + part + #end if + + + + Ch0: Bandwidth (Hz) + bw0 + 0 + real + + #if not $nchan() > 0 + all + #elif $bw0() + none + #else + part + #end if + + + + + Ch1: Center Freq (Hz) + center_freq1 + 0 + real + #if $nchan() > 1 then 'none' else 'all'# + + + Ch1: Gain (dB) + gain1 + 0 + real + #if $nchan() > 1 then 'none' else 'all'# + + + Ch1: Antenna + ant1 + + string + + #if not $nchan() > 1 + all + #elif $ant1() + none + #else + part + #end if + + + + Ch1: Bandwidth (Hz) + bw1 + 0 + real + + #if not $nchan() > 1 + all + #elif $bw1() + none + #else + part + #end if + + + + + Ch2: Center Freq (Hz) + center_freq2 + 0 + real + #if $nchan() > 2 then 'none' else 'all'# + + + Ch2: Gain (dB) + gain2 + 0 + real + #if $nchan() > 2 then 'none' else 'all'# + + + Ch2: Antenna + ant2 + + string + + #if not $nchan() > 2 + all + #elif $ant2() + none + #else + part + #end if + + + + Ch2: Bandwidth (Hz) + bw2 + 0 + real + + #if not $nchan() > 2 + all + #elif $bw2() + none + #else + part + #end if + + + + + Ch3: Center Freq (Hz) + center_freq3 + 0 + real + #if $nchan() > 3 then 'none' else 'all'# + + + Ch3: Gain (dB) + gain3 + 0 + real + #if $nchan() > 3 then 'none' else 'all'# + + + Ch3: Antenna + ant3 + + string + + #if not $nchan() > 3 + all + #elif $ant3() + none + #else + part + #end if + + + + Ch3: Bandwidth (Hz) + bw3 + 0 + real + + #if not $nchan() > 3 + all + #elif $bw3() + none + #else + part + #end if + + + + + Ch4: Center Freq (Hz) + center_freq4 + 0 + real + #if $nchan() > 4 then 'none' else 'all'# + + + Ch4: Gain (dB) + gain4 + 0 + real + #if $nchan() > 4 then 'none' else 'all'# + + + Ch4: Antenna + ant4 + + string + + #if not $nchan() > 4 + all + #elif $ant4() + none + #else + part + #end if + + + + Ch4: Bandwidth (Hz) + bw4 + 0 + real + + #if not $nchan() > 4 + all + #elif $bw4() + none + #else + part + #end if + + + + + Ch5: Center Freq (Hz) + center_freq5 + 0 + real + #if $nchan() > 5 then 'none' else 'all'# + + + Ch5: Gain (dB) + gain5 + 0 + real + #if $nchan() > 5 then 'none' else 'all'# + + + Ch5: Antenna + ant5 + + string + + #if not $nchan() > 5 + all + #elif $ant5() + none + #else + part + #end if + + + + Ch5: Bandwidth (Hz) + bw5 + 0 + real + + #if not $nchan() > 5 + all + #elif $bw5() + none + #else + part + #end if + + + + + Ch6: Center Freq (Hz) + center_freq6 + 0 + real + #if $nchan() > 6 then 'none' else 'all'# + + + Ch6: Gain (dB) + gain6 + 0 + real + #if $nchan() > 6 then 'none' else 'all'# + + + Ch6: Antenna + ant6 + + string + + #if not $nchan() > 6 + all + #elif $ant6() + none + #else + part + #end if + + + + Ch6: Bandwidth (Hz) + bw6 + 0 + real + + #if not $nchan() > 6 + all + #elif $bw6() + none + #else + part + #end if + + + + + Ch7: Center Freq (Hz) + center_freq7 + 0 + real + #if $nchan() > 7 then 'none' else 'all'# + + + Ch7: Gain (dB) + gain7 + 0 + real + #if $nchan() > 7 then 'none' else 'all'# + + + Ch7: Antenna + ant7 + + string + + #if not $nchan() > 7 + all + #elif $ant7() + none + #else + part + #end if + + + + Ch7: Bandwidth (Hz) + bw7 + 0 + real + + #if not $nchan() > 7 + all + #elif $bw7() + none + #else + part + #end if + + + + + Ch8: Center Freq (Hz) + center_freq8 + 0 + real + #if $nchan() > 8 then 'none' else 'all'# + + + Ch8: Gain (dB) + gain8 + 0 + real + #if $nchan() > 8 then 'none' else 'all'# + + + Ch8: Antenna + ant8 + + string + + #if not $nchan() > 8 + all + #elif $ant8() + none + #else + part + #end if + + + + Ch8: Bandwidth (Hz) + bw8 + 0 + real + + #if not $nchan() > 8 + all + #elif $bw8() + none + #else + part + #end if + + + + + Ch9: Center Freq (Hz) + center_freq9 + 0 + real + #if $nchan() > 9 then 'none' else 'all'# + + + Ch9: Gain (dB) + gain9 + 0 + real + #if $nchan() > 9 then 'none' else 'all'# + + + Ch9: Antenna + ant9 + + string + + #if not $nchan() > 9 + all + #elif $ant9() + none + #else + part + #end if + + + + Ch9: Bandwidth (Hz) + bw9 + 0 + real + + #if not $nchan() > 9 + all + #elif $bw9() + none + #else + part + #end if + + + + + Ch10: Center Freq (Hz) + center_freq10 + 0 + real + #if $nchan() > 10 then 'none' else 'all'# + + + Ch10: Gain (dB) + gain10 + 0 + real + #if $nchan() > 10 then 'none' else 'all'# + + + Ch10: Antenna + ant10 + + string + + #if not $nchan() > 10 + all + #elif $ant10() + none + #else + part + #end if + + + + Ch10: Bandwidth (Hz) + bw10 + 0 + real + + #if not $nchan() > 10 + all + #elif $bw10() + none + #else + part + #end if + + + + + Ch11: Center Freq (Hz) + center_freq11 + 0 + real + #if $nchan() > 11 then 'none' else 'all'# + + + Ch11: Gain (dB) + gain11 + 0 + real + #if $nchan() > 11 then 'none' else 'all'# + + + Ch11: Antenna + ant11 + + string + + #if not $nchan() > 11 + all + #elif $ant11() + none + #else + part + #end if + + + + Ch11: Bandwidth (Hz) + bw11 + 0 + real + + #if not $nchan() > 11 + all + #elif $bw11() + none + #else + part + #end if + + + + + Ch12: Center Freq (Hz) + center_freq12 + 0 + real + #if $nchan() > 12 then 'none' else 'all'# + + + Ch12: Gain (dB) + gain12 + 0 + real + #if $nchan() > 12 then 'none' else 'all'# + + + Ch12: Antenna + ant12 + + string + + #if not $nchan() > 12 + all + #elif $ant12() + none + #else + part + #end if + + + + Ch12: Bandwidth (Hz) + bw12 + 0 + real + + #if not $nchan() > 12 + all + #elif $bw12() + none + #else + part + #end if + + + + + Ch13: Center Freq (Hz) + center_freq13 + 0 + real + #if $nchan() > 13 then 'none' else 'all'# + + + Ch13: Gain (dB) + gain13 + 0 + real + #if $nchan() > 13 then 'none' else 'all'# + + + Ch13: Antenna + ant13 + + string + + #if not $nchan() > 13 + all + #elif $ant13() + none + #else + part + #end if + + + + Ch13: Bandwidth (Hz) + bw13 + 0 + real + + #if not $nchan() > 13 + all + #elif $bw13() + none + #else + part + #end if + + + + + Ch14: Center Freq (Hz) + center_freq14 + 0 + real + #if $nchan() > 14 then 'none' else 'all'# + + + Ch14: Gain (dB) + gain14 + 0 + real + #if $nchan() > 14 then 'none' else 'all'# + + + Ch14: Antenna + ant14 + + string + + #if not $nchan() > 14 + all + #elif $ant14() + none + #else + part + #end if + + + + Ch14: Bandwidth (Hz) + bw14 + 0 + real + + #if not $nchan() > 14 + all + #elif $bw14() + none + #else + part + #end if + + + + + Ch15: Center Freq (Hz) + center_freq15 + 0 + real + #if $nchan() > 15 then 'none' else 'all'# + + + Ch15: Gain (dB) + gain15 + 0 + real + #if $nchan() > 15 then 'none' else 'all'# + + + Ch15: Antenna + ant15 + + string + + #if not $nchan() > 15 + all + #elif $ant15() + none + #else + part + #end if + + + + Ch15: Bandwidth (Hz) + bw15 + 0 + real + + #if not $nchan() > 15 + all + #elif $bw15() + none + #else + part + #end if + + + + 16 >= $nchan + $nchan > 0 + 4 >= $num_mboards + $num_mboards > 0 + $nchan >= $num_mboards + + out + $type + $type.vlen + $nchan + + +The UHD USRP Source 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 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 device 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 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. + + diff --git a/gr-uhd/include/.gitignore b/gr-uhd/include/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-uhd/include/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-uhd/include/Makefile.am b/gr-uhd/include/Makefile.am new file mode 100644 index 000000000..4a04c98c1 --- /dev/null +++ b/gr-uhd/include/Makefile.am @@ -0,0 +1,27 @@ +# +# Copyright 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 $(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/include/gr_uhd_api.h b/gr-uhd/include/gr_uhd_api.h new file mode 100644 index 000000000..a9b99fd87 --- /dev/null +++ b/gr-uhd/include/gr_uhd_api.h @@ -0,0 +1,33 @@ +/* + * Copyright 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_GR_UHD_API_H +#define INCLUDED_GR_UHD_API_H + +#include + +#ifdef gnuradio_uhd_EXPORTS +# define GR_UHD_API UHD_EXPORT +#else +# define GR_UHD_API UHD_EXPORT +#endif + +#endif /* INCLUDED_GR_UHD_API_H */ diff --git a/gr-uhd/include/gr_uhd_usrp_sink.h b/gr-uhd/include/gr_uhd_usrp_sink.h new file mode 100644 index 000000000..caa8c230f --- /dev/null +++ b/gr-uhd/include/gr_uhd_usrp_sink.h @@ -0,0 +1,196 @@ +/* + * 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_GR_UHD_USRP_SINK_H +#define INCLUDED_GR_UHD_USRP_SINK_H + +#include +#include +#include + +class uhd_usrp_sink; + +GR_UHD_API boost::shared_ptr 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_usrp_sink : public gr_sync_block{ +public: + + /*! + * Set the IO signature for this block. + * \param sig the input signature + */ + 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) = 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 + ) = 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 = 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) = 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 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) = 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) = 0; + + /*! + * Get the current time registers. + * \return the current usrp time + */ + virtual uhd::time_spec_t get_time_now(void) = 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. + * \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 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_GR_UHD_USRP_SINK_H */ diff --git a/gr-uhd/include/gr_uhd_usrp_source.h b/gr-uhd/include/gr_uhd_usrp_source.h new file mode 100644 index 000000000..a5f9600da --- /dev/null +++ b/gr-uhd/include/gr_uhd_usrp_source.h @@ -0,0 +1,196 @@ +/* + * 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_GR_UHD_USRP_SOURCE_H +#define INCLUDED_GR_UHD_USRP_SOURCE_H + +#include +#include +#include + +class uhd_usrp_source; + +GR_UHD_API boost::shared_ptr 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_usrp_source : public gr_sync_block{ +public: + + /*! + * Set the IO signature for this block. + * \param sig the output signature + */ + 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) = 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 + ) = 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 = 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) = 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 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 + * \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) = 0; + + /*! + * Get the current time registers. + * \return the current usrp time + */ + virtual uhd::time_spec_t get_time_now(void) = 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. + * \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 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_GR_UHD_USRP_SOURCE_H */ diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index 7ddb45cb3..8d8578d64 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -29,10 +29,8 @@ AM_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 + gr_uhd_usrp_source.cc \ + gr_uhd_usrp_sink.cc libgnuradio_uhd_la_LIBADD = \ $(GNURADIO_CORE_LA) \ @@ -40,11 +38,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/gr_uhd_api.h b/gr-uhd/lib/gr_uhd_api.h deleted file mode 100644 index a9b99fd87..000000000 --- a/gr-uhd/lib/gr_uhd_api.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 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_GR_UHD_API_H -#define INCLUDED_GR_UHD_API_H - -#include - -#ifdef gnuradio_uhd_EXPORTS -# define GR_UHD_API UHD_EXPORT -#else -# define GR_UHD_API UHD_EXPORT -#endif - -#endif /* INCLUDED_GR_UHD_API_H */ diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc new file mode 100644 index 000000000..2ca4c33a1 --- /dev/null +++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc @@ -0,0 +1,207 @@ +/* + * 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 +#include +#include + +/*********************************************************************** + * UHD Multi USRP Sink + **********************************************************************/ +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_usrp_sink_impl : public uhd_usrp_sink{ +public: + uhd_usrp_sink_impl( + const uhd::device_addr_t &device_addr, + const uhd::io_type_t &io_type, + size_t num_channels + ): + uhd_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); + _sample_rate = this->get_samp_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); + } + + 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); + } + + 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 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_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){ + 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::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; + } + +/*********************************************************************** + * Work + **********************************************************************/ + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ){ + //send a mid-burst packet with time spec + _metadata.start_of_burst = false; + _metadata.end_of_burst = false; + _metadata.has_time_spec = true; + + size_t num_sent = _dev->get_device()->send( + input_items, noutput_items, _metadata, + _type, uhd::device::SEND_MODE_FULL_BUFF, 1.0 + ); + + //increment the timespec by the number of samples sent + _metadata.time_spec += uhd::time_spec_t(0, num_sent, _sample_rate); + return num_sent; + } + + //Send an empty start-of-burst packet to begin streaming. + //Set at a time in the near future to avoid late packets. + bool start(void){ + _metadata.start_of_burst = true; + _metadata.end_of_burst = false; + _metadata.has_time_spec = true; + _metadata.time_spec = get_time_now() + uhd::time_spec_t(0.01); + + _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){ + _metadata.start_of_burst = false; + _metadata.end_of_burst = true; + _metadata.has_time_spec = false; + + _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; + uhd::tx_metadata_t _metadata; + double _sample_rate; +}; + +/*********************************************************************** + * Make UHD Multi USRP Sink + **********************************************************************/ +boost::shared_ptr 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( + new uhd_usrp_sink_impl(device_addr, io_type, num_channels) + ); +} diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc new file mode 100644 index 000000000..17877d04c --- /dev/null +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -0,0 +1,199 @@ +/* + * 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 +#include +#include +#include +#include + +/*********************************************************************** + * UHD Multi USRP Source + **********************************************************************/ +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_usrp_source_impl : public uhd_usrp_source{ +public: + uhd_usrp_source_impl( + const uhd::device_addr_t &device_addr, + const uhd::io_type_t &io_type, + size_t num_channels + ): + uhd_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); + } + + 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); + } + + 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 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_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){ + 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::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; + } + +/*********************************************************************** + * 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_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( + new uhd_usrp_source_impl(device_addr, io_type, num_channels) + ); +} diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.cc b/gr-uhd/lib/uhd_multi_usrp_sink.cc deleted file mode 100644 index 126d006d6..000000000 --- a/gr-uhd/lib/uhd_multi_usrp_sink.cc +++ /dev/null @@ -1,199 +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 -#include -#include - -/*********************************************************************** - * 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 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( - 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); - _sample_rate = this->get_samp_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 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::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; - } - -/*********************************************************************** - * Work - **********************************************************************/ - int work( - int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items - ){ - //send a mid-burst packet with time spec - _metadata.start_of_burst = false; - _metadata.end_of_burst = false; - _metadata.has_time_spec = true; - - size_t num_sent = _dev->get_device()->send( - input_items, noutput_items, _metadata, - _type, uhd::device::SEND_MODE_FULL_BUFF, 1.0 - ); - - //increment the timespec by the number of samples sent - _metadata.time_spec += uhd::time_spec_t(0, num_sent, _sample_rate); - return num_sent; - } - - //Send an empty start-of-burst packet to begin streaming. - //Set at a time in the near future to avoid late packets. - bool start(void){ - _metadata.start_of_burst = true; - _metadata.end_of_burst = false; - _metadata.has_time_spec = true; - _metadata.time_spec = get_time_now() + uhd::time_spec_t(0.01); - - _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){ - _metadata.start_of_burst = false; - _metadata.end_of_burst = true; - _metadata.has_time_spec = false; - - _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; - uhd::tx_metadata_t _metadata; - double _sample_rate; -}; - -/*********************************************************************** - * Make UHD Multi USRP Sink - **********************************************************************/ -boost::shared_ptr uhd_make_multi_usrp_sink( - const uhd::device_addr_t &device_addr, - const uhd::io_type_t &io_type, - size_t num_channels -){ - return boost::shared_ptr( - 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 deleted file mode 100644 index b15339eb7..000000000 --- a/gr-uhd/lib/uhd_multi_usrp_sink.h +++ /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. - */ - -#ifndef INCLUDED_UHD_MULTI_USRP_SINK_H -#define INCLUDED_UHD_MULTI_USRP_SINK_H - -#include -#include -#include - -class uhd_multi_usrp_sink; - -GR_UHD_API boost::shared_ptr uhd_make_multi_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{ -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(double 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 double 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 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 dboard iface object. - * \return the dboard_iface object - */ - virtual uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan) = 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 deleted file mode 100644 index affcfce75..000000000 --- a/gr-uhd/lib/uhd_multi_usrp_source.cc +++ /dev/null @@ -1,191 +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 -#include -#include -#include -#include - -/*********************************************************************** - * 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 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( - 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(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 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::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; - } - -/*********************************************************************** - * 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_make_multi_usrp_source( - const uhd::device_addr_t &device_addr, - const uhd::io_type_t &io_type, - size_t num_channels -){ - return boost::shared_ptr( - 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 deleted file mode 100644 index 0f26c9457..000000000 --- a/gr-uhd/lib/uhd_multi_usrp_source.h +++ /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. - */ - -#ifndef INCLUDED_UHD_MULTI_USRP_SOURCE_H -#define INCLUDED_UHD_MULTI_USRP_SOURCE_H - -#include -#include -#include - -class uhd_multi_usrp_source; - -GR_UHD_API boost::shared_ptr uhd_make_multi_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{ -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(double 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 double 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 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 dboard iface object. - * \return the dboard_iface object - */ - virtual uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan) = 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 deleted file mode 100644 index 88b2479a9..000000000 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ /dev/null @@ -1,186 +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 -#include -#include - -/*********************************************************************** - * 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 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::dboard_iface::sptr get_dboard_iface(size_t chan){ - return _dev->get_tx_dboard_iface(chan); - } - - 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_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( - 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 f8b8479aa..000000000 --- a/gr-uhd/lib/uhd_single_usrp_sink.h +++ /dev/null @@ -1,180 +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 -#include -#include - -class uhd_single_usrp_sink; - -GR_UHD_API boost::shared_ptr 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 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 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 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 4495ea048..000000000 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ /dev/null @@ -1,253 +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 -#include -#include -#include -#include - -/*********************************************************************** - * 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 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::dboard_iface::sptr get_dboard_iface(size_t chan){ - return _dev->get_rx_dboard_iface(chan); - } - - 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 -boost::shared_ptr 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( - new uhd_single_usrp_source_impl_with_tags(device_addr, io_type, num_channels) - ); - - return boost::shared_ptr( - 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 2808e8563..000000000 --- a/gr-uhd/lib/uhd_single_usrp_source.h +++ /dev/null @@ -1,180 +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 -#include -#include - -class uhd_single_usrp_source; - -GR_UHD_API boost::shared_ptr 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 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 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 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..b464f903d 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -66,10 +66,7 @@ class device_addr_t(device_addr_t, str): ######################################################################## # Cast constructor args (FIXME swig handle overloads?) ######################################################################## -for attr in ( - 'single_usrp_source', 'single_usrp_sink', - 'multi_usrp_source', 'multi_usrp_sink' -): +for attr in ('usrp_source', 'usrp_sink'): def constructor_factory(old_constructor): def constructor_interceptor(*args, **kwargs): args = list(args) @@ -84,3 +81,11 @@ for attr in ( return constructor_interceptor import uhd_swig globals()[attr] = constructor_factory(getattr(uhd_swig, attr)) + +######################################################################## +# Aliases for deprecated constructors +######################################################################## +single_usrp_source = usrp_source +single_usrp_sink = usrp_sink +multi_usrp_source = usrp_source +multi_usrp_sink = usrp_sink diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index e90f850bd..a42344fab 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -53,10 +53,8 @@ // block headers //////////////////////////////////////////////////////////////////////// %{ -#include -#include -#include -#include +#include +#include %} //////////////////////////////////////////////////////////////////////// @@ -105,17 +103,11 @@ //////////////////////////////////////////////////////////////////////// // block magic //////////////////////////////////////////////////////////////////////// -GR_SWIG_BLOCK_MAGIC(uhd,multi_usrp_source) -%include +GR_SWIG_BLOCK_MAGIC(uhd,usrp_source) +%include -GR_SWIG_BLOCK_MAGIC(uhd,multi_usrp_sink) -%include - -GR_SWIG_BLOCK_MAGIC(uhd,single_usrp_source) -%include - -GR_SWIG_BLOCK_MAGIC(uhd,single_usrp_sink) -%include +GR_SWIG_BLOCK_MAGIC(uhd,usrp_sink) +%include //////////////////////////////////////////////////////////////////////// // helpful constants -- cgit From 77f646ca0f578698ff5121a0b3360bd536f8d48d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 10 Feb 2011 12:07:11 -0800 Subject: uhd: tweaks to the grc blocks --- gr-uhd/grc/gen_uhd_usrp_blocks.py | 2 +- gr-uhd/grc/uhd_usrp_sink.xml | 4 ++-- gr-uhd/grc/uhd_usrp_source.xml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/gen_uhd_usrp_blocks.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py index ec4633427..ee8d692dd 100644 --- a/gr-uhd/grc/gen_uhd_usrp_blocks.py +++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py @@ -153,7 +153,7 @@ self.\$(id).set_bandwidth(\$bw$(n), $n) Num Channels nchan - 2 + 1 int #for $n in range(1, $max_nchan+1)