From 54179f7f860dcf8bc986fd90a22a5be8322b5fdf Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 24 Feb 2010 14:42:25 -0800 Subject: Created gr uhd skeleton build. Checks uhd pkg config and gens the makefiles. --- gr-uhd/.gitignore | 2 ++ gr-uhd/Makefile.am | 29 +++++++++++++++++++++++++++++ gr-uhd/apps/.gitignore | 2 ++ gr-uhd/apps/Makefile.am | 22 ++++++++++++++++++++++ gr-uhd/grc/.gitignore | 2 ++ gr-uhd/grc/Makefile.am | 22 ++++++++++++++++++++++ gr-uhd/lib/.gitignore | 2 ++ gr-uhd/lib/Makefile.am | 22 ++++++++++++++++++++++ gr-uhd/swig/.gitignore | 2 ++ gr-uhd/swig/Makefile.am | 22 ++++++++++++++++++++++ 10 files changed, 127 insertions(+) create mode 100644 gr-uhd/.gitignore create mode 100644 gr-uhd/Makefile.am create mode 100644 gr-uhd/apps/.gitignore create mode 100644 gr-uhd/apps/Makefile.am create mode 100644 gr-uhd/grc/.gitignore create mode 100644 gr-uhd/grc/Makefile.am create mode 100644 gr-uhd/lib/.gitignore create mode 100644 gr-uhd/lib/Makefile.am create mode 100644 gr-uhd/swig/.gitignore create mode 100644 gr-uhd/swig/Makefile.am (limited to 'gr-uhd') diff --git a/gr-uhd/.gitignore b/gr-uhd/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-uhd/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-uhd/Makefile.am b/gr-uhd/Makefile.am new file mode 100644 index 000000000..83190a1d0 --- /dev/null +++ b/gr-uhd/Makefile.am @@ -0,0 +1,29 @@ +# +# Copyright 2010 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common + +SUBDIRS = lib apps + +if PYTHON +SUBDIRS += swig grc +endif + diff --git a/gr-uhd/apps/.gitignore b/gr-uhd/apps/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-uhd/apps/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-uhd/apps/Makefile.am b/gr-uhd/apps/Makefile.am new file mode 100644 index 000000000..b78d07ee8 --- /dev/null +++ b/gr-uhd/apps/Makefile.am @@ -0,0 +1,22 @@ +# +# Copyright 2010 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common diff --git a/gr-uhd/grc/.gitignore b/gr-uhd/grc/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-uhd/grc/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-uhd/grc/Makefile.am b/gr-uhd/grc/Makefile.am new file mode 100644 index 000000000..b78d07ee8 --- /dev/null +++ b/gr-uhd/grc/Makefile.am @@ -0,0 +1,22 @@ +# +# Copyright 2010 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common diff --git a/gr-uhd/lib/.gitignore b/gr-uhd/lib/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-uhd/lib/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am new file mode 100644 index 000000000..b78d07ee8 --- /dev/null +++ b/gr-uhd/lib/Makefile.am @@ -0,0 +1,22 @@ +# +# Copyright 2010 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common diff --git a/gr-uhd/swig/.gitignore b/gr-uhd/swig/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-uhd/swig/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am new file mode 100644 index 000000000..b78d07ee8 --- /dev/null +++ b/gr-uhd/swig/Makefile.am @@ -0,0 +1,22 @@ +# +# Copyright 2010 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common -- cgit From 7c23fd43214e8a729b3022db281dc85040f0e749 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 26 Feb 2010 15:17:38 -0800 Subject: Created simple source (with nothing in it) and some swig build stuff. Seems to work and compile --- gr-uhd/lib/Makefile.am | 19 +++ gr-uhd/lib/uhd_simple_source.cc | 81 +++++++++++++ gr-uhd/lib/uhd_simple_source.h | 50 ++++++++ gr-uhd/swig/.gitignore | 2 + gr-uhd/swig/Makefile.am | 44 +++++++ gr-uhd/swig/Makefile.swig.gen | 259 ++++++++++++++++++++++++++++++++++++++++ gr-uhd/swig/__init__.py | 28 +++++ gr-uhd/swig/uhd_swig.i | 31 +++++ 8 files changed, 514 insertions(+) create mode 100644 gr-uhd/lib/uhd_simple_source.cc create mode 100644 gr-uhd/lib/uhd_simple_source.h create mode 100644 gr-uhd/swig/Makefile.swig.gen create mode 100644 gr-uhd/swig/__init__.py create mode 100644 gr-uhd/swig/uhd_swig.i (limited to 'gr-uhd') diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index b78d07ee8..2f49ed2d6 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -20,3 +20,22 @@ # include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = \ + $(STD_DEFINES_AND_INCLUDES) \ + $(WITH_INCLUDES) \ + $(UHD_CFLAGS) + +lib_LTLIBRARIES = libgnuradio-uhd.la + +libgnuradio_uhd_la_SOURCES = \ + uhd_simple_source.cc + +libgnuradio_uhd_la_LIBADD = \ + $(GNURADIO_CORE_LA) \ + $(UHD_LIBS) + +grinclude_HEADERS = \ + uhd_simple_source.h + +noinst_HEADERS = diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc new file mode 100644 index 000000000..588b27627 --- /dev/null +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -0,0 +1,81 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include + +/*********************************************************************** + * Helper Functions + **********************************************************************/ +static gr_io_signature_sptr make_io_sig(const std::string &type){ + if(type == "32fc"){ + return gr_make_io_signature(1, 1, sizeof(std::complex)); + } + if(type == "16sc"){ + return gr_make_io_signature(1, 1, sizeof(std::complex)); + } + throw std::runtime_error("unknown type"); +} + +/*********************************************************************** + * Make UHD Source + **********************************************************************/ +boost::shared_ptr uhd_make_simple_source( + const uhd::device_addr_t &addr, + const std::string &type +){ + return boost::shared_ptr( + new uhd_simple_source(addr, type) + ); +} + +/*********************************************************************** + * UHD Source + **********************************************************************/ +uhd_simple_source::uhd_simple_source( + const uhd::device_addr_t &addr, + const std::string &type +) : gr_sync_block( + "uhd source", + gr_make_io_signature(0, 0, 0), + make_io_sig(type) +){ + _type = type; + _dev = uhd::device::make(addr); +} + +uhd_simple_source::~uhd_simple_source(void){ + /* NOP */ +} + +/*********************************************************************** + * Work + **********************************************************************/ +int uhd_simple_source::work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items +){ + uhd::metadata_t metadata; + return _dev->recv(boost::asio::buffer(output_items[0], noutput_items), metadata, _type); +} diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h new file mode 100644 index 000000000..156b9f357 --- /dev/null +++ b/gr-uhd/lib/uhd_simple_source.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_UHD_SIMPLE_SOURCE_H +#define INCLUDED_UHD_SIMPLE_SOURCE_H + +#include +#include + +class uhd_simple_source; + +boost::shared_ptr +uhd_make_simple_source(const uhd::device_addr_t &addr, const std::string &type); + +class uhd_simple_source : public gr_sync_block{ +public: + uhd_simple_source(const uhd::device_addr_t &addr, const std::string &type); + ~uhd_simple_source(void); + + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ); + +protected: + uhd::device::sptr _dev; + std::string _type; +}; + +#endif /* INCLUDED_UHD_SIMPLE_SOURCE_H */ diff --git a/gr-uhd/swig/.gitignore b/gr-uhd/swig/.gitignore index b336cc7ce..02d25cc00 100644 --- a/gr-uhd/swig/.gitignore +++ b/gr-uhd/swig/.gitignore @@ -1,2 +1,4 @@ +/uhd_swig.cc +/uhd_swig.py /Makefile /Makefile.in diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am index b78d07ee8..3b1fd20f8 100644 --- a/gr-uhd/swig/Makefile.am +++ b/gr-uhd/swig/Makefile.am @@ -20,3 +20,47 @@ # include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = \ + $(STD_DEFINES_AND_INCLUDES) \ + $(PYTHON_CPPFLAGS) \ + $(WITH_INCLUDES) \ + -I$(top_srcdir)/gr-uhd/lib + +if PYTHON +# ---------------------------------------------------------------- +# The SWIG library +# TESTS = run_tests + +TOP_SWIG_IFILES = \ + uhd_swig.i + +# Install so that they end up available as: +# import gnuradio.uhd +# This ends up at: +# ${prefix}/lib/python${python_version}/site-packages/gnuradio/uhd +uhd_swig_pythondir_category = \ + gnuradio/uhd + +# additional libraries for linking with the SWIG-generated library +uhd_swig_la_swig_libadd = \ + $(top_builddir)/gr-uhd/lib/libgnuradio-uhd.la + +# additional Python files to be installed along with the SWIG-generated one +uhd_swig_python = \ + __init__.py + +# additional SWIG files to be installed +uhd_swig_swiginclude_headers = + +include $(top_srcdir)/Makefile.swig + +# FIXME better way to set this? +STD_SWIG_PYTHON_ARGS += -I$(top_srcdir)/gr-uhd/lib + +# add some of the variables generated inside the Makefile.swig.gen +BUILT_SOURCES = $(swig_built_sources) + +# Do not distribute the output of SWIG +no_dist_files = $(swig_built_sources) +endif diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen new file mode 100644 index 000000000..3804461a4 --- /dev/null +++ b/gr-uhd/swig/Makefile.swig.gen @@ -0,0 +1,259 @@ +# -*- Makefile -*- +# +# Copyright 2009 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +# Makefile.swig.gen for uhd_swig.i + +## Default install locations for these files: +## +## Default location for the Python directory is: +## ${prefix}/lib/python${python_version}/site-packages/[category]/uhd_swig +## Default location for the Python exec directory is: +## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/uhd_swig +## +## The following can be overloaded to change the install location, but +## this has to be done in the including Makefile.am -before- +## Makefile.swig is included. + +uhd_swig_pythondir_category ?= gnuradio/uhd_swig +uhd_swig_pylibdir_category ?= $(uhd_swig_pythondir_category) +uhd_swig_pythondir = $(pythondir)/$(uhd_swig_pythondir_category) +uhd_swig_pylibdir = $(pyexecdir)/$(uhd_swig_pylibdir_category) + +## SWIG headers are always installed into the same directory. + +uhd_swig_swigincludedir = $(swigincludedir) + +## This is a template file for a "generated" Makefile addition (in +## this case, "Makefile.swig.gen"). By including the top-level +## Makefile.swig, this file will be used to generate the SWIG +## dependencies. Assign the variable TOP_SWIG_FILES to be the list of +## SWIG .i files to generated wrappings for; there can be more than 1 +## so long as the names are unique (no sorting is done on the +## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i +## file will generate .cc, .py, and possibly .h files -- meaning that +## all of these files will have the same base name (that provided for +## the SWIG .i file). +## +## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the +## right thing. For more info, see < +## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > + +## Stamps used to ensure parallel make does the right thing. These +## are removed by "make clean", but otherwise unused except during the +## parallel built. These will not be included in a tarball, because +## the SWIG-generated files will be removed from the distribution. + +STAMPS += $(DEPDIR)/uhd_swig-generate-* + +## Other cleaned files: dependency files generated by SWIG or this Makefile + +MOSTLYCLEANFILES += $(DEPDIR)/*.S* + +## Add the .py and .cc files to the list of SWIG built sources. The +## .h file is sometimes built, but not always ... so that one has to +## be added manually by the including Makefile.am . + +swig_built_sources += uhd_swig.py uhd_swig.cc + +## Various SWIG variables. These can be overloaded in the including +## Makefile.am by setting the variable value there, then including +## Makefile.swig . + +uhd_swig_swiginclude_HEADERS = \ + uhd_swig.i \ + $(uhd_swig_swiginclude_headers) + +uhd_swig_pylib_LTLIBRARIES = \ + _uhd_swig.la + +_uhd_swig_la_SOURCES = \ + uhd_swig.cc \ + $(uhd_swig_la_swig_sources) + +_uhd_swig_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(uhd_swig_la_swig_libadd) + +_uhd_swig_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(uhd_swig_la_swig_ldflags) + +_uhd_swig_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + $(uhd_swig_la_swig_cxxflags) + +uhd_swig_python_PYTHON = \ + uhd_swig.py \ + $(uhd_swig_python) + +## Entry rule for running SWIG + +uhd_swig.h uhd_swig.py uhd_swig.cc: uhd_swig.i +## This rule will get called only when MAKE decides that one of the +## targets needs to be created or re-created, because: +## +## * The .i file is newer than any or all of the generated files; +## +## * Any or all of the .cc, .h, or .py files does not exist and is +## needed (in the case this file is not needed, the rule for it is +## ignored); or +## +## * Some SWIG-based dependecy of the .cc file isn't met and hence the +## .cc file needs be be regenerated. Explanation: Because MAKE +## knows how to handle dependencies for .cc files (regardless of +## their name or extension), then the .cc file is used as a target +## instead of the .i file -- but with the dependencies of the .i +## file. It is this last reason why the line: +## +## if test -f $@; then :; else +## +## cannot be used in this case: If a .i file dependecy is not met, +## then the .cc file needs to be rebuilt. But if the stamp is newer +## than the .cc file, and the .cc file exists, then in the original +## version (with the 'test' above) the internal MAKE call will not +## be issued and hence the .cc file will not be rebuilt. +## +## Once execution gets to here, it should always proceed no matter the +## state of a stamp (as discussed in link above). The +## $(DEPDIR)/uhd_swig-generate stuff is used to allow for parallel +## builds to "do the right thing". The stamp has no relationship with +## either the target files or dependency file; it is used solely for +## the protection of multiple builds during a given call to MAKE. +## +## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM +## (15). At a caught signal, the quoted command will be issued before +## exiting. In this case, remove any stamp, whether temporary of not. +## The trap is valid until the process exits; the process includes all +## commands appended via "\"s. +## + trap 'rm -rf $(DEPDIR)/uhd_swig-generate-*' 1 2 13 15; \ +## +## Create a temporary directory, which acts as a lock. The first +## process to create the directory will succeed and issue the MAKE +## command to do the actual work, while all subsequent processes will +## fail -- leading them to wait for the first process to finish. +## + if mkdir $(DEPDIR)/uhd_swig-generate-lock 2>/dev/null; then \ +## +## This code is being executed by the first process to succeed in +## creating the directory lock. +## +## Remove the stamp associated with this filename. +## + rm -f $(DEPDIR)/uhd_swig-generate-stamp; \ +## +## Tell MAKE to run the rule for creating this stamp. +## + $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/uhd_swig-generate-stamp WHAT=$<; \ +## +## Now that the .cc, .h, and .py files have been (re)created from the +## .i file, future checking of this rule during the same MAKE +## execution will come back that the rule doesn't need to be executed +## because none of the conditions mentioned at the start of this rule +## will be positive. Remove the the directory lock, which frees up +## any waiting process(es) to continue. +## + rmdir $(DEPDIR)/uhd_swig-generate-lock; \ + else \ +## +## This code is being executed by any follower processes while the +## directory lock is in place. +## +## Wait until the first process is done, testing once per second. +## + while test -d $(DEPDIR)/uhd_swig-generate-lock; do \ + sleep 1; \ + done; \ +## +## Succeed if and only if the first process succeeded; exit this +## process returning the status of the generated stamp. +## + test -f $(DEPDIR)/uhd_swig-generate-stamp; \ + exit $$?; \ + fi; + +$(DEPDIR)/uhd_swig-generate-stamp: +## This rule will be called only by the first process issuing the +## above rule to succeed in creating the lock directory, after +## removing the actual stamp file in order to guarantee that MAKE will +## execute this rule. +## +## Call SWIG to generate the various output files; special +## post-processing on 'mingw32' host OS for the dependency file. +## + if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(uhd_swig_swig_args) \ + -MD -MF $(DEPDIR)/uhd_swig.Std \ + -module uhd_swig -o uhd_swig.cc $(WHAT); then \ + if test $(host_os) = mingw32; then \ + $(RM) $(DEPDIR)/uhd_swig.Sd; \ + $(SED) 's,\\\\,/,g' < $(DEPDIR)/uhd_swig.Std \ + > $(DEPDIR)/uhd_swig.Sd; \ + $(RM) $(DEPDIR)/uhd_swig.Std; \ + $(MV) $(DEPDIR)/uhd_swig.Sd $(DEPDIR)/uhd_swig.Std; \ + fi; \ + else \ + $(RM) $(DEPDIR)/uhd_swig.S*; exit 1; \ + fi; +## +## Mess with the SWIG output .Std dependency file, to create a +## dependecy file valid for the input .i file: Basically, simulate the +## dependency file created for libraries by GNU's libtool for C++, +## where all of the dependencies for the target are first listed, then +## each individual dependency is listed as a target with no further +## dependencies. +## +## (1) remove the current dependency file +## + $(RM) $(DEPDIR)/uhd_swig.d +## +## (2) Copy the whole SWIG file: +## + cp $(DEPDIR)/uhd_swig.Std $(DEPDIR)/uhd_swig.d +## +## (3) all a carriage return to the end of the dependency file. +## + echo "" >> $(DEPDIR)/uhd_swig.d +## +## (4) from the SWIG file, remove the first line (the target); remove +## trailing " \" and " " from each line. Append ":" to each line, +## followed by 2 carriage returns, then append this to the end of +## the dependency file. +## + $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/uhd_swig.Std | \ + awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/uhd_swig.d +## +## (5) remove the SWIG-generated file +## + $(RM) $(DEPDIR)/uhd_swig.Std +## +## Create the stamp for this filename generation, to signal success in +## executing this rule; allows other threads waiting on this process +## to continue. +## + touch $(DEPDIR)/uhd_swig-generate-stamp + +# KLUDGE: Force runtime include of a SWIG dependency file. This is +# not guaranteed to be portable, but will probably work. If it works, +# we have accurate dependencies for our swig stuff, which is good. + +@am__include@ @am__quote@./$(DEPDIR)/uhd_swig.d@am__quote@ + diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py new file mode 100644 index 000000000..2fed17e57 --- /dev/null +++ b/gr-uhd/swig/__init__.py @@ -0,0 +1,28 @@ +# +# Copyright 2010 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +# The presence of this file turns this directory into a Python package + +# Add SWIG generated code to this namespace +from uhd_swig import * + +# Add other content from pure-Python modules here + diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i new file mode 100644 index 000000000..e20d22a26 --- /dev/null +++ b/gr-uhd/swig/uhd_swig.i @@ -0,0 +1,31 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +%include "gnuradio.i" + +%{ +#include +%} + +GR_SWIG_BLOCK_MAGIC(uhd,simple_source) + +%include -- cgit From 00f9ccaa50ed26d71a66d19f8f1518874004c5de Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 1 Mar 2010 11:50:09 -0800 Subject: recv noise with uhd --- gr-uhd/grc/Makefile.am | 5 ++++ gr-uhd/lib/Makefile.am | 4 ++- gr-uhd/lib/uhd_simple_source.cc | 56 +++++++++++++++++++++++++++++++++++------ gr-uhd/lib/uhd_simple_source.h | 5 +++- 4 files changed, 60 insertions(+), 10 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/Makefile.am b/gr-uhd/grc/Makefile.am index b78d07ee8..a46146272 100644 --- a/gr-uhd/grc/Makefile.am +++ b/gr-uhd/grc/Makefile.am @@ -20,3 +20,8 @@ # include $(top_srcdir)/Makefile.common + +grcblocksdir = $(grc_blocksdir) + +dist_grcblocks_DATA = \ + uhd_simple_source.xml diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index 2f49ed2d6..73424ae8e 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -29,6 +29,7 @@ AM_CPPFLAGS = \ lib_LTLIBRARIES = libgnuradio-uhd.la libgnuradio_uhd_la_SOURCES = \ + utils.cc \ uhd_simple_source.cc libgnuradio_uhd_la_LIBADD = \ @@ -38,4 +39,5 @@ libgnuradio_uhd_la_LIBADD = \ grinclude_HEADERS = \ uhd_simple_source.h -noinst_HEADERS = +noinst_HEADERS = \ + utils.h diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 588b27627..4bd3622f3 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -22,17 +22,19 @@ #include #include +#include #include +#include "utils.h" /*********************************************************************** * Helper Functions **********************************************************************/ -static gr_io_signature_sptr make_io_sig(const std::string &type){ +static size_t get_size(const std::string &type){ if(type == "32fc"){ - return gr_make_io_signature(1, 1, sizeof(std::complex)); + return sizeof(std::complex); } if(type == "16sc"){ - return gr_make_io_signature(1, 1, sizeof(std::complex)); + return sizeof(std::complex); } throw std::runtime_error("unknown type"); } @@ -41,11 +43,11 @@ static gr_io_signature_sptr make_io_sig(const std::string &type){ * Make UHD Source **********************************************************************/ boost::shared_ptr uhd_make_simple_source( - const uhd::device_addr_t &addr, + const std::string &args, const std::string &type ){ return boost::shared_ptr( - new uhd_simple_source(addr, type) + new uhd_simple_source(args_to_device_addr(args), type) ); } @@ -58,14 +60,27 @@ uhd_simple_source::uhd_simple_source( ) : gr_sync_block( "uhd source", gr_make_io_signature(0, 0, 0), - make_io_sig(type) + gr_make_io_signature(1, 1, get_size(type)) ){ _type = type; _dev = uhd::device::make(addr); + _sizeof_samp = get_size(type); + + set_streaming(true); } uhd_simple_source::~uhd_simple_source(void){ - /* NOP */ + set_streaming(false); +} + +/*********************************************************************** + * DDC Control + **********************************************************************/ +void uhd_simple_source::set_streaming(bool enb){ + wax::obj ddc = (*_dev) + [uhd::DEVICE_PROP_MBOARD] + [uhd::named_prop_t(uhd::MBOARD_PROP_RX_DSP, "ddc0")]; + ddc[std::string("enabled")] = enb; } /*********************************************************************** @@ -76,6 +91,31 @@ int uhd_simple_source::work( gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ){ + + size_t total_items_read = 0; + size_t count = 0; uhd::metadata_t metadata; - return _dev->recv(boost::asio::buffer(output_items[0], noutput_items), metadata, _type); + while(total_items_read == 0 or total_items_read + 1500/_sizeof_samp < size_t(noutput_items)){ + size_t items_read = _dev->recv( + boost::asio::buffer( + (uint8_t *)output_items[0]+(total_items_read*_sizeof_samp), + (noutput_items-total_items_read)*_sizeof_samp + ), metadata, _type + ); + + //record items read and recv again + if (items_read > 0){ + total_items_read += items_read; + continue; + } + + //if we have read at least once, but not this time, get out + if (total_items_read > 0) break; + + //the timeout part + boost::this_thread::sleep(boost::posix_time::milliseconds(1)); + count++; if (count > 50) break; + } + + return total_items_read; } diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index 156b9f357..43c4a647a 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -29,7 +29,7 @@ class uhd_simple_source; boost::shared_ptr -uhd_make_simple_source(const uhd::device_addr_t &addr, const std::string &type); +uhd_make_simple_source(const std::string &args, const std::string &type); class uhd_simple_source : public gr_sync_block{ public: @@ -43,8 +43,11 @@ public: ); protected: + void set_streaming(bool enb); + uhd::device::sptr _dev; std::string _type; + size_t _sizeof_samp; }; #endif /* INCLUDED_UHD_SIMPLE_SOURCE_H */ -- cgit From c85606eaaf5a73387d4423bdeb2f63483394137e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 1 Mar 2010 16:16:16 -0800 Subject: using samples prop, added unchecked in files for utils and grc rx wrapper --- gr-uhd/grc/uhd_simple_source.xml | 43 +++++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_simple_source.cc | 6 +++-- gr-uhd/lib/utils.cc | 49 ++++++++++++++++++++++++++++++++++++++++ gr-uhd/lib/utils.h | 30 ++++++++++++++++++++++++ 4 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 gr-uhd/grc/uhd_simple_source.xml create mode 100644 gr-uhd/lib/utils.cc create mode 100644 gr-uhd/lib/utils.h (limited to 'gr-uhd') diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml new file mode 100644 index 000000000..90bde1cd3 --- /dev/null +++ b/gr-uhd/grc/uhd_simple_source.xml @@ -0,0 +1,43 @@ + + + + UHD Simple Source + uhd_simple_source + UHD + from gnuradio import uhd + uhd.simple_source($args, "$type.type") + + Output Type + type + enum + + + + + Args + args + + string + + + out + $type + $type.vlen + + + + diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 4bd3622f3..360b91434 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -92,10 +92,12 @@ int uhd_simple_source::work( gr_vector_void_star &output_items ){ + const size_t max_samples = wax::cast((*_dev)[uhd::DEVICE_PROP_MAX_RX_SAMPLES]); + size_t total_items_read = 0; size_t count = 0; uhd::metadata_t metadata; - while(total_items_read == 0 or total_items_read + 1500/_sizeof_samp < size_t(noutput_items)){ + while(total_items_read == 0 or total_items_read + max_samples < size_t(noutput_items)){ size_t items_read = _dev->recv( boost::asio::buffer( (uint8_t *)output_items[0]+(total_items_read*_sizeof_samp), @@ -114,7 +116,7 @@ int uhd_simple_source::work( //the timeout part boost::this_thread::sleep(boost::posix_time::milliseconds(1)); - count++; if (count > 50) break; + if (++count > 50) break; } return total_items_read; diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc new file mode 100644 index 000000000..6b2121064 --- /dev/null +++ b/gr-uhd/lib/utils.cc @@ -0,0 +1,49 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include "utils.h" +#include +#include +#include + +static std::string trim(const std::string &in){ + return boost::algorithm::trim_copy(in); +} + +uhd::device_addr_t args_to_device_addr(const std::string &args){ + uhd::device_addr_t addr; + + //split the args at the semi-colons + std::vector pairs; + boost::split(pairs, args, boost::is_any_of(";")); + BOOST_FOREACH(std::string pair, pairs){ + if (trim(pair) == "") continue; + + //split the key value pairs at the equals + std::vector key_val; + boost::split(key_val, pair, boost::is_any_of("=")); + if (key_val.size() != 2) throw std::runtime_error("invalid args string: "+args); + addr[trim(key_val[0])] = trim(key_val[1]); + } + + return addr; +} diff --git a/gr-uhd/lib/utils.h b/gr-uhd/lib/utils.h new file mode 100644 index 000000000..7530faba2 --- /dev/null +++ b/gr-uhd/lib/utils.h @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_NOINST_UTILS_H +#define INCLUDED_NOINST_UTILS_H + +#include + +uhd::device_addr_t args_to_device_addr(const std::string &args); + +#endif /* INCLUDED_NOINST_UTILS_H */ -- cgit From 6d71414a0a467dc37fc903b327be22f8d0ddeade Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 2 Mar 2010 14:43:20 -0800 Subject: Added the uhd simple sink lib block, swig wrapper, grc wrapper. It seems to work, but still getting the kinks out of tx->usrp2 --- gr-uhd/grc/Makefile.am | 3 +- gr-uhd/grc/uhd_simple_sink.xml | 43 ++++++++++++++++++++ gr-uhd/lib/Makefile.am | 6 ++- gr-uhd/lib/uhd_simple_sink.cc | 87 +++++++++++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_simple_sink.h | 52 ++++++++++++++++++++++++ gr-uhd/lib/uhd_simple_source.cc | 21 ++-------- gr-uhd/lib/utils.cc | 11 ++++++ gr-uhd/lib/utils.h | 2 + gr-uhd/swig/uhd_swig.i | 5 ++- 9 files changed, 209 insertions(+), 21 deletions(-) create mode 100644 gr-uhd/grc/uhd_simple_sink.xml create mode 100644 gr-uhd/lib/uhd_simple_sink.cc create mode 100644 gr-uhd/lib/uhd_simple_sink.h (limited to 'gr-uhd') diff --git a/gr-uhd/grc/Makefile.am b/gr-uhd/grc/Makefile.am index a46146272..61eb32770 100644 --- a/gr-uhd/grc/Makefile.am +++ b/gr-uhd/grc/Makefile.am @@ -24,4 +24,5 @@ include $(top_srcdir)/Makefile.common grcblocksdir = $(grc_blocksdir) dist_grcblocks_DATA = \ - uhd_simple_source.xml + uhd_simple_source.xml \ + uhd_simple_sink.xml diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml new file mode 100644 index 000000000..1259c38c0 --- /dev/null +++ b/gr-uhd/grc/uhd_simple_sink.xml @@ -0,0 +1,43 @@ + + + + UHD Simple Sink + uhd_simple_sink + UHD + from gnuradio import uhd + uhd.simple_sink($args, "$type.type") + + Input Type + type + enum + + + + + Args + args + + string + + + out + $type + $type.vlen + + + + diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index 73424ae8e..d4363406b 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -30,14 +30,16 @@ lib_LTLIBRARIES = libgnuradio-uhd.la libgnuradio_uhd_la_SOURCES = \ utils.cc \ - uhd_simple_source.cc + uhd_simple_source.cc \ + uhd_simple_sink.cc libgnuradio_uhd_la_LIBADD = \ $(GNURADIO_CORE_LA) \ $(UHD_LIBS) grinclude_HEADERS = \ - uhd_simple_source.h + uhd_simple_source.h \ + uhd_simple_sink.h noinst_HEADERS = \ utils.h diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc new file mode 100644 index 000000000..269487f0e --- /dev/null +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -0,0 +1,87 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include "utils.h" + +/*********************************************************************** + * Make UHD Sink + **********************************************************************/ +boost::shared_ptr uhd_make_simple_sink( + const std::string &args, + const std::string &type +){ + return boost::shared_ptr( + new uhd_simple_sink(args_to_device_addr(args), type) + ); +} + +/*********************************************************************** + * UHD Sink + **********************************************************************/ +uhd_simple_sink::uhd_simple_sink( + const uhd::device_addr_t &addr, + const std::string &type +) : gr_sync_block( + "uhd sink", + gr_make_io_signature(1, 1, get_size(type)), + gr_make_io_signature(0, 0, 0) +){ + _type = type; + _dev = uhd::device::make(addr); + _sizeof_samp = get_size(type); +} + +uhd_simple_sink::~uhd_simple_sink(void){ + //NOP +} + +/*********************************************************************** + * Work + **********************************************************************/ +int uhd_simple_sink::work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items +){ + + const size_t max_samples = wax::cast((*_dev)[uhd::DEVICE_PROP_MAX_TX_SAMPLES]); + size_t total_items_sent = 0; + uhd::metadata_t metadata; + metadata.start_of_burst = true; + + //handles fragmentation + while(total_items_sent < size_t(noutput_items)){ + size_t items_sent = _dev->send( + boost::asio::buffer( + (uint8_t *)input_items[0]+(total_items_sent*_sizeof_samp), + std::min(max_samples, noutput_items-total_items_sent)*_sizeof_samp + ), metadata, _type + ); + total_items_sent += items_sent; + } + + return noutput_items; +} diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h new file mode 100644 index 000000000..76b4a26cf --- /dev/null +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_UHD_SIMPLE_SINK_H +#define INCLUDED_UHD_SIMPLE_SINK_H + +#include +#include + +class uhd_simple_sink; + +boost::shared_ptr +uhd_make_simple_sink(const std::string &args, const std::string &type); + +class uhd_simple_sink : public gr_sync_block{ +public: + uhd_simple_sink(const uhd::device_addr_t &addr, const std::string &type); + ~uhd_simple_sink(void); + + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ); + +protected: + + uhd::device::sptr _dev; + std::string _type; + size_t _sizeof_samp; +}; + +#endif /* INCLUDED_UHD_SIMPLE_SINK_H */ diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 360b91434..f6a783ef9 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -26,19 +26,6 @@ #include #include "utils.h" -/*********************************************************************** - * Helper Functions - **********************************************************************/ -static size_t get_size(const std::string &type){ - if(type == "32fc"){ - return sizeof(std::complex); - } - if(type == "16sc"){ - return sizeof(std::complex); - } - throw std::runtime_error("unknown type"); -} - /*********************************************************************** * Make UHD Source **********************************************************************/ @@ -95,9 +82,9 @@ int uhd_simple_source::work( const size_t max_samples = wax::cast((*_dev)[uhd::DEVICE_PROP_MAX_RX_SAMPLES]); size_t total_items_read = 0; - size_t count = 0; + size_t count = 50; uhd::metadata_t metadata; - while(total_items_read == 0 or total_items_read + max_samples < size_t(noutput_items)){ + while(total_items_read < size_t(noutput_items)){ size_t items_read = _dev->recv( boost::asio::buffer( (uint8_t *)output_items[0]+(total_items_read*_sizeof_samp), @@ -116,8 +103,8 @@ int uhd_simple_source::work( //the timeout part boost::this_thread::sleep(boost::posix_time::milliseconds(1)); - if (++count > 50) break; + if (--count == 0) break; } - + return total_items_read; } diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc index 6b2121064..c92846dc1 100644 --- a/gr-uhd/lib/utils.cc +++ b/gr-uhd/lib/utils.cc @@ -24,6 +24,7 @@ #include #include #include +#include static std::string trim(const std::string &in){ return boost::algorithm::trim_copy(in); @@ -47,3 +48,13 @@ uhd::device_addr_t args_to_device_addr(const std::string &args){ return addr; } + +size_t get_size(const std::string &type){ + if(type == "32fc"){ + return sizeof(std::complex); + } + if(type == "16sc"){ + return sizeof(std::complex); + } + throw std::runtime_error("unknown type"); +} diff --git a/gr-uhd/lib/utils.h b/gr-uhd/lib/utils.h index 7530faba2..9a6dd604a 100644 --- a/gr-uhd/lib/utils.h +++ b/gr-uhd/lib/utils.h @@ -27,4 +27,6 @@ uhd::device_addr_t args_to_device_addr(const std::string &args); +size_t get_size(const std::string &type); + #endif /* INCLUDED_NOINST_UTILS_H */ diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index e20d22a26..06a1c88ff 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -24,8 +24,11 @@ %{ #include +#include %} GR_SWIG_BLOCK_MAGIC(uhd,simple_source) - %include + +GR_SWIG_BLOCK_MAGIC(uhd,simple_sink) +%include -- cgit From 23f6fc0f5f484380fe5f934ec97c4397d3675cb6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 3 Mar 2010 12:32:18 -0800 Subject: Got the source and sink working with current uhd. --- gr-uhd/lib/uhd_simple_sink.cc | 8 +++----- gr-uhd/lib/uhd_simple_source.cc | 21 ++++++++++++++------- gr-uhd/lib/uhd_simple_source.h | 1 + gr-uhd/lib/utils.cc | 4 ++-- 4 files changed, 20 insertions(+), 14 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index 269487f0e..01581bb76 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -66,18 +66,16 @@ int uhd_simple_sink::work( gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ){ - - const size_t max_samples = wax::cast((*_dev)[uhd::DEVICE_PROP_MAX_TX_SAMPLES]); size_t total_items_sent = 0; - uhd::metadata_t metadata; + uhd::tx_metadata_t metadata; metadata.start_of_burst = true; - //handles fragmentation + //call until the input items are all sent while(total_items_sent < size_t(noutput_items)){ size_t items_sent = _dev->send( boost::asio::buffer( (uint8_t *)input_items[0]+(total_items_sent*_sizeof_samp), - std::min(max_samples, noutput_items-total_items_sent)*_sizeof_samp + (noutput_items-total_items_sent)*_sizeof_samp ), metadata, _type ); total_items_sent += items_sent; diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index f6a783ef9..17691c7ae 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -53,7 +53,7 @@ uhd_simple_source::uhd_simple_source( _dev = uhd::device::make(addr); _sizeof_samp = get_size(type); - set_streaming(true); + set_streaming(false); } uhd_simple_source::~uhd_simple_source(void){ @@ -68,6 +68,7 @@ void uhd_simple_source::set_streaming(bool enb){ [uhd::DEVICE_PROP_MBOARD] [uhd::named_prop_t(uhd::MBOARD_PROP_RX_DSP, "ddc0")]; ddc[std::string("enabled")] = enb; + _is_streaming = enb; } /*********************************************************************** @@ -78,12 +79,16 @@ int uhd_simple_source::work( gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ){ - - const size_t max_samples = wax::cast((*_dev)[uhd::DEVICE_PROP_MAX_RX_SAMPLES]); + //conditionally start streaming in the work call + //this prevents streaming before the runtime is ready + if (not _is_streaming) set_streaming(true); size_t total_items_read = 0; - size_t count = 50; - uhd::metadata_t metadata; + size_t timeout_count = 50; + uhd::rx_metadata_t metadata; + + //call until the output items are all filled + //or an exit condition below is encountered while(total_items_read < size_t(noutput_items)){ size_t items_read = _dev->recv( boost::asio::buffer( @@ -99,11 +104,13 @@ int uhd_simple_source::work( } //if we have read at least once, but not this time, get out - if (total_items_read > 0) break; + // commented out behaviour: I believe that it would be better to + // fill the buffer entirely to mimimize scheduler context switching + //if (total_items_read > 0) break; //the timeout part boost::this_thread::sleep(boost::posix_time::milliseconds(1)); - if (--count == 0) break; + if (--timeout_count == 0) break; } return total_items_read; diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index 43c4a647a..5d2dafe49 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -44,6 +44,7 @@ public: protected: void set_streaming(bool enb); + bool _is_streaming; //shadow for the streaming status uhd::device::sptr _dev; std::string _type; diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc index c92846dc1..e36320c3c 100644 --- a/gr-uhd/lib/utils.cc +++ b/gr-uhd/lib/utils.cc @@ -20,7 +20,7 @@ * Boston, MA 02110-1301, USA. */ -#include "utils.h" +#include "utils.h" //local include #include #include #include @@ -54,7 +54,7 @@ size_t get_size(const std::string &type){ return sizeof(std::complex); } if(type == "16sc"){ - return sizeof(std::complex); + return sizeof(std::complex); } throw std::runtime_error("unknown type"); } -- cgit From 6c79d5158ace300038937688bb11309736926214 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 4 Mar 2010 18:38:47 -0800 Subject: removed timeout from here --- gr-uhd/lib/uhd_simple_source.cc | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 17691c7ae..a8977abc3 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -22,7 +22,6 @@ #include #include -#include #include #include "utils.h" @@ -84,7 +83,6 @@ int uhd_simple_source::work( if (not _is_streaming) set_streaming(true); size_t total_items_read = 0; - size_t timeout_count = 50; uhd::rx_metadata_t metadata; //call until the output items are all filled @@ -96,21 +94,10 @@ int uhd_simple_source::work( (noutput_items-total_items_read)*_sizeof_samp ), metadata, _type ); + total_items_read += items_read; - //record items read and recv again - if (items_read > 0){ - total_items_read += items_read; - continue; - } - - //if we have read at least once, but not this time, get out - // commented out behaviour: I believe that it would be better to - // fill the buffer entirely to mimimize scheduler context switching - //if (total_items_read > 0) break; - - //the timeout part - boost::this_thread::sleep(boost::posix_time::milliseconds(1)); - if (--timeout_count == 0) break; + //we timed out, get out of here + if (items_read == 0) break; } return total_items_read; -- cgit From 19d3c0cab37123f8bfd19fdfc576f44b6069300f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 10 Mar 2010 14:48:50 -0800 Subject: Added samp rate param and using the simple device from uhd --- gr-uhd/grc/uhd_simple_sink.xml | 10 +++++++++- gr-uhd/grc/uhd_simple_source.xml | 10 +++++++++- gr-uhd/lib/uhd_simple_sink.cc | 16 ++++++++++++---- gr-uhd/lib/uhd_simple_sink.h | 10 ++++++---- gr-uhd/lib/uhd_simple_source.cc | 33 +++++++++++++++++---------------- gr-uhd/lib/uhd_simple_source.h | 13 +++++++------ gr-uhd/lib/utils.cc | 28 ++-------------------------- gr-uhd/lib/utils.h | 5 ++--- 8 files changed, 64 insertions(+), 61 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml index 1259c38c0..078288e04 100644 --- a/gr-uhd/grc/uhd_simple_sink.xml +++ b/gr-uhd/grc/uhd_simple_sink.xml @@ -9,7 +9,9 @@ uhd_simple_sink UHD from gnuradio import uhd - uhd.simple_sink($args, "$type.type") + uhd.simple_sink($args, "$type.type") +self.$(id).set_samp_rate($samp_rate) + set_samp_rate($samp_rate) Input Type type @@ -33,6 +35,12 @@ string + + Samp Rate (Sps) + samp_rate + samp_rate + real + out $type diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml index 90bde1cd3..45496b098 100644 --- a/gr-uhd/grc/uhd_simple_source.xml +++ b/gr-uhd/grc/uhd_simple_source.xml @@ -9,7 +9,9 @@ uhd_simple_source UHD from gnuradio import uhd - uhd.simple_source($args, "$type.type") + uhd.simple_source($args, "$type.type") +self.$(id).set_samp_rate($samp_rate) + set_samp_rate($samp_rate) Output Type type @@ -33,6 +35,12 @@ string + + Samp Rate (Sps) + samp_rate + samp_rate + real + out $type diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index 01581bb76..c1edf29bb 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -34,7 +34,7 @@ boost::shared_ptr uhd_make_simple_sink( const std::string &type ){ return boost::shared_ptr( - new uhd_simple_sink(args_to_device_addr(args), type) + new uhd_simple_sink(args, type) ); } @@ -42,7 +42,7 @@ boost::shared_ptr uhd_make_simple_sink( * UHD Sink **********************************************************************/ uhd_simple_sink::uhd_simple_sink( - const uhd::device_addr_t &addr, + const std::string &args, const std::string &type ) : gr_sync_block( "uhd sink", @@ -50,7 +50,7 @@ uhd_simple_sink::uhd_simple_sink( gr_make_io_signature(0, 0, 0) ){ _type = type; - _dev = uhd::device::make(addr); + _dev = uhd::simple_device::make(args); _sizeof_samp = get_size(type); } @@ -58,6 +58,14 @@ uhd_simple_sink::~uhd_simple_sink(void){ //NOP } +void uhd_simple_sink::set_samp_rate(double rate){ + return _dev->set_tx_rate(rate); +} + +double uhd_simple_sink::get_samp_rate(void){ + return _dev->get_tx_rate(); +} + /*********************************************************************** * Work **********************************************************************/ @@ -72,7 +80,7 @@ int uhd_simple_sink::work( //call until the input items are all sent while(total_items_sent < size_t(noutput_items)){ - size_t items_sent = _dev->send( + size_t items_sent = _dev->get_device()->send( boost::asio::buffer( (uint8_t *)input_items[0]+(total_items_sent*_sizeof_samp), (noutput_items-total_items_sent)*_sizeof_samp diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index 76b4a26cf..301cdd24f 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -24,7 +24,7 @@ #define INCLUDED_UHD_SIMPLE_SINK_H #include -#include +#include class uhd_simple_sink; @@ -33,9 +33,12 @@ uhd_make_simple_sink(const std::string &args, const std::string &type); class uhd_simple_sink : public gr_sync_block{ public: - uhd_simple_sink(const uhd::device_addr_t &addr, const std::string &type); + uhd_simple_sink(const std::string &args, const std::string &type); ~uhd_simple_sink(void); + void set_samp_rate(double rate); + double get_samp_rate(void); + int work( int noutput_items, gr_vector_const_void_star &input_items, @@ -43,8 +46,7 @@ public: ); protected: - - uhd::device::sptr _dev; + uhd::simple_device::sptr _dev; std::string _type; size_t _sizeof_samp; }; diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index a8977abc3..827cad458 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -33,7 +33,7 @@ boost::shared_ptr uhd_make_simple_source( const std::string &type ){ return boost::shared_ptr( - new uhd_simple_source(args_to_device_addr(args), type) + new uhd_simple_source(args, type) ); } @@ -41,7 +41,7 @@ boost::shared_ptr uhd_make_simple_source( * UHD Source **********************************************************************/ uhd_simple_source::uhd_simple_source( - const uhd::device_addr_t &addr, + const std::string &args, const std::string &type ) : gr_sync_block( "uhd source", @@ -49,25 +49,23 @@ uhd_simple_source::uhd_simple_source( gr_make_io_signature(1, 1, get_size(type)) ){ _type = type; - _dev = uhd::device::make(addr); + _dev = uhd::simple_device::make(args); _sizeof_samp = get_size(type); - set_streaming(false); + _dev->set_streaming(false); + _is_streaming = false; } uhd_simple_source::~uhd_simple_source(void){ - set_streaming(false); + _dev->set_streaming(false); } -/*********************************************************************** - * DDC Control - **********************************************************************/ -void uhd_simple_source::set_streaming(bool enb){ - wax::obj ddc = (*_dev) - [uhd::DEVICE_PROP_MBOARD] - [uhd::named_prop_t(uhd::MBOARD_PROP_RX_DSP, "ddc0")]; - ddc[std::string("enabled")] = enb; - _is_streaming = enb; +void uhd_simple_source::set_samp_rate(double rate){ + return _dev->set_rx_rate(rate); +} + +double uhd_simple_source::get_samp_rate(void){ + return _dev->get_rx_rate(); } /*********************************************************************** @@ -80,7 +78,10 @@ int uhd_simple_source::work( ){ //conditionally start streaming in the work call //this prevents streaming before the runtime is ready - if (not _is_streaming) set_streaming(true); + if (not _is_streaming){ + _dev->set_streaming(true); + _is_streaming = true; + } size_t total_items_read = 0; uhd::rx_metadata_t metadata; @@ -88,7 +89,7 @@ int uhd_simple_source::work( //call until the output items are all filled //or an exit condition below is encountered while(total_items_read < size_t(noutput_items)){ - size_t items_read = _dev->recv( + size_t items_read = _dev->get_device()->recv( boost::asio::buffer( (uint8_t *)output_items[0]+(total_items_read*_sizeof_samp), (noutput_items-total_items_read)*_sizeof_samp diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index 5d2dafe49..0ddf9d563 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -24,7 +24,7 @@ #define INCLUDED_UHD_SIMPLE_SOURCE_H #include -#include +#include class uhd_simple_source; @@ -33,9 +33,12 @@ uhd_make_simple_source(const std::string &args, const std::string &type); class uhd_simple_source : public gr_sync_block{ public: - uhd_simple_source(const uhd::device_addr_t &addr, const std::string &type); + uhd_simple_source(const std::string &args, const std::string &type); ~uhd_simple_source(void); + void set_samp_rate(double rate); + double get_samp_rate(void); + int work( int noutput_items, gr_vector_const_void_star &input_items, @@ -43,12 +46,10 @@ public: ); protected: - void set_streaming(bool enb); - bool _is_streaming; //shadow for the streaming status - - uhd::device::sptr _dev; + uhd::simple_device::sptr _dev; std::string _type; size_t _sizeof_samp; + bool _is_streaming; }; #endif /* INCLUDED_UHD_SIMPLE_SOURCE_H */ diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc index e36320c3c..0351d6370 100644 --- a/gr-uhd/lib/utils.cc +++ b/gr-uhd/lib/utils.cc @@ -21,33 +21,9 @@ */ #include "utils.h" //local include -#include -#include -#include +#include #include - -static std::string trim(const std::string &in){ - return boost::algorithm::trim_copy(in); -} - -uhd::device_addr_t args_to_device_addr(const std::string &args){ - uhd::device_addr_t addr; - - //split the args at the semi-colons - std::vector pairs; - boost::split(pairs, args, boost::is_any_of(";")); - BOOST_FOREACH(std::string pair, pairs){ - if (trim(pair) == "") continue; - - //split the key value pairs at the equals - std::vector key_val; - boost::split(key_val, pair, boost::is_any_of("=")); - if (key_val.size() != 2) throw std::runtime_error("invalid args string: "+args); - addr[trim(key_val[0])] = trim(key_val[1]); - } - - return addr; -} +#include size_t get_size(const std::string &type){ if(type == "32fc"){ diff --git a/gr-uhd/lib/utils.h b/gr-uhd/lib/utils.h index 9a6dd604a..eb3a133bc 100644 --- a/gr-uhd/lib/utils.h +++ b/gr-uhd/lib/utils.h @@ -23,9 +23,8 @@ #ifndef INCLUDED_NOINST_UTILS_H #define INCLUDED_NOINST_UTILS_H -#include - -uhd::device_addr_t args_to_device_addr(const std::string &args); +#include +#include size_t get_size(const std::string &type); -- cgit From b5c1edfd488ccdd8a2c6ff5a2efb3de35a048d67 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 16 Mar 2010 19:43:08 -0700 Subject: added set center freq call --- gr-uhd/grc/uhd_simple_sink.xml | 9 ++++++++- gr-uhd/grc/uhd_simple_source.xml | 9 ++++++++- gr-uhd/lib/uhd_simple_sink.cc | 4 ++++ gr-uhd/lib/uhd_simple_sink.h | 2 ++ gr-uhd/lib/uhd_simple_source.cc | 4 ++++ gr-uhd/lib/uhd_simple_source.h | 2 ++ 6 files changed, 28 insertions(+), 2 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml index 078288e04..cad6194ee 100644 --- a/gr-uhd/grc/uhd_simple_sink.xml +++ b/gr-uhd/grc/uhd_simple_sink.xml @@ -10,8 +10,10 @@ UHD from gnuradio import uhd uhd.simple_sink($args, "$type.type") -self.$(id).set_samp_rate($samp_rate) +self.$(id).set_samp_rate($samp_rate) +self.$(id).set_center_freq($center_freq) set_samp_rate($samp_rate) + set_center_freq($center_freq) Input Type type @@ -41,6 +43,11 @@ self.$(id).set_samp_rate($samp_rate) samp_rate real + + Center Freq (Hz) + center_freq + real + out $type diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml index 45496b098..519b7ad6c 100644 --- a/gr-uhd/grc/uhd_simple_source.xml +++ b/gr-uhd/grc/uhd_simple_source.xml @@ -10,8 +10,10 @@ UHD from gnuradio import uhd uhd.simple_source($args, "$type.type") -self.$(id).set_samp_rate($samp_rate) +self.$(id).set_samp_rate($samp_rate) +self.$(id).set_center_freq($center_freq) set_samp_rate($samp_rate) + set_center_freq($center_freq) Output Type type @@ -41,6 +43,11 @@ self.$(id).set_samp_rate($samp_rate) samp_rate real + + Center Freq (Hz) + center_freq + real + out $type diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index c1edf29bb..f208bd294 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -66,6 +66,10 @@ double uhd_simple_sink::get_samp_rate(void){ return _dev->get_tx_rate(); } +void uhd_simple_sink::set_center_freq(double freq){ + _dev->set_tx_freq(freq); +} + /*********************************************************************** * Work **********************************************************************/ diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index 301cdd24f..28965d870 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -39,6 +39,8 @@ public: void set_samp_rate(double rate); double get_samp_rate(void); + void set_center_freq(double freq); + int work( int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 827cad458..1a0bb2b61 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -68,6 +68,10 @@ double uhd_simple_source::get_samp_rate(void){ return _dev->get_rx_rate(); } +void uhd_simple_source::set_center_freq(double freq){ + _dev->set_rx_freq(freq); +} + /*********************************************************************** * Work **********************************************************************/ diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index 0ddf9d563..cfab8b7a4 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -39,6 +39,8 @@ public: void set_samp_rate(double rate); double get_samp_rate(void); + void set_center_freq(double freq); + int work( int noutput_items, gr_vector_const_void_star &input_items, -- cgit From 0abfa7d596265a2b7d54da1206979171a0891fb4 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 26 Mar 2010 14:01:27 -0700 Subject: using new streaming api --- gr-uhd/lib/uhd_simple_source.cc | 18 +++++++++++------- gr-uhd/lib/uhd_simple_source.h | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 1a0bb2b61..87b727874 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -52,12 +52,19 @@ uhd_simple_source::uhd_simple_source( _dev = uhd::simple_device::make(args); _sizeof_samp = get_size(type); - _dev->set_streaming(false); - _is_streaming = false; + set_streaming(false); } uhd_simple_source::~uhd_simple_source(void){ - _dev->set_streaming(false); + set_streaming(false); +} + +void uhd_simple_source::set_streaming(bool enb){ + uhd::stream_cmd_t stream_cmd; + stream_cmd.stream_now = true; + stream_cmd.continuous = enb; + _dev->issue_stream_cmd(stream_cmd); + _is_streaming = enb; } void uhd_simple_source::set_samp_rate(double rate){ @@ -82,10 +89,7 @@ int uhd_simple_source::work( ){ //conditionally start streaming in the work call //this prevents streaming before the runtime is ready - if (not _is_streaming){ - _dev->set_streaming(true); - _is_streaming = true; - } + if (not _is_streaming) set_streaming(true); size_t total_items_read = 0; uhd::rx_metadata_t metadata; diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index cfab8b7a4..98378d518 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -52,6 +52,7 @@ protected: std::string _type; size_t _sizeof_samp; bool _is_streaming; + void set_streaming(bool enb); }; #endif /* INCLUDED_UHD_SIMPLE_SOURCE_H */ -- cgit From 6851718b6d9a97a8c9397a1548708c7075de98e4 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 29 Mar 2010 15:30:02 -0700 Subject: added swig includes and tune result return --- gr-uhd/lib/uhd_simple_sink.cc | 4 ++-- gr-uhd/lib/uhd_simple_sink.h | 2 +- gr-uhd/lib/uhd_simple_source.cc | 4 ++-- gr-uhd/lib/uhd_simple_source.h | 2 +- gr-uhd/swig/uhd_swig.i | 3 +++ 5 files changed, 9 insertions(+), 6 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index f208bd294..499ae4d6e 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -66,8 +66,8 @@ double uhd_simple_sink::get_samp_rate(void){ return _dev->get_tx_rate(); } -void uhd_simple_sink::set_center_freq(double freq){ - _dev->set_tx_freq(freq); +uhd::tune_result_t uhd_simple_sink::set_center_freq(double freq){ + return _dev->set_tx_freq(freq); } /*********************************************************************** diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index 28965d870..e57ba4abb 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -39,7 +39,7 @@ public: void set_samp_rate(double rate); double get_samp_rate(void); - void set_center_freq(double freq); + uhd::tune_result_t set_center_freq(double freq); int work( int noutput_items, diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 87b727874..725cb2807 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -75,8 +75,8 @@ double uhd_simple_source::get_samp_rate(void){ return _dev->get_rx_rate(); } -void uhd_simple_source::set_center_freq(double freq){ - _dev->set_rx_freq(freq); +uhd::tune_result_t uhd_simple_source::set_center_freq(double freq){ + return _dev->set_rx_freq(freq); } /*********************************************************************** diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index 98378d518..27fa2c382 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -39,7 +39,7 @@ public: void set_samp_rate(double rate); double get_samp_rate(void); - void set_center_freq(double freq); + uhd::tune_result_t set_center_freq(double freq); int work( int noutput_items, diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 06a1c88ff..363d9c914 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -27,6 +27,9 @@ #include %} +%include +%include + GR_SWIG_BLOCK_MAGIC(uhd,simple_source) %include -- cgit From a87552815119742d98561f9b53ab0da5513514bb Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 30 Mar 2010 14:08:11 -0700 Subject: gr-uhd working with io type --- gr-uhd/grc/uhd_simple_sink.xml | 6 +++--- gr-uhd/grc/uhd_simple_source.xml | 6 +++--- gr-uhd/lib/uhd_simple_sink.cc | 14 ++++++-------- gr-uhd/lib/uhd_simple_sink.h | 7 +++---- gr-uhd/lib/uhd_simple_source.cc | 14 ++++++-------- gr-uhd/lib/uhd_simple_source.h | 7 +++---- gr-uhd/lib/utils.cc | 13 ------------- gr-uhd/lib/utils.h | 5 ----- gr-uhd/swig/Makefile.am | 5 ++++- gr-uhd/swig/uhd_swig.i | 2 ++ 10 files changed, 30 insertions(+), 49 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml index cad6194ee..fa9e19be7 100644 --- a/gr-uhd/grc/uhd_simple_sink.xml +++ b/gr-uhd/grc/uhd_simple_sink.xml @@ -9,7 +9,7 @@ uhd_simple_sink UHD from gnuradio import uhd - uhd.simple_sink($args, "$type.type") + uhd.simple_sink($args, uhd.io_type_t.$type.type) self.$(id).set_samp_rate($samp_rate) self.$(id).set_center_freq($center_freq) set_samp_rate($samp_rate) @@ -21,13 +21,13 @@ self.$(id).set_center_freq($center_freq) diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml index 519b7ad6c..7deffeeec 100644 --- a/gr-uhd/grc/uhd_simple_source.xml +++ b/gr-uhd/grc/uhd_simple_source.xml @@ -9,7 +9,7 @@ uhd_simple_source UHD from gnuradio import uhd - uhd.simple_source($args, "$type.type") + uhd.simple_source($args, uhd.io_type_t.$type.type) self.$(id).set_samp_rate($samp_rate) self.$(id).set_center_freq($center_freq) set_samp_rate($samp_rate) @@ -21,13 +21,13 @@ self.$(id).set_center_freq($center_freq) diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index 499ae4d6e..a22b52421 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -31,7 +31,7 @@ **********************************************************************/ boost::shared_ptr uhd_make_simple_sink( const std::string &args, - const std::string &type + const uhd::io_type_t::tid_t &type ){ return boost::shared_ptr( new uhd_simple_sink(args, type) @@ -43,15 +43,13 @@ boost::shared_ptr uhd_make_simple_sink( **********************************************************************/ uhd_simple_sink::uhd_simple_sink( const std::string &args, - const std::string &type + const uhd::io_type_t &type ) : gr_sync_block( "uhd sink", - gr_make_io_signature(1, 1, get_size(type)), + gr_make_io_signature(1, 1, type.size), gr_make_io_signature(0, 0, 0) -){ - _type = type; +), _type(type){ _dev = uhd::simple_device::make(args); - _sizeof_samp = get_size(type); } uhd_simple_sink::~uhd_simple_sink(void){ @@ -86,8 +84,8 @@ int uhd_simple_sink::work( while(total_items_sent < size_t(noutput_items)){ size_t items_sent = _dev->get_device()->send( boost::asio::buffer( - (uint8_t *)input_items[0]+(total_items_sent*_sizeof_samp), - (noutput_items-total_items_sent)*_sizeof_samp + (uint8_t *)input_items[0]+(total_items_sent*_type.size), + (noutput_items-total_items_sent)*_type.size ), metadata, _type ); total_items_sent += items_sent; diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index e57ba4abb..aa8d1144c 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -29,11 +29,11 @@ class uhd_simple_sink; boost::shared_ptr -uhd_make_simple_sink(const std::string &args, const std::string &type); +uhd_make_simple_sink(const std::string &args, const uhd::io_type_t::tid_t &type); class uhd_simple_sink : public gr_sync_block{ public: - uhd_simple_sink(const std::string &args, const std::string &type); + uhd_simple_sink(const std::string &args, const uhd::io_type_t &type); ~uhd_simple_sink(void); void set_samp_rate(double rate); @@ -49,8 +49,7 @@ public: protected: uhd::simple_device::sptr _dev; - std::string _type; - size_t _sizeof_samp; + const uhd::io_type_t _type; }; #endif /* INCLUDED_UHD_SIMPLE_SINK_H */ diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 725cb2807..677099f11 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -30,7 +30,7 @@ **********************************************************************/ boost::shared_ptr uhd_make_simple_source( const std::string &args, - const std::string &type + const uhd::io_type_t::tid_t &type ){ return boost::shared_ptr( new uhd_simple_source(args, type) @@ -42,15 +42,13 @@ boost::shared_ptr uhd_make_simple_source( **********************************************************************/ uhd_simple_source::uhd_simple_source( const std::string &args, - const std::string &type + const uhd::io_type_t &type ) : gr_sync_block( "uhd source", gr_make_io_signature(0, 0, 0), - gr_make_io_signature(1, 1, get_size(type)) -){ - _type = type; + gr_make_io_signature(1, 1, type.size) +), _type(type){ _dev = uhd::simple_device::make(args); - _sizeof_samp = get_size(type); set_streaming(false); } @@ -99,8 +97,8 @@ int uhd_simple_source::work( while(total_items_read < size_t(noutput_items)){ size_t items_read = _dev->get_device()->recv( boost::asio::buffer( - (uint8_t *)output_items[0]+(total_items_read*_sizeof_samp), - (noutput_items-total_items_read)*_sizeof_samp + (uint8_t *)output_items[0]+(total_items_read*_type.size), + (noutput_items-total_items_read)*_type.size ), metadata, _type ); total_items_read += items_read; diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index 27fa2c382..50b1c9518 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -29,11 +29,11 @@ class uhd_simple_source; boost::shared_ptr -uhd_make_simple_source(const std::string &args, const std::string &type); +uhd_make_simple_source(const std::string &args, const uhd::io_type_t::tid_t &type); class uhd_simple_source : public gr_sync_block{ public: - uhd_simple_source(const std::string &args, const std::string &type); + uhd_simple_source(const std::string &args, const uhd::io_type_t &type); ~uhd_simple_source(void); void set_samp_rate(double rate); @@ -49,8 +49,7 @@ public: protected: uhd::simple_device::sptr _dev; - std::string _type; - size_t _sizeof_samp; + const uhd::io_type_t _type; bool _is_streaming; void set_streaming(bool enb); }; diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc index 0351d6370..e81241303 100644 --- a/gr-uhd/lib/utils.cc +++ b/gr-uhd/lib/utils.cc @@ -21,16 +21,3 @@ */ #include "utils.h" //local include -#include -#include -#include - -size_t get_size(const std::string &type){ - if(type == "32fc"){ - return sizeof(std::complex); - } - if(type == "16sc"){ - return sizeof(std::complex); - } - throw std::runtime_error("unknown type"); -} diff --git a/gr-uhd/lib/utils.h b/gr-uhd/lib/utils.h index eb3a133bc..9e3acf571 100644 --- a/gr-uhd/lib/utils.h +++ b/gr-uhd/lib/utils.h @@ -23,9 +23,4 @@ #ifndef INCLUDED_NOINST_UTILS_H #define INCLUDED_NOINST_UTILS_H -#include -#include - -size_t get_size(const std::string &type); - #endif /* INCLUDED_NOINST_UTILS_H */ diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am index 3b1fd20f8..183e6b587 100644 --- a/gr-uhd/swig/Makefile.am +++ b/gr-uhd/swig/Makefile.am @@ -25,6 +25,7 @@ AM_CPPFLAGS = \ $(STD_DEFINES_AND_INCLUDES) \ $(PYTHON_CPPFLAGS) \ $(WITH_INCLUDES) \ + $(UHD_CFLAGS) \ -I$(top_srcdir)/gr-uhd/lib if PYTHON @@ -56,7 +57,9 @@ uhd_swig_swiginclude_headers = include $(top_srcdir)/Makefile.swig # FIXME better way to set this? -STD_SWIG_PYTHON_ARGS += -I$(top_srcdir)/gr-uhd/lib +STD_SWIG_PYTHON_ARGS += \ + $(UHD_CFLAGS) \ + -I$(top_srcdir)/gr-uhd/lib # add some of the variables generated inside the Makefile.swig.gen BUILT_SOURCES = $(swig_built_sources) diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 363d9c914..2642f9450 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -27,8 +27,10 @@ #include %} +%include %include %include +%include GR_SWIG_BLOCK_MAGIC(uhd,simple_source) %include -- cgit From e390bcd9a69e13add9ffe3da430ba8ce19e88819 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 1 Apr 2010 16:01:08 -0700 Subject: Use simple usrp from uhd. --- gr-uhd/lib/uhd_simple_sink.cc | 2 +- gr-uhd/lib/uhd_simple_sink.h | 4 ++-- gr-uhd/lib/uhd_simple_source.cc | 2 +- gr-uhd/lib/uhd_simple_source.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index a22b52421..107a4ef6c 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -49,7 +49,7 @@ uhd_simple_sink::uhd_simple_sink( gr_make_io_signature(1, 1, type.size), gr_make_io_signature(0, 0, 0) ), _type(type){ - _dev = uhd::simple_device::make(args); + _dev = uhd::usrp::simple_usrp::make(args); } uhd_simple_sink::~uhd_simple_sink(void){ diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index aa8d1144c..735f72bdd 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -24,7 +24,7 @@ #define INCLUDED_UHD_SIMPLE_SINK_H #include -#include +#include class uhd_simple_sink; @@ -48,7 +48,7 @@ public: ); protected: - uhd::simple_device::sptr _dev; + uhd::usrp::simple_usrp::sptr _dev; const uhd::io_type_t _type; }; diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 677099f11..4a40c2cfc 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -48,7 +48,7 @@ uhd_simple_source::uhd_simple_source( gr_make_io_signature(0, 0, 0), gr_make_io_signature(1, 1, type.size) ), _type(type){ - _dev = uhd::simple_device::make(args); + _dev = uhd::usrp::simple_usrp::make(args); set_streaming(false); } diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index 50b1c9518..c498c5715 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -24,7 +24,7 @@ #define INCLUDED_UHD_SIMPLE_SOURCE_H #include -#include +#include class uhd_simple_source; @@ -48,7 +48,7 @@ public: ); protected: - uhd::simple_device::sptr _dev; + uhd::usrp::simple_usrp::sptr _dev; const uhd::io_type_t _type; bool _is_streaming; void set_streaming(bool enb); -- cgit From 8dfa110cf286db709a503adafc296a8b23225645 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 5 Apr 2010 17:25:19 -0700 Subject: fix for paradigm shift --- gr-uhd/lib/uhd_simple_source.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 4a40c2cfc..85e7f8f37 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -58,10 +58,10 @@ uhd_simple_source::~uhd_simple_source(void){ } void uhd_simple_source::set_streaming(bool enb){ - uhd::stream_cmd_t stream_cmd; - stream_cmd.stream_now = true; - stream_cmd.continuous = enb; - _dev->issue_stream_cmd(stream_cmd); + if (enb) + _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); + else + _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); _is_streaming = enb; } -- cgit From b89d6edb60a069215d02fb78614c9dbfb46b4899 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 14 Apr 2010 12:16:43 -0700 Subject: added more access methods to uhd source and sink --- gr-uhd/lib/uhd_simple_sink.cc | 31 +++++++++++++++++++++- gr-uhd/lib/uhd_simple_sink.h | 57 +++++++++++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_simple_source.cc | 31 +++++++++++++++++++++- gr-uhd/lib/uhd_simple_source.h | 57 +++++++++++++++++++++++++++++++++++++++++ gr-uhd/lib/utils.cc | 14 ++++++++++ gr-uhd/lib/utils.h | 2 ++ 6 files changed, 190 insertions(+), 2 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index 107a4ef6c..bf2b02d31 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -57,7 +57,8 @@ uhd_simple_sink::~uhd_simple_sink(void){ } void uhd_simple_sink::set_samp_rate(double rate){ - return _dev->set_tx_rate(rate); + _dev->set_tx_rate(rate); + do_samp_rate_error_message(rate, get_samp_rate()); } double uhd_simple_sink::get_samp_rate(void){ @@ -68,6 +69,34 @@ uhd::tune_result_t uhd_simple_sink::set_center_freq(double freq){ return _dev->set_tx_freq(freq); } +uhd::freq_range_t uhd_simple_sink::get_freq_range(void){ + return _dev->get_tx_freq_range(); +} + +void uhd_simple_sink::set_gain(float gain){ + return _dev->set_tx_gain(gain); +} + +float uhd_simple_sink::get_gain(void){ + return _dev->get_tx_gain(); +} + +uhd::gain_range_t uhd_simple_sink::get_gain_range(void){ + return _dev->get_tx_gain_range(); +} + +void uhd_simple_sink::set_antenna(const std::string &ant){ + return _dev->set_tx_antenna(ant); +} + +std::string uhd_simple_sink::get_antenna(void){ + return _dev->get_tx_antenna(); +} + +std::vector uhd_simple_sink::get_antennas(void){ + return _dev->get_tx_antennas(); +} + /*********************************************************************** * Work **********************************************************************/ diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index 735f72bdd..0229e38ca 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -36,11 +36,68 @@ public: uhd_simple_sink(const std::string &args, const uhd::io_type_t &type); ~uhd_simple_sink(void); + /*! + * Set the sample rate for the usrp device. + * \param rate a new rate in Sps + */ void set_samp_rate(double rate); + + /*! + * 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 + */ double get_samp_rate(void); + /*! + * Tune the usrp device to the desired center frequency. + * \param freq the desired frequency in Hz + * \return a tune result with the actual frequencies + */ uhd::tune_result_t set_center_freq(double freq); + /*! + * Get the tunable frequency range. + * \return the frequency range in Hz + */ + uhd::freq_range_t get_freq_range(void); + + /*! + * Set the gain for the dboard. + * \param gain the gain in dB + */ + void set_gain(float gain); + + /*! + * Get the actual dboard gain setting. + * \return the actual gain in dB + */ + float get_gain(void); + + /*! + * Get the settable gain range. + * \return the gain range in dB + */ + uhd::gain_range_t get_gain_range(void); + + /*! + * Set the antenna to use. + * \param ant the antenna string + */ + void set_antenna(const std::string &ant); + + /*! + * Get the antenna in use. + * \return the antenna string + */ + std::string get_antenna(void); + + /*! + * Get a list of possible antennas. + * \return a vector of antenna strings + */ + std::vector get_antennas(void); + int work( int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 85e7f8f37..e63fe9647 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -66,7 +66,8 @@ void uhd_simple_source::set_streaming(bool enb){ } void uhd_simple_source::set_samp_rate(double rate){ - return _dev->set_rx_rate(rate); + _dev->set_rx_rate(rate); + do_samp_rate_error_message(rate, get_samp_rate()); } double uhd_simple_source::get_samp_rate(void){ @@ -77,6 +78,34 @@ uhd::tune_result_t uhd_simple_source::set_center_freq(double freq){ return _dev->set_rx_freq(freq); } +uhd::freq_range_t uhd_simple_source::get_freq_range(void){ + return _dev->get_rx_freq_range(); +} + +void uhd_simple_source::set_gain(float gain){ + return _dev->set_rx_gain(gain); +} + +float uhd_simple_source::get_gain(void){ + return _dev->get_rx_gain(); +} + +uhd::gain_range_t uhd_simple_source::get_gain_range(void){ + return _dev->get_rx_gain_range(); +} + +void uhd_simple_source::set_antenna(const std::string &ant){ + return _dev->set_rx_antenna(ant); +} + +std::string uhd_simple_source::get_antenna(void){ + return _dev->get_rx_antenna(); +} + +std::vector uhd_simple_source::get_antennas(void){ + return _dev->get_rx_antennas(); +} + /*********************************************************************** * Work **********************************************************************/ diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index c498c5715..7d286f09c 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -36,11 +36,68 @@ public: uhd_simple_source(const std::string &args, const uhd::io_type_t &type); ~uhd_simple_source(void); + /*! + * Set the sample rate for the usrp device. + * \param rate a new rate in Sps + */ void set_samp_rate(double rate); + + /*! + * 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 + */ double get_samp_rate(void); + /*! + * Tune the usrp device to the desired center frequency. + * \param freq the desired frequency in Hz + * \return a tune result with the actual frequencies + */ uhd::tune_result_t set_center_freq(double freq); + /*! + * Get the tunable frequency range. + * \return the frequency range in Hz + */ + uhd::freq_range_t get_freq_range(void); + + /*! + * Set the gain for the dboard. + * \param gain the gain in dB + */ + void set_gain(float gain); + + /*! + * Get the actual dboard gain setting. + * \return the actual gain in dB + */ + float get_gain(void); + + /*! + * Get the settable gain range. + * \return the gain range in dB + */ + uhd::gain_range_t get_gain_range(void); + + /*! + * Set the antenna to use. + * \param ant the antenna string + */ + void set_antenna(const std::string &ant); + + /*! + * Get the antenna in use. + * \return the antenna string + */ + std::string get_antenna(void); + + /*! + * Get a list of possible antennas. + * \return a vector of antenna strings + */ + std::vector get_antennas(void); + int work( int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc index e81241303..ddc36eb99 100644 --- a/gr-uhd/lib/utils.cc +++ b/gr-uhd/lib/utils.cc @@ -21,3 +21,17 @@ */ #include "utils.h" //local include +#include +#include +#include + +void do_samp_rate_error_message(double target_rate, double actual_rate){ + static const double max_allowed_error = 1.0; //Sps + if (std::abs(target_rate - actual_rate) > max_allowed_error){ + std::cerr << boost::format( + "The hardware does not support the requested sample rate:\n" + " Target sample rate: %f MSps\n" + " Actual sample rate: %f MSps\n" + ) % (target_rate/1e6) % (actual_rate/1e6) << std::endl; + } +} diff --git a/gr-uhd/lib/utils.h b/gr-uhd/lib/utils.h index 9e3acf571..cf349e5aa 100644 --- a/gr-uhd/lib/utils.h +++ b/gr-uhd/lib/utils.h @@ -23,4 +23,6 @@ #ifndef INCLUDED_NOINST_UTILS_H #define INCLUDED_NOINST_UTILS_H +void do_samp_rate_error_message(double target_rate, double actual_rate); + #endif /* INCLUDED_NOINST_UTILS_H */ -- cgit From ec7bdb4c93c8046b7d80bdad9b151c990946b181 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 14 Apr 2010 12:31:19 -0700 Subject: added to uhd grc files, also removed warning for grc generator with uhd blocks --- gr-uhd/grc/uhd_simple_sink.xml | 20 +++++++++++++++++++- gr-uhd/grc/uhd_simple_source.xml | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml index fa9e19be7..7971a296b 100644 --- a/gr-uhd/grc/uhd_simple_sink.xml +++ b/gr-uhd/grc/uhd_simple_sink.xml @@ -11,9 +11,15 @@ from gnuradio import uhd uhd.simple_sink($args, uhd.io_type_t.$type.type) self.$(id).set_samp_rate($samp_rate) -self.$(id).set_center_freq($center_freq) +self.$(id).set_center_freq($center_freq) +self.$(id).set_gain($gain) +#if $ant() +self.$(id).set_antenna($antenna) +#end if set_samp_rate($samp_rate) set_center_freq($center_freq) + set_gain($gain) + set_antenna($antenna) Input Type type @@ -48,6 +54,18 @@ self.$(id).set_center_freq($center_freq) center_freq real + + Gain (dB) + gain + 0 + real + + + Antenna + ant + string + #if $ant() == '' then 'part' else 'none'# + out $type diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml index 7deffeeec..10a2f2c56 100644 --- a/gr-uhd/grc/uhd_simple_source.xml +++ b/gr-uhd/grc/uhd_simple_source.xml @@ -11,9 +11,15 @@ from gnuradio import uhd uhd.simple_source($args, uhd.io_type_t.$type.type) self.$(id).set_samp_rate($samp_rate) -self.$(id).set_center_freq($center_freq) +self.$(id).set_center_freq($center_freq) +self.$(id).set_gain($gain) +#if $ant() +self.$(id).set_antenna($antenna) +#end if set_samp_rate($samp_rate) set_center_freq($center_freq) + set_gain($gain) + set_antenna($antenna) Output Type type @@ -48,6 +54,18 @@ self.$(id).set_center_freq($center_freq) center_freq real + + Gain (dB) + gain + 0 + real + + + Antenna + ant + string + #if $ant() == '' then 'part' else 'none'# + out $type -- cgit From 001bbc6a303218785337b1df7221a3fdcc47a2cd Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 15 Apr 2010 19:47:36 -0700 Subject: typo fix, called variable ant, not antenna --- gr-uhd/grc/uhd_simple_sink.xml | 4 ++-- gr-uhd/grc/uhd_simple_source.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml index 7971a296b..b6406e80d 100644 --- a/gr-uhd/grc/uhd_simple_sink.xml +++ b/gr-uhd/grc/uhd_simple_sink.xml @@ -14,12 +14,12 @@ self.$(id).set_samp_rate($samp_rate) self.$(id).set_center_freq($center_freq) self.$(id).set_gain($gain) #if $ant() -self.$(id).set_antenna($antenna) +self.$(id).set_antenna($ant) #end if set_samp_rate($samp_rate) set_center_freq($center_freq) set_gain($gain) - set_antenna($antenna) + set_antenna($ant) Input Type type diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml index 10a2f2c56..34b6817c9 100644 --- a/gr-uhd/grc/uhd_simple_source.xml +++ b/gr-uhd/grc/uhd_simple_source.xml @@ -14,12 +14,12 @@ self.$(id).set_samp_rate($samp_rate) self.$(id).set_center_freq($center_freq) self.$(id).set_gain($gain) #if $ant() -self.$(id).set_antenna($antenna) +self.$(id).set_antenna($ant) #end if set_samp_rate($samp_rate) set_center_freq($center_freq) set_gain($gain) - set_antenna($antenna) + set_antenna($ant) Output Type type -- cgit From 999bba14d657a11fa9bfc1b9587e1341e2f28e07 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 23 Apr 2010 10:11:53 -0700 Subject: added docs to uhd grc blocks, added pkg config path to make support easier --- gr-uhd/grc/uhd_simple_sink.xml | 17 +++++++++++++++++ gr-uhd/grc/uhd_simple_source.xml | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml index b6406e80d..2992f650e 100644 --- a/gr-uhd/grc/uhd_simple_sink.xml +++ b/gr-uhd/grc/uhd_simple_sink.xml @@ -72,5 +72,22 @@ self.$(id).set_antenna($ant) $type.vlen +The UHD Sink Block: + +Args: +Args is a delimited string used to locate UHD devices on your system. \ +If left blank, the first UHD device found will be used. \ +Used args to specify a specfic device. \ +USRP2 Example: addr=192.168.10.2 + +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. + +Antenna: +For subdevices/daughterboards 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. diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml index 34b6817c9..ecd963928 100644 --- a/gr-uhd/grc/uhd_simple_source.xml +++ b/gr-uhd/grc/uhd_simple_source.xml @@ -72,5 +72,22 @@ self.$(id).set_antenna($ant) $type.vlen +The UHD Source Block: + +Args: +Args is a delimited string used to locate UHD devices on your system. \ +If left blank, the first UHD device found will be used. \ +Used args to specify a specfic device. \ +USRP2 Example: addr=192.168.10.2 + +Sample rate: +The sample rate is the number of samples per second output 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. + +Antenna: +For subdevices/daughterboards 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. -- cgit From 1e4bf239c1f09a0180585de62746922bcd34b639 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 27 Apr 2010 16:07:34 -0700 Subject: Added call to get access to the underlying uhd simple usrp object. Made the simple uhd source and sink into mostly virtual classes with the implementation within the cc files. --- gr-uhd/lib/uhd_simple_sink.cc | 161 ++++++++++++++++++--------------- gr-uhd/lib/uhd_simple_sink.h | 48 +++++----- gr-uhd/lib/uhd_simple_source.cc | 195 ++++++++++++++++++++++------------------ gr-uhd/lib/uhd_simple_source.h | 52 +++++------ 4 files changed, 245 insertions(+), 211 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index bf2b02d31..889371e91 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -22,103 +22,118 @@ #include #include -#include #include #include "utils.h" /*********************************************************************** - * Make UHD Sink + * UHD Sink **********************************************************************/ -boost::shared_ptr uhd_make_simple_sink( - const std::string &args, - const uhd::io_type_t::tid_t &type -){ - return boost::shared_ptr( - new uhd_simple_sink(args, type) - ); +uhd_simple_sink::uhd_simple_sink(gr_io_signature_sptr sig) +:gr_sync_block("uhd sink", sig, gr_make_io_signature(0, 0, 0)){ + /* NOP */ } /*********************************************************************** - * UHD Sink + * UHD Sink Impl **********************************************************************/ -uhd_simple_sink::uhd_simple_sink( - const std::string &args, - const uhd::io_type_t &type -) : gr_sync_block( - "uhd sink", - gr_make_io_signature(1, 1, type.size), - gr_make_io_signature(0, 0, 0) -), _type(type){ - _dev = uhd::usrp::simple_usrp::make(args); -} +class uhd_simple_sink_impl : public uhd_simple_sink{ +public: + uhd_simple_sink_impl( + const std::string &args, + const uhd::io_type_t &type + ) : uhd_simple_sink(gr_make_io_signature(1, 1, type.size)), _type(type) + { + _dev = uhd::usrp::simple_usrp::make(args); + } -uhd_simple_sink::~uhd_simple_sink(void){ - //NOP -} + ~uhd_simple_sink_impl(void){ + //NOP + } -void uhd_simple_sink::set_samp_rate(double rate){ - _dev->set_tx_rate(rate); - do_samp_rate_error_message(rate, get_samp_rate()); -} + void set_samp_rate(double rate){ + _dev->set_tx_rate(rate); + do_samp_rate_error_message(rate, get_samp_rate()); + } -double uhd_simple_sink::get_samp_rate(void){ - return _dev->get_tx_rate(); -} + double get_samp_rate(void){ + return _dev->get_tx_rate(); + } -uhd::tune_result_t uhd_simple_sink::set_center_freq(double freq){ - return _dev->set_tx_freq(freq); -} + uhd::tune_result_t set_center_freq(double freq){ + return _dev->set_tx_freq(freq); + } -uhd::freq_range_t uhd_simple_sink::get_freq_range(void){ - return _dev->get_tx_freq_range(); -} + uhd::freq_range_t get_freq_range(void){ + return _dev->get_tx_freq_range(); + } -void uhd_simple_sink::set_gain(float gain){ - return _dev->set_tx_gain(gain); -} + void set_gain(float gain){ + return _dev->set_tx_gain(gain); + } -float uhd_simple_sink::get_gain(void){ - return _dev->get_tx_gain(); -} + float get_gain(void){ + return _dev->get_tx_gain(); + } -uhd::gain_range_t uhd_simple_sink::get_gain_range(void){ - return _dev->get_tx_gain_range(); -} + uhd::gain_range_t get_gain_range(void){ + return _dev->get_tx_gain_range(); + } -void uhd_simple_sink::set_antenna(const std::string &ant){ - return _dev->set_tx_antenna(ant); -} + void set_antenna(const std::string &ant){ + return _dev->set_tx_antenna(ant); + } -std::string uhd_simple_sink::get_antenna(void){ - return _dev->get_tx_antenna(); -} + std::string get_antenna(void){ + return _dev->get_tx_antenna(); + } -std::vector uhd_simple_sink::get_antennas(void){ - return _dev->get_tx_antennas(); -} + std::vector get_antennas(void){ + return _dev->get_tx_antennas(); + } /*********************************************************************** * Work **********************************************************************/ -int uhd_simple_sink::work( - int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items -){ - size_t total_items_sent = 0; - uhd::tx_metadata_t metadata; - metadata.start_of_burst = true; - - //call until the input items are all sent - while(total_items_sent < size_t(noutput_items)){ - size_t items_sent = _dev->get_device()->send( - boost::asio::buffer( - (uint8_t *)input_items[0]+(total_items_sent*_type.size), - (noutput_items-total_items_sent)*_type.size - ), metadata, _type - ); - total_items_sent += items_sent; + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ){ + size_t total_items_sent = 0; + uhd::tx_metadata_t metadata; + metadata.start_of_burst = true; + + //call until the input items are all sent + while(total_items_sent < size_t(noutput_items)){ + size_t items_sent = _dev->get_device()->send( + boost::asio::buffer( + (uint8_t *)input_items[0]+(total_items_sent*_type.size), + (noutput_items-total_items_sent)*_type.size + ), metadata, _type + ); + total_items_sent += items_sent; + } + + return noutput_items; } - return noutput_items; + uhd::usrp::simple_usrp::sptr get_device(void){ + return _dev; + } + +protected: + uhd::usrp::simple_usrp::sptr _dev; + const uhd::io_type_t _type; +}; + +/*********************************************************************** + * Make UHD Sink + **********************************************************************/ +boost::shared_ptr uhd_make_simple_sink( + const std::string &args, + const uhd::io_type_t::tid_t &type +){ + return boost::shared_ptr( + new uhd_simple_sink_impl(args, type) + ); } diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index 0229e38ca..9ecf51aea 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -28,85 +28,87 @@ class uhd_simple_sink; -boost::shared_ptr -uhd_make_simple_sink(const std::string &args, const uhd::io_type_t::tid_t &type); +boost::shared_ptr uhd_make_simple_sink( + const std::string &args, + const uhd::io_type_t::tid_t &type +); class uhd_simple_sink : public gr_sync_block{ public: - uhd_simple_sink(const std::string &args, const uhd::io_type_t &type); - ~uhd_simple_sink(void); + + /*! + * Set the IO signature for this block. + * \param sig the input signature + */ + uhd_simple_sink(gr_io_signature_sptr sig); /*! * Set the sample rate for the usrp device. * \param rate a new rate in Sps */ - void set_samp_rate(double rate); + 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 */ - double get_samp_rate(void); + virtual double get_samp_rate(void) = 0; /*! * Tune the usrp device to the desired center frequency. * \param freq the desired frequency in Hz * \return a tune result with the actual frequencies */ - uhd::tune_result_t set_center_freq(double freq); + virtual uhd::tune_result_t set_center_freq(double freq) = 0; /*! * Get the tunable frequency range. * \return the frequency range in Hz */ - uhd::freq_range_t get_freq_range(void); + virtual uhd::freq_range_t get_freq_range(void) = 0; /*! * Set the gain for the dboard. * \param gain the gain in dB */ - void set_gain(float gain); + virtual void set_gain(float gain) = 0; /*! * Get the actual dboard gain setting. * \return the actual gain in dB */ - float get_gain(void); + virtual float get_gain(void) = 0; /*! * Get the settable gain range. * \return the gain range in dB */ - uhd::gain_range_t get_gain_range(void); + virtual uhd::gain_range_t get_gain_range(void) = 0; /*! * Set the antenna to use. * \param ant the antenna string */ - void set_antenna(const std::string &ant); + virtual void set_antenna(const std::string &ant) = 0; /*! * Get the antenna in use. * \return the antenna string */ - std::string get_antenna(void); + virtual std::string get_antenna(void) = 0; /*! * Get a list of possible antennas. * \return a vector of antenna strings */ - std::vector get_antennas(void); + virtual std::vector get_antennas(void) = 0; - int work( - int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items - ); - -protected: - uhd::usrp::simple_usrp::sptr _dev; - const uhd::io_type_t _type; + /*! + * Get access to the underlying uhd device object. + * \return the simple usrp device object + */ + virtual uhd::usrp::simple_usrp::sptr get_device(void) = 0; }; #endif /* INCLUDED_UHD_SIMPLE_SINK_H */ diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index e63fe9647..8c3fdeef8 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -26,115 +26,132 @@ #include "utils.h" /*********************************************************************** - * Make UHD Source + * UHD Source **********************************************************************/ -boost::shared_ptr uhd_make_simple_source( - const std::string &args, - const uhd::io_type_t::tid_t &type -){ - return boost::shared_ptr( - new uhd_simple_source(args, type) - ); +uhd_simple_source::uhd_simple_source(gr_io_signature_sptr sig) +:gr_sync_block("uhd source", gr_make_io_signature(0, 0, 0), sig){ + /* NOP */ } /*********************************************************************** - * UHD Source + * UHD Source Impl **********************************************************************/ -uhd_simple_source::uhd_simple_source( - const std::string &args, - const uhd::io_type_t &type -) : gr_sync_block( - "uhd source", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(1, 1, type.size) -), _type(type){ - _dev = uhd::usrp::simple_usrp::make(args); - - set_streaming(false); -} - -uhd_simple_source::~uhd_simple_source(void){ - set_streaming(false); -} +class uhd_simple_source_impl : public uhd_simple_source{ +public: + uhd_simple_source_impl( + const std::string &args, + const uhd::io_type_t &type + ) : uhd_simple_source(gr_make_io_signature(1, 1, type.size)), _type(type) + { + _dev = uhd::usrp::simple_usrp::make(args); + set_streaming(false); + } -void uhd_simple_source::set_streaming(bool enb){ - if (enb) - _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); - else - _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); - _is_streaming = enb; -} + ~uhd_simple_source_impl(void){ + set_streaming(false); + } -void uhd_simple_source::set_samp_rate(double rate){ - _dev->set_rx_rate(rate); - do_samp_rate_error_message(rate, get_samp_rate()); -} + void set_samp_rate(double rate){ + _dev->set_rx_rate(rate); + do_samp_rate_error_message(rate, get_samp_rate()); + } -double uhd_simple_source::get_samp_rate(void){ - return _dev->get_rx_rate(); -} + double get_samp_rate(void){ + return _dev->get_rx_rate(); + } -uhd::tune_result_t uhd_simple_source::set_center_freq(double freq){ - return _dev->set_rx_freq(freq); -} + uhd::tune_result_t set_center_freq(double freq){ + return _dev->set_rx_freq(freq); + } -uhd::freq_range_t uhd_simple_source::get_freq_range(void){ - return _dev->get_rx_freq_range(); -} + uhd::freq_range_t get_freq_range(void){ + return _dev->get_rx_freq_range(); + } -void uhd_simple_source::set_gain(float gain){ - return _dev->set_rx_gain(gain); -} + void set_gain(float gain){ + return _dev->set_rx_gain(gain); + } -float uhd_simple_source::get_gain(void){ - return _dev->get_rx_gain(); -} + float get_gain(void){ + return _dev->get_rx_gain(); + } -uhd::gain_range_t uhd_simple_source::get_gain_range(void){ - return _dev->get_rx_gain_range(); -} + uhd::gain_range_t get_gain_range(void){ + return _dev->get_rx_gain_range(); + } -void uhd_simple_source::set_antenna(const std::string &ant){ - return _dev->set_rx_antenna(ant); -} + void set_antenna(const std::string &ant){ + return _dev->set_rx_antenna(ant); + } -std::string uhd_simple_source::get_antenna(void){ - return _dev->get_rx_antenna(); -} + std::string get_antenna(void){ + return _dev->get_rx_antenna(); + } -std::vector uhd_simple_source::get_antennas(void){ - return _dev->get_rx_antennas(); -} + std::vector get_antennas(void){ + return _dev->get_rx_antennas(); + } /*********************************************************************** * Work **********************************************************************/ -int uhd_simple_source::work( - int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items -){ - //conditionally start streaming in the work call - //this prevents streaming before the runtime is ready - if (not _is_streaming) set_streaming(true); - - size_t total_items_read = 0; - uhd::rx_metadata_t metadata; - - //call until the output items are all filled - //or an exit condition below is encountered - while(total_items_read < size_t(noutput_items)){ - size_t items_read = _dev->get_device()->recv( - boost::asio::buffer( - (uint8_t *)output_items[0]+(total_items_read*_type.size), - (noutput_items-total_items_read)*_type.size - ), metadata, _type - ); - total_items_read += items_read; - - //we timed out, get out of here - if (items_read == 0) break; + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ){ + //conditionally start streaming in the work call + //this prevents streaming before the runtime is ready + if (not _is_streaming) set_streaming(true); + + size_t total_items_read = 0; + uhd::rx_metadata_t metadata; + + //call until the output items are all filled + //or an exit condition below is encountered + while(total_items_read < size_t(noutput_items)){ + size_t items_read = _dev->get_device()->recv( + boost::asio::buffer( + (uint8_t *)output_items[0]+(total_items_read*_type.size), + (noutput_items-total_items_read)*_type.size + ), metadata, _type + ); + total_items_read += items_read; + + //we timed out, get out of here + if (items_read == 0) break; + } + + return total_items_read; + } + + uhd::usrp::simple_usrp::sptr get_device(void){ + return _dev; } - return total_items_read; +private: + uhd::usrp::simple_usrp::sptr _dev; + const uhd::io_type_t _type; + bool _is_streaming; + + void set_streaming(bool enb){ + if (enb) + _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); + else + _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); + _is_streaming = enb; + } +}; + + +/*********************************************************************** + * Make UHD Source + **********************************************************************/ +boost::shared_ptr uhd_make_simple_source( + const std::string &args, + const uhd::io_type_t::tid_t &type +){ + return boost::shared_ptr( + new uhd_simple_source_impl(args, type) + ); } diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index 7d286f09c..480bb4d3f 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -28,87 +28,87 @@ class uhd_simple_source; -boost::shared_ptr -uhd_make_simple_source(const std::string &args, const uhd::io_type_t::tid_t &type); +boost::shared_ptr uhd_make_simple_source( + const std::string &args, + const uhd::io_type_t::tid_t &type +); class uhd_simple_source : public gr_sync_block{ public: - uhd_simple_source(const std::string &args, const uhd::io_type_t &type); - ~uhd_simple_source(void); + + /*! + * Set the IO signature for this block. + * \param sig the output signature + */ + uhd_simple_source(gr_io_signature_sptr sig); /*! * Set the sample rate for the usrp device. * \param rate a new rate in Sps */ - void set_samp_rate(double rate); + 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 */ - double get_samp_rate(void); + virtual double get_samp_rate(void) = 0; /*! * Tune the usrp device to the desired center frequency. * \param freq the desired frequency in Hz * \return a tune result with the actual frequencies */ - uhd::tune_result_t set_center_freq(double freq); + virtual uhd::tune_result_t set_center_freq(double freq) = 0; /*! * Get the tunable frequency range. * \return the frequency range in Hz */ - uhd::freq_range_t get_freq_range(void); + virtual uhd::freq_range_t get_freq_range(void) = 0; /*! * Set the gain for the dboard. * \param gain the gain in dB */ - void set_gain(float gain); + virtual void set_gain(float gain) = 0; /*! * Get the actual dboard gain setting. * \return the actual gain in dB */ - float get_gain(void); + virtual float get_gain(void) = 0; /*! * Get the settable gain range. * \return the gain range in dB */ - uhd::gain_range_t get_gain_range(void); + virtual uhd::gain_range_t get_gain_range(void) = 0; /*! * Set the antenna to use. * \param ant the antenna string */ - void set_antenna(const std::string &ant); + virtual void set_antenna(const std::string &ant) = 0; /*! * Get the antenna in use. * \return the antenna string */ - std::string get_antenna(void); + virtual std::string get_antenna(void) = 0; /*! * Get a list of possible antennas. * \return a vector of antenna strings */ - std::vector get_antennas(void); - - int work( - int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items - ); - -protected: - uhd::usrp::simple_usrp::sptr _dev; - const uhd::io_type_t _type; - bool _is_streaming; - void set_streaming(bool enb); + virtual std::vector get_antennas(void) = 0; + + /*! + * Get access to the underlying uhd device object. + * \return the simple usrp device object + */ + virtual uhd::usrp::simple_usrp::sptr get_device(void) = 0; }; #endif /* INCLUDED_UHD_SIMPLE_SOURCE_H */ -- cgit From 2c4bb0b5ea22ed73f3de6cac8a27083d950879bb Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 18 May 2010 12:25:42 -0700 Subject: using the send and recv full buffer modes, avoids extra loop in implementation --- gr-uhd/lib/uhd_simple_sink.cc | 25 ++++++++----------------- gr-uhd/lib/uhd_simple_source.cc | 31 +++++++++---------------------- 2 files changed, 17 insertions(+), 39 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index 889371e91..ccec0e29c 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -91,6 +91,10 @@ public: return _dev->get_tx_antennas(); } + uhd::usrp::simple_usrp::sptr get_device(void){ + return _dev; + } + /*********************************************************************** * Work **********************************************************************/ @@ -99,26 +103,13 @@ public: gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ){ - size_t total_items_sent = 0; uhd::tx_metadata_t metadata; metadata.start_of_burst = true; - //call until the input items are all sent - while(total_items_sent < size_t(noutput_items)){ - size_t items_sent = _dev->get_device()->send( - boost::asio::buffer( - (uint8_t *)input_items[0]+(total_items_sent*_type.size), - (noutput_items-total_items_sent)*_type.size - ), metadata, _type - ); - total_items_sent += items_sent; - } - - return noutput_items; - } - - uhd::usrp::simple_usrp::sptr get_device(void){ - return _dev; + return _dev->get_device()->send( + boost::asio::buffer(input_items[0], noutput_items*_type.size), + metadata, _type, uhd::device::SEND_MODE_FULL_BUFF + ); } protected: diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 8c3fdeef8..76179c326 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -92,6 +92,10 @@ public: return _dev->get_rx_antennas(); } + uhd::usrp::simple_usrp::sptr get_device(void){ + return _dev; + } + /*********************************************************************** * Work **********************************************************************/ @@ -104,29 +108,12 @@ public: //this prevents streaming before the runtime is ready if (not _is_streaming) set_streaming(true); - size_t total_items_read = 0; - uhd::rx_metadata_t metadata; - - //call until the output items are all filled - //or an exit condition below is encountered - while(total_items_read < size_t(noutput_items)){ - size_t items_read = _dev->get_device()->recv( - boost::asio::buffer( - (uint8_t *)output_items[0]+(total_items_read*_type.size), - (noutput_items-total_items_read)*_type.size - ), metadata, _type - ); - total_items_read += items_read; - - //we timed out, get out of here - if (items_read == 0) break; - } - - return total_items_read; - } + uhd::rx_metadata_t metadata; //not passed out of this block - uhd::usrp::simple_usrp::sptr get_device(void){ - return _dev; + return _dev->get_device()->recv( + boost::asio::buffer(output_items[0], noutput_items*_type.size), + metadata, _type, uhd::device::RECV_MODE_FULL_BUFF + ); } private: -- cgit From 8aea15e3a93821bdc43e9376cc27f3ab0ed48e87 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sun, 30 May 2010 23:09:57 -0700 Subject: gr-uhd: make versioned libraries --- gr-uhd/lib/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index d4363406b..2ac4cc2e6 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -37,6 +37,8 @@ libgnuradio_uhd_la_LIBADD = \ $(GNURADIO_CORE_LA) \ $(UHD_LIBS) +libgnuradio_uhd_la_LDFLAGS = $(LTVERSIONFLAGS) + grinclude_HEADERS = \ uhd_simple_source.h \ uhd_simple_sink.h -- cgit From 1e71bdae9956d64e06bdfbb0c87530619807e100 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 30 Jun 2010 10:12:02 -0700 Subject: uhd: added calls to set time and clock config --- gr-uhd/lib/uhd_simple_sink.cc | 12 ++++++++++++ gr-uhd/lib/uhd_simple_sink.h | 18 ++++++++++++++++++ gr-uhd/lib/uhd_simple_source.cc | 12 ++++++++++++ gr-uhd/lib/uhd_simple_source.h | 18 ++++++++++++++++++ gr-uhd/swig/uhd_swig.i | 2 ++ 5 files changed, 62 insertions(+) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index ccec0e29c..44f60a05f 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -91,6 +91,18 @@ public: return _dev->get_tx_antennas(); } + void set_clock_config(const uhd::clock_config_t &clock_config){ + return _dev->set_clock_config(clock_config); + } + + 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::simple_usrp::sptr get_device(void){ return _dev; } diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index 9ecf51aea..aad90d098 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -104,6 +104,24 @@ public: */ virtual std::vector get_antennas(void) = 0; + /*! + * Set the clock configuration. + * \param clock_config the new configuration + */ + virtual void set_clock_config(const uhd::clock_config_t &clock_config) = 0; + + /*! + * Set the time registers asap. + * \param time_spec the new time + */ + virtual void set_time_now(const uhd::time_spec_t &time_spec) = 0; + + /*! + * Set the time registers at the next pps. + * \param time_spec the new time + */ + virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; + /*! * Get access to the underlying uhd device object. * \return the simple usrp device object diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 76179c326..49e4f168a 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -92,6 +92,18 @@ public: return _dev->get_rx_antennas(); } + void set_clock_config(const uhd::clock_config_t &clock_config){ + return _dev->set_clock_config(clock_config); + } + + 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::simple_usrp::sptr get_device(void){ return _dev; } diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index 480bb4d3f..06e4d2431 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -104,6 +104,24 @@ public: */ virtual std::vector get_antennas(void) = 0; + /*! + * Set the clock configuration. + * \param clock_config the new configuration + */ + virtual void set_clock_config(const uhd::clock_config_t &clock_config) = 0; + + /*! + * Set the time registers asap. + * \param time_spec the new time + */ + virtual void set_time_now(const uhd::time_spec_t &time_spec) = 0; + + /*! + * Set the time registers at the next pps. + * \param time_spec the new time + */ + virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; + /*! * Get access to the underlying uhd device object. * \return the simple usrp device object diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 2642f9450..5956a686c 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -31,6 +31,8 @@ %include %include %include +%include +%include GR_SWIG_BLOCK_MAGIC(uhd,simple_source) %include -- cgit From 4e636b2b4bb29d5224aeff4ae79af121020338f1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 2 Jul 2010 18:30:31 -0700 Subject: uhd mimo: created mimo source and sink block for gr-uhd --- gr-uhd/grc/Makefile.am | 2 + gr-uhd/grc/uhd_mimo_sink.xml | 99 ++++++++++++++++++++++++++ gr-uhd/grc/uhd_mimo_source.xml | 99 ++++++++++++++++++++++++++ gr-uhd/lib/Makefile.am | 4 ++ gr-uhd/lib/uhd_mimo_sink.cc | 136 +++++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_mimo_sink.h | 129 +++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_mimo_source.cc | 154 ++++++++++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_mimo_source.h | 129 +++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_simple_sink.cc | 6 +- gr-uhd/lib/uhd_simple_source.cc | 6 +- gr-uhd/swig/uhd_swig.i | 8 +++ 11 files changed, 766 insertions(+), 6 deletions(-) create mode 100644 gr-uhd/grc/uhd_mimo_sink.xml create mode 100644 gr-uhd/grc/uhd_mimo_source.xml create mode 100644 gr-uhd/lib/uhd_mimo_sink.cc create mode 100644 gr-uhd/lib/uhd_mimo_sink.h create mode 100644 gr-uhd/lib/uhd_mimo_source.cc create mode 100644 gr-uhd/lib/uhd_mimo_source.h (limited to 'gr-uhd') diff --git a/gr-uhd/grc/Makefile.am b/gr-uhd/grc/Makefile.am index 61eb32770..cf3f77080 100644 --- a/gr-uhd/grc/Makefile.am +++ b/gr-uhd/grc/Makefile.am @@ -24,5 +24,7 @@ include $(top_srcdir)/Makefile.common grcblocksdir = $(grc_blocksdir) dist_grcblocks_DATA = \ + uhd_mimo_source.xml \ + uhd_mimo_sink.xml \ uhd_simple_source.xml \ uhd_simple_sink.xml diff --git a/gr-uhd/grc/uhd_mimo_sink.xml b/gr-uhd/grc/uhd_mimo_sink.xml new file mode 100644 index 000000000..faafbfd2f --- /dev/null +++ b/gr-uhd/grc/uhd_mimo_sink.xml @@ -0,0 +1,99 @@ + + + + UHD MIMO Sink + uhd_mimo_sink + UHD + from gnuradio import uhd + uhd.mimo_sink($nchan, $args, uhd.io_type_t.$type.type) +self.$(id).set_samp_rate_all($samp_rate) +map(lambda x: self.$(id).set_center_freq(*x), enumerate($center_freqs)) +map(lambda x: self.$(id).set_gain(*x), enumerate($gains)) +#if $ants() +map(lambda x: self.$(id).set_antenna(*x), enumerate($ants)) +#end if + set_samp_rate($samp_rate) + + Input Type + type + enum + + + + + Num Channels + nchan + 2 + int + + + Args + args + addr=192.168.10.2 192.168.20.2 + string + + + Samp Rate (Sps) + samp_rate + samp_rate + real + + + Center Freqs (Hz) + center_freqs + 0, 0 + real_vector + + + Gains (dB) + gains + 0, 0 + real_vector + + + Antennas + ants + ['RX2', 'RX2'] + raw + #if not $ants() then 'part' else 'none'# + + + out + $type + $type.vlen + $nchan + + +The UHD Sink Block: + +Args: +Args is a delimited string used to locate UHD devices on your system. \ +If left blank, the first UHD device found will be used. \ +Used args to specify a specfic device. \ +USRP2 Example: addr=192.168.10.2 + +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. + +Antenna: +For subdevices/daughterboards 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. + + diff --git a/gr-uhd/grc/uhd_mimo_source.xml b/gr-uhd/grc/uhd_mimo_source.xml new file mode 100644 index 000000000..1cffa62cc --- /dev/null +++ b/gr-uhd/grc/uhd_mimo_source.xml @@ -0,0 +1,99 @@ + + + + UHD MIMO Source + uhd_mimo_source + UHD + from gnuradio import uhd + uhd.mimo_source($nchan, $args, uhd.io_type_t.$type.type) +self.$(id).set_samp_rate_all($samp_rate) +map(lambda x: self.$(id).set_center_freq(*x), enumerate($center_freqs)) +map(lambda x: self.$(id).set_gain(*x), enumerate($gains)) +#if $ants() +map(lambda x: self.$(id).set_antenna(*x), enumerate($ants)) +#end if + set_samp_rate($samp_rate) + + Output Type + type + enum + + + + + Num Channels + nchan + 2 + int + + + Args + args + addr=192.168.10.2 192.168.20.2 + string + + + Samp Rate (Sps) + samp_rate + samp_rate + real + + + Center Freqs (Hz) + center_freqs + 0, 0 + real_vector + + + Gains (dB) + gains + 0, 0 + real_vector + + + Antennas + ants + ['RX2', 'RX2'] + raw + #if not $ants() then 'part' else 'none'# + + + out + $type + $type.vlen + $nchan + + +The UHD Source Block: + +Args: +Args is a delimited string used to locate UHD devices on your system. \ +If left blank, the first UHD device found will be used. \ +Used args to specify a specfic device. \ +USRP2 Example: addr=192.168.10.2 + +Sample rate: +The sample rate is the number of samples per second output 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. + +Antenna: +For subdevices/daughterboards 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. + + diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index 2ac4cc2e6..8aae63326 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -30,6 +30,8 @@ lib_LTLIBRARIES = libgnuradio-uhd.la libgnuradio_uhd_la_SOURCES = \ utils.cc \ + uhd_mimo_source.cc \ + uhd_mimo_sink.cc \ uhd_simple_source.cc \ uhd_simple_sink.cc @@ -40,6 +42,8 @@ libgnuradio_uhd_la_LIBADD = \ libgnuradio_uhd_la_LDFLAGS = $(LTVERSIONFLAGS) grinclude_HEADERS = \ + uhd_mimo_source.h \ + uhd_mimo_sink.h \ uhd_simple_source.h \ uhd_simple_sink.h diff --git a/gr-uhd/lib/uhd_mimo_sink.cc b/gr-uhd/lib/uhd_mimo_sink.cc new file mode 100644 index 000000000..9226d6004 --- /dev/null +++ b/gr-uhd/lib/uhd_mimo_sink.cc @@ -0,0 +1,136 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include "utils.h" + +/*********************************************************************** + * UHD Sink + **********************************************************************/ +uhd_mimo_sink::uhd_mimo_sink(gr_io_signature_sptr sig) +:gr_sync_block("uhd mimo sink", sig, gr_make_io_signature(0, 0, 0)){ + /* NOP */ +} + +/*********************************************************************** + * UHD Sink Impl + **********************************************************************/ +class uhd_mimo_sink_impl : public uhd_mimo_sink{ +public: + uhd_mimo_sink_impl( + size_t num_channels, + const std::string &args, + const uhd::io_type_t &type + ) : uhd_mimo_sink(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) + { + _dev = uhd::usrp::mimo_usrp::make(args); + } + + ~uhd_mimo_sink_impl(void){ + //NOP + } + + void set_samp_rate_all(double rate){ + _dev->set_tx_rate_all(rate); + do_samp_rate_error_message(rate, get_samp_rate_all()); + } + + double get_samp_rate_all(void){ + return _dev->get_tx_rate_all(); + } + + uhd::tune_result_t set_center_freq(size_t chan, double freq){ + return _dev->set_tx_freq(chan, freq); + } + + uhd::freq_range_t get_freq_range(size_t chan){ + return _dev->get_tx_freq_range(chan); + } + + void set_gain(size_t chan, float gain){ + return _dev->set_tx_gain(chan, gain); + } + + float get_gain(size_t chan){ + return _dev->get_tx_gain(chan); + } + + uhd::gain_range_t get_gain_range(size_t chan){ + return _dev->get_tx_gain_range(chan); + } + + void set_antenna(size_t chan, const std::string &ant){ + return _dev->set_tx_antenna(chan, ant); + } + + 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_time_next_pps(const uhd::time_spec_t &time_spec){ + return _dev->set_time_next_pps(time_spec); + } + + uhd::usrp::mimo_usrp::sptr get_device(void){ + return _dev; + } + +/*********************************************************************** + * Work + **********************************************************************/ + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ){ + uhd::tx_metadata_t metadata; + metadata.start_of_burst = true; + + return _dev->get_device()->send( + input_items, noutput_items, metadata, + _type, uhd::device::SEND_MODE_FULL_BUFF + ); + } + +protected: + uhd::usrp::mimo_usrp::sptr _dev; + const uhd::io_type_t _type; +}; + +/*********************************************************************** + * Make UHD Sink + **********************************************************************/ +boost::shared_ptr uhd_make_mimo_sink( + size_t num_channels, + const std::string &args, + const uhd::io_type_t::tid_t &type +){ + return boost::shared_ptr( + new uhd_mimo_sink_impl(num_channels, args, type) + ); +} diff --git a/gr-uhd/lib/uhd_mimo_sink.h b/gr-uhd/lib/uhd_mimo_sink.h new file mode 100644 index 000000000..280f7c0e8 --- /dev/null +++ b/gr-uhd/lib/uhd_mimo_sink.h @@ -0,0 +1,129 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_UHD_MIMO_SINK_H +#define INCLUDED_UHD_MIMO_SINK_H + +#include +#include + +class uhd_mimo_sink; + +boost::shared_ptr uhd_make_mimo_sink( + size_t num_channels, + const std::string &args, + const uhd::io_type_t::tid_t &type +); + +class uhd_mimo_sink : public gr_sync_block{ +public: + + /*! + * Set the IO signature for this block. + * \param sig the input signature + */ + uhd_mimo_sink(gr_io_signature_sptr sig); + + /*! + * Set the sample rate for the usrp device (across all mboards). + * \param rate a new rate in Sps + */ + virtual void set_samp_rate_all(double rate) = 0; + + /*! + * Get the sample rate for the usrp device (across all mboards). + * This is the actual sample rate and may differ from the rate set. + * \return the actual rate in Sps + */ + virtual double get_samp_rate_all(void) = 0; + + /*! + * Tune the usrp device to the desired center frequency. + * \param chan the channel number from 0 to N-1 + * \param freq the desired frequency in Hz + * \return a tune result with the actual frequencies + */ + virtual uhd::tune_result_t set_center_freq(size_t chan, double freq) = 0; + + /*! + * Get the tunable frequency range. + * \param chan the channel number from 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 chan the channel number from 0 to N-1 + * \param gain the gain in dB + */ + virtual void set_gain(size_t chan, float gain) = 0; + + /*! + * Get the actual dboard gain setting. + * \param chan the channel number from 0 to N-1 + * \return the actual gain in dB + */ + virtual float get_gain(size_t chan) = 0; + + /*! + * Get the settable gain range. + * \param chan the channel number from 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 chan the channel number from 0 to N-1 + * \param ant the antenna string + */ + virtual void set_antenna(size_t chan, const std::string &ant) = 0; + + /*! + * Get the antenna in use. + * \param chan the channel number from 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 number from 0 to N-1 + * \return a vector of antenna strings + */ + virtual std::vector get_antennas(size_t chan) = 0; + + /*! + * Set the time registers at the next pps (across all mboards). + * \param time_spec the new time + */ + virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; + + /*! + * Get access to the underlying uhd device object. + * \return the mimo usrp device object + */ + virtual uhd::usrp::mimo_usrp::sptr get_device(void) = 0; +}; + +#endif /* INCLUDED_UHD_MIMO_SINK_H */ diff --git a/gr-uhd/lib/uhd_mimo_source.cc b/gr-uhd/lib/uhd_mimo_source.cc new file mode 100644 index 000000000..bcd6aa695 --- /dev/null +++ b/gr-uhd/lib/uhd_mimo_source.cc @@ -0,0 +1,154 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include "utils.h" + +/*********************************************************************** + * UHD Source + **********************************************************************/ +uhd_mimo_source::uhd_mimo_source(gr_io_signature_sptr sig) +:gr_sync_block("uhd mimo source", gr_make_io_signature(0, 0, 0), sig){ + /* NOP */ +} + +/*********************************************************************** + * UHD Source Impl + **********************************************************************/ +class uhd_mimo_source_impl : public uhd_mimo_source{ +public: + uhd_mimo_source_impl( + size_t num_channels, + const std::string &args, + const uhd::io_type_t &type + ) : uhd_mimo_source(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) + { + _dev = uhd::usrp::mimo_usrp::make(args); + set_streaming(false); + } + + ~uhd_mimo_source_impl(void){ + //NOP + } + + void set_samp_rate_all(double rate){ + _dev->set_rx_rate_all(rate); + do_samp_rate_error_message(rate, get_samp_rate_all()); + } + + double get_samp_rate_all(void){ + return _dev->get_rx_rate_all(); + } + + uhd::tune_result_t set_center_freq(size_t chan, double freq){ + return _dev->set_rx_freq(chan, freq); + } + + uhd::freq_range_t get_freq_range(size_t chan){ + return _dev->get_rx_freq_range(chan); + } + + void set_gain(size_t chan, float gain){ + return _dev->set_rx_gain(chan, gain); + } + + float get_gain(size_t chan){ + return _dev->get_rx_gain(chan); + } + + uhd::gain_range_t get_gain_range(size_t chan){ + return _dev->get_rx_gain_range(chan); + } + + void set_antenna(size_t chan, const std::string &ant){ + return _dev->set_rx_antenna(chan, ant); + } + + 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_time_next_pps(const uhd::time_spec_t &time_spec){ + return _dev->set_time_next_pps(time_spec); + } + + uhd::usrp::mimo_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 + ){ + //conditionally start streaming in the work call + //this prevents streaming before the runtime is ready + if (not _is_streaming) set_streaming(true); + + uhd::rx_metadata_t metadata; //not passed out of this block + + return _dev->get_device()->recv( + output_items, noutput_items, metadata, + _type, uhd::device::RECV_MODE_FULL_BUFF + ); + } + +protected: + uhd::usrp::mimo_usrp::sptr _dev; + const uhd::io_type_t _type; + bool _is_streaming; + + void set_streaming(bool enb){ + if (enb){ //FIXME TODO handle this better + uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); + stream_cmd.stream_now = false; + stream_cmd.time_spec = uhd::time_spec_t(1, 0); + _dev->issue_stream_cmd(stream_cmd); + sleep(1); + } + else + _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); + _is_streaming = enb; + } +}; + +/*********************************************************************** + * Make UHD Source + **********************************************************************/ +boost::shared_ptr uhd_make_mimo_source( + size_t num_channels, + const std::string &args, + const uhd::io_type_t::tid_t &type +){ + return boost::shared_ptr( + new uhd_mimo_source_impl(num_channels, args, type) + ); +} diff --git a/gr-uhd/lib/uhd_mimo_source.h b/gr-uhd/lib/uhd_mimo_source.h new file mode 100644 index 000000000..916f50972 --- /dev/null +++ b/gr-uhd/lib/uhd_mimo_source.h @@ -0,0 +1,129 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_UHD_MIMO_SOURCE_H +#define INCLUDED_UHD_MIMO_SOURCE_H + +#include +#include + +class uhd_mimo_source; + +boost::shared_ptr uhd_make_mimo_source( + size_t num_channels, + const std::string &args, + const uhd::io_type_t::tid_t &type +); + +class uhd_mimo_source : public gr_sync_block{ +public: + + /*! + * Set the IO signature for this block. + * \param sig the output signature + */ + uhd_mimo_source(gr_io_signature_sptr sig); + + /*! + * Set the sample rate for the usrp device (across all mboards). + * \param rate a new rate in Sps + */ + virtual void set_samp_rate_all(double rate) = 0; + + /*! + * Get the sample rate for the usrp device (across all mboards). + * This is the actual sample rate and may differ from the rate set. + * \return the actual rate in Sps + */ + virtual double get_samp_rate_all(void) = 0; + + /*! + * Tune the usrp device to the desired center frequency. + * \param chan the channel number from 0 to N-1 + * \param freq the desired frequency in Hz + * \return a tune result with the actual frequencies + */ + virtual uhd::tune_result_t set_center_freq(size_t chan, double freq) = 0; + + /*! + * Get the tunable frequency range. + * \param chan the channel number from 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 chan the channel number from 0 to N-1 + * \param gain the gain in dB + */ + virtual void set_gain(size_t chan, float gain) = 0; + + /*! + * Get the actual dboard gain setting. + * \param chan the channel number from 0 to N-1 + * \return the actual gain in dB + */ + virtual float get_gain(size_t chan) = 0; + + /*! + * Get the settable gain range. + * \param chan the channel number from 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 chan the channel number from 0 to N-1 + * \param ant the antenna string + */ + virtual void set_antenna(size_t chan, const std::string &ant) = 0; + + /*! + * Get the antenna in use. + * \param chan the channel number from 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 number from 0 to N-1 + * \return a vector of antenna strings + */ + virtual std::vector get_antennas(size_t chan) = 0; + + /*! + * Set the time registers at the next pps (across all mboards). + * \param time_spec the new time + */ + virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; + + /*! + * Get access to the underlying uhd device object. + * \return the mimo usrp device object + */ + virtual uhd::usrp::mimo_usrp::sptr get_device(void) = 0; +}; + +#endif /* INCLUDED_UHD_MIMO_SOURCE_H */ diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index 44f60a05f..1443490cd 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -29,7 +29,7 @@ * UHD Sink **********************************************************************/ uhd_simple_sink::uhd_simple_sink(gr_io_signature_sptr sig) -:gr_sync_block("uhd sink", sig, gr_make_io_signature(0, 0, 0)){ +:gr_sync_block("uhd simple sink", sig, gr_make_io_signature(0, 0, 0)){ /* NOP */ } @@ -119,8 +119,8 @@ public: metadata.start_of_burst = true; return _dev->get_device()->send( - boost::asio::buffer(input_items[0], noutput_items*_type.size), - metadata, _type, uhd::device::SEND_MODE_FULL_BUFF + input_items, noutput_items, metadata, + _type, uhd::device::SEND_MODE_FULL_BUFF ); } diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 49e4f168a..c680aa313 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -29,7 +29,7 @@ * UHD Source **********************************************************************/ uhd_simple_source::uhd_simple_source(gr_io_signature_sptr sig) -:gr_sync_block("uhd source", gr_make_io_signature(0, 0, 0), sig){ +:gr_sync_block("uhd simple source", gr_make_io_signature(0, 0, 0), sig){ /* NOP */ } @@ -123,8 +123,8 @@ public: uhd::rx_metadata_t metadata; //not passed out of this block return _dev->get_device()->recv( - boost::asio::buffer(output_items[0], noutput_items*_type.size), - metadata, _type, uhd::device::RECV_MODE_FULL_BUFF + output_items, noutput_items, metadata, + _type, uhd::device::RECV_MODE_FULL_BUFF ); } diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 5956a686c..34e140887 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -23,6 +23,8 @@ %include "gnuradio.i" %{ +#include +#include #include #include %} @@ -34,6 +36,12 @@ %include %include +GR_SWIG_BLOCK_MAGIC(uhd,mimo_source) +%include + +GR_SWIG_BLOCK_MAGIC(uhd,mimo_sink) +%include + GR_SWIG_BLOCK_MAGIC(uhd,simple_source) %include -- cgit From 26cf4db8892b43ff8c085589c2fefe2a8e228dde Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 4 Jul 2010 20:22:35 -0700 Subject: uhd: added call to readback time registers, work on locking clocks in mimo config --- gr-uhd/lib/uhd_mimo_sink.cc | 4 ++++ gr-uhd/lib/uhd_mimo_sink.h | 6 ++++++ gr-uhd/lib/uhd_mimo_source.cc | 33 +++++++++++++++++++++++++++++---- gr-uhd/lib/uhd_mimo_source.h | 6 ++++++ gr-uhd/lib/uhd_simple_sink.cc | 4 ++++ gr-uhd/lib/uhd_simple_sink.h | 6 ++++++ gr-uhd/lib/uhd_simple_source.cc | 4 ++++ gr-uhd/lib/uhd_simple_source.h | 6 ++++++ 8 files changed, 65 insertions(+), 4 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_mimo_sink.cc b/gr-uhd/lib/uhd_mimo_sink.cc index 9226d6004..6d603d7bc 100644 --- a/gr-uhd/lib/uhd_mimo_sink.cc +++ b/gr-uhd/lib/uhd_mimo_sink.cc @@ -92,6 +92,10 @@ public: return _dev->get_tx_antennas(chan); } + 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); } diff --git a/gr-uhd/lib/uhd_mimo_sink.h b/gr-uhd/lib/uhd_mimo_sink.h index 280f7c0e8..951980908 100644 --- a/gr-uhd/lib/uhd_mimo_sink.h +++ b/gr-uhd/lib/uhd_mimo_sink.h @@ -113,6 +113,12 @@ public: */ virtual std::vector get_antennas(size_t chan) = 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 (across all mboards). * \param time_spec the new time diff --git a/gr-uhd/lib/uhd_mimo_source.cc b/gr-uhd/lib/uhd_mimo_source.cc index bcd6aa695..fb811572b 100644 --- a/gr-uhd/lib/uhd_mimo_source.cc +++ b/gr-uhd/lib/uhd_mimo_source.cc @@ -46,10 +46,11 @@ public: { _dev = uhd::usrp::mimo_usrp::make(args); set_streaming(false); + sync_times(); //TODO may want option to disable this } ~uhd_mimo_source_impl(void){ - //NOP + set_streaming(false); } void set_samp_rate_all(double rate){ @@ -93,6 +94,10 @@ public: return _dev->get_rx_antennas(chan); } + 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); } @@ -126,13 +131,33 @@ protected: const uhd::io_type_t _type; bool _is_streaming; + void sync_times(void){ + //set the times to zero at the next pps and sleep (race condition) + set_time_next_pps(uhd::time_spec_t(0, 0)); sleep(1); + + //catch the seconds rollover at the next pps + double last_frac_secs = 0.0, curr_frac_secs = 0.0; + while(curr_frac_secs > last_frac_secs){ + last_frac_secs = curr_frac_secs; + curr_frac_secs = get_time_now().get_frac_secs(); + } + + //set the times to zero at the next pps and sleep (all boards synced) + set_time_next_pps(uhd::time_spec_t(0, 0)); sleep(1); + } + void set_streaming(bool enb){ - if (enb){ //FIXME TODO handle this better + if (enb){ + //make an estimate of the trip time + uhd::time_spec_t time1 = get_time_now(); + uhd::time_spec_t time2 = get_time_now(); + double rtt = 2*(time2 - time1).get_real_secs(); + + //setup a stream command that starts streaming slightly in the future uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); stream_cmd.stream_now = false; - stream_cmd.time_spec = uhd::time_spec_t(1, 0); + stream_cmd.time_spec = time2 + uhd::time_spec_t(0, (_dev->get_num_channels()+1)*rtt); _dev->issue_stream_cmd(stream_cmd); - sleep(1); } else _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); diff --git a/gr-uhd/lib/uhd_mimo_source.h b/gr-uhd/lib/uhd_mimo_source.h index 916f50972..e234779df 100644 --- a/gr-uhd/lib/uhd_mimo_source.h +++ b/gr-uhd/lib/uhd_mimo_source.h @@ -113,6 +113,12 @@ public: */ virtual std::vector get_antennas(size_t chan) = 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 (across all mboards). * \param time_spec the new time diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index 1443490cd..d4bb7d437 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -95,6 +95,10 @@ public: 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); } diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index aad90d098..7f1596259 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -110,6 +110,12 @@ public: */ 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 diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index c680aa313..c734e9244 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -96,6 +96,10 @@ public: 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); } diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index 06e4d2431..8568fc2d4 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -110,6 +110,12 @@ public: */ 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 -- cgit From 2a43a733070da86cc321b2ae98c88951933e7b4a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 6 Jul 2010 15:45:30 -0700 Subject: uhd: mimo source and sink, stream in future, and lock the clocks --- gr-uhd/lib/uhd_mimo_sink.cc | 25 ++++++++++++++++++++----- gr-uhd/lib/uhd_mimo_source.cc | 24 ++---------------------- 2 files changed, 22 insertions(+), 27 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_mimo_sink.cc b/gr-uhd/lib/uhd_mimo_sink.cc index 6d603d7bc..43ec04164 100644 --- a/gr-uhd/lib/uhd_mimo_sink.cc +++ b/gr-uhd/lib/uhd_mimo_sink.cc @@ -44,7 +44,9 @@ public: const uhd::io_type_t &type ) : uhd_mimo_sink(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) { + _first_run = false; _dev = uhd::usrp::mimo_usrp::make(args); + _dev->set_time_unknown_pps(uhd::time_spec_t()); //TODO may want option to disable this } ~uhd_mimo_sink_impl(void){ @@ -112,18 +114,31 @@ public: gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ){ - uhd::tx_metadata_t metadata; - metadata.start_of_burst = true; - - return _dev->get_device()->send( - input_items, noutput_items, metadata, + //init the metadata on the first call to work + //and set the timespec with the current time + some offset + if (not _first_run){ + _first_run = true; + _metadata.start_of_burst = true; + _metadata.has_time_spec = true; + _metadata.time_spec = get_time_now() + uhd::time_spec_t(0, 0.01); //10ms offset in future + } + + //call to send with metadata slightly in the future (send-at) + size_t num_sent = _dev->get_device()->send( + input_items, noutput_items, _metadata, _type, uhd::device::SEND_MODE_FULL_BUFF ); + + //increment the send-at time by the number of samples sent + _metadata.time_spec += uhd::time_spec_t(0, num_sent, get_samp_rate_all()); + return num_sent; } protected: uhd::usrp::mimo_usrp::sptr _dev; const uhd::io_type_t _type; + uhd::tx_metadata_t _metadata; + bool _first_run; }; /*********************************************************************** diff --git a/gr-uhd/lib/uhd_mimo_source.cc b/gr-uhd/lib/uhd_mimo_source.cc index fb811572b..28bd1e109 100644 --- a/gr-uhd/lib/uhd_mimo_source.cc +++ b/gr-uhd/lib/uhd_mimo_source.cc @@ -46,7 +46,7 @@ public: { _dev = uhd::usrp::mimo_usrp::make(args); set_streaming(false); - sync_times(); //TODO may want option to disable this + _dev->set_time_unknown_pps(uhd::time_spec_t()); //TODO may want option to disable this } ~uhd_mimo_source_impl(void){ @@ -131,32 +131,12 @@ protected: const uhd::io_type_t _type; bool _is_streaming; - void sync_times(void){ - //set the times to zero at the next pps and sleep (race condition) - set_time_next_pps(uhd::time_spec_t(0, 0)); sleep(1); - - //catch the seconds rollover at the next pps - double last_frac_secs = 0.0, curr_frac_secs = 0.0; - while(curr_frac_secs > last_frac_secs){ - last_frac_secs = curr_frac_secs; - curr_frac_secs = get_time_now().get_frac_secs(); - } - - //set the times to zero at the next pps and sleep (all boards synced) - set_time_next_pps(uhd::time_spec_t(0, 0)); sleep(1); - } - void set_streaming(bool enb){ if (enb){ - //make an estimate of the trip time - uhd::time_spec_t time1 = get_time_now(); - uhd::time_spec_t time2 = get_time_now(); - double rtt = 2*(time2 - time1).get_real_secs(); - //setup a stream command that starts streaming slightly in the future uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); stream_cmd.stream_now = false; - stream_cmd.time_spec = time2 + uhd::time_spec_t(0, (_dev->get_num_channels()+1)*rtt); + stream_cmd.time_spec = get_time_now() + uhd::time_spec_t(0, 0.01); //10ms offset in future _dev->issue_stream_cmd(stream_cmd); } else -- cgit From c6e8a20c39357dc12bf28030a1bb0c36596403b9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 6 Jul 2010 17:05:38 -0700 Subject: uhd: added callbacks in the mimo grc blocks --- gr-uhd/grc/uhd_mimo_sink.xml | 3 +++ gr-uhd/grc/uhd_mimo_source.xml | 3 +++ 2 files changed, 6 insertions(+) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/uhd_mimo_sink.xml b/gr-uhd/grc/uhd_mimo_sink.xml index faafbfd2f..00d7f678f 100644 --- a/gr-uhd/grc/uhd_mimo_sink.xml +++ b/gr-uhd/grc/uhd_mimo_sink.xml @@ -17,6 +17,9 @@ map(lambda x: self.$(id).set_gain(*x), enumerate($gains)) map(lambda x: self.$(id).set_antenna(*x), enumerate($ants)) #end if set_samp_rate($samp_rate) + map(lambda x: self.$(id).set_center_freq(*x), enumerate($center_freqs)) + map(lambda x: self.$(id).set_gain(*x), enumerate($gains)) + map(lambda x: self.$(id).set_antenna(*x), enumerate($ants)) Input Type type diff --git a/gr-uhd/grc/uhd_mimo_source.xml b/gr-uhd/grc/uhd_mimo_source.xml index 1cffa62cc..98081bff0 100644 --- a/gr-uhd/grc/uhd_mimo_source.xml +++ b/gr-uhd/grc/uhd_mimo_source.xml @@ -17,6 +17,9 @@ map(lambda x: self.$(id).set_gain(*x), enumerate($gains)) map(lambda x: self.$(id).set_antenna(*x), enumerate($ants)) #end if set_samp_rate($samp_rate) + map(lambda x: self.$(id).set_center_freq(*x), enumerate($center_freqs)) + map(lambda x: self.$(id).set_gain(*x), enumerate($gains)) + map(lambda x: self.$(id).set_antenna(*x), enumerate($ants)) Output Type type -- cgit From c3c4303b9fa4987369e9641ab4206724da74f3b2 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 22 Jul 2010 13:31:53 -0700 Subject: uhd: better error messages for tune and set sample rate --- gr-uhd/lib/uhd_mimo_sink.cc | 6 ++++-- gr-uhd/lib/uhd_mimo_source.cc | 6 ++++-- gr-uhd/lib/uhd_simple_sink.cc | 6 ++++-- gr-uhd/lib/uhd_simple_source.cc | 6 ++++-- gr-uhd/lib/utils.cc | 25 ++++++++++++++++++++++--- gr-uhd/lib/utils.h | 14 +++++++++++++- 6 files changed, 51 insertions(+), 12 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_mimo_sink.cc b/gr-uhd/lib/uhd_mimo_sink.cc index 43ec04164..95174522a 100644 --- a/gr-uhd/lib/uhd_mimo_sink.cc +++ b/gr-uhd/lib/uhd_mimo_sink.cc @@ -55,7 +55,7 @@ public: void set_samp_rate_all(double rate){ _dev->set_tx_rate_all(rate); - do_samp_rate_error_message(rate, get_samp_rate_all()); + do_samp_rate_error_message(rate, get_samp_rate_all(), "TX"); } double get_samp_rate_all(void){ @@ -63,7 +63,9 @@ public: } uhd::tune_result_t set_center_freq(size_t chan, double freq){ - return _dev->set_tx_freq(chan, freq); + uhd::tune_result_t tr = _dev->set_tx_freq(chan, freq); + do_tune_freq_error_message(freq, _dev->get_tx_freq(chan), "TX"); + return tr; } uhd::freq_range_t get_freq_range(size_t chan){ diff --git a/gr-uhd/lib/uhd_mimo_source.cc b/gr-uhd/lib/uhd_mimo_source.cc index 28bd1e109..b620a56fc 100644 --- a/gr-uhd/lib/uhd_mimo_source.cc +++ b/gr-uhd/lib/uhd_mimo_source.cc @@ -55,7 +55,7 @@ public: void set_samp_rate_all(double rate){ _dev->set_rx_rate_all(rate); - do_samp_rate_error_message(rate, get_samp_rate_all()); + do_samp_rate_error_message(rate, get_samp_rate_all(), "RX"); } double get_samp_rate_all(void){ @@ -63,7 +63,9 @@ public: } uhd::tune_result_t set_center_freq(size_t chan, double freq){ - return _dev->set_rx_freq(chan, freq); + uhd::tune_result_t tr = _dev->set_rx_freq(chan, freq); + do_tune_freq_error_message(freq, _dev->get_rx_freq(chan), "RX"); + return tr; } uhd::freq_range_t get_freq_range(size_t chan){ diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index d4bb7d437..9df6c8e02 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -52,7 +52,7 @@ public: void set_samp_rate(double rate){ _dev->set_tx_rate(rate); - do_samp_rate_error_message(rate, get_samp_rate()); + do_samp_rate_error_message(rate, get_samp_rate(), "TX"); } double get_samp_rate(void){ @@ -60,7 +60,9 @@ public: } uhd::tune_result_t set_center_freq(double freq){ - return _dev->set_tx_freq(freq); + uhd::tune_result_t tr = _dev->set_tx_freq(freq); + do_tune_freq_error_message(freq, _dev->get_tx_freq(), "TX"); + return tr; } uhd::freq_range_t get_freq_range(void){ diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index c734e9244..846c0faeb 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -53,7 +53,7 @@ public: void set_samp_rate(double rate){ _dev->set_rx_rate(rate); - do_samp_rate_error_message(rate, get_samp_rate()); + do_samp_rate_error_message(rate, get_samp_rate(), "RX"); } double get_samp_rate(void){ @@ -61,7 +61,9 @@ public: } uhd::tune_result_t set_center_freq(double freq){ - return _dev->set_rx_freq(freq); + uhd::tune_result_t tr = _dev->set_rx_freq(freq); + do_tune_freq_error_message(freq, _dev->get_rx_freq(), "RX"); + return tr; } uhd::freq_range_t get_freq_range(void){ diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc index ddc36eb99..5d40c4fff 100644 --- a/gr-uhd/lib/utils.cc +++ b/gr-uhd/lib/utils.cc @@ -25,13 +25,32 @@ #include #include -void do_samp_rate_error_message(double target_rate, double actual_rate){ +void do_samp_rate_error_message( + double target_rate, + double actual_rate, + const std::string &xx +){ static const double max_allowed_error = 1.0; //Sps if (std::abs(target_rate - actual_rate) > max_allowed_error){ std::cerr << boost::format( - "The hardware does not support the requested sample rate:\n" + "Warning: The hardware does not support the requested %s sample rate:\n" " Target sample rate: %f MSps\n" " Actual sample rate: %f MSps\n" - ) % (target_rate/1e6) % (actual_rate/1e6) << std::endl; + ) % xx % (target_rate/1e6) % (actual_rate/1e6) << std::endl; + } +} + +void do_tune_freq_error_message( + double target_freq, + double actual_freq, + const std::string &xx +){ + static const double max_allowed_error = 1.0; //Hz + if (std::abs(target_freq - actual_freq) > max_allowed_error){ + std::cerr << boost::format( + "Warning: The hardware does not support the requested %s frequency:\n" + " Target frequency: %f MHz\n" + " Actual frequency: %f MHz\n" + ) % xx % (target_freq/1e6) % (actual_freq/1e6) << std::endl; } } diff --git a/gr-uhd/lib/utils.h b/gr-uhd/lib/utils.h index cf349e5aa..4a05476bd 100644 --- a/gr-uhd/lib/utils.h +++ b/gr-uhd/lib/utils.h @@ -23,6 +23,18 @@ #ifndef INCLUDED_NOINST_UTILS_H #define INCLUDED_NOINST_UTILS_H -void do_samp_rate_error_message(double target_rate, double actual_rate); +#include + +void do_samp_rate_error_message( + double target_rate, + double actual_rate, + const std::string &xx +); + +void do_tune_freq_error_message( + double target_freq, + double actual_freq, + const std::string &xx +); #endif /* INCLUDED_NOINST_UTILS_H */ -- cgit From ae7cf499472b8174b9b12e1da23482a20bac461a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 28 Jul 2010 16:44:14 -0700 Subject: uhd: use time delay in proportion to the number of channels --- gr-uhd/lib/uhd_mimo_source.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_mimo_source.cc b/gr-uhd/lib/uhd_mimo_source.cc index b620a56fc..2b5384ce3 100644 --- a/gr-uhd/lib/uhd_mimo_source.cc +++ b/gr-uhd/lib/uhd_mimo_source.cc @@ -136,9 +136,10 @@ protected: void set_streaming(bool enb){ if (enb){ //setup a stream command that starts streaming slightly in the future + static const double reasonable_delay = 0.01; //10 ms (order of magnitude >> 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(0, 0.01); //10ms offset in future + stream_cmd.time_spec = get_time_now() + uhd::time_spec_t(_dev->get_num_channels() * reasonable_delay); _dev->issue_stream_cmd(stream_cmd); } else -- cgit From 068cac15d2d4ef787dee7bcbb1158c03805b2656 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 5 Aug 2010 17:35:16 -0700 Subject: uhd: added subdev spec setting to gr-uhd blocks, and simple uhd grc wrappers (mimo coming) --- gr-uhd/grc/uhd_simple_sink.xml | 8 ++++++++ gr-uhd/grc/uhd_simple_source.xml | 8 ++++++++ gr-uhd/lib/uhd_mimo_sink.cc | 4 ++++ gr-uhd/lib/uhd_mimo_sink.h | 7 +++++++ gr-uhd/lib/uhd_mimo_source.cc | 4 ++++ gr-uhd/lib/uhd_mimo_source.h | 7 +++++++ gr-uhd/lib/uhd_simple_sink.cc | 4 ++++ gr-uhd/lib/uhd_simple_sink.h | 6 ++++++ gr-uhd/lib/uhd_simple_source.cc | 4 ++++ gr-uhd/lib/uhd_simple_source.h | 6 ++++++ gr-uhd/lib/utils.cc | 22 +++++++++++----------- 11 files changed, 69 insertions(+), 11 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml index 2992f650e..782b984ae 100644 --- a/gr-uhd/grc/uhd_simple_sink.xml +++ b/gr-uhd/grc/uhd_simple_sink.xml @@ -10,6 +10,7 @@ UHD from gnuradio import uhd uhd.simple_sink($args, uhd.io_type_t.$type.type) +self.$(id).set_subdev_spec($sd_spec) self.$(id).set_samp_rate($samp_rate) self.$(id).set_center_freq($center_freq) self.$(id).set_gain($gain) @@ -43,6 +44,13 @@ self.$(id).set_antenna($ant) string + + Subdev Spec + sd_spec + + string + #if $sd_spec() then 'none' else 'part'# + Samp Rate (Sps) samp_rate diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml index ecd963928..ae7518803 100644 --- a/gr-uhd/grc/uhd_simple_source.xml +++ b/gr-uhd/grc/uhd_simple_source.xml @@ -10,6 +10,7 @@ UHD from gnuradio import uhd uhd.simple_source($args, uhd.io_type_t.$type.type) +self.$(id).set_subdev_spec($sd_spec) self.$(id).set_samp_rate($samp_rate) self.$(id).set_center_freq($center_freq) self.$(id).set_gain($gain) @@ -43,6 +44,13 @@ self.$(id).set_antenna($ant) string + + Subdev Spec + sd_spec + + string + #if $sd_spec() then 'none' else 'part'# + Samp Rate (Sps) samp_rate diff --git a/gr-uhd/lib/uhd_mimo_sink.cc b/gr-uhd/lib/uhd_mimo_sink.cc index 95174522a..0a2ce1b0a 100644 --- a/gr-uhd/lib/uhd_mimo_sink.cc +++ b/gr-uhd/lib/uhd_mimo_sink.cc @@ -53,6 +53,10 @@ public: //NOP } + void set_subdev_spec(size_t chan, const std::string &spec){ + return _dev->set_tx_subdev_spec(chan, spec); + } + void set_samp_rate_all(double rate){ _dev->set_tx_rate_all(rate); do_samp_rate_error_message(rate, get_samp_rate_all(), "TX"); diff --git a/gr-uhd/lib/uhd_mimo_sink.h b/gr-uhd/lib/uhd_mimo_sink.h index 951980908..46679d973 100644 --- a/gr-uhd/lib/uhd_mimo_sink.h +++ b/gr-uhd/lib/uhd_mimo_sink.h @@ -43,6 +43,13 @@ public: */ uhd_mimo_sink(gr_io_signature_sptr sig); + /*! + * Set the subdevice specification. + * \param chan the channel number from 0 to N-1 + * \param spec the subdev spec markup string + */ + virtual void set_subdev_spec(size_t chan, const std::string &spec) = 0; + /*! * Set the sample rate for the usrp device (across all mboards). * \param rate a new rate in Sps diff --git a/gr-uhd/lib/uhd_mimo_source.cc b/gr-uhd/lib/uhd_mimo_source.cc index b620a56fc..718af08f5 100644 --- a/gr-uhd/lib/uhd_mimo_source.cc +++ b/gr-uhd/lib/uhd_mimo_source.cc @@ -53,6 +53,10 @@ public: set_streaming(false); } + void set_subdev_spec(size_t chan, const std::string &spec){ + return _dev->set_rx_subdev_spec(chan, spec); + } + void set_samp_rate_all(double rate){ _dev->set_rx_rate_all(rate); do_samp_rate_error_message(rate, get_samp_rate_all(), "RX"); diff --git a/gr-uhd/lib/uhd_mimo_source.h b/gr-uhd/lib/uhd_mimo_source.h index e234779df..fbd7f2c42 100644 --- a/gr-uhd/lib/uhd_mimo_source.h +++ b/gr-uhd/lib/uhd_mimo_source.h @@ -43,6 +43,13 @@ public: */ uhd_mimo_source(gr_io_signature_sptr sig); + /*! + * Set the subdevice specification. + * \param chan the channel number from 0 to N-1 + * \param spec the subdev spec markup string + */ + virtual void set_subdev_spec(size_t chan, const std::string &spec) = 0; + /*! * Set the sample rate for the usrp device (across all mboards). * \param rate a new rate in Sps diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index 9df6c8e02..7b31218db 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -50,6 +50,10 @@ public: //NOP } + 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); do_samp_rate_error_message(rate, get_samp_rate(), "TX"); diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index 7f1596259..0abf30681 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -42,6 +42,12 @@ public: */ uhd_simple_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 diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 846c0faeb..2ace1da68 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -51,6 +51,10 @@ public: set_streaming(false); } + 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); do_samp_rate_error_message(rate, get_samp_rate(), "RX"); diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index 8568fc2d4..b95c0cfd9 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -42,6 +42,12 @@ public: */ uhd_simple_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 diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc index 5d40c4fff..da8352965 100644 --- a/gr-uhd/lib/utils.cc +++ b/gr-uhd/lib/utils.cc @@ -21,8 +21,8 @@ */ #include "utils.h" //local include +#include #include -#include #include void do_samp_rate_error_message( @@ -32,11 +32,11 @@ void do_samp_rate_error_message( ){ static const double max_allowed_error = 1.0; //Sps if (std::abs(target_rate - actual_rate) > max_allowed_error){ - std::cerr << boost::format( - "Warning: The hardware does not support the requested %s sample rate:\n" - " Target sample rate: %f MSps\n" - " Actual sample rate: %f MSps\n" - ) % xx % (target_rate/1e6) % (actual_rate/1e6) << std::endl; + uhd::print_warning(str(boost::format( + "The hardware does not support the requested %s sample rate:\n" + "Target sample rate: %f MSps\n" + "Actual sample rate: %f MSps\n" + ) % xx % (target_rate/1e6) % (actual_rate/1e6))); } } @@ -47,10 +47,10 @@ void do_tune_freq_error_message( ){ static const double max_allowed_error = 1.0; //Hz if (std::abs(target_freq - actual_freq) > max_allowed_error){ - std::cerr << boost::format( - "Warning: The hardware does not support the requested %s frequency:\n" - " Target frequency: %f MHz\n" - " Actual frequency: %f MHz\n" - ) % xx % (target_freq/1e6) % (actual_freq/1e6) << std::endl; + uhd::print_warning(str(boost::format( + "The hardware does not support the requested %s frequency:\n" + "Target frequency: %f MHz\n" + "Actual frequency: %f MHz\n" + ) % xx % (target_freq/1e6) % (actual_freq/1e6))); } } -- cgit From 97fed571222f034b62afa4de51c66d0566d5c74e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 9 Aug 2010 14:06:44 -0700 Subject: uhd: generating mimo source and sink blocks, added subdev spec --- gr-uhd/grc/.gitignore | 1 + gr-uhd/grc/Makefile.am | 10 ++ gr-uhd/grc/gen_uhd_mimo_blocks_xml.py | 190 ++++++++++++++++++++++++++++++++++ gr-uhd/grc/uhd_mimo_sink.xml | 102 ------------------ gr-uhd/grc/uhd_mimo_source.xml | 102 ------------------ gr-uhd/grc/uhd_simple_sink.xml | 3 +- gr-uhd/grc/uhd_simple_source.xml | 1 + 7 files changed, 204 insertions(+), 205 deletions(-) create mode 100755 gr-uhd/grc/gen_uhd_mimo_blocks_xml.py delete mode 100644 gr-uhd/grc/uhd_mimo_sink.xml delete mode 100644 gr-uhd/grc/uhd_mimo_source.xml (limited to 'gr-uhd') diff --git a/gr-uhd/grc/.gitignore b/gr-uhd/grc/.gitignore index b336cc7ce..479c2b650 100644 --- a/gr-uhd/grc/.gitignore +++ b/gr-uhd/grc/.gitignore @@ -1,2 +1,3 @@ +/uhd_mimo*.xml /Makefile /Makefile.in diff --git a/gr-uhd/grc/Makefile.am b/gr-uhd/grc/Makefile.am index cf3f77080..fa056ca8a 100644 --- a/gr-uhd/grc/Makefile.am +++ b/gr-uhd/grc/Makefile.am @@ -28,3 +28,13 @@ dist_grcblocks_DATA = \ uhd_mimo_sink.xml \ uhd_simple_source.xml \ uhd_simple_sink.xml + +######################################################################## +# Rules for generating the mimo source and sink blocks +######################################################################## +BUILT_SOURCES = uhd_mimo_sink.xml uhd_mimo_source.xml +EXTRA_DIST = $(srcdir)/gen_uhd_mimo_blocks_xml.py + +$(BUILT_SOURCES): $(srcdir)/gen_uhd_mimo_blocks_xml.py + @echo "generating $@..." + $(PYTHON) $< $@ diff --git a/gr-uhd/grc/gen_uhd_mimo_blocks_xml.py b/gr-uhd/grc/gen_uhd_mimo_blocks_xml.py new file mode 100755 index 000000000..7e61563cc --- /dev/null +++ b/gr-uhd/grc/gen_uhd_mimo_blocks_xml.py @@ -0,0 +1,190 @@ +#!/usr/bin/env python +""" +Copyright 2010 Free Software Foundation, Inc. + +This file is part of GNU Radio + +GNU Radio Companion is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +GNU Radio Companion is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +""" + +MAIN_TMPL = """\ + + + UHD MIMO $sourk.title() + uhd_mimo_$(sourk) + UHD + from gnuradio import uhd + uhd.mimo_$(sourk)(\$nchan, \$args, uhd.io_type_t.\$type.type) +self.\$(id).set_samp_rate_all(\$samp_rate) +#for $n in range($max_nchan) +\#if \$nchan() > $n +self.\$(id).set_subdev_spec($n, \$sd_spec$(n)) +self.\$(id).set_center_freq($n, \$center_freq$(n)) +self.\$(id).set_gain($n, \$gain$(n)) + \#if \$ant$(n)() +self.\$(id).set_antenna($n, \$ant$(n)) + \#end if +\#end if +#end for + + set_samp_rate(\$samp_rate) + #for $n in range($max_nchan) + set_center_freq($n, \$center_freq$(n)) + set_gain($n, \$gain$(n)) + set_antenna($n, \$ant$(n)) + #end for + + Input Type + type + enum + + + + + Num Channels + nchan + 2 + int + #for $n in range(2, $max_nchan+1) + + #end for + + + Args + args + addr=192.168.10.2 192.168.20.2 + string + + + Samp Rate (Sps) + samp_rate + samp_rate + real + + $params + $max_nchan >= \$nchan + \$nchan >= 0 + <$sourk> + $direction + \$type + \$type.vlen + \$nchan + + +The UHD $sourk.title() Block: + +Args: +Args is a delimited string used to locate UHD devices on your system. \\ +If left blank, the first UHD device found will be used. \\ +Used args to specify a specfic device. \\ +USRP2 Example: addr=192.168.10.2 + +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. + +Antenna: +For subdevices/daughterboards 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. + + +""" + +PARAMS_TMPL = """ + + Ch$(n): Subdev Spec + sd_spec$(n) + + string + + \#if not \$nchan() > $n + all + \#elif \$sd_spec$(n)() + none + \#else + part + \#end if + + + + 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 + + +""" + +def parse_tmpl(_tmpl, **kwargs): + from Cheetah import Template + return str(Template.Template(_tmpl, kwargs)) + +max_num_channels = 8 + +if __name__ == '__main__': + import sys + for file in sys.argv[1:]: + if 'source' in file: + sourk = 'source' + direction = 'out' + elif 'sink' in file: + sourk = 'sink' + direction = 'in' + else: raise Exception, 'is %s a source or sink?'%file + + params = ''.join([parse_tmpl(PARAMS_TMPL, n=n) for n in range(max_num_channels)]) + open(file, 'w').write(parse_tmpl(MAIN_TMPL, + max_nchan=max_num_channels, + params=params, + sourk=sourk, + direction=direction, + )) diff --git a/gr-uhd/grc/uhd_mimo_sink.xml b/gr-uhd/grc/uhd_mimo_sink.xml deleted file mode 100644 index 00d7f678f..000000000 --- a/gr-uhd/grc/uhd_mimo_sink.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - UHD MIMO Sink - uhd_mimo_sink - UHD - from gnuradio import uhd - uhd.mimo_sink($nchan, $args, uhd.io_type_t.$type.type) -self.$(id).set_samp_rate_all($samp_rate) -map(lambda x: self.$(id).set_center_freq(*x), enumerate($center_freqs)) -map(lambda x: self.$(id).set_gain(*x), enumerate($gains)) -#if $ants() -map(lambda x: self.$(id).set_antenna(*x), enumerate($ants)) -#end if - set_samp_rate($samp_rate) - map(lambda x: self.$(id).set_center_freq(*x), enumerate($center_freqs)) - map(lambda x: self.$(id).set_gain(*x), enumerate($gains)) - map(lambda x: self.$(id).set_antenna(*x), enumerate($ants)) - - Input Type - type - enum - - - - - Num Channels - nchan - 2 - int - - - Args - args - addr=192.168.10.2 192.168.20.2 - string - - - Samp Rate (Sps) - samp_rate - samp_rate - real - - - Center Freqs (Hz) - center_freqs - 0, 0 - real_vector - - - Gains (dB) - gains - 0, 0 - real_vector - - - Antennas - ants - ['RX2', 'RX2'] - raw - #if not $ants() then 'part' else 'none'# - - - out - $type - $type.vlen - $nchan - - -The UHD Sink Block: - -Args: -Args is a delimited string used to locate UHD devices on your system. \ -If left blank, the first UHD device found will be used. \ -Used args to specify a specfic device. \ -USRP2 Example: addr=192.168.10.2 - -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. - -Antenna: -For subdevices/daughterboards 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. - - diff --git a/gr-uhd/grc/uhd_mimo_source.xml b/gr-uhd/grc/uhd_mimo_source.xml deleted file mode 100644 index 98081bff0..000000000 --- a/gr-uhd/grc/uhd_mimo_source.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - UHD MIMO Source - uhd_mimo_source - UHD - from gnuradio import uhd - uhd.mimo_source($nchan, $args, uhd.io_type_t.$type.type) -self.$(id).set_samp_rate_all($samp_rate) -map(lambda x: self.$(id).set_center_freq(*x), enumerate($center_freqs)) -map(lambda x: self.$(id).set_gain(*x), enumerate($gains)) -#if $ants() -map(lambda x: self.$(id).set_antenna(*x), enumerate($ants)) -#end if - set_samp_rate($samp_rate) - map(lambda x: self.$(id).set_center_freq(*x), enumerate($center_freqs)) - map(lambda x: self.$(id).set_gain(*x), enumerate($gains)) - map(lambda x: self.$(id).set_antenna(*x), enumerate($ants)) - - Output Type - type - enum - - - - - Num Channels - nchan - 2 - int - - - Args - args - addr=192.168.10.2 192.168.20.2 - string - - - Samp Rate (Sps) - samp_rate - samp_rate - real - - - Center Freqs (Hz) - center_freqs - 0, 0 - real_vector - - - Gains (dB) - gains - 0, 0 - real_vector - - - Antennas - ants - ['RX2', 'RX2'] - raw - #if not $ants() then 'part' else 'none'# - - - out - $type - $type.vlen - $nchan - - -The UHD Source Block: - -Args: -Args is a delimited string used to locate UHD devices on your system. \ -If left blank, the first UHD device found will be used. \ -Used args to specify a specfic device. \ -USRP2 Example: addr=192.168.10.2 - -Sample rate: -The sample rate is the number of samples per second output 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. - -Antenna: -For subdevices/daughterboards 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. - - diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml index 782b984ae..1913d7ffb 100644 --- a/gr-uhd/grc/uhd_simple_sink.xml +++ b/gr-uhd/grc/uhd_simple_sink.xml @@ -60,6 +60,7 @@ self.$(id).set_antenna($ant) Center Freq (Hz) center_freq + 0 real @@ -75,7 +76,7 @@ self.$(id).set_antenna($ant) #if $ant() == '' then 'part' else 'none'# - out + in $type $type.vlen diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml index ae7518803..614204157 100644 --- a/gr-uhd/grc/uhd_simple_source.xml +++ b/gr-uhd/grc/uhd_simple_source.xml @@ -60,6 +60,7 @@ self.$(id).set_antenna($ant) Center Freq (Hz) center_freq + 0 real -- cgit From 5c7cf9723b4ddd5f5b004a6cbd8e02b7d1356623 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 20 Sep 2010 19:02:02 -0700 Subject: uhd: work on uhd single usrp wrapper --- gr-uhd/lib/Makefile.am | 8 +- gr-uhd/lib/uhd_single_usrp_sink.cc | 151 ++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_single_usrp_sink.h | 143 ++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_single_usrp_source.cc | 165 +++++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_single_usrp_source.h | 143 ++++++++++++++++++++++++++++++ 5 files changed, 608 insertions(+), 2 deletions(-) create mode 100644 gr-uhd/lib/uhd_single_usrp_sink.cc create mode 100644 gr-uhd/lib/uhd_single_usrp_sink.h create mode 100644 gr-uhd/lib/uhd_single_usrp_source.cc create mode 100644 gr-uhd/lib/uhd_single_usrp_source.h (limited to 'gr-uhd') diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index 8aae63326..1260201a5 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -33,7 +33,9 @@ libgnuradio_uhd_la_SOURCES = \ uhd_mimo_source.cc \ uhd_mimo_sink.cc \ uhd_simple_source.cc \ - uhd_simple_sink.cc + uhd_simple_sink.cc \ + uhd_single_usrp_source.cc \ + uhd_single_usrp_sink.cc libgnuradio_uhd_la_LIBADD = \ $(GNURADIO_CORE_LA) \ @@ -45,7 +47,9 @@ grinclude_HEADERS = \ uhd_mimo_source.h \ uhd_mimo_sink.h \ uhd_simple_source.h \ - uhd_simple_sink.h + uhd_simple_sink.h \ + uhd_single_usrp_source.h \ + uhd_single_usrp_sink.h noinst_HEADERS = \ utils.h diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc new file mode 100644 index 000000000..1cd5afc87 --- /dev/null +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -0,0 +1,151 @@ +/* + * 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 +#include +#include +#include "utils.h" + +/*********************************************************************** + * UHD Single USPR 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 USPR Sink Impl + **********************************************************************/ +class uhd_single_usrp_sink_impl : public uhd_single_usrp_sink{ +public: + uhd_single_usrp_sink_impl( + const std::string &args, + const uhd::io_type_t &type + ) : uhd_single_usrp_sink(gr_make_io_signature(1, 1, type.size)), _type(type) + { + _dev = uhd::usrp::single_usrp::make(args); + } + + ~uhd_single_usrp_sink_impl(void){ + //NOP + } + + 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); + do_samp_rate_error_message(rate, get_samp_rate(), "TX"); + } + + double get_samp_rate(void){ + return _dev->get_tx_rate(); + } + + uhd::tune_result_t set_center_freq(double freq, size_t chan){ + uhd::tune_result_t tr = _dev->set_tx_freq(freq, chan); + do_tune_freq_error_message(freq, _dev->get_tx_freq(chan), "TX"); + return tr; + } + + uhd::freq_range_t get_freq_range(size_t chan){ + return _dev->get_tx_freq_range(chan); + } + + void set_gain(float gain, size_t chan){ + return _dev->set_tx_gain(gain, chan); + } + + float get_gain(size_t chan){ + return _dev->get_tx_gain(chan); + } + + uhd::gain_range_t get_gain_range(size_t chan){ + return _dev->get_tx_gain_range(chan); + } + + void set_antenna(const std::string &ant, size_t chan){ + return _dev->set_tx_antenna(ant, chan); + } + + std::string get_antenna(size_t chan){ + return _dev->get_tx_antenna(chan); + } + + std::vector get_antennas(size_t chan){ + return _dev->get_tx_antennas(chan); + } + + void set_clock_config(const uhd::clock_config_t &clock_config){ + return _dev->set_clock_config(clock_config); + } + + uhd::time_spec_t get_time_now(void){ + return _dev->get_time_now(); + } + + void set_time_now(const uhd::time_spec_t &time_spec){ + return _dev->set_time_now(time_spec); + } + + void set_time_next_pps(const uhd::time_spec_t &time_spec){ + return _dev->set_time_next_pps(time_spec); + } + + uhd::usrp::single_usrp::sptr get_device(void){ + return _dev; + } + +/*********************************************************************** + * Work + **********************************************************************/ + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ){ + uhd::tx_metadata_t metadata; + metadata.start_of_burst = true; + + return _dev->get_device()->send( + input_items, noutput_items, metadata, + _type, uhd::device::SEND_MODE_FULL_BUFF + ); + } + +protected: + uhd::usrp::single_usrp::sptr _dev; + const uhd::io_type_t _type; +}; + +/*********************************************************************** + * Make UHD Single USPR Sink + **********************************************************************/ +boost::shared_ptr uhd_make_single_usrp_sink( + const std::string &args, + const uhd::io_type_t::tid_t &type +){ + return boost::shared_ptr( + new uhd_single_usrp_sink_impl(args, type) + ); +} diff --git a/gr-uhd/lib/uhd_single_usrp_sink.h b/gr-uhd/lib/uhd_single_usrp_sink.h new file mode 100644 index 000000000..61417168a --- /dev/null +++ b/gr-uhd/lib/uhd_single_usrp_sink.h @@ -0,0 +1,143 @@ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_UHD_SINGLE_USRP_SINK_H +#define INCLUDED_UHD_SINGLE_USRP_SINK_H + +#include +#include + +class uhd_single_usrp_sink; + +boost::shared_ptr uhd_make_single_usrp_sink( + const std::string &args, + const uhd::io_type_t::tid_t &type +); + +class uhd_single_usrp_sink : public gr_sync_block{ +public: + + /*! + * Set the IO signature for this block. + * \param sig the input signature + */ + uhd_single_usrp_sink(gr_io_signature_sptr sig); + + /*! + * Set the subdevice specification. + * \param spec the subdev spec markup string + */ + virtual void set_subdev_spec(const std::string &spec) = 0; + + /*! + * Set the sample rate for the usrp device. + * \param rate a new rate in Sps + */ + virtual void set_samp_rate(double rate) = 0; + + /*! + * Get the sample rate for the usrp device. + * This is the actual sample rate and may differ from the rate set. + * \return the actual rate in Sps + */ + virtual double get_samp_rate(void) = 0; + + /*! + * Tune the usrp device to the desired center frequency. + * \param freq the desired frequency in Hz + * \return a tune result with the actual frequencies + */ + virtual uhd::tune_result_t set_center_freq(double freq, size_t chan = 0) = 0; + + /*! + * Get the tunable frequency range. + * \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 + */ + virtual void set_gain(float gain, size_t chan = 0) = 0; + + /*! + * Get the actual dboard gain setting. + * \return the actual gain in dB + */ + virtual float get_gain(size_t chan = 0) = 0; + + /*! + * Get the settable gain range. + * \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 + */ + virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0; + + /*! + * Get the antenna in use. + * \return the antenna string + */ + virtual std::string get_antenna(size_t chan = 0) = 0; + + /*! + * Get a list of possible antennas. + * \return a vector of antenna strings + */ + virtual std::vector get_antennas(size_t chan = 0) = 0; + + /*! + * Set the clock configuration. + * \param clock_config the new configuration + */ + virtual void set_clock_config(const uhd::clock_config_t &clock_config) = 0; + + /*! + * Get the current time registers. + * \return the current usrp time + */ + virtual uhd::time_spec_t get_time_now(void) = 0; + + /*! + * Set the time registers asap. + * \param time_spec the new time + */ + virtual void set_time_now(const uhd::time_spec_t &time_spec) = 0; + + /*! + * Set the time registers at the next pps. + * \param time_spec the new time + */ + virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; + + /*! + * Get access to the underlying uhd device object. + * \return the single usrp device object + */ + virtual uhd::usrp::single_usrp::sptr get_device(void) = 0; +}; + +#endif /* INCLUDED_UHD_SINGLE_USRP_SINK_H */ diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc new file mode 100644 index 000000000..13e4d6d43 --- /dev/null +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -0,0 +1,165 @@ +/* + * 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 +#include +#include +#include "utils.h" + +/*********************************************************************** + * UHD Single USPR 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 USPR Source Impl + **********************************************************************/ +class uhd_single_usrp_source_impl : public uhd_single_usrp_source{ +public: + uhd_single_usrp_source_impl( + const std::string &args, + const uhd::io_type_t &type + ) : uhd_single_usrp_source(gr_make_io_signature(1, 1, type.size)), _type(type) + { + _dev = uhd::usrp::single_usrp::make(args); + set_streaming(false); + } + + ~uhd_single_usrp_source_impl(void){ + set_streaming(false); + } + + 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); + do_samp_rate_error_message(rate, get_samp_rate(), "RX"); + } + + double get_samp_rate(void){ + return _dev->get_rx_rate(); + } + + uhd::tune_result_t set_center_freq(double freq, size_t chan){ + uhd::tune_result_t tr = _dev->set_rx_freq(freq, chan); + do_tune_freq_error_message(freq, _dev->get_rx_freq(chan), "RX"); + return tr; + } + + uhd::freq_range_t get_freq_range(size_t chan){ + return _dev->get_rx_freq_range(chan); + } + + void set_gain(float gain, size_t chan){ + return _dev->set_rx_gain(gain, chan); + } + + float get_gain(size_t chan){ + return _dev->get_rx_gain(chan); + } + + uhd::gain_range_t get_gain_range(size_t chan){ + return _dev->get_rx_gain_range(chan); + } + + void set_antenna(const std::string &ant, size_t chan){ + return _dev->set_rx_antenna(ant, chan); + } + + std::string get_antenna(size_t chan){ + return _dev->get_rx_antenna(chan); + } + + std::vector get_antennas(size_t chan){ + return _dev->get_rx_antennas(chan); + } + + void set_clock_config(const uhd::clock_config_t &clock_config){ + return _dev->set_clock_config(clock_config); + } + + uhd::time_spec_t get_time_now(void){ + return _dev->get_time_now(); + } + + void set_time_now(const uhd::time_spec_t &time_spec){ + return _dev->set_time_now(time_spec); + } + + void set_time_next_pps(const uhd::time_spec_t &time_spec){ + return _dev->set_time_next_pps(time_spec); + } + + uhd::usrp::single_usrp::sptr get_device(void){ + return _dev; + } + +/*********************************************************************** + * Work + **********************************************************************/ + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ){ + //conditionally start streaming in the work call + //this prevents streaming before the runtime is ready + if (not _is_streaming) set_streaming(true); + + uhd::rx_metadata_t metadata; //not passed out of this block + + return _dev->get_device()->recv( + output_items, noutput_items, metadata, + _type, uhd::device::RECV_MODE_FULL_BUFF + ); + } + +private: + uhd::usrp::single_usrp::sptr _dev; + const uhd::io_type_t _type; + bool _is_streaming; + + void set_streaming(bool enb){ + if (enb) + _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); + else + _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); + _is_streaming = enb; + } +}; + + +/*********************************************************************** + * Make UHD Single USPR Source + **********************************************************************/ +boost::shared_ptr uhd_make_single_usrp_source( + const std::string &args, + const uhd::io_type_t::tid_t &type +){ + return boost::shared_ptr( + new uhd_single_usrp_source_impl(args, type) + ); +} diff --git a/gr-uhd/lib/uhd_single_usrp_source.h b/gr-uhd/lib/uhd_single_usrp_source.h new file mode 100644 index 000000000..6634a9c2a --- /dev/null +++ b/gr-uhd/lib/uhd_single_usrp_source.h @@ -0,0 +1,143 @@ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_UHD_SINGLE_USRP_SOURCE_H +#define INCLUDED_UHD_SINGLE_USRP_SOURCE_H + +#include +#include + +class uhd_single_usrp_source; + +boost::shared_ptr uhd_make_single_source( + const std::string &args, + const uhd::io_type_t::tid_t &type +); + +class uhd_single_usrp_source : public gr_sync_block{ +public: + + /*! + * Set the IO signature for this block. + * \param sig the output signature + */ + uhd_single_usrp_source(gr_io_signature_sptr sig); + + /*! + * Set the subdevice specification. + * \param spec the subdev spec markup string + */ + virtual void set_subdev_spec(const std::string &spec) = 0; + + /*! + * Set the sample rate for the usrp device. + * \param rate a new rate in Sps + */ + virtual void set_samp_rate(double rate) = 0; + + /*! + * Get the sample rate for the usrp device. + * This is the actual sample rate and may differ from the rate set. + * \return the actual rate in Sps + */ + virtual double get_samp_rate(void) = 0; + + /*! + * Tune the usrp device to the desired center frequency. + * \param freq the desired frequency in Hz + * \return a tune result with the actual frequencies + */ + virtual uhd::tune_result_t set_center_freq(double freq, size_t chan = 0) = 0; + + /*! + * Get the tunable frequency range. + * \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 + */ + virtual void set_gain(float gain, size_t chan = 0) = 0; + + /*! + * Get the actual dboard gain setting. + * \return the actual gain in dB + */ + virtual float get_gain(size_t chan = 0) = 0; + + /*! + * Get the settable gain range. + * \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 + */ + virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0; + + /*! + * Get the antenna in use. + * \return the antenna string + */ + virtual std::string get_antenna(size_t chan = 0) = 0; + + /*! + * Get a list of possible antennas. + * \return a vector of antenna strings + */ + virtual std::vector get_antennas(size_t chan = 0) = 0; + + /*! + * Set the clock configuration. + * \param clock_config the new configuration + */ + virtual void set_clock_config(const uhd::clock_config_t &clock_config) = 0; + + /*! + * Get the current time registers. + * \return the current usrp time + */ + virtual uhd::time_spec_t get_time_now(void) = 0; + + /*! + * Set the time registers asap. + * \param time_spec the new time + */ + virtual void set_time_now(const uhd::time_spec_t &time_spec) = 0; + + /*! + * Set the time registers at the next pps. + * \param time_spec the new time + */ + virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; + + /*! + * Get access to the underlying uhd device object. + * \return the single usrp device object + */ + virtual uhd::usrp::single_usrp::sptr get_device(void) = 0; +}; + +#endif /* INCLUDED_UHD_SINGLE_USRP_SOURCE_H */ -- cgit From 385eafd8559b90a027604dd5c0ab734bea54f6d8 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 21 Sep 2010 17:12:47 -0700 Subject: uhd: added grc and swig wrappers for single usrp --- gr-uhd/grc/.gitignore | 1 + gr-uhd/grc/Makefile.am | 26 +++- gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py | 205 +++++++++++++++++++++++++++ gr-uhd/grc/uhd_simple_sink.xml | 2 +- gr-uhd/grc/uhd_simple_source.xml | 2 +- gr-uhd/swig/uhd_swig.i | 14 ++ 6 files changed, 243 insertions(+), 7 deletions(-) create mode 100755 gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py (limited to 'gr-uhd') diff --git a/gr-uhd/grc/.gitignore b/gr-uhd/grc/.gitignore index 479c2b650..c95275d8d 100644 --- a/gr-uhd/grc/.gitignore +++ b/gr-uhd/grc/.gitignore @@ -1,3 +1,4 @@ /uhd_mimo*.xml +/uhd_single*.xml /Makefile /Makefile.in diff --git a/gr-uhd/grc/Makefile.am b/gr-uhd/grc/Makefile.am index fa056ca8a..a19a28f03 100644 --- a/gr-uhd/grc/Makefile.am +++ b/gr-uhd/grc/Makefile.am @@ -23,18 +23,34 @@ include $(top_srcdir)/Makefile.common grcblocksdir = $(grc_blocksdir) -dist_grcblocks_DATA = \ +generated_uhd_mimo_blocks = \ uhd_mimo_source.xml \ - uhd_mimo_sink.xml \ + uhd_mimo_sink.xml + +generated_uhd_single_usrp_blocks = \ + uhd_single_usrp_source.xml \ + uhd_single_usrp_sink.xml + +BUILT_SOURCES = \ + $(generated_uhd_mimo_blocks) \ + $(generated_uhd_single_usrp_blocks) + +dist_grcblocks_DATA = \ + $(BUILT_SOURCES) \ uhd_simple_source.xml \ uhd_simple_sink.xml ######################################################################## # Rules for generating the mimo source and sink blocks ######################################################################## -BUILT_SOURCES = uhd_mimo_sink.xml uhd_mimo_source.xml -EXTRA_DIST = $(srcdir)/gen_uhd_mimo_blocks_xml.py +EXTRA_DIST = \ + $(srcdir)/gen_uhd_mimo_blocks_xml.py \ + $(srcdir)/gen_uhd_single_usrp_blocks_xml.py + +$(generated_uhd_mimo_blocks): $(srcdir)/gen_uhd_mimo_blocks_xml.py + @echo "generating $@..." + $(PYTHON) $< $@ -$(BUILT_SOURCES): $(srcdir)/gen_uhd_mimo_blocks_xml.py +$(generated_uhd_single_usrp_blocks): $(srcdir)/gen_uhd_single_usrp_blocks_xml.py @echo "generating $@..." $(PYTHON) $< $@ diff --git a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py new file mode 100755 index 000000000..0d13a8391 --- /dev/null +++ b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py @@ -0,0 +1,205 @@ +#!/usr/bin/env python +""" +Copyright 2010 Free Software Foundation, Inc. + +This file is part of GNU Radio + +GNU Radio Companion is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +GNU Radio Companion is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +""" + +MAIN_TMPL = """\ + + + UHD Single USRP $sourk.title() + uhd_single_usrp_$(sourk) + UHD + from gnuradio import uhd + uhd.single_usrp_$(sourk)(\$nchan, \$dev_addr, uhd.io_type_t.\$type.type) +self.\$(id).set_subdev_spec(\$sd_spec) +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 +\#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) + #end for + + Input Type + type + enum + + + + + Num Channels + nchan + 1 + int + part + + + + + + Device Addr + dev_addr + addr=192.168.10.2 + string + + + 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. \\ +Used args to specify a specfic device. +USRP2 Example: addr=192.168.10.2 +USRP1 Example: serial=12345678 + +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. + +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 + +Antenna: +For subdevices/daughterboards 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. + + +""" + +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 + + +""" + +def parse_tmpl(_tmpl, **kwargs): + from Cheetah import Template + return str(Template.Template(_tmpl, kwargs)) + +max_num_channels = 4 + +if __name__ == '__main__': + import sys + for file in sys.argv[1:]: + if 'source' in file: + sourk = 'source' + direction = 'out' + elif 'sink' in file: + sourk = 'sink' + direction = 'in' + else: raise Exception, 'is %s a source or sink?'%file + + params = ''.join([parse_tmpl(PARAMS_TMPL, n=n) for n in range(max_num_channels)]) + open(file, 'w').write(parse_tmpl(MAIN_TMPL, + max_nchan=max_num_channels, + params=params, + sourk=sourk, + direction=direction, + )) diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml index 1913d7ffb..66dc5bf14 100644 --- a/gr-uhd/grc/uhd_simple_sink.xml +++ b/gr-uhd/grc/uhd_simple_sink.xml @@ -5,7 +5,7 @@ ################################################### --> - UHD Simple Sink + UHD Simple Sink (DEPRECATED) uhd_simple_sink UHD from gnuradio import uhd diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml index 614204157..00c60f41d 100644 --- a/gr-uhd/grc/uhd_simple_source.xml +++ b/gr-uhd/grc/uhd_simple_source.xml @@ -5,7 +5,7 @@ ################################################### --> - UHD Simple Source + UHD Simple Source (DEPRECATED) uhd_simple_source UHD from gnuradio import uhd diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 34e140887..d755dfeee 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -21,12 +21,20 @@ */ %include "gnuradio.i" +%include "std_string.i" +%include "std_vector.i" + +namespace std { + %template(StringVector) vector; +} %{ #include #include #include #include +#include +#include %} %include @@ -47,3 +55,9 @@ GR_SWIG_BLOCK_MAGIC(uhd,simple_source) GR_SWIG_BLOCK_MAGIC(uhd,simple_sink) %include + +GR_SWIG_BLOCK_MAGIC(uhd,single_usrp_source) +%include + +GR_SWIG_BLOCK_MAGIC(uhd,single_usrp_sink) +%include -- cgit From 2831c9313d09685090cea531a177469b57792c9a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 22 Sep 2010 17:40:02 -0700 Subject: uhd: tweaks and fixes, single wrapper working --- gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py | 11 +++++++++-- gr-uhd/lib/uhd_single_usrp_source.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py index 0d13a8391..1ad3c0927 100755 --- a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py @@ -22,11 +22,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA MAIN_TMPL = """\ - UHD Single USRP $sourk.title() + UHD: Single USRP $sourk.title() uhd_single_usrp_$(sourk) UHD from gnuradio import uhd - uhd.single_usrp_$(sourk)(\$nchan, \$dev_addr, uhd.io_type_t.\$type.type) + uhd.single_usrp_$(sourk)(\$dev_addr, uhd.io_type_t.\$type.type) self.\$(id).set_subdev_spec(\$sd_spec) self.\$(id).set_samp_rate(\$samp_rate) #for $n in range($max_nchan) @@ -86,6 +86,13 @@ self.\$(id).set_antenna(\$ant$(n), $n) dev_addr addr=192.168.10.2 string + + \#if \$dev_addr() + none + \#else + part + \#end if + Subdev Spec diff --git a/gr-uhd/lib/uhd_single_usrp_source.h b/gr-uhd/lib/uhd_single_usrp_source.h index 6634a9c2a..5da7e2b9a 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.h +++ b/gr-uhd/lib/uhd_single_usrp_source.h @@ -27,7 +27,7 @@ class uhd_single_usrp_source; -boost::shared_ptr uhd_make_single_source( +boost::shared_ptr uhd_make_single_usrp_source( const std::string &args, const uhd::io_type_t::tid_t &type ); -- cgit From 1fe3790faed05b92ca4ad3a27da6eb23632d7e57 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 23 Sep 2010 19:05:10 -0700 Subject: uhd: multi channel single usrp source and sink working --- gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py | 2 +- gr-uhd/lib/uhd_single_usrp_sink.cc | 10 ++++++---- gr-uhd/lib/uhd_single_usrp_sink.h | 3 ++- gr-uhd/lib/uhd_single_usrp_source.cc | 10 ++++++---- gr-uhd/lib/uhd_single_usrp_source.h | 3 ++- 5 files changed, 17 insertions(+), 11 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py index 1ad3c0927..5b3cb5b5a 100755 --- a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py @@ -26,7 +26,7 @@ MAIN_TMPL = """\ uhd_single_usrp_$(sourk) UHD from gnuradio import uhd - uhd.single_usrp_$(sourk)(\$dev_addr, uhd.io_type_t.\$type.type) + uhd.single_usrp_$(sourk)(\$dev_addr, uhd.io_type_t.\$type.type, \$nchan) self.\$(id).set_subdev_spec(\$sd_spec) self.\$(id).set_samp_rate(\$samp_rate) #for $n in range($max_nchan) diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc index 1cd5afc87..8cb3726d1 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -39,8 +39,9 @@ class uhd_single_usrp_sink_impl : public uhd_single_usrp_sink{ public: uhd_single_usrp_sink_impl( const std::string &args, - const uhd::io_type_t &type - ) : uhd_single_usrp_sink(gr_make_io_signature(1, 1, type.size)), _type(type) + const uhd::io_type_t &type, + size_t num_channels + ) : uhd_single_usrp_sink(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) { _dev = uhd::usrp::single_usrp::make(args); } @@ -143,9 +144,10 @@ protected: **********************************************************************/ boost::shared_ptr uhd_make_single_usrp_sink( const std::string &args, - const uhd::io_type_t::tid_t &type + const uhd::io_type_t::tid_t &type, + size_t num_channels ){ return boost::shared_ptr( - new uhd_single_usrp_sink_impl(args, type) + new uhd_single_usrp_sink_impl(args, type, num_channels) ); } diff --git a/gr-uhd/lib/uhd_single_usrp_sink.h b/gr-uhd/lib/uhd_single_usrp_sink.h index 61417168a..bec788193 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.h +++ b/gr-uhd/lib/uhd_single_usrp_sink.h @@ -29,7 +29,8 @@ class uhd_single_usrp_sink; boost::shared_ptr uhd_make_single_usrp_sink( const std::string &args, - const uhd::io_type_t::tid_t &type + const uhd::io_type_t::tid_t &type, + size_t num_channels = 1 ); class uhd_single_usrp_sink : public gr_sync_block{ diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index 13e4d6d43..5da4385b2 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -39,8 +39,9 @@ class uhd_single_usrp_source_impl : public uhd_single_usrp_source{ public: uhd_single_usrp_source_impl( const std::string &args, - const uhd::io_type_t &type - ) : uhd_single_usrp_source(gr_make_io_signature(1, 1, type.size)), _type(type) + const uhd::io_type_t &type, + size_t num_channels + ) : uhd_single_usrp_source(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) { _dev = uhd::usrp::single_usrp::make(args); set_streaming(false); @@ -157,9 +158,10 @@ private: **********************************************************************/ boost::shared_ptr uhd_make_single_usrp_source( const std::string &args, - const uhd::io_type_t::tid_t &type + const uhd::io_type_t::tid_t &type, + size_t num_channels ){ return boost::shared_ptr( - new uhd_single_usrp_source_impl(args, type) + new uhd_single_usrp_source_impl(args, type, num_channels) ); } diff --git a/gr-uhd/lib/uhd_single_usrp_source.h b/gr-uhd/lib/uhd_single_usrp_source.h index 5da7e2b9a..196b7c675 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.h +++ b/gr-uhd/lib/uhd_single_usrp_source.h @@ -29,7 +29,8 @@ class uhd_single_usrp_source; boost::shared_ptr uhd_make_single_usrp_source( const std::string &args, - const uhd::io_type_t::tid_t &type + const uhd::io_type_t::tid_t &type, + size_t num_channels = 1 ); class uhd_single_usrp_source : public gr_sync_block{ -- cgit From d2452adf306502b1f7489f49454e8814bc84c6d4 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 24 Sep 2010 16:09:38 -0700 Subject: uhd: handle error codes in uhd source blocks --- gr-uhd/lib/uhd_simple_source.cc | 19 ++++++++++++++++++- gr-uhd/lib/uhd_single_usrp_source.cc | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index 2ace1da68..c1e11e85d 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include "utils.h" /*********************************************************************** @@ -132,10 +134,25 @@ public: uhd::rx_metadata_t metadata; //not passed out of this block - return _dev->get_device()->recv( + 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; + } } private: diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index 5da4385b2..ff9ba0653 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "utils.h" /*********************************************************************** @@ -132,10 +134,25 @@ public: uhd::rx_metadata_t metadata; //not passed out of this block - return _dev->get_device()->recv( + 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; + } } private: -- cgit From 068aa7f5b2591f7cc06e4495c89600101bd19b6b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 14 Oct 2010 10:29:19 -0700 Subject: uhd: use start and stop methods for single source/sink blocks --- gr-uhd/lib/uhd_single_usrp_sink.cc | 29 ++++++++++++++++++++++++++++- gr-uhd/lib/uhd_single_usrp_source.cc | 28 ++++++++++------------------ 2 files changed, 38 insertions(+), 19 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc index 8cb3726d1..96f86c8db 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -41,7 +41,7 @@ public: const std::string &args, const uhd::io_type_t &type, size_t num_channels - ) : uhd_single_usrp_sink(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) + ) : uhd_single_usrp_sink(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type), _nchan(num_channels) { _dev = uhd::usrp::single_usrp::make(args); } @@ -134,9 +134,36 @@ public: ); } + //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; }; /*********************************************************************** diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index ff9ba0653..b5e39b5a4 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -46,11 +46,6 @@ public: ) : uhd_single_usrp_source(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) { _dev = uhd::usrp::single_usrp::make(args); - set_streaming(false); - } - - ~uhd_single_usrp_source_impl(void){ - set_streaming(false); } void set_subdev_spec(const std::string &spec){ @@ -128,10 +123,6 @@ public: gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ){ - //conditionally start streaming in the work call - //this prevents streaming before the runtime is ready - if (not _is_streaming) set_streaming(true); - uhd::rx_metadata_t metadata; //not passed out of this block size_t num_samps = _dev->get_device()->recv( @@ -155,18 +146,19 @@ public: } } + bool start(void){ + _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); + return true; + } + + bool stop(void){ + _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); + return true; + } + private: uhd::usrp::single_usrp::sptr _dev; const uhd::io_type_t _type; - bool _is_streaming; - - void set_streaming(bool enb){ - if (enb) - _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); - else - _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); - _is_streaming = enb; - } }; -- cgit From 5e9908fbec19ce9309c12ea61c0303e6666e981a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 18 Oct 2010 01:03:11 -0700 Subject: uhd: removed utils warning functions, moved into the lower level wrappers --- gr-uhd/lib/Makefile.am | 4 +-- gr-uhd/lib/uhd_mimo_sink.cc | 6 ++-- gr-uhd/lib/uhd_mimo_source.cc | 6 ++-- gr-uhd/lib/uhd_simple_sink.cc | 6 ++-- gr-uhd/lib/uhd_simple_source.cc | 6 ++-- gr-uhd/lib/uhd_single_usrp_sink.cc | 3 -- gr-uhd/lib/uhd_single_usrp_source.cc | 3 -- gr-uhd/lib/utils.cc | 56 ------------------------------------ gr-uhd/lib/utils.h | 40 -------------------------- 9 files changed, 13 insertions(+), 117 deletions(-) delete mode 100644 gr-uhd/lib/utils.cc delete mode 100644 gr-uhd/lib/utils.h (limited to 'gr-uhd') diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index 1260201a5..69a41e788 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -29,7 +29,6 @@ AM_CPPFLAGS = \ lib_LTLIBRARIES = libgnuradio-uhd.la libgnuradio_uhd_la_SOURCES = \ - utils.cc \ uhd_mimo_source.cc \ uhd_mimo_sink.cc \ uhd_simple_source.cc \ @@ -51,5 +50,4 @@ grinclude_HEADERS = \ uhd_single_usrp_source.h \ uhd_single_usrp_sink.h -noinst_HEADERS = \ - utils.h +noinst_HEADERS = diff --git a/gr-uhd/lib/uhd_mimo_sink.cc b/gr-uhd/lib/uhd_mimo_sink.cc index 0a2ce1b0a..03d310b1e 100644 --- a/gr-uhd/lib/uhd_mimo_sink.cc +++ b/gr-uhd/lib/uhd_mimo_sink.cc @@ -23,7 +23,7 @@ #include #include #include -#include "utils.h" +//#include "utils.h" /*********************************************************************** * UHD Sink @@ -59,7 +59,7 @@ public: void set_samp_rate_all(double rate){ _dev->set_tx_rate_all(rate); - do_samp_rate_error_message(rate, get_samp_rate_all(), "TX"); + //do_samp_rate_error_message(rate, get_samp_rate_all(), "TX"); } double get_samp_rate_all(void){ @@ -68,7 +68,7 @@ public: uhd::tune_result_t set_center_freq(size_t chan, double freq){ uhd::tune_result_t tr = _dev->set_tx_freq(chan, freq); - do_tune_freq_error_message(freq, _dev->get_tx_freq(chan), "TX"); + //do_tune_freq_error_message(freq, _dev->get_tx_freq(chan), "TX"); return tr; } diff --git a/gr-uhd/lib/uhd_mimo_source.cc b/gr-uhd/lib/uhd_mimo_source.cc index 62157142d..abd70ba36 100644 --- a/gr-uhd/lib/uhd_mimo_source.cc +++ b/gr-uhd/lib/uhd_mimo_source.cc @@ -23,7 +23,7 @@ #include #include #include -#include "utils.h" +//#include "utils.h" /*********************************************************************** * UHD Source @@ -59,7 +59,7 @@ public: void set_samp_rate_all(double rate){ _dev->set_rx_rate_all(rate); - do_samp_rate_error_message(rate, get_samp_rate_all(), "RX"); + //do_samp_rate_error_message(rate, get_samp_rate_all(), "RX"); } double get_samp_rate_all(void){ @@ -68,7 +68,7 @@ public: uhd::tune_result_t set_center_freq(size_t chan, double freq){ uhd::tune_result_t tr = _dev->set_rx_freq(chan, freq); - do_tune_freq_error_message(freq, _dev->get_rx_freq(chan), "RX"); + //do_tune_freq_error_message(freq, _dev->get_rx_freq(chan), "RX"); return tr; } diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc index 7b31218db..d7b04465d 100644 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ b/gr-uhd/lib/uhd_simple_sink.cc @@ -23,7 +23,7 @@ #include #include #include -#include "utils.h" +//#include "utils.h" /*********************************************************************** * UHD Sink @@ -56,7 +56,7 @@ public: void set_samp_rate(double rate){ _dev->set_tx_rate(rate); - do_samp_rate_error_message(rate, get_samp_rate(), "TX"); + //do_samp_rate_error_message(rate, get_samp_rate(), "TX"); } double get_samp_rate(void){ @@ -65,7 +65,7 @@ public: uhd::tune_result_t set_center_freq(double freq){ uhd::tune_result_t tr = _dev->set_tx_freq(freq); - do_tune_freq_error_message(freq, _dev->get_tx_freq(), "TX"); + //do_tune_freq_error_message(freq, _dev->get_tx_freq(), "TX"); return tr; } diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc index c1e11e85d..d74c8414d 100644 --- a/gr-uhd/lib/uhd_simple_source.cc +++ b/gr-uhd/lib/uhd_simple_source.cc @@ -25,7 +25,7 @@ #include #include #include -#include "utils.h" +//#include "utils.h" /*********************************************************************** * UHD Source @@ -59,7 +59,7 @@ public: void set_samp_rate(double rate){ _dev->set_rx_rate(rate); - do_samp_rate_error_message(rate, get_samp_rate(), "RX"); + //do_samp_rate_error_message(rate, get_samp_rate(), "RX"); } double get_samp_rate(void){ @@ -68,7 +68,7 @@ public: uhd::tune_result_t set_center_freq(double freq){ uhd::tune_result_t tr = _dev->set_rx_freq(freq); - do_tune_freq_error_message(freq, _dev->get_rx_freq(), "RX"); + //do_tune_freq_error_message(freq, _dev->get_rx_freq(), "RX"); return tr; } diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc index 96f86c8db..cd7d7a618 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -22,7 +22,6 @@ #include #include #include -#include "utils.h" /*********************************************************************** * UHD Single USPR Sink @@ -56,7 +55,6 @@ public: void set_samp_rate(double rate){ _dev->set_tx_rate(rate); - do_samp_rate_error_message(rate, get_samp_rate(), "TX"); } double get_samp_rate(void){ @@ -65,7 +63,6 @@ public: uhd::tune_result_t set_center_freq(double freq, size_t chan){ uhd::tune_result_t tr = _dev->set_tx_freq(freq, chan); - do_tune_freq_error_message(freq, _dev->get_tx_freq(chan), "TX"); return tr; } diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index b5e39b5a4..fc2c453eb 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -24,7 +24,6 @@ #include #include #include -#include "utils.h" /*********************************************************************** * UHD Single USPR Source @@ -54,7 +53,6 @@ public: void set_samp_rate(double rate){ _dev->set_rx_rate(rate); - do_samp_rate_error_message(rate, get_samp_rate(), "RX"); } double get_samp_rate(void){ @@ -63,7 +61,6 @@ public: uhd::tune_result_t set_center_freq(double freq, size_t chan){ uhd::tune_result_t tr = _dev->set_rx_freq(freq, chan); - do_tune_freq_error_message(freq, _dev->get_rx_freq(chan), "RX"); return tr; } diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc deleted file mode 100644 index da8352965..000000000 --- a/gr-uhd/lib/utils.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include "utils.h" //local include -#include -#include -#include - -void do_samp_rate_error_message( - double target_rate, - double actual_rate, - const std::string &xx -){ - static const double max_allowed_error = 1.0; //Sps - if (std::abs(target_rate - actual_rate) > max_allowed_error){ - uhd::print_warning(str(boost::format( - "The hardware does not support the requested %s sample rate:\n" - "Target sample rate: %f MSps\n" - "Actual sample rate: %f MSps\n" - ) % xx % (target_rate/1e6) % (actual_rate/1e6))); - } -} - -void do_tune_freq_error_message( - double target_freq, - double actual_freq, - const std::string &xx -){ - static const double max_allowed_error = 1.0; //Hz - if (std::abs(target_freq - actual_freq) > max_allowed_error){ - uhd::print_warning(str(boost::format( - "The hardware does not support the requested %s frequency:\n" - "Target frequency: %f MHz\n" - "Actual frequency: %f MHz\n" - ) % xx % (target_freq/1e6) % (actual_freq/1e6))); - } -} diff --git a/gr-uhd/lib/utils.h b/gr-uhd/lib/utils.h deleted file mode 100644 index 4a05476bd..000000000 --- a/gr-uhd/lib/utils.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_NOINST_UTILS_H -#define INCLUDED_NOINST_UTILS_H - -#include - -void do_samp_rate_error_message( - double target_rate, - double actual_rate, - const std::string &xx -); - -void do_tune_freq_error_message( - double target_freq, - double actual_freq, - const std::string &xx -); - -#endif /* INCLUDED_NOINST_UTILS_H */ -- cgit From 4ac5545625d3d6df9881695f764c9c94049edb7b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 18 Oct 2010 12:18:13 -0700 Subject: uhd: added multi usrp skeleton and added deprecation note to other headers --- gr-uhd/lib/Makefile.am | 8 +-- gr-uhd/lib/uhd_mimo_sink.h | 3 + gr-uhd/lib/uhd_mimo_source.h | 3 + gr-uhd/lib/uhd_multi_usrp_sink.cc | 24 +++++++ gr-uhd/lib/uhd_multi_usrp_sink.h | 138 ++++++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_multi_usrp_source.cc | 24 +++++++ gr-uhd/lib/uhd_multi_usrp_source.h | 138 ++++++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_simple_sink.h | 3 + gr-uhd/lib/uhd_simple_source.h | 3 + 9 files changed, 340 insertions(+), 4 deletions(-) create mode 100644 gr-uhd/lib/uhd_multi_usrp_sink.cc create mode 100644 gr-uhd/lib/uhd_multi_usrp_sink.h create mode 100644 gr-uhd/lib/uhd_multi_usrp_source.cc create mode 100644 gr-uhd/lib/uhd_multi_usrp_source.h (limited to 'gr-uhd') diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index 69a41e788..d9a296c75 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -31,6 +31,8 @@ lib_LTLIBRARIES = libgnuradio-uhd.la libgnuradio_uhd_la_SOURCES = \ uhd_mimo_source.cc \ uhd_mimo_sink.cc \ + uhd_multi_usrp_source.cc \ + uhd_multi_usrp_sink.cc \ uhd_simple_source.cc \ uhd_simple_sink.cc \ uhd_single_usrp_source.cc \ @@ -43,10 +45,8 @@ libgnuradio_uhd_la_LIBADD = \ libgnuradio_uhd_la_LDFLAGS = $(LTVERSIONFLAGS) grinclude_HEADERS = \ - uhd_mimo_source.h \ - uhd_mimo_sink.h \ - uhd_simple_source.h \ - uhd_simple_sink.h \ + uhd_multi_usrp_source.h \ + uhd_multi_usrp_sink.h \ uhd_single_usrp_source.h \ uhd_single_usrp_sink.h diff --git a/gr-uhd/lib/uhd_mimo_sink.h b/gr-uhd/lib/uhd_mimo_sink.h index 46679d973..a0a30381c 100644 --- a/gr-uhd/lib/uhd_mimo_sink.h +++ b/gr-uhd/lib/uhd_mimo_sink.h @@ -34,6 +34,9 @@ boost::shared_ptr uhd_make_mimo_sink( const uhd::io_type_t::tid_t &type ); +/*********************************************************************** + * DEPRECATED + **********************************************************************/ class uhd_mimo_sink : public gr_sync_block{ public: diff --git a/gr-uhd/lib/uhd_mimo_source.h b/gr-uhd/lib/uhd_mimo_source.h index fbd7f2c42..f6f18eedc 100644 --- a/gr-uhd/lib/uhd_mimo_source.h +++ b/gr-uhd/lib/uhd_mimo_source.h @@ -34,6 +34,9 @@ boost::shared_ptr uhd_make_mimo_source( const uhd::io_type_t::tid_t &type ); +/*********************************************************************** + * DEPRECATED + **********************************************************************/ class uhd_mimo_source : public gr_sync_block{ public: diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.cc b/gr-uhd/lib/uhd_multi_usrp_sink.cc new file mode 100644 index 000000000..6854649c3 --- /dev/null +++ b/gr-uhd/lib/uhd_multi_usrp_sink.cc @@ -0,0 +1,24 @@ +/* + * 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 +#include +#include diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.h b/gr-uhd/lib/uhd_multi_usrp_sink.h new file mode 100644 index 000000000..b29657e94 --- /dev/null +++ b/gr-uhd/lib/uhd_multi_usrp_sink.h @@ -0,0 +1,138 @@ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_UHD_MULTI_USRP_SINK_H +#define INCLUDED_UHD_MULTI_USRP_SINK_H + +#include +#include + +class uhd_multi_usrp_sink; + +boost::shared_ptr uhd_make_multi_usrp_sink( + const std::string &args, + const uhd::io_type_t::tid_t &type, + size_t num_channels +); + +class uhd_multi_usrp_sink : public gr_sync_block{ +public: + + /*! + * Set the IO signature for this block. + * \param sig the input signature + */ + uhd_multi_usrp_sink(gr_io_signature_sptr sig); + + /*! + * Set the subdevice specification. + * \param spec the subdev spec markup string + */ + 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 freq the desired frequency in Hz + * \return a tune result with the actual frequencies + */ + virtual uhd::tune_result_t set_center_freq(double freq, size_t chan = 0) = 0; + + /*! + * Get the tunable frequency range. + * \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 + */ + virtual void set_gain(float gain, size_t chan = 0) = 0; + + /*! + * Get the actual dboard gain setting. + * \return the actual gain in dB + */ + virtual float get_gain(size_t chan = 0) = 0; + + /*! + * Get the settable gain range. + * \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 + */ + virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0; + + /*! + * Get the antenna in use. + * \return the antenna string + */ + virtual std::string get_antenna(size_t chan = 0) = 0; + + /*! + * Get a list of possible antennas. + * \return a vector of antenna strings + */ + virtual std::vector get_antennas(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, 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; + + /*! + * Get access to the underlying uhd device object. + * \return the multi usrp device object + */ + virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0; +}; + +#endif /* INCLUDED_UHD_MULTI_USRP_SINK_H */ diff --git a/gr-uhd/lib/uhd_multi_usrp_source.cc b/gr-uhd/lib/uhd_multi_usrp_source.cc new file mode 100644 index 000000000..27caffbfc --- /dev/null +++ b/gr-uhd/lib/uhd_multi_usrp_source.cc @@ -0,0 +1,24 @@ +/* + * 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 +#include +#include diff --git a/gr-uhd/lib/uhd_multi_usrp_source.h b/gr-uhd/lib/uhd_multi_usrp_source.h new file mode 100644 index 000000000..b2c4a3ac1 --- /dev/null +++ b/gr-uhd/lib/uhd_multi_usrp_source.h @@ -0,0 +1,138 @@ +/* + * Copyright 2010 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_UHD_MULTI_USRP_SOURCE_H +#define INCLUDED_UHD_MULTI_USRP_SOURCE_H + +#include +#include + +class uhd_multi_usrp_source; + +boost::shared_ptr uhd_make_multi_usrp_source( + const std::string &args, + const uhd::io_type_t::tid_t &type, + size_t num_channels +); + +class uhd_multi_usrp_source : public gr_sync_block{ +public: + + /*! + * Set the IO signature for this block. + * \param sig the output signature + */ + uhd_multi_usrp_source(gr_io_signature_sptr sig); + + /*! + * Set the subdevice specification. + * \param spec the subdev spec markup string + */ + 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 freq the desired frequency in Hz + * \return a tune result with the actual frequencies + */ + virtual uhd::tune_result_t set_center_freq(double freq, size_t chan = 0) = 0; + + /*! + * Get the tunable frequency range. + * \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 + */ + virtual void set_gain(float gain, size_t chan = 0) = 0; + + /*! + * Get the actual dboard gain setting. + * \return the actual gain in dB + */ + virtual float get_gain(size_t chan = 0) = 0; + + /*! + * Get the settable gain range. + * \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 + */ + virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0; + + /*! + * Get the antenna in use. + * \return the antenna string + */ + virtual std::string get_antenna(size_t chan = 0) = 0; + + /*! + * Get a list of possible antennas. + * \return a vector of antenna strings + */ + virtual std::vector get_antennas(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, 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; + + /*! + * 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_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index 0abf30681..44b868698 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -33,6 +33,9 @@ boost::shared_ptr uhd_make_simple_sink( const uhd::io_type_t::tid_t &type ); +/*********************************************************************** + * DEPRECATED + **********************************************************************/ class uhd_simple_sink : public gr_sync_block{ public: diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index b95c0cfd9..4e79afa21 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -33,6 +33,9 @@ boost::shared_ptr uhd_make_simple_source( const uhd::io_type_t::tid_t &type ); +/*********************************************************************** + * DEPRECATED + **********************************************************************/ class uhd_simple_source : public gr_sync_block{ public: -- cgit From 873228d25b3ea5df8eb10f6652518f144858af61 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 18 Oct 2010 13:46:51 -0700 Subject: uhd: filled in multi usrp code and swig file --- gr-uhd/lib/uhd_multi_usrp_sink.cc | 151 ++++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_multi_usrp_sink.h | 6 ++ gr-uhd/lib/uhd_multi_usrp_source.cc | 154 +++++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_multi_usrp_source.h | 6 ++ gr-uhd/lib/uhd_single_usrp_sink.cc | 10 +-- gr-uhd/lib/uhd_single_usrp_source.cc | 6 +- gr-uhd/swig/uhd_swig.i | 33 +++++--- 7 files changed, 344 insertions(+), 22 deletions(-) (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 6854649c3..202f12840 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.cc +++ b/gr-uhd/lib/uhd_multi_usrp_sink.cc @@ -22,3 +22,154 @@ #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 std::string &args, + const uhd::io_type_t &type, + size_t num_channels + ) : uhd_multi_usrp_sink(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type), _nchan(num_channels) + { + _dev = uhd::usrp::multi_usrp::make(args); + } + + void set_subdev_spec(const std::string &spec, size_t mboard){ + return _dev->set_tx_subdev_spec(spec, mboard); + } + + void set_samp_rate(double rate){ + _dev->set_tx_rate(rate); + } + + double get_samp_rate(void){ + return _dev->get_tx_rate(); + } + + uhd::tune_result_t set_center_freq(double freq, size_t chan){ + uhd::tune_result_t tr = _dev->set_tx_freq(freq, chan); + return tr; + } + + uhd::freq_range_t get_freq_range(size_t chan){ + return _dev->get_tx_freq_range(chan); + } + + void set_gain(float gain, size_t chan){ + return _dev->set_tx_gain(gain, chan); + } + + float get_gain(size_t chan){ + return _dev->get_tx_gain(chan); + } + + uhd::gain_range_t get_gain_range(size_t chan){ + return _dev->get_tx_gain_range(chan); + } + + void set_antenna(const std::string &ant, size_t chan){ + return _dev->set_tx_antenna(ant, chan); + } + + std::string get_antenna(size_t chan){ + return _dev->get_tx_antenna(chan); + } + + std::vector get_antennas(size_t chan){ + return _dev->get_tx_antennas(chan); + } + + void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard){ + return _dev->set_clock_config(clock_config, mboard); + } + + uhd::time_spec_t get_time_now(void){ + return _dev->get_time_now(); + } + + void set_time_next_pps(const uhd::time_spec_t &time_spec){ + return _dev->set_time_next_pps(time_spec); + } + + void set_time_unknown_pps(const uhd::time_spec_t &time_spec){ + return _dev->set_time_unknown_pps(time_spec); + } + + uhd::usrp::multi_usrp::sptr get_device(void){ + return _dev; + } + +/*********************************************************************** + * Work + **********************************************************************/ + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ){ + uhd::tx_metadata_t metadata; + metadata.start_of_burst = true; + + return _dev->get_device()->send( + input_items, noutput_items, metadata, + _type, uhd::device::SEND_MODE_FULL_BUFF + ); + } + + //Send an empty start-of-burst packet to begin streaming. + //Set at a time in the near future so data will be sync'd. + bool start(void){ + uhd::tx_metadata_t metadata; + metadata.start_of_burst = true; + metadata.has_time_spec = true; + metadata.time_spec = get_time_now() + uhd::time_spec_t(0.01); //10ms offset in future + + _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::multi_usrp::sptr _dev; + const uhd::io_type_t _type; + size_t _nchan; +}; + +/*********************************************************************** + * Make UHD Multi USRP Sink + **********************************************************************/ +boost::shared_ptr uhd_make_multi_usrp_sink( + const std::string &args, + const uhd::io_type_t::tid_t &type, + size_t num_channels +){ + return boost::shared_ptr( + new uhd_multi_usrp_sink_impl(args, type, num_channels) + ); +} diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.h b/gr-uhd/lib/uhd_multi_usrp_sink.h index b29657e94..13bba20fb 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.h +++ b/gr-uhd/lib/uhd_multi_usrp_sink.h @@ -128,6 +128,12 @@ public: */ virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; + /*! + * Sync the time registers with an unknown pps edge. + * \param time_spec the new time + */ + virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0; + /*! * Get access to the underlying uhd device object. * \return the multi usrp device object diff --git a/gr-uhd/lib/uhd_multi_usrp_source.cc b/gr-uhd/lib/uhd_multi_usrp_source.cc index 27caffbfc..c10c08c50 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.cc +++ b/gr-uhd/lib/uhd_multi_usrp_source.cc @@ -22,3 +22,157 @@ #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 std::string &args, + const uhd::io_type_t &type, + size_t num_channels + ) : uhd_multi_usrp_source(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) + { + _dev = uhd::usrp::multi_usrp::make(args); + } + + 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(double freq, size_t chan){ + uhd::tune_result_t tr = _dev->set_rx_freq(freq, chan); + return tr; + } + + uhd::freq_range_t get_freq_range(size_t chan){ + return _dev->get_rx_freq_range(chan); + } + + void set_gain(float gain, size_t chan){ + return _dev->set_rx_gain(gain, chan); + } + + float get_gain(size_t chan){ + return _dev->get_rx_gain(chan); + } + + uhd::gain_range_t get_gain_range(size_t chan){ + return _dev->get_rx_gain_range(chan); + } + + void set_antenna(const std::string &ant, size_t chan){ + return _dev->set_rx_antenna(ant, chan); + } + + std::string get_antenna(size_t chan){ + return _dev->get_rx_antenna(chan); + } + + std::vector get_antennas(size_t chan){ + return _dev->get_rx_antennas(chan); + } + + void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard){ + return _dev->set_clock_config(clock_config, mboard); + } + + uhd::time_spec_t get_time_now(void){ + return _dev->get_time_now(); + } + + void set_time_next_pps(const uhd::time_spec_t &time_spec){ + return _dev->set_time_next_pps(time_spec); + } + + void set_time_unknown_pps(const uhd::time_spec_t &time_spec){ + return _dev->set_time_unknown_pps(time_spec); + } + + uhd::usrp::multi_usrp::sptr get_device(void){ + return _dev; + } + +/*********************************************************************** + * Work + **********************************************************************/ + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ){ + uhd::rx_metadata_t metadata; //not passed out of this block + + size_t num_samps = _dev->get_device()->recv( + output_items, noutput_items, metadata, + _type, uhd::device::RECV_MODE_FULL_BUFF + ); + + 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.01; //10 ms (order of magnitude >> 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(_dev->get_num_mboards() * 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 std::string &args, + const uhd::io_type_t::tid_t &type, + size_t num_channels +){ + return boost::shared_ptr( + new uhd_multi_usrp_source_impl(args, type, num_channels) + ); +} diff --git a/gr-uhd/lib/uhd_multi_usrp_source.h b/gr-uhd/lib/uhd_multi_usrp_source.h index b2c4a3ac1..b94e53f01 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.h +++ b/gr-uhd/lib/uhd_multi_usrp_source.h @@ -128,6 +128,12 @@ public: */ virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; + /*! + * Sync the time registers with an unknown pps edge. + * \param time_spec the new time + */ + virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0; + /*! * Get access to the underlying uhd device object. * \return the multi usrp device object diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc index cd7d7a618..96c1dbdf4 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -24,7 +24,7 @@ #include /*********************************************************************** - * UHD Single USPR Sink + * 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)){ @@ -32,7 +32,7 @@ uhd_single_usrp_sink::uhd_single_usrp_sink(gr_io_signature_sptr sig) } /*********************************************************************** - * UHD Single USPR Sink Impl + * UHD Single USRP Sink Impl **********************************************************************/ class uhd_single_usrp_sink_impl : public uhd_single_usrp_sink{ public: @@ -45,10 +45,6 @@ public: _dev = uhd::usrp::single_usrp::make(args); } - ~uhd_single_usrp_sink_impl(void){ - //NOP - } - void set_subdev_spec(const std::string &spec){ return _dev->set_tx_subdev_spec(spec); } @@ -164,7 +160,7 @@ protected: }; /*********************************************************************** - * Make UHD Single USPR Sink + * Make UHD Single USRP Sink **********************************************************************/ boost::shared_ptr uhd_make_single_usrp_sink( const std::string &args, diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index fc2c453eb..7c3694a99 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -26,7 +26,7 @@ #include /*********************************************************************** - * UHD Single USPR Source + * 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){ @@ -34,7 +34,7 @@ uhd_single_usrp_source::uhd_single_usrp_source(gr_io_signature_sptr sig) } /*********************************************************************** - * UHD Single USPR Source Impl + * UHD Single USRP Source Impl **********************************************************************/ class uhd_single_usrp_source_impl : public uhd_single_usrp_source{ public: @@ -160,7 +160,7 @@ private: /*********************************************************************** - * Make UHD Single USPR Source + * Make UHD Single USRP Source **********************************************************************/ boost::shared_ptr uhd_make_single_usrp_source( const std::string &args, diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index d755dfeee..1631a768a 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -29,10 +29,13 @@ namespace std { } %{ -#include -#include -#include -#include +#include //deprecated +#include //deprecated +#include //deprecated +#include //deprecated + +#include +#include #include #include %} @@ -44,17 +47,23 @@ namespace std { %include %include -GR_SWIG_BLOCK_MAGIC(uhd,mimo_source) -%include +GR_SWIG_BLOCK_MAGIC(uhd,mimo_source) //deprecated +%include //deprecated + +GR_SWIG_BLOCK_MAGIC(uhd,mimo_sink) //deprecated +%include //deprecated + +GR_SWIG_BLOCK_MAGIC(uhd,simple_source) //deprecated +%include //deprecated -GR_SWIG_BLOCK_MAGIC(uhd,mimo_sink) -%include +GR_SWIG_BLOCK_MAGIC(uhd,simple_sink) //deprecated +%include //deprecated -GR_SWIG_BLOCK_MAGIC(uhd,simple_source) -%include +GR_SWIG_BLOCK_MAGIC(uhd,multi_usrp_source) +%include -GR_SWIG_BLOCK_MAGIC(uhd,simple_sink) -%include +GR_SWIG_BLOCK_MAGIC(uhd,multi_usrp_sink) +%include GR_SWIG_BLOCK_MAGIC(uhd,single_usrp_source) %include -- cgit From d029af43c3367a4611185ade70639cc6b7cc5e3d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 18 Oct 2010 14:09:23 -0700 Subject: uhd: created multi usrp grc wrapper generator, removed mimo gen and checked in its generated files --- gr-uhd/grc/.gitignore | 2 +- gr-uhd/grc/Makefile.am | 21 +- gr-uhd/grc/gen_uhd_mimo_blocks_xml.py | 190 ---------- gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py | 211 +++++++++++ gr-uhd/grc/uhd_mimo_sink.xml | 550 ++++++++++++++++++++++++++++ gr-uhd/grc/uhd_mimo_source.xml | 550 ++++++++++++++++++++++++++++ gr-uhd/lib/Makefile.am | 11 +- 7 files changed, 1332 insertions(+), 203 deletions(-) delete mode 100755 gr-uhd/grc/gen_uhd_mimo_blocks_xml.py create mode 100755 gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py create mode 100644 gr-uhd/grc/uhd_mimo_sink.xml create mode 100644 gr-uhd/grc/uhd_mimo_source.xml (limited to 'gr-uhd') diff --git a/gr-uhd/grc/.gitignore b/gr-uhd/grc/.gitignore index c95275d8d..d8ab9bd0c 100644 --- a/gr-uhd/grc/.gitignore +++ b/gr-uhd/grc/.gitignore @@ -1,4 +1,4 @@ -/uhd_mimo*.xml +/uhd_multi*.xml /uhd_single*.xml /Makefile /Makefile.in diff --git a/gr-uhd/grc/Makefile.am b/gr-uhd/grc/Makefile.am index a19a28f03..04b7dca36 100644 --- a/gr-uhd/grc/Makefile.am +++ b/gr-uhd/grc/Makefile.am @@ -23,31 +23,36 @@ include $(top_srcdir)/Makefile.common grcblocksdir = $(grc_blocksdir) -generated_uhd_mimo_blocks = \ - uhd_mimo_source.xml \ - uhd_mimo_sink.xml +generated_uhd_multi_usrp_blocks = \ + uhd_multi_usrp_source.xml \ + uhd_multi_usrp_sink.xml generated_uhd_single_usrp_blocks = \ uhd_single_usrp_source.xml \ uhd_single_usrp_sink.xml BUILT_SOURCES = \ - $(generated_uhd_mimo_blocks) \ + $(generated_uhd_multi_usrp_blocks) \ $(generated_uhd_single_usrp_blocks) dist_grcblocks_DATA = \ - $(BUILT_SOURCES) \ + $(BUILT_SOURCES) + +# add the deprecated files +dist_grcblocks_DATA += \ + uhd_mimo_source.xml \ + uhd_mimo_sink.xml \ uhd_simple_source.xml \ uhd_simple_sink.xml ######################################################################## -# Rules for generating the mimo source and sink blocks +# Rules for generating the source and sink xml wrappers ######################################################################## EXTRA_DIST = \ - $(srcdir)/gen_uhd_mimo_blocks_xml.py \ + $(srcdir)/gen_uhd_multi_usrp_blocks_xml.py \ $(srcdir)/gen_uhd_single_usrp_blocks_xml.py -$(generated_uhd_mimo_blocks): $(srcdir)/gen_uhd_mimo_blocks_xml.py +$(generated_uhd_multi_usrp_blocks): $(srcdir)/gen_uhd_multi_usrp_blocks_xml.py @echo "generating $@..." $(PYTHON) $< $@ diff --git a/gr-uhd/grc/gen_uhd_mimo_blocks_xml.py b/gr-uhd/grc/gen_uhd_mimo_blocks_xml.py deleted file mode 100755 index 7e61563cc..000000000 --- a/gr-uhd/grc/gen_uhd_mimo_blocks_xml.py +++ /dev/null @@ -1,190 +0,0 @@ -#!/usr/bin/env python -""" -Copyright 2010 Free Software Foundation, Inc. - -This file is part of GNU Radio - -GNU Radio Companion is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -GNU Radio Companion is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -""" - -MAIN_TMPL = """\ - - - UHD MIMO $sourk.title() - uhd_mimo_$(sourk) - UHD - from gnuradio import uhd - uhd.mimo_$(sourk)(\$nchan, \$args, uhd.io_type_t.\$type.type) -self.\$(id).set_samp_rate_all(\$samp_rate) -#for $n in range($max_nchan) -\#if \$nchan() > $n -self.\$(id).set_subdev_spec($n, \$sd_spec$(n)) -self.\$(id).set_center_freq($n, \$center_freq$(n)) -self.\$(id).set_gain($n, \$gain$(n)) - \#if \$ant$(n)() -self.\$(id).set_antenna($n, \$ant$(n)) - \#end if -\#end if -#end for - - set_samp_rate(\$samp_rate) - #for $n in range($max_nchan) - set_center_freq($n, \$center_freq$(n)) - set_gain($n, \$gain$(n)) - set_antenna($n, \$ant$(n)) - #end for - - Input Type - type - enum - - - - - Num Channels - nchan - 2 - int - #for $n in range(2, $max_nchan+1) - - #end for - - - Args - args - addr=192.168.10.2 192.168.20.2 - string - - - Samp Rate (Sps) - samp_rate - samp_rate - real - - $params - $max_nchan >= \$nchan - \$nchan >= 0 - <$sourk> - $direction - \$type - \$type.vlen - \$nchan - - -The UHD $sourk.title() Block: - -Args: -Args is a delimited string used to locate UHD devices on your system. \\ -If left blank, the first UHD device found will be used. \\ -Used args to specify a specfic device. \\ -USRP2 Example: addr=192.168.10.2 - -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. - -Antenna: -For subdevices/daughterboards 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. - - -""" - -PARAMS_TMPL = """ - - Ch$(n): Subdev Spec - sd_spec$(n) - - string - - \#if not \$nchan() > $n - all - \#elif \$sd_spec$(n)() - none - \#else - part - \#end if - - - - 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 - - -""" - -def parse_tmpl(_tmpl, **kwargs): - from Cheetah import Template - return str(Template.Template(_tmpl, kwargs)) - -max_num_channels = 8 - -if __name__ == '__main__': - import sys - for file in sys.argv[1:]: - if 'source' in file: - sourk = 'source' - direction = 'out' - elif 'sink' in file: - sourk = 'sink' - direction = 'in' - else: raise Exception, 'is %s a source or sink?'%file - - params = ''.join([parse_tmpl(PARAMS_TMPL, n=n) for n in range(max_num_channels)]) - open(file, 'w').write(parse_tmpl(MAIN_TMPL, - max_nchan=max_num_channels, - params=params, - sourk=sourk, - direction=direction, - )) diff --git a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py new file mode 100755 index 000000000..a4da53a18 --- /dev/null +++ b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py @@ -0,0 +1,211 @@ +#!/usr/bin/env python +""" +Copyright 2010 Free Software Foundation, Inc. + +This file is part of GNU Radio + +GNU Radio Companion is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +GNU Radio Companion is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +""" + +MAIN_TMPL = """\ + + + UHD: Multi USRP $sourk.title() + uhd_multi_usrp_$(sourk) + UHD + from gnuradio import uhd + uhd.multi_usrp_$(sourk)(\$dev_addr, uhd.io_type_t.\$type.type, \$nchan) +self.\$(id).set_subdev_spec(\$sd_spec) +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 +\#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) + #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 + + + + 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 Multi 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. \\ +Used args to specify a specfic device. +USRP2 Example: addr=192.168.10.2 192.168.10.3 + +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. + +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 + +Antenna: +For subdevices/daughterboards 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. + + +""" + +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 + + +""" + +def parse_tmpl(_tmpl, **kwargs): + from Cheetah import Template + return str(Template.Template(_tmpl, kwargs)) + +max_num_channels = 4 + +if __name__ == '__main__': + import sys + for file in sys.argv[1:]: + if 'source' in file: + sourk = 'source' + direction = 'out' + elif 'sink' in file: + sourk = 'sink' + direction = 'in' + else: raise Exception, 'is %s a source or sink?'%file + + params = ''.join([parse_tmpl(PARAMS_TMPL, n=n) for n in range(max_num_channels)]) + open(file, 'w').write(parse_tmpl(MAIN_TMPL, + max_nchan=max_num_channels, + params=params, + sourk=sourk, + direction=direction, + )) diff --git a/gr-uhd/grc/uhd_mimo_sink.xml b/gr-uhd/grc/uhd_mimo_sink.xml new file mode 100644 index 000000000..2f5f2011f --- /dev/null +++ b/gr-uhd/grc/uhd_mimo_sink.xml @@ -0,0 +1,550 @@ + + + UHD MIMO Sink + uhd_mimo_sink + UHD + from gnuradio import uhd + uhd.mimo_sink($nchan, $args, uhd.io_type_t.$type.type) +self.$(id).set_samp_rate_all($samp_rate) +#if $nchan() > 0 +self.$(id).set_subdev_spec(0, $sd_spec0) +self.$(id).set_center_freq(0, $center_freq0) +self.$(id).set_gain(0, $gain0) + #if $ant0() +self.$(id).set_antenna(0, $ant0) + #end if +#end if +#if $nchan() > 1 +self.$(id).set_subdev_spec(1, $sd_spec1) +self.$(id).set_center_freq(1, $center_freq1) +self.$(id).set_gain(1, $gain1) + #if $ant1() +self.$(id).set_antenna(1, $ant1) + #end if +#end if +#if $nchan() > 2 +self.$(id).set_subdev_spec(2, $sd_spec2) +self.$(id).set_center_freq(2, $center_freq2) +self.$(id).set_gain(2, $gain2) + #if $ant2() +self.$(id).set_antenna(2, $ant2) + #end if +#end if +#if $nchan() > 3 +self.$(id).set_subdev_spec(3, $sd_spec3) +self.$(id).set_center_freq(3, $center_freq3) +self.$(id).set_gain(3, $gain3) + #if $ant3() +self.$(id).set_antenna(3, $ant3) + #end if +#end if +#if $nchan() > 4 +self.$(id).set_subdev_spec(4, $sd_spec4) +self.$(id).set_center_freq(4, $center_freq4) +self.$(id).set_gain(4, $gain4) + #if $ant4() +self.$(id).set_antenna(4, $ant4) + #end if +#end if +#if $nchan() > 5 +self.$(id).set_subdev_spec(5, $sd_spec5) +self.$(id).set_center_freq(5, $center_freq5) +self.$(id).set_gain(5, $gain5) + #if $ant5() +self.$(id).set_antenna(5, $ant5) + #end if +#end if +#if $nchan() > 6 +self.$(id).set_subdev_spec(6, $sd_spec6) +self.$(id).set_center_freq(6, $center_freq6) +self.$(id).set_gain(6, $gain6) + #if $ant6() +self.$(id).set_antenna(6, $ant6) + #end if +#end if +#if $nchan() > 7 +self.$(id).set_subdev_spec(7, $sd_spec7) +self.$(id).set_center_freq(7, $center_freq7) +self.$(id).set_gain(7, $gain7) + #if $ant7() +self.$(id).set_antenna(7, $ant7) + #end if +#end if + + set_samp_rate($samp_rate) + set_center_freq(0, $center_freq0) + set_gain(0, $gain0) + set_antenna(0, $ant0) + set_center_freq(1, $center_freq1) + set_gain(1, $gain1) + set_antenna(1, $ant1) + set_center_freq(2, $center_freq2) + set_gain(2, $gain2) + set_antenna(2, $ant2) + set_center_freq(3, $center_freq3) + set_gain(3, $gain3) + set_antenna(3, $ant3) + set_center_freq(4, $center_freq4) + set_gain(4, $gain4) + set_antenna(4, $ant4) + set_center_freq(5, $center_freq5) + set_gain(5, $gain5) + set_antenna(5, $ant5) + set_center_freq(6, $center_freq6) + set_gain(6, $gain6) + set_antenna(6, $ant6) + set_center_freq(7, $center_freq7) + set_gain(7, $gain7) + set_antenna(7, $ant7) + + Input Type + type + enum + + + + + Num Channels + nchan + 2 + int + + + + + + + + + + Args + args + addr=192.168.10.2 192.168.20.2 + string + + + Samp Rate (Sps) + samp_rate + samp_rate + real + + + + Ch0: Subdev Spec + sd_spec0 + + string + + #if not $nchan() > 0 + all + #elif $sd_spec0() + none + #else + part + #end if + + + + 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 + + + + + Ch1: Subdev Spec + sd_spec1 + + string + + #if not $nchan() > 1 + all + #elif $sd_spec1() + 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 + + + + + Ch2: Subdev Spec + sd_spec2 + + string + + #if not $nchan() > 2 + all + #elif $sd_spec2() + 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 + + + + + Ch3: Subdev Spec + sd_spec3 + + string + + #if not $nchan() > 3 + all + #elif $sd_spec3() + 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 + + + + + Ch4: Subdev Spec + sd_spec4 + + string + + #if not $nchan() > 4 + all + #elif $sd_spec4() + 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 + + + + + Ch5: Subdev Spec + sd_spec5 + + string + + #if not $nchan() > 5 + all + #elif $sd_spec5() + 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 + + + + + Ch6: Subdev Spec + sd_spec6 + + string + + #if not $nchan() > 6 + all + #elif $sd_spec6() + 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 + + + + + Ch7: Subdev Spec + sd_spec7 + + string + + #if not $nchan() > 7 + all + #elif $sd_spec7() + 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 + + + + 8 >= $nchan + $nchan >= 0 + + in + $type + $type.vlen + $nchan + + +The UHD Sink Block: + +Args: +Args is a delimited string used to locate UHD devices on your system. \ +If left blank, the first UHD device found will be used. \ +Used args to specify a specfic device. \ +USRP2 Example: addr=192.168.10.2 + +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. + +Antenna: +For subdevices/daughterboards 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. + + diff --git a/gr-uhd/grc/uhd_mimo_source.xml b/gr-uhd/grc/uhd_mimo_source.xml new file mode 100644 index 000000000..d8f4e6d66 --- /dev/null +++ b/gr-uhd/grc/uhd_mimo_source.xml @@ -0,0 +1,550 @@ + + + UHD MIMO Source + uhd_mimo_source + UHD + from gnuradio import uhd + uhd.mimo_source($nchan, $args, uhd.io_type_t.$type.type) +self.$(id).set_samp_rate_all($samp_rate) +#if $nchan() > 0 +self.$(id).set_subdev_spec(0, $sd_spec0) +self.$(id).set_center_freq(0, $center_freq0) +self.$(id).set_gain(0, $gain0) + #if $ant0() +self.$(id).set_antenna(0, $ant0) + #end if +#end if +#if $nchan() > 1 +self.$(id).set_subdev_spec(1, $sd_spec1) +self.$(id).set_center_freq(1, $center_freq1) +self.$(id).set_gain(1, $gain1) + #if $ant1() +self.$(id).set_antenna(1, $ant1) + #end if +#end if +#if $nchan() > 2 +self.$(id).set_subdev_spec(2, $sd_spec2) +self.$(id).set_center_freq(2, $center_freq2) +self.$(id).set_gain(2, $gain2) + #if $ant2() +self.$(id).set_antenna(2, $ant2) + #end if +#end if +#if $nchan() > 3 +self.$(id).set_subdev_spec(3, $sd_spec3) +self.$(id).set_center_freq(3, $center_freq3) +self.$(id).set_gain(3, $gain3) + #if $ant3() +self.$(id).set_antenna(3, $ant3) + #end if +#end if +#if $nchan() > 4 +self.$(id).set_subdev_spec(4, $sd_spec4) +self.$(id).set_center_freq(4, $center_freq4) +self.$(id).set_gain(4, $gain4) + #if $ant4() +self.$(id).set_antenna(4, $ant4) + #end if +#end if +#if $nchan() > 5 +self.$(id).set_subdev_spec(5, $sd_spec5) +self.$(id).set_center_freq(5, $center_freq5) +self.$(id).set_gain(5, $gain5) + #if $ant5() +self.$(id).set_antenna(5, $ant5) + #end if +#end if +#if $nchan() > 6 +self.$(id).set_subdev_spec(6, $sd_spec6) +self.$(id).set_center_freq(6, $center_freq6) +self.$(id).set_gain(6, $gain6) + #if $ant6() +self.$(id).set_antenna(6, $ant6) + #end if +#end if +#if $nchan() > 7 +self.$(id).set_subdev_spec(7, $sd_spec7) +self.$(id).set_center_freq(7, $center_freq7) +self.$(id).set_gain(7, $gain7) + #if $ant7() +self.$(id).set_antenna(7, $ant7) + #end if +#end if + + set_samp_rate($samp_rate) + set_center_freq(0, $center_freq0) + set_gain(0, $gain0) + set_antenna(0, $ant0) + set_center_freq(1, $center_freq1) + set_gain(1, $gain1) + set_antenna(1, $ant1) + set_center_freq(2, $center_freq2) + set_gain(2, $gain2) + set_antenna(2, $ant2) + set_center_freq(3, $center_freq3) + set_gain(3, $gain3) + set_antenna(3, $ant3) + set_center_freq(4, $center_freq4) + set_gain(4, $gain4) + set_antenna(4, $ant4) + set_center_freq(5, $center_freq5) + set_gain(5, $gain5) + set_antenna(5, $ant5) + set_center_freq(6, $center_freq6) + set_gain(6, $gain6) + set_antenna(6, $ant6) + set_center_freq(7, $center_freq7) + set_gain(7, $gain7) + set_antenna(7, $ant7) + + Input Type + type + enum + + + + + Num Channels + nchan + 2 + int + + + + + + + + + + Args + args + addr=192.168.10.2 192.168.20.2 + string + + + Samp Rate (Sps) + samp_rate + samp_rate + real + + + + Ch0: Subdev Spec + sd_spec0 + + string + + #if not $nchan() > 0 + all + #elif $sd_spec0() + none + #else + part + #end if + + + + 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 + + + + + Ch1: Subdev Spec + sd_spec1 + + string + + #if not $nchan() > 1 + all + #elif $sd_spec1() + 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 + + + + + Ch2: Subdev Spec + sd_spec2 + + string + + #if not $nchan() > 2 + all + #elif $sd_spec2() + 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 + + + + + Ch3: Subdev Spec + sd_spec3 + + string + + #if not $nchan() > 3 + all + #elif $sd_spec3() + 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 + + + + + Ch4: Subdev Spec + sd_spec4 + + string + + #if not $nchan() > 4 + all + #elif $sd_spec4() + 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 + + + + + Ch5: Subdev Spec + sd_spec5 + + string + + #if not $nchan() > 5 + all + #elif $sd_spec5() + 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 + + + + + Ch6: Subdev Spec + sd_spec6 + + string + + #if not $nchan() > 6 + all + #elif $sd_spec6() + 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 + + + + + Ch7: Subdev Spec + sd_spec7 + + string + + #if not $nchan() > 7 + all + #elif $sd_spec7() + 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 + + + + 8 >= $nchan + $nchan >= 0 + + out + $type + $type.vlen + $nchan + + +The UHD Source Block: + +Args: +Args is a delimited string used to locate UHD devices on your system. \ +If left blank, the first UHD device found will be used. \ +Used args to specify a specfic device. \ +USRP2 Example: addr=192.168.10.2 + +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. + +Antenna: +For subdevices/daughterboards 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. + + diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index d9a296c75..b4b1abfc6 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -29,15 +29,18 @@ AM_CPPFLAGS = \ lib_LTLIBRARIES = libgnuradio-uhd.la libgnuradio_uhd_la_SOURCES = \ - uhd_mimo_source.cc \ - uhd_mimo_sink.cc \ uhd_multi_usrp_source.cc \ uhd_multi_usrp_sink.cc \ - uhd_simple_source.cc \ - uhd_simple_sink.cc \ uhd_single_usrp_source.cc \ uhd_single_usrp_sink.cc +# add the deprecated sources +libgnuradio_uhd_la_SOURCES += \ + uhd_mimo_source.cc \ + uhd_mimo_sink.cc \ + uhd_simple_source.cc \ + uhd_simple_sink.cc + libgnuradio_uhd_la_LIBADD = \ $(GNURADIO_CORE_LA) \ $(UHD_LIBS) -- cgit From 1e5db4248e2488e0f1b44ac1405d78e16c2408d8 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 18 Oct 2010 16:13:10 -0700 Subject: uhd: work on multi usrp blocks, use block tree to categorize blocks, deprecate mimo blocks --- gr-uhd/grc/Makefile.am | 1 + gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py | 101 +++++++++++++++++++-------- gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py | 3 +- gr-uhd/grc/uhd_block_tree.xml | 23 ++++++ gr-uhd/grc/uhd_mimo_sink.xml | 3 +- gr-uhd/grc/uhd_mimo_source.xml | 3 +- gr-uhd/grc/uhd_simple_sink.xml | 1 - gr-uhd/grc/uhd_simple_source.xml | 1 - 8 files changed, 99 insertions(+), 37 deletions(-) create mode 100644 gr-uhd/grc/uhd_block_tree.xml (limited to 'gr-uhd') diff --git a/gr-uhd/grc/Makefile.am b/gr-uhd/grc/Makefile.am index 04b7dca36..d424ca709 100644 --- a/gr-uhd/grc/Makefile.am +++ b/gr-uhd/grc/Makefile.am @@ -36,6 +36,7 @@ BUILT_SOURCES = \ $(generated_uhd_single_usrp_blocks) dist_grcblocks_DATA = \ + uhd_block_tree.xml \ $(BUILT_SOURCES) # add the deprecated files diff --git a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py index a4da53a18..8de4408d5 100755 --- a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py @@ -24,10 +24,16 @@ MAIN_TMPL = """\ UHD: Multi USRP $sourk.title() uhd_multi_usrp_$(sourk) - UHD from gnuradio import uhd uhd.multi_usrp_$(sourk)(\$dev_addr, uhd.io_type_t.\$type.type, \$nchan) -self.\$(id).set_subdev_spec(\$sd_spec) +\#if \$sync() +self.\$(id).set_time_unknown_pps(uhd.time_spec_t()) +\#end if +#for $m in range($max_mboards) +\#if \$num_mboards() > $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 @@ -62,25 +68,6 @@ self.\$(id).set_antenna(\$ant$(n), $n) vlen:2 - - Num Channels - nchan - 1 - int - part - - - - Device Addr dev_addr @@ -95,18 +82,61 @@ self.\$(id).set_antenna(\$ant$(n), $n) - Subdev Spec - sd_spec + Sync + sync + sync + enum + \#if \$sync() then 'none' else 'part'# + + + + + Num Mboards + num_mboards + 2 + int + #for $m in range(1, $max_mboards) + + #end for + + #for $m in range($max_mboards) + + Mb$(m): Subdev Spec + sd_spec$(m) string - \#if \$sd_spec() + \#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) + + #end for + Samp Rate (Sps) samp_rate @@ -115,8 +145,10 @@ self.\$(id).set_antenna(\$ant$(n), $n) $params $max_nchan >= \$nchan - \$nchan >= 0 - (len((\$sd_spec).split()) or 1) == \$nchan + \$nchan > 0 + $max_mboards >= \$num_mboards + \$num_mboards > 0 + \$nchan >= \$num_mboards <$sourk> $direction \$type @@ -132,18 +164,27 @@ If left blank, the first UHD device found will be used. \\ Used args to specify a specfic device. USRP2 Example: addr=192.168.10.2 192.168.10.3 +Num Motherboards: +Selects the number of USRP motherboards in this multi-USRP configuration. + +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. 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: A:AB -Dual channel example: A:AB B:0 +Single channel example: :AB +Dual channel example: :A :B Antenna: For subdevices/daughterboards with only one antenna, this may be left blank. \\ @@ -189,7 +230,8 @@ def parse_tmpl(_tmpl, **kwargs): from Cheetah import Template return str(Template.Template(_tmpl, kwargs)) -max_num_channels = 4 +max_num_mboards = 4 +max_num_channels = max_num_mboards*4 if __name__ == '__main__': import sys @@ -205,6 +247,7 @@ if __name__ == '__main__': 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 index 5b3cb5b5a..5b87719e5 100755 --- a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py @@ -24,7 +24,6 @@ MAIN_TMPL = """\ UHD: Single USRP $sourk.title() uhd_single_usrp_$(sourk) - UHD from gnuradio import uhd uhd.single_usrp_$(sourk)(\$dev_addr, uhd.io_type_t.\$type.type, \$nchan) self.\$(id).set_subdev_spec(\$sd_spec) @@ -115,7 +114,7 @@ self.\$(id).set_antenna(\$ant$(n), $n) $params $max_nchan >= \$nchan - \$nchan >= 0 + \$nchan > 0 (len((\$sd_spec).split()) or 1) == \$nchan <$sourk> $direction diff --git a/gr-uhd/grc/uhd_block_tree.xml b/gr-uhd/grc/uhd_block_tree.xml new file mode 100644 index 000000000..e8c4f069d --- /dev/null +++ b/gr-uhd/grc/uhd_block_tree.xml @@ -0,0 +1,23 @@ + + + + + + UHD + uhd_single_usrp_source + uhd_single_usrp_sink + uhd_multi_usrp_source + uhd_multi_usrp_sink + + + UHD (DEPRECATED) + uhd_simple_source + uhd_simple_sink + uhd_mimo_source + uhd_mimo_sink + + diff --git a/gr-uhd/grc/uhd_mimo_sink.xml b/gr-uhd/grc/uhd_mimo_sink.xml index 2f5f2011f..13865c913 100644 --- a/gr-uhd/grc/uhd_mimo_sink.xml +++ b/gr-uhd/grc/uhd_mimo_sink.xml @@ -1,8 +1,7 @@ - UHD MIMO Sink + UHD MIMO Sink (DEPRECATED) uhd_mimo_sink - UHD from gnuradio import uhd uhd.mimo_sink($nchan, $args, uhd.io_type_t.$type.type) self.$(id).set_samp_rate_all($samp_rate) diff --git a/gr-uhd/grc/uhd_mimo_source.xml b/gr-uhd/grc/uhd_mimo_source.xml index d8f4e6d66..6167838b0 100644 --- a/gr-uhd/grc/uhd_mimo_source.xml +++ b/gr-uhd/grc/uhd_mimo_source.xml @@ -1,8 +1,7 @@ - UHD MIMO Source + UHD MIMO Source (DEPRECATED) uhd_mimo_source - UHD from gnuradio import uhd uhd.mimo_source($nchan, $args, uhd.io_type_t.$type.type) self.$(id).set_samp_rate_all($samp_rate) diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml index 66dc5bf14..ee6051432 100644 --- a/gr-uhd/grc/uhd_simple_sink.xml +++ b/gr-uhd/grc/uhd_simple_sink.xml @@ -7,7 +7,6 @@ UHD Simple Sink (DEPRECATED) uhd_simple_sink - UHD from gnuradio import uhd uhd.simple_sink($args, uhd.io_type_t.$type.type) self.$(id).set_subdev_spec($sd_spec) diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml index 00c60f41d..825981d66 100644 --- a/gr-uhd/grc/uhd_simple_source.xml +++ b/gr-uhd/grc/uhd_simple_source.xml @@ -7,7 +7,6 @@ UHD Simple Source (DEPRECATED) uhd_simple_source - UHD from gnuradio import uhd uhd.simple_source($args, uhd.io_type_t.$type.type) self.$(id).set_subdev_spec($sd_spec) -- cgit From 7f46efca9cb0c87e9130c117ac41650f6e0c25cc Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 18 Oct 2010 16:49:08 -0700 Subject: uhd: renamed make function params, cleanup, clock config for multi usrp --- gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py | 11 ++++++++++- gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py | 6 +++++- gr-uhd/lib/uhd_multi_usrp_sink.cc | 19 ++++++++++++------- gr-uhd/lib/uhd_multi_usrp_sink.h | 4 ++-- gr-uhd/lib/uhd_multi_usrp_source.cc | 18 +++++++++++------- gr-uhd/lib/uhd_multi_usrp_source.h | 4 ++-- gr-uhd/lib/uhd_single_usrp_sink.cc | 19 ++++++++++++------- gr-uhd/lib/uhd_single_usrp_sink.h | 4 ++-- gr-uhd/lib/uhd_single_usrp_source.cc | 18 +++++++++++------- gr-uhd/lib/uhd_single_usrp_source.h | 4 ++-- 10 files changed, 69 insertions(+), 38 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py index 8de4408d5..aa550157d 100755 --- a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py @@ -25,8 +25,17 @@ MAIN_TMPL = """\ UHD: Multi USRP $sourk.title() uhd_multi_usrp_$(sourk) from gnuradio import uhd - uhd.multi_usrp_$(sourk)(\$dev_addr, uhd.io_type_t.\$type.type, \$nchan) + uhd.multi_usrp_$(sourk)( + device_addr=\$dev_addr, + io_type=uhd.io_type_t.\$type.type, + num_channels=\$nchan, +) \#if \$sync() +clk_cfg = uhd.clock_config_t() +clk_cfg.ref_source = uhd.clock_config_t.REF_SMA +clk_cfg.pps_source = uhd.clock_config_t.PPS_SMA +clk_cfg.pps_polarity = uhd.clock_config_t.PPS_POS +self.\$(id).set_clock_config(clk_cfg, ~0); self.\$(id).set_time_unknown_pps(uhd.time_spec_t()) \#end if #for $m in range($max_mboards) diff --git a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py index 5b87719e5..4d645afe1 100755 --- a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py @@ -25,7 +25,11 @@ MAIN_TMPL = """\ UHD: Single USRP $sourk.title() uhd_single_usrp_$(sourk) from gnuradio import uhd - uhd.single_usrp_$(sourk)(\$dev_addr, uhd.io_type_t.\$type.type, \$nchan) + uhd.single_usrp_$(sourk)( + device_addr=\$dev_addr, + io_type=uhd.io_type_t.\$type.type, + num_channels\$nchan, +) self.\$(id).set_subdev_spec(\$sd_spec) self.\$(id).set_samp_rate(\$samp_rate) #for $n in range($max_nchan) diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.cc b/gr-uhd/lib/uhd_multi_usrp_sink.cc index 202f12840..31dbac44f 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.cc +++ b/gr-uhd/lib/uhd_multi_usrp_sink.cc @@ -37,12 +37,17 @@ uhd_multi_usrp_sink::uhd_multi_usrp_sink(gr_io_signature_sptr sig) class uhd_multi_usrp_sink_impl : public uhd_multi_usrp_sink{ public: uhd_multi_usrp_sink_impl( - const std::string &args, - const uhd::io_type_t &type, + const std::string &device_addr, + const uhd::io_type_t &io_type, size_t num_channels - ) : uhd_multi_usrp_sink(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type), _nchan(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(args); + _dev = uhd::usrp::multi_usrp::make(device_addr); } void set_subdev_spec(const std::string &spec, size_t mboard){ @@ -165,11 +170,11 @@ protected: * Make UHD Multi USRP Sink **********************************************************************/ boost::shared_ptr uhd_make_multi_usrp_sink( - const std::string &args, - const uhd::io_type_t::tid_t &type, + const std::string &device_addr, + const uhd::io_type_t::tid_t &io_type, size_t num_channels ){ return boost::shared_ptr( - new uhd_multi_usrp_sink_impl(args, type, num_channels) + 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 index 13bba20fb..5dacc1fac 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.h +++ b/gr-uhd/lib/uhd_multi_usrp_sink.h @@ -28,8 +28,8 @@ class uhd_multi_usrp_sink; boost::shared_ptr uhd_make_multi_usrp_sink( - const std::string &args, - const uhd::io_type_t::tid_t &type, + const std::string &device_addr, + const uhd::io_type_t::tid_t &io_type, size_t num_channels ); diff --git a/gr-uhd/lib/uhd_multi_usrp_source.cc b/gr-uhd/lib/uhd_multi_usrp_source.cc index c10c08c50..1fcb57650 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.cc +++ b/gr-uhd/lib/uhd_multi_usrp_source.cc @@ -39,12 +39,16 @@ uhd_multi_usrp_source::uhd_multi_usrp_source(gr_io_signature_sptr sig) class uhd_multi_usrp_source_impl : public uhd_multi_usrp_source{ public: uhd_multi_usrp_source_impl( - const std::string &args, - const uhd::io_type_t &type, + const std::string &device_addr, + const uhd::io_type_t &io_type, size_t num_channels - ) : uhd_multi_usrp_source(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) + ): + uhd_multi_usrp_source(gr_make_io_signature( + num_channels, num_channels, io_type.size + )), + _type(io_type) { - _dev = uhd::usrp::multi_usrp::make(args); + _dev = uhd::usrp::multi_usrp::make(device_addr); } void set_subdev_spec(const std::string &spec, size_t mboard){ @@ -168,11 +172,11 @@ private: * Make UHD Multi USRP Source **********************************************************************/ boost::shared_ptr uhd_make_multi_usrp_source( - const std::string &args, - const uhd::io_type_t::tid_t &type, + const std::string &device_addr, + const uhd::io_type_t::tid_t &io_type, size_t num_channels ){ return boost::shared_ptr( - new uhd_multi_usrp_source_impl(args, type, num_channels) + 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 index b94e53f01..36c4b6fdc 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.h +++ b/gr-uhd/lib/uhd_multi_usrp_source.h @@ -28,8 +28,8 @@ class uhd_multi_usrp_source; boost::shared_ptr uhd_make_multi_usrp_source( - const std::string &args, - const uhd::io_type_t::tid_t &type, + const std::string &device_addr, + const uhd::io_type_t::tid_t &io_type, size_t num_channels ); diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc index 96c1dbdf4..4297a83ff 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -37,12 +37,17 @@ uhd_single_usrp_sink::uhd_single_usrp_sink(gr_io_signature_sptr sig) class uhd_single_usrp_sink_impl : public uhd_single_usrp_sink{ public: uhd_single_usrp_sink_impl( - const std::string &args, - const uhd::io_type_t &type, + const std::string &device_addr, + const uhd::io_type_t &io_type, size_t num_channels - ) : uhd_single_usrp_sink(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type), _nchan(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(args); + _dev = uhd::usrp::single_usrp::make(device_addr); } void set_subdev_spec(const std::string &spec){ @@ -163,11 +168,11 @@ protected: * Make UHD Single USRP Sink **********************************************************************/ boost::shared_ptr uhd_make_single_usrp_sink( - const std::string &args, - const uhd::io_type_t::tid_t &type, + const std::string &device_addr, + const uhd::io_type_t::tid_t &io_type, size_t num_channels ){ return boost::shared_ptr( - new uhd_single_usrp_sink_impl(args, type, num_channels) + 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 index bec788193..e83bb6ded 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.h +++ b/gr-uhd/lib/uhd_single_usrp_sink.h @@ -28,8 +28,8 @@ class uhd_single_usrp_sink; boost::shared_ptr uhd_make_single_usrp_sink( - const std::string &args, - const uhd::io_type_t::tid_t &type, + const std::string &device_addr, + const uhd::io_type_t::tid_t &io_type, size_t num_channels = 1 ); diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index 7c3694a99..27a788d96 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -39,12 +39,16 @@ uhd_single_usrp_source::uhd_single_usrp_source(gr_io_signature_sptr sig) class uhd_single_usrp_source_impl : public uhd_single_usrp_source{ public: uhd_single_usrp_source_impl( - const std::string &args, - const uhd::io_type_t &type, + const std::string &device_addr, + const uhd::io_type_t &io_type, size_t num_channels - ) : uhd_single_usrp_source(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) + ): + uhd_single_usrp_source(gr_make_io_signature( + num_channels, num_channels, io_type.size + )), + _type(io_type) { - _dev = uhd::usrp::single_usrp::make(args); + _dev = uhd::usrp::single_usrp::make(device_addr); } void set_subdev_spec(const std::string &spec){ @@ -163,11 +167,11 @@ private: * Make UHD Single USRP Source **********************************************************************/ boost::shared_ptr uhd_make_single_usrp_source( - const std::string &args, - const uhd::io_type_t::tid_t &type, + const std::string &device_addr, + const uhd::io_type_t::tid_t &io_type, size_t num_channels ){ return boost::shared_ptr( - new uhd_single_usrp_source_impl(args, type, num_channels) + 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 index 196b7c675..c323fbd7e 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.h +++ b/gr-uhd/lib/uhd_single_usrp_source.h @@ -28,8 +28,8 @@ class uhd_single_usrp_source; boost::shared_ptr uhd_make_single_usrp_source( - const std::string &args, - const uhd::io_type_t::tid_t &type, + const std::string &device_addr, + const uhd::io_type_t::tid_t &io_type, size_t num_channels = 1 ); -- cgit From 8c6445cb3dd2a8db361203fedf55f3efb6953635 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 18 Oct 2010 17:31:48 -0700 Subject: uhd: typo fix for single usrp grc file generator --- gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py index 4d645afe1..7bc2425ee 100755 --- a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py @@ -28,7 +28,7 @@ MAIN_TMPL = """\ uhd.single_usrp_$(sourk)( device_addr=\$dev_addr, io_type=uhd.io_type_t.\$type.type, - num_channels\$nchan, + num_channels=\$nchan, ) self.\$(id).set_subdev_spec(\$sd_spec) self.\$(id).set_samp_rate(\$samp_rate) -- cgit From 343cba5663d0eefdd3ee3918bef812dc1bd75508 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 18 Oct 2010 18:29:20 -0700 Subject: uhd: tweaked and tested multi usrp with a single channel --- gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py | 16 ++++++++-------- gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py | 2 ++ gr-uhd/lib/uhd_multi_usrp_source.cc | 4 ++-- gr-uhd/swig/uhd_swig.i | 20 ++++++++++++++++++++ 4 files changed, 32 insertions(+), 10 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py index aa550157d..229716732 100755 --- a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py @@ -31,15 +31,15 @@ MAIN_TMPL = """\ num_channels=\$nchan, ) \#if \$sync() -clk_cfg = uhd.clock_config_t() -clk_cfg.ref_source = uhd.clock_config_t.REF_SMA -clk_cfg.pps_source = uhd.clock_config_t.PPS_SMA -clk_cfg.pps_polarity = uhd.clock_config_t.PPS_POS -self.\$(id).set_clock_config(clk_cfg, ~0); +_clk_cfg = uhd.clock_config_t() +_clk_cfg.ref_source = uhd.clock_config_t.REF_SMA +_clk_cfg.pps_source = uhd.clock_config_t.PPS_SMA +_clk_cfg.pps_polarity = uhd.clock_config_t.PPS_POS +self.\$(id).set_clock_config(_clk_cfg, uhd.ALL_MBOARDS); self.\$(id).set_time_unknown_pps(uhd.time_spec_t()) \#end if #for $m in range($max_mboards) -\#if \$num_mboards() > $m +\#if \$num_mboards() > $m and \$sd_spec$(m)() self.\$(id).set_subdev_spec(\$sd_spec$(m), $m) \#end if #end for @@ -110,7 +110,7 @@ self.\$(id).set_antenna(\$ant$(n), $n) num_mboards 2 int - #for $m in range(1, $max_mboards) + #for $m in range(1, $max_mboards+1) @@ -59,6 +62,7 @@ self.\$(id).set_antenna(\$ant$(n), $n) 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 @@ -196,9 +200,14 @@ Single channel example: :AB Dual channel example: :A :B Antenna: -For subdevices/daughterboards with only one antenna, this may be left blank. \\ +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. """ @@ -233,6 +242,21 @@ PARAMS_TMPL = """ \#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): diff --git a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py index 02cdf64cc..cb2143f8f 100755 --- a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py @@ -41,6 +41,9 @@ 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 @@ -49,6 +52,7 @@ self.\$(id).set_antenna(\$ant$(n), $n) 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 @@ -152,9 +156,14 @@ Single channel example: A:AB Dual channel example: A:AB B:0 Antenna: -For subdevices/daughterboards with only one antenna, this may be left blank. \\ +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. """ @@ -189,6 +198,21 @@ PARAMS_TMPL = """ \#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): -- cgit From 5a2de999da86d48cd7f005d08cc48965cb8c7a65 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 25 Oct 2010 16:22:05 -0700 Subject: uhd: move tune functions to tune_request and provide wrapper for simple case --- gr-uhd/lib/uhd_multi_usrp_sink.cc | 7 ++++--- gr-uhd/lib/uhd_multi_usrp_sink.h | 16 +++++++++++++++- gr-uhd/lib/uhd_multi_usrp_source.cc | 7 ++++--- gr-uhd/lib/uhd_multi_usrp_source.h | 16 +++++++++++++++- gr-uhd/lib/uhd_single_usrp_sink.cc | 7 ++++--- gr-uhd/lib/uhd_single_usrp_sink.h | 16 +++++++++++++++- gr-uhd/lib/uhd_single_usrp_source.cc | 7 ++++--- gr-uhd/lib/uhd_single_usrp_source.h | 16 +++++++++++++++- gr-uhd/swig/uhd_swig.i | 1 + 9 files changed, 77 insertions(+), 16 deletions(-) (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 b75a8303c..ee16e2928 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.cc +++ b/gr-uhd/lib/uhd_multi_usrp_sink.cc @@ -62,9 +62,10 @@ public: return _dev->get_tx_rate(); } - uhd::tune_result_t set_center_freq(double freq, size_t chan){ - uhd::tune_result_t tr = _dev->set_tx_freq(freq, chan); - return tr; + 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){ diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.h b/gr-uhd/lib/uhd_multi_usrp_sink.h index a94e7bd5a..370e59d0e 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.h +++ b/gr-uhd/lib/uhd_multi_usrp_sink.h @@ -64,11 +64,25 @@ public: /*! * 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 */ - virtual uhd::tune_result_t set_center_freq(double freq, size_t chan) = 0; + 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. diff --git a/gr-uhd/lib/uhd_multi_usrp_source.cc b/gr-uhd/lib/uhd_multi_usrp_source.cc index 226e8b86f..029a763e3 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.cc +++ b/gr-uhd/lib/uhd_multi_usrp_source.cc @@ -63,9 +63,10 @@ public: return _dev->get_rx_rate(); } - uhd::tune_result_t set_center_freq(double freq, size_t chan){ - uhd::tune_result_t tr = _dev->set_rx_freq(freq, chan); - return tr; + 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){ diff --git a/gr-uhd/lib/uhd_multi_usrp_source.h b/gr-uhd/lib/uhd_multi_usrp_source.h index 081c82ee6..b3cbdae1f 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.h +++ b/gr-uhd/lib/uhd_multi_usrp_source.h @@ -64,11 +64,25 @@ public: /*! * 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 */ - virtual uhd::tune_result_t set_center_freq(double freq, size_t chan) = 0; + 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. diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc index 24981a59a..622f506b5 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -62,9 +62,10 @@ public: return _dev->get_tx_rate(); } - uhd::tune_result_t set_center_freq(double freq, size_t chan){ - uhd::tune_result_t tr = _dev->set_tx_freq(freq, chan); - return tr; + 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){ diff --git a/gr-uhd/lib/uhd_single_usrp_sink.h b/gr-uhd/lib/uhd_single_usrp_sink.h index 390667df9..a4c4e6452 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.h +++ b/gr-uhd/lib/uhd_single_usrp_sink.h @@ -63,11 +63,25 @@ public: /*! * 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 */ - virtual uhd::tune_result_t set_center_freq(double freq, size_t chan = 0) = 0; + 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. diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index f7c7fc839..907e8be54 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -63,9 +63,10 @@ public: return _dev->get_rx_rate(); } - uhd::tune_result_t set_center_freq(double freq, size_t chan){ - uhd::tune_result_t tr = _dev->set_rx_freq(freq, chan); - return tr; + 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){ diff --git a/gr-uhd/lib/uhd_single_usrp_source.h b/gr-uhd/lib/uhd_single_usrp_source.h index 415c52e9a..495f8c611 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.h +++ b/gr-uhd/lib/uhd_single_usrp_source.h @@ -63,11 +63,25 @@ public: /*! * 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 */ - virtual uhd::tune_result_t set_center_freq(double freq, size_t chan = 0) = 0; + 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. diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 5b3b52472..d332bb617 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -69,6 +69,7 @@ namespace std { //////////////////////////////////////////////////////////////////////// %include %include +%include %include %include %include -- cgit From 3dab5d93a45928baa4fb23878d644751e06943a0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 28 Oct 2010 13:24:23 -0700 Subject: uhd: make a tune_request_t that inherits from float for GRC, added docs --- gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py | 24 +++++++++++++++--------- gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py | 16 +++++++++++----- gr-uhd/swig/__init__.py | 12 ++++++++++++ 3 files changed, 38 insertions(+), 14 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py index ae40e551a..112d88159 100755 --- a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py @@ -180,15 +180,6 @@ USRP2 Example: addr=192.168.10.2 192.168.10.3 Num Motherboards: Selects the number of USRP motherboards in this multi-USRP configuration. -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. - Subdevice specification: Each motherboard should have its own subdevice specification \\ and all subdevice specifications should be the same length. \\ @@ -199,6 +190,21 @@ See the application notes for further details. Single channel example: :AB Dual channel example: :A :B +Num Channels: +Selects the total number of channels in this multi-USRP configuration. +Ex: 4 motherboards with 2 channels per board = 8 channels total + +Sample rate: +The sample rate is the number of samples per second input by this block. \\ +The UHD device driver will try its best to match the requested sample rate. \\ +If the requested rate is not possible, the UHD block will print an error at runtime. + +Center frequency: +The center frequency is the overall frequency of the RF chain. \\ +For greater control of how the UHD tunes elements in the RF chain, \\ +pass a tune_request_t object rather than a simple target frequency. +Tuning with an LO offset example: uhd.tune_request_t(freq, lo_off) + Antenna: For subdevices with only one antenna, this may be left blank. \\ Otherwise, the user should specify one of the possible antenna choices. \\ diff --git a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py index cb2143f8f..9b6422f7a 100755 --- a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py @@ -142,11 +142,6 @@ Used args to specify a specfic device. USRP2 Example: addr=192.168.10.2 USRP1 Example: serial=12345678 -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. - 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). \\ @@ -155,6 +150,17 @@ See the application notes for further details. Single channel example: A:AB Dual channel example: A:AB B:0 +Sample rate: +The sample rate is the number of samples per second input by this block. \\ +The UHD device driver will try its best to match the requested sample rate. \\ +If the requested rate is not possible, the UHD block will print an error at runtime. + +Center frequency: +The center frequency is the overall frequency of the RF chain. \\ +For greater control of how the UHD tunes elements in the RF chain, \\ +pass a tune_request_t object rather than a simple target frequency. +Tuning with an LO offset example: uhd.tune_request_t(freq, lo_off) + Antenna: For subdevices with only one antenna, this may be left blank. \\ Otherwise, the user should specify one of the possible antenna choices. \\ diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 2fed17e57..0fdacb796 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -21,8 +21,20 @@ # The presence of this file turns this directory into a Python package +######################################################################## # Add SWIG generated code to this namespace +######################################################################## from uhd_swig import * +######################################################################## # Add other content from pure-Python modules here +######################################################################## +class tune_request_t(tune_request_t, float): + """ + Make the python tune request object inherit from float + so that it can be passed in GRC as a frequency parameter. + The type checking in GRC will accept the tune request. + """ + def __new__(self, *args): return float.__new__(self) + def __float__(self): return self.target_freq -- cgit From 2aef04843d248d0584b4865c62d7ca0772113dc9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 28 Oct 2010 17:22:25 -0700 Subject: uhd: added ref clock option to single usrp blocks, minor grc fix on empty option keys --- gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py index 9b6422f7a..7337c71d7 100755 --- a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py @@ -30,6 +30,13 @@ MAIN_TMPL = """\ io_type=uhd.io_type_t.\$type.type, num_channels=\$nchan, ) +\#if \$ref_clk() +_clk_cfg = uhd.clock_config_t() +_clk_cfg.ref_source = uhd.clock_config_t.REF_SMA +_clk_cfg.pps_source = uhd.clock_config_t.PPS_SMA +_clk_cfg.pps_polarity = uhd.clock_config_t.PPS_POS +self.\$(id).set_clock_config(_clk_cfg); +\#end if \#if \$sd_spec() self.\$(id).set_subdev_spec(\$sd_spec) \#end if @@ -103,6 +110,21 @@ self.\$(id).set_bandwidth(\$bw$(n), $n) \#end if + + Ref Clock + ref_clk + + enum + \#if \$ref_clk() then 'none' else 'part'# + + + Subdev Spec sd_spec -- cgit From 38c60bd0bfb411c2557b84f92bcbd66395475ba6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 1 Nov 2010 19:01:49 -0700 Subject: uhd: swig changes for templated ranges --- gr-uhd/swig/uhd_swig.i | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index d332bb617..3c6773374 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -68,6 +68,7 @@ namespace std { // used types //////////////////////////////////////////////////////////////////////// %include +%include %include %include %include @@ -75,6 +76,17 @@ namespace std { %include %include +//Re-create range typedefs here with %template as they are not imported. +//Replicate all the levels of templated inheritance so swig understands. + +%template(float_range_t) uhd::range_t; +%template(_float_range_vector_t) std::vector >; +%template(gain_range_t) uhd::meta_range_t; + +%template(double_range_t) uhd::range_t; +%template(_double_range_vector_t) std::vector >; +%template(freq_range_t) uhd::meta_range_t; + //////////////////////////////////////////////////////////////////////// // block magic //////////////////////////////////////////////////////////////////////// -- cgit From ed4094208c501e91838ccc333059e4731e8ae908 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Thu, 14 Oct 2010 12:34:08 -0600 Subject: regenerated after changes to the template --- gr-uhd/swig/Makefile.swig.gen | 59 +++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 14 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen index 3804461a4..36475a12e 100644 --- a/gr-uhd/swig/Makefile.swig.gen +++ b/gr-uhd/swig/Makefile.swig.gen @@ -72,7 +72,7 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S* ## .h file is sometimes built, but not always ... so that one has to ## be added manually by the including Makefile.am . -swig_built_sources += uhd_swig.py uhd_swig.cc +swig_built_sources += uhd_swig.py uhd_swig_python.cc ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including @@ -83,21 +83,21 @@ uhd_swig_swiginclude_HEADERS = \ $(uhd_swig_swiginclude_headers) uhd_swig_pylib_LTLIBRARIES = \ - _uhd_swig.la + _uhd_swig_python.la -_uhd_swig_la_SOURCES = \ - uhd_swig.cc \ +_uhd_swig_python_la_SOURCES = \ + uhd_swig_python.cc \ $(uhd_swig_la_swig_sources) -_uhd_swig_la_LIBADD = \ +_uhd_swig_python_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ $(uhd_swig_la_swig_libadd) -_uhd_swig_la_LDFLAGS = \ +_uhd_swig_python_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ $(uhd_swig_la_swig_ldflags) -_uhd_swig_la_CXXFLAGS = \ +_uhd_swig_python_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ $(uhd_swig_la_swig_cxxflags) @@ -105,9 +105,23 @@ uhd_swig_python_PYTHON = \ uhd_swig.py \ $(uhd_swig_python) +if GUILE +uhd_swig_pylib_LTLIBRARIES += _uhd_swig_guile.la + +_uhd_swig_guile_la_SOURCES = \ + uhd_swig_guile.cc \ + $(uhd_swig_la_swig_sources) + +# Guile can use the same flags as python does +_uhd_swig_guile_la_LIBADD = $(_uhd_swig_python_la_LIBADD) +_uhd_swig_guile_la_LDFLAGS = $(_uhd_swig_python_la_LDFLAGS) +_uhd_swig_guile_la_CXXFLAGS = $(_uhd_swig_python_la_CXXFLAGS) + +endif # end of GUILE + ## Entry rule for running SWIG -uhd_swig.h uhd_swig.py uhd_swig.cc: uhd_swig.i +uhd_swig.h uhd_swig.py uhd_swig_python.cc: uhd_swig.i ## This rule will get called only when MAKE decides that one of the ## targets needs to be created or re-created, because: ## @@ -159,11 +173,12 @@ uhd_swig.h uhd_swig.py uhd_swig.cc: uhd_swig.i ## ## Remove the stamp associated with this filename. ## - rm -f $(DEPDIR)/uhd_swig-generate-stamp; \ + rm -f $(DEPDIR)/uhd_swig-generate-*stamp; \ ## ## Tell MAKE to run the rule for creating this stamp. ## - $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/uhd_swig-generate-stamp WHAT=$<; \ + $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/uhd_swig-generate-python-stamp WHAT=$<; \ + $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/uhd_swig-generate-guile-stamp WHAT=$<; \ ## ## Now that the .cc, .h, and .py files have been (re)created from the ## .i file, future checking of this rule during the same MAKE @@ -187,11 +202,27 @@ uhd_swig.h uhd_swig.py uhd_swig.cc: uhd_swig.i ## Succeed if and only if the first process succeeded; exit this ## process returning the status of the generated stamp. ## - test -f $(DEPDIR)/uhd_swig-generate-stamp; \ + test -f $(DEPDIR)/uhd_swig-generate-python-stamp; \ exit $$?; \ fi; -$(DEPDIR)/uhd_swig-generate-stamp: +$(DEPDIR)/uhd_swig-generate-guile-stamp: + if $(SWIG) $(STD_SWIG_GUILE_ARGS) $(uhd_swig_swig_args) \ + -MD -MF $(DEPDIR)/uhd_swig.Std \ + -module uhd_swig -o uhd_swig_guile.cc $(WHAT); then \ + if test $(host_os) = mingw32; then \ + $(RM) $(DEPDIR)/uhd_swig.Sd; \ + $(SED) 's,\\\\,/,g' < $(DEPDIR)/uhd_swig.Std \ + > $(DEPDIR)/uhd_swig.Sd; \ + $(RM) $(DEPDIR)/uhd_swig.Std; \ + $(MV) $(DEPDIR)/uhd_swig.Sd $(DEPDIR)/uhd_swig.Std; \ + fi; \ + else \ + $(RM) $(DEPDIR)/uhd_swig.S*; exit 1; \ + fi; + touch $(DEPDIR)/uhd_swig-generate-guile-stamp + +$(DEPDIR)/uhd_swig-generate-python-stamp: ## This rule will be called only by the first process issuing the ## above rule to succeed in creating the lock directory, after ## removing the actual stamp file in order to guarantee that MAKE will @@ -202,7 +233,7 @@ $(DEPDIR)/uhd_swig-generate-stamp: ## if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(uhd_swig_swig_args) \ -MD -MF $(DEPDIR)/uhd_swig.Std \ - -module uhd_swig -o uhd_swig.cc $(WHAT); then \ + -module uhd_swig -o uhd_swig_python.cc $(WHAT); then \ if test $(host_os) = mingw32; then \ $(RM) $(DEPDIR)/uhd_swig.Sd; \ $(SED) 's,\\\\,/,g' < $(DEPDIR)/uhd_swig.Std \ @@ -249,7 +280,7 @@ $(DEPDIR)/uhd_swig-generate-stamp: ## executing this rule; allows other threads waiting on this process ## to continue. ## - touch $(DEPDIR)/uhd_swig-generate-stamp + touch $(DEPDIR)/uhd_swig-generate-python-stamp # KLUDGE: Force runtime include of a SWIG dependency file. This is # not guaranteed to be portable, but will probably work. If it works, -- cgit From f97d37a216d1a3ff888f8b57c0090f9def9dd021 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Mon, 18 Oct 2010 19:24:49 -0700 Subject: Update generated files --- gr-uhd/swig/Makefile.swig.gen | 112 ++++++++++++++++++++++++++++++------------ 1 file changed, 80 insertions(+), 32 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen index 36475a12e..d10f6baa5 100644 --- a/gr-uhd/swig/Makefile.swig.gen +++ b/gr-uhd/swig/Makefile.swig.gen @@ -38,6 +38,16 @@ uhd_swig_pylibdir_category ?= $(uhd_swig_pythondir_category) uhd_swig_pythondir = $(pythondir)/$(uhd_swig_pythondir_category) uhd_swig_pylibdir = $(pyexecdir)/$(uhd_swig_pylibdir_category) +# The .so libraries for the guile modules get installed whereever guile +# is installed, usually /usr/lib/guile/gnuradio/ +# FIXME: determince whether these should be installed with gnuradio. +uhd_swig_scmlibdir = @GUILE_PKLIBDIR@/gnuradio + +# The scm files for the guile modules get installed where ever guile +# is installed, usually /usr/share/guile/site/uhd_swig +# FIXME: determince whether these should be installed with gnuradio. +uhd_swig_scmdir = @GUILE_PKDATADIR@/gnuradio + ## SWIG headers are always installed into the same directory. uhd_swig_swigincludedir = $(swigincludedir) @@ -73,6 +83,9 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S* ## be added manually by the including Makefile.am . swig_built_sources += uhd_swig.py uhd_swig_python.cc +if GUILE +swig_built_sources += uhd_swig.scm uhd_swig_guile.cc +endif ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including @@ -106,11 +119,11 @@ uhd_swig_python_PYTHON = \ $(uhd_swig_python) if GUILE -uhd_swig_pylib_LTLIBRARIES += _uhd_swig_guile.la - +uhd_swig_scmlib_LTLIBRARIES = _uhd_swig_guile.la _uhd_swig_guile_la_SOURCES = \ - uhd_swig_guile.cc \ + uhd_swig_guile.cc \ $(uhd_swig_la_swig_sources) +uhd_swig_scm_DATA = uhd_swig.scm # Guile can use the same flags as python does _uhd_swig_guile_la_LIBADD = $(_uhd_swig_python_la_LIBADD) @@ -121,7 +134,8 @@ endif # end of GUILE ## Entry rule for running SWIG -uhd_swig.h uhd_swig.py uhd_swig_python.cc: uhd_swig.i +# $(python_deps) $(guile_deps): uhd_swig.i +uhd_swig_python.h uhd_swig.py uhd_swig_python.cc: uhd_swig.i ## This rule will get called only when MAKE decides that one of the ## targets needs to be created or re-created, because: ## @@ -178,7 +192,6 @@ uhd_swig.h uhd_swig.py uhd_swig_python.cc: uhd_swig.i ## Tell MAKE to run the rule for creating this stamp. ## $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/uhd_swig-generate-python-stamp WHAT=$<; \ - $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/uhd_swig-generate-guile-stamp WHAT=$<; \ ## ## Now that the .cc, .h, and .py files have been (re)created from the ## .i file, future checking of this rule during the same MAKE @@ -206,21 +219,23 @@ uhd_swig.h uhd_swig.py uhd_swig_python.cc: uhd_swig.i exit $$?; \ fi; -$(DEPDIR)/uhd_swig-generate-guile-stamp: - if $(SWIG) $(STD_SWIG_GUILE_ARGS) $(uhd_swig_swig_args) \ - -MD -MF $(DEPDIR)/uhd_swig.Std \ - -module uhd_swig -o uhd_swig_guile.cc $(WHAT); then \ - if test $(host_os) = mingw32; then \ - $(RM) $(DEPDIR)/uhd_swig.Sd; \ - $(SED) 's,\\\\,/,g' < $(DEPDIR)/uhd_swig.Std \ - > $(DEPDIR)/uhd_swig.Sd; \ - $(RM) $(DEPDIR)/uhd_swig.Std; \ - $(MV) $(DEPDIR)/uhd_swig.Sd $(DEPDIR)/uhd_swig.Std; \ - fi; \ +# the comments for the target above apply to this target as well, but it seemed +# silly to include them twice. The only main change is for guile. +uhd_swig_guile.h uhd_swig.scm uhd_swig_guile.cc: uhd_swig.i +if GUILE + trap 'rm -rf $(DEPDIR)/uhd_swig-generate-*' 1 2 13 15; \ + if mkdir $(DEPDIR)/uhd_swig-generate-lock 2>/dev/null; then \ + rm -f $(DEPDIR)/uhd_swig-generate-*stamp; \ + $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/uhd_swig-generate-guile-stamp WHAT=$<; \ + rmdir $(DEPDIR)/uhd_swig-generate-lock; \ else \ - $(RM) $(DEPDIR)/uhd_swig.S*; exit 1; \ + while test -d $(DEPDIR)/uhd_swig-generate-lock; do \ + sleep 1; \ + done; \ + test -f $(DEPDIR)/uhd_swig-generate-guile-stamp; \ + exit $$?; \ fi; - touch $(DEPDIR)/uhd_swig-generate-guile-stamp +endif # end of GUILE $(DEPDIR)/uhd_swig-generate-python-stamp: ## This rule will be called only by the first process issuing the @@ -232,17 +247,17 @@ $(DEPDIR)/uhd_swig-generate-python-stamp: ## post-processing on 'mingw32' host OS for the dependency file. ## if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(uhd_swig_swig_args) \ - -MD -MF $(DEPDIR)/uhd_swig.Std \ + -MD -MF $(DEPDIR)/uhd_swig_python.Std \ -module uhd_swig -o uhd_swig_python.cc $(WHAT); then \ if test $(host_os) = mingw32; then \ - $(RM) $(DEPDIR)/uhd_swig.Sd; \ - $(SED) 's,\\\\,/,g' < $(DEPDIR)/uhd_swig.Std \ - > $(DEPDIR)/uhd_swig.Sd; \ - $(RM) $(DEPDIR)/uhd_swig.Std; \ - $(MV) $(DEPDIR)/uhd_swig.Sd $(DEPDIR)/uhd_swig.Std; \ + $(RM) $(DEPDIR)/uhd_swig_python.Sd; \ + $(SED) 's,\\\\,/,g' < $(DEPDIR)/uhd_swig_python.Std \ + > $(DEPDIR)/uhd_swig_python.Sd; \ + $(RM) $(DEPDIR)/uhd_swig_python.Std; \ + $(MV) $(DEPDIR)/uhd_swig_python.Sd $(DEPDIR)/uhd_swig_python.Std; \ fi; \ else \ - $(RM) $(DEPDIR)/uhd_swig.S*; exit 1; \ + $(RM) $(DEPDIR)/uhd_swig_python.S*; exit 1; \ fi; ## ## Mess with the SWIG output .Std dependency file, to create a @@ -254,27 +269,27 @@ $(DEPDIR)/uhd_swig-generate-python-stamp: ## ## (1) remove the current dependency file ## - $(RM) $(DEPDIR)/uhd_swig.d + $(RM) $(DEPDIR)/uhd_swig_python.d ## ## (2) Copy the whole SWIG file: ## - cp $(DEPDIR)/uhd_swig.Std $(DEPDIR)/uhd_swig.d + cp $(DEPDIR)/uhd_swig_python.Std $(DEPDIR)/uhd_swig_python.d ## ## (3) all a carriage return to the end of the dependency file. ## - echo "" >> $(DEPDIR)/uhd_swig.d + echo "" >> $(DEPDIR)/uhd_swig_python.d ## ## (4) from the SWIG file, remove the first line (the target); remove ## trailing " \" and " " from each line. Append ":" to each line, ## followed by 2 carriage returns, then append this to the end of ## the dependency file. ## - $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/uhd_swig.Std | \ - awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/uhd_swig.d + $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/uhd_swig_python.Std | \ + awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/uhd_swig_python.d ## ## (5) remove the SWIG-generated file ## - $(RM) $(DEPDIR)/uhd_swig.Std + $(RM) $(DEPDIR)/uhd_swig_python.Std ## ## Create the stamp for this filename generation, to signal success in ## executing this rule; allows other threads waiting on this process @@ -286,5 +301,38 @@ $(DEPDIR)/uhd_swig-generate-python-stamp: # not guaranteed to be portable, but will probably work. If it works, # we have accurate dependencies for our swig stuff, which is good. -@am__include@ @am__quote@./$(DEPDIR)/uhd_swig.d@am__quote@ +@am__include@ @am__quote@./$(DEPDIR)/uhd_swig_python.d@am__quote@ + +if GUILE +$(DEPDIR)/uhd_swig-generate-guile-stamp: +# the comments for the target above apply to this target as well, but it seemed +# silly to include them twice. The only main change is for guile. + if $(SWIG) $(STD_SWIG_GUILE_ARGS) $(uhd_swig_swig_args) \ + -MD -MF $(DEPDIR)/uhd_swig_guile.Std \ + -module uhd_swig -o uhd_swig_guile.cc $(WHAT); then \ + if test $(host_os) = mingw32; then \ + $(RM) $(DEPDIR)/uhd_swig_guile.Sd; \ + $(SED) 's,\\\\,/,g' < $(DEPDIR)/uhd_swig_guile.Std \ + > $(DEPDIR)/uhd_swig_guile.Sd; \ + $(RM) $(DEPDIR)/uhd_swig_guile.Std; \ + $(MV) $(DEPDIR)/uhd_swig_guile.Sd $(DEPDIR)/uhd_swig_guile.Std; \ + fi; \ + else \ + $(RM) $(DEPDIR)/uhd_swig_guile.S*; exit 1; \ + fi; + touch $(DEPDIR)/uhd_swig-generate-guile-stamp + $(RM) $(DEPDIR)/uhd_swig_guile.d + cp $(DEPDIR)/uhd_swig_guile.Std $(DEPDIR)/uhd_swig_guile.d + echo "" >> $(DEPDIR)/uhd_swig_guile.d + $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/uhd_swig_guile.Std | \ + awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/uhd_swig_guile.d + $(RM) $(DEPDIR)/uhd_swig_guile.Std + touch $(DEPDIR)/uhd_swig-generate-guile-stamp +else + touch $(DEPDIR)/uhd_swig-generate-guile-stamp +endif + +@am__include@ @am__quote@./$(DEPDIR)/uhd_swig_guile.d@am__quote@ + +#gnuradio_swig_py_runtime_python.h: gnuradio_swig_py_runtime.i -- cgit From 1e34972f4433cbfef3500fc73a285c7c436cfd6b Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Fri, 22 Oct 2010 22:00:09 -0700 Subject: Rengenerate Makefile.swig.gen's --- gr-uhd/swig/Makefile.swig.gen | 246 +++++------------------------------------- 1 file changed, 28 insertions(+), 218 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen index d10f6baa5..e06723814 100644 --- a/gr-uhd/swig/Makefile.swig.gen +++ b/gr-uhd/swig/Makefile.swig.gen @@ -41,12 +41,12 @@ uhd_swig_pylibdir = $(pyexecdir)/$(uhd_swig_pylibdir_category) # The .so libraries for the guile modules get installed whereever guile # is installed, usually /usr/lib/guile/gnuradio/ # FIXME: determince whether these should be installed with gnuradio. -uhd_swig_scmlibdir = @GUILE_PKLIBDIR@/gnuradio +uhd_swig_scmlibdir = $(libdir)/guile/gnuradio # The scm files for the guile modules get installed where ever guile # is installed, usually /usr/share/guile/site/uhd_swig # FIXME: determince whether these should be installed with gnuradio. -uhd_swig_scmdir = @GUILE_PKDATADIR@/gnuradio +uhd_swig_scmdir = $(guiledir)/gnuradio ## SWIG headers are always installed into the same directory. @@ -82,9 +82,11 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S* ## .h file is sometimes built, but not always ... so that one has to ## be added manually by the including Makefile.am . -swig_built_sources += uhd_swig.py uhd_swig_python.cc +# generating the py or scm file also generates the .cc or .h files, +# but dependencies work better without the .cc ort .h files listed. +swig_built_sources += uhd_swig.py if GUILE -swig_built_sources += uhd_swig.scm uhd_swig_guile.cc +swig_built_sources += uhd_swig.scm endif ## Various SWIG variables. These can be overloaded in the including @@ -96,243 +98,51 @@ uhd_swig_swiginclude_HEADERS = \ $(uhd_swig_swiginclude_headers) uhd_swig_pylib_LTLIBRARIES = \ - _uhd_swig_python.la + _uhd_swig.la -_uhd_swig_python_la_SOURCES = \ - uhd_swig_python.cc \ +_uhd_swig_la_SOURCES = \ + python/uhd_swig.cc \ $(uhd_swig_la_swig_sources) -_uhd_swig_python_la_LIBADD = \ +_uhd_swig_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ $(uhd_swig_la_swig_libadd) -_uhd_swig_python_la_LDFLAGS = \ +# _uhd_swig_la_DEPENDENCIES = python/uhd_swig.lo + +_uhd_swig_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ $(uhd_swig_la_swig_ldflags) -_uhd_swig_python_la_CXXFLAGS = \ +_uhd_swig_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ $(uhd_swig_la_swig_cxxflags) uhd_swig_python_PYTHON = \ uhd_swig.py \ - $(uhd_swig_python) + $(uhd_swig) if GUILE -uhd_swig_scmlib_LTLIBRARIES = _uhd_swig_guile.la -_uhd_swig_guile_la_SOURCES = \ - uhd_swig_guile.cc \ +uhd_swig_scmlib_LTLIBRARIES = uhd_swig_guile.la +uhd_swig_guile_la_SOURCES = \ + guile/uhd_swig.cc \ $(uhd_swig_la_swig_sources) uhd_swig_scm_DATA = uhd_swig.scm # Guile can use the same flags as python does -_uhd_swig_guile_la_LIBADD = $(_uhd_swig_python_la_LIBADD) -_uhd_swig_guile_la_LDFLAGS = $(_uhd_swig_python_la_LDFLAGS) -_uhd_swig_guile_la_CXXFLAGS = $(_uhd_swig_python_la_CXXFLAGS) - -endif # end of GUILE +uhd_swig_guile_la_LIBADD = $(_uhd_swig_la_LIBADD) +uhd_swig_guile_la_LDFLAGS = $(_uhd_swig_la_LDFLAGS) +uhd_swig_guile_la_CXXFLAGS = $(_uhd_swig_la_CXXFLAGS) -## Entry rule for running SWIG - -# $(python_deps) $(guile_deps): uhd_swig.i -uhd_swig_python.h uhd_swig.py uhd_swig_python.cc: uhd_swig.i -## This rule will get called only when MAKE decides that one of the -## targets needs to be created or re-created, because: -## -## * The .i file is newer than any or all of the generated files; -## -## * Any or all of the .cc, .h, or .py files does not exist and is -## needed (in the case this file is not needed, the rule for it is -## ignored); or -## -## * Some SWIG-based dependecy of the .cc file isn't met and hence the -## .cc file needs be be regenerated. Explanation: Because MAKE -## knows how to handle dependencies for .cc files (regardless of -## their name or extension), then the .cc file is used as a target -## instead of the .i file -- but with the dependencies of the .i -## file. It is this last reason why the line: -## -## if test -f $@; then :; else -## -## cannot be used in this case: If a .i file dependecy is not met, -## then the .cc file needs to be rebuilt. But if the stamp is newer -## than the .cc file, and the .cc file exists, then in the original -## version (with the 'test' above) the internal MAKE call will not -## be issued and hence the .cc file will not be rebuilt. -## -## Once execution gets to here, it should always proceed no matter the -## state of a stamp (as discussed in link above). The -## $(DEPDIR)/uhd_swig-generate stuff is used to allow for parallel -## builds to "do the right thing". The stamp has no relationship with -## either the target files or dependency file; it is used solely for -## the protection of multiple builds during a given call to MAKE. -## -## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM -## (15). At a caught signal, the quoted command will be issued before -## exiting. In this case, remove any stamp, whether temporary of not. -## The trap is valid until the process exits; the process includes all -## commands appended via "\"s. -## - trap 'rm -rf $(DEPDIR)/uhd_swig-generate-*' 1 2 13 15; \ -## -## Create a temporary directory, which acts as a lock. The first -## process to create the directory will succeed and issue the MAKE -## command to do the actual work, while all subsequent processes will -## fail -- leading them to wait for the first process to finish. -## - if mkdir $(DEPDIR)/uhd_swig-generate-lock 2>/dev/null; then \ -## -## This code is being executed by the first process to succeed in -## creating the directory lock. -## -## Remove the stamp associated with this filename. -## - rm -f $(DEPDIR)/uhd_swig-generate-*stamp; \ -## -## Tell MAKE to run the rule for creating this stamp. -## - $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/uhd_swig-generate-python-stamp WHAT=$<; \ -## -## Now that the .cc, .h, and .py files have been (re)created from the -## .i file, future checking of this rule during the same MAKE -## execution will come back that the rule doesn't need to be executed -## because none of the conditions mentioned at the start of this rule -## will be positive. Remove the the directory lock, which frees up -## any waiting process(es) to continue. -## - rmdir $(DEPDIR)/uhd_swig-generate-lock; \ - else \ -## -## This code is being executed by any follower processes while the -## directory lock is in place. -## -## Wait until the first process is done, testing once per second. -## - while test -d $(DEPDIR)/uhd_swig-generate-lock; do \ - sleep 1; \ - done; \ -## -## Succeed if and only if the first process succeeded; exit this -## process returning the status of the generated stamp. -## - test -f $(DEPDIR)/uhd_swig-generate-python-stamp; \ - exit $$?; \ - fi; +guile/uhd_swig.lo: uhd_swig.lo +uhd_swig.scm: uhd_swig.i -# the comments for the target above apply to this target as well, but it seemed -# silly to include them twice. The only main change is for guile. -uhd_swig_guile.h uhd_swig.scm uhd_swig_guile.cc: uhd_swig.i -if GUILE - trap 'rm -rf $(DEPDIR)/uhd_swig-generate-*' 1 2 13 15; \ - if mkdir $(DEPDIR)/uhd_swig-generate-lock 2>/dev/null; then \ - rm -f $(DEPDIR)/uhd_swig-generate-*stamp; \ - $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/uhd_swig-generate-guile-stamp WHAT=$<; \ - rmdir $(DEPDIR)/uhd_swig-generate-lock; \ - else \ - while test -d $(DEPDIR)/uhd_swig-generate-lock; do \ - sleep 1; \ - done; \ - test -f $(DEPDIR)/uhd_swig-generate-guile-stamp; \ - exit $$?; \ - fi; endif # end of GUILE -$(DEPDIR)/uhd_swig-generate-python-stamp: -## This rule will be called only by the first process issuing the -## above rule to succeed in creating the lock directory, after -## removing the actual stamp file in order to guarantee that MAKE will -## execute this rule. -## -## Call SWIG to generate the various output files; special -## post-processing on 'mingw32' host OS for the dependency file. -## - if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(uhd_swig_swig_args) \ - -MD -MF $(DEPDIR)/uhd_swig_python.Std \ - -module uhd_swig -o uhd_swig_python.cc $(WHAT); then \ - if test $(host_os) = mingw32; then \ - $(RM) $(DEPDIR)/uhd_swig_python.Sd; \ - $(SED) 's,\\\\,/,g' < $(DEPDIR)/uhd_swig_python.Std \ - > $(DEPDIR)/uhd_swig_python.Sd; \ - $(RM) $(DEPDIR)/uhd_swig_python.Std; \ - $(MV) $(DEPDIR)/uhd_swig_python.Sd $(DEPDIR)/uhd_swig_python.Std; \ - fi; \ - else \ - $(RM) $(DEPDIR)/uhd_swig_python.S*; exit 1; \ - fi; -## -## Mess with the SWIG output .Std dependency file, to create a -## dependecy file valid for the input .i file: Basically, simulate the -## dependency file created for libraries by GNU's libtool for C++, -## where all of the dependencies for the target are first listed, then -## each individual dependency is listed as a target with no further -## dependencies. -## -## (1) remove the current dependency file -## - $(RM) $(DEPDIR)/uhd_swig_python.d -## -## (2) Copy the whole SWIG file: -## - cp $(DEPDIR)/uhd_swig_python.Std $(DEPDIR)/uhd_swig_python.d -## -## (3) all a carriage return to the end of the dependency file. -## - echo "" >> $(DEPDIR)/uhd_swig_python.d -## -## (4) from the SWIG file, remove the first line (the target); remove -## trailing " \" and " " from each line. Append ":" to each line, -## followed by 2 carriage returns, then append this to the end of -## the dependency file. -## - $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/uhd_swig_python.Std | \ - awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/uhd_swig_python.d -## -## (5) remove the SWIG-generated file -## - $(RM) $(DEPDIR)/uhd_swig_python.Std -## -## Create the stamp for this filename generation, to signal success in -## executing this rule; allows other threads waiting on this process -## to continue. -## - touch $(DEPDIR)/uhd_swig-generate-python-stamp - -# KLUDGE: Force runtime include of a SWIG dependency file. This is -# not guaranteed to be portable, but will probably work. If it works, -# we have accurate dependencies for our swig stuff, which is good. - -@am__include@ @am__quote@./$(DEPDIR)/uhd_swig_python.d@am__quote@ - -if GUILE -$(DEPDIR)/uhd_swig-generate-guile-stamp: -# the comments for the target above apply to this target as well, but it seemed -# silly to include them twice. The only main change is for guile. - if $(SWIG) $(STD_SWIG_GUILE_ARGS) $(uhd_swig_swig_args) \ - -MD -MF $(DEPDIR)/uhd_swig_guile.Std \ - -module uhd_swig -o uhd_swig_guile.cc $(WHAT); then \ - if test $(host_os) = mingw32; then \ - $(RM) $(DEPDIR)/uhd_swig_guile.Sd; \ - $(SED) 's,\\\\,/,g' < $(DEPDIR)/uhd_swig_guile.Std \ - > $(DEPDIR)/uhd_swig_guile.Sd; \ - $(RM) $(DEPDIR)/uhd_swig_guile.Std; \ - $(MV) $(DEPDIR)/uhd_swig_guile.Sd $(DEPDIR)/uhd_swig_guile.Std; \ - fi; \ - else \ - $(RM) $(DEPDIR)/uhd_swig_guile.S*; exit 1; \ - fi; - touch $(DEPDIR)/uhd_swig-generate-guile-stamp - $(RM) $(DEPDIR)/uhd_swig_guile.d - cp $(DEPDIR)/uhd_swig_guile.Std $(DEPDIR)/uhd_swig_guile.d - echo "" >> $(DEPDIR)/uhd_swig_guile.d - $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/uhd_swig_guile.Std | \ - awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/uhd_swig_guile.d - $(RM) $(DEPDIR)/uhd_swig_guile.Std - touch $(DEPDIR)/uhd_swig-generate-guile-stamp -else - touch $(DEPDIR)/uhd_swig-generate-guile-stamp -endif - -@am__include@ @am__quote@./$(DEPDIR)/uhd_swig_guile.d@am__quote@ +python/uhd_swig.lo: +uhd_swig.lo: uhd_swig.py uhd_swig.scm +uhd_swig.py: uhd_swig.i -#gnuradio_swig_py_runtime_python.h: gnuradio_swig_py_runtime.i +-include python/uhd_swig.d -- cgit From 6421d47062f4bf5abbdf26142616a5965f1edfa0 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Fri, 22 Oct 2010 23:28:06 -0700 Subject: regenerate --- gr-uhd/swig/Makefile.swig.gen | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen index e06723814..88ed33834 100644 --- a/gr-uhd/swig/Makefile.swig.gen +++ b/gr-uhd/swig/Makefile.swig.gen @@ -41,7 +41,7 @@ uhd_swig_pylibdir = $(pyexecdir)/$(uhd_swig_pylibdir_category) # The .so libraries for the guile modules get installed whereever guile # is installed, usually /usr/lib/guile/gnuradio/ # FIXME: determince whether these should be installed with gnuradio. -uhd_swig_scmlibdir = $(libdir)/guile/gnuradio +uhd_swig_scmlibdir = $(libdir) # The scm files for the guile modules get installed where ever guile # is installed, usually /usr/share/guile/site/uhd_swig @@ -124,16 +124,16 @@ uhd_swig_python_PYTHON = \ $(uhd_swig) if GUILE -uhd_swig_scmlib_LTLIBRARIES = uhd_swig_guile.la -uhd_swig_guile_la_SOURCES = \ +uhd_swig_scmlib_LTLIBRARIES = libguile-uhd_swig.la +libguile_uhd_swig_la_SOURCES = \ guile/uhd_swig.cc \ $(uhd_swig_la_swig_sources) uhd_swig_scm_DATA = uhd_swig.scm # Guile can use the same flags as python does -uhd_swig_guile_la_LIBADD = $(_uhd_swig_la_LIBADD) -uhd_swig_guile_la_LDFLAGS = $(_uhd_swig_la_LDFLAGS) -uhd_swig_guile_la_CXXFLAGS = $(_uhd_swig_la_CXXFLAGS) +libguile_uhd_swig_la_LIBADD = $(_uhd_swig_la_LIBADD) +libguile_uhd_swig_la_LDFLAGS = $(_uhd_swig_la_LDFLAGS) +libguile_uhd_swig_la_CXXFLAGS = $(_uhd_swig_la_CXXFLAGS) guile/uhd_swig.lo: uhd_swig.lo uhd_swig.scm: uhd_swig.i -- cgit From d94769a975612072dc03fa378bc79856c07cd66b Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Sat, 30 Oct 2010 12:14:41 -0600 Subject: add load-extension support --- gr-uhd/swig/uhd_swig.i | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index d332bb617..8486b24a5 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -109,3 +109,13 @@ GR_SWIG_BLOCK_MAGIC(uhd,single_usrp_sink) static const size_t ALL_MBOARDS = uhd::usrp::multi_usrp::ALL_MBOARDS; %} static const size_t ALL_MBOARDS; + +#if SWIGGUILE +%scheme %{ +(load-extension "libguile-uhd_swig" "scm_init_gnuradio_uhd_swig_module") +%} + +%goops %{ +(use-modules (gnuradio gnuradio_core_runtime)) +%} +#endif -- cgit From 2c54f4a56304b3dba7a66ed1baf06dc0bd8393e8 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Sun, 31 Oct 2010 10:12:43 -0700 Subject: additional regenerated files --- gr-uhd/swig/Makefile.swig.gen | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen index 88ed33834..86ead5b00 100644 --- a/gr-uhd/swig/Makefile.swig.gen +++ b/gr-uhd/swig/Makefile.swig.gen @@ -46,7 +46,7 @@ uhd_swig_scmlibdir = $(libdir) # The scm files for the guile modules get installed where ever guile # is installed, usually /usr/share/guile/site/uhd_swig # FIXME: determince whether these should be installed with gnuradio. -uhd_swig_scmdir = $(guiledir)/gnuradio +uhd_swig_scmdir = $(guiledir) ## SWIG headers are always installed into the same directory. @@ -128,7 +128,7 @@ uhd_swig_scmlib_LTLIBRARIES = libguile-uhd_swig.la libguile_uhd_swig_la_SOURCES = \ guile/uhd_swig.cc \ $(uhd_swig_la_swig_sources) -uhd_swig_scm_DATA = uhd_swig.scm +nobase_uhd_swig_scm_DATA = gnuradio/uhd_swig.scm gnuradio/uhd_swig-primitive.scm # Guile can use the same flags as python does libguile_uhd_swig_la_LIBADD = $(_uhd_swig_la_LIBADD) @@ -137,6 +137,9 @@ libguile_uhd_swig_la_CXXFLAGS = $(_uhd_swig_la_CXXFLAGS) guile/uhd_swig.lo: uhd_swig.lo uhd_swig.scm: uhd_swig.i +gnuradio/uhd_swig-primitive.scm: uhd_swig.scm + +-include guile/uhd_swig.d endif # end of GUILE -- cgit From 23d960981d6afcedb3a7fd1066a8acbfb0b4afdf Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Sun, 31 Oct 2010 14:16:25 -0700 Subject: Use uhd_swig_swig_args instead of stomping on STD_SWIG_PYTHON_ARGS --- gr-uhd/swig/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am index 183e6b587..744dd8efe 100644 --- a/gr-uhd/swig/Makefile.am +++ b/gr-uhd/swig/Makefile.am @@ -56,8 +56,7 @@ uhd_swig_swiginclude_headers = include $(top_srcdir)/Makefile.swig -# FIXME better way to set this? -STD_SWIG_PYTHON_ARGS += \ +uhd_swig_swig_args = \ $(UHD_CFLAGS) \ -I$(top_srcdir)/gr-uhd/lib -- cgit From bc8fd41b84219cd08f057c524fe0b90ffef6f8aa Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Mon, 1 Nov 2010 16:28:14 -0700 Subject: regenerated --- gr-uhd/swig/Makefile.swig.gen | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen index 86ead5b00..c0823e5f2 100644 --- a/gr-uhd/swig/Makefile.swig.gen +++ b/gr-uhd/swig/Makefile.swig.gen @@ -84,10 +84,10 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S* # generating the py or scm file also generates the .cc or .h files, # but dependencies work better without the .cc ort .h files listed. -swig_built_sources += uhd_swig.py -if GUILE -swig_built_sources += uhd_swig.scm -endif +# swig_built_sources += uhd_swig.py +# if GUILE +# swig_built_sources += gnuradio/uhd_swig.scm +# endif ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including @@ -135,15 +135,14 @@ libguile_uhd_swig_la_LIBADD = $(_uhd_swig_la_LIBADD) libguile_uhd_swig_la_LDFLAGS = $(_uhd_swig_la_LDFLAGS) libguile_uhd_swig_la_CXXFLAGS = $(_uhd_swig_la_CXXFLAGS) -guile/uhd_swig.lo: uhd_swig.lo -uhd_swig.scm: uhd_swig.i -gnuradio/uhd_swig-primitive.scm: uhd_swig.scm +guile/uhd_swig.cc: gnuradio/uhd_swig.scm +gnuradio/uhd_swig.scm: uhd_swig.i +gnuradio/uhd_swig-primitive.scm: gnuradio/uhd_swig.scm -include guile/uhd_swig.d endif # end of GUILE -python/uhd_swig.lo: uhd_swig.lo: uhd_swig.py uhd_swig.scm uhd_swig.py: uhd_swig.i -- cgit From df92b7c6315c567e58e0d9c293d7c9c2699023d3 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Wed, 10 Nov 2010 13:01:38 -0800 Subject: regenerated --- gr-uhd/swig/Makefile.swig.gen | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen index c0823e5f2..1ddbf0bd9 100644 --- a/gr-uhd/swig/Makefile.swig.gen +++ b/gr-uhd/swig/Makefile.swig.gen @@ -67,28 +67,10 @@ uhd_swig_swigincludedir = $(swigincludedir) ## right thing. For more info, see < ## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > -## Stamps used to ensure parallel make does the right thing. These -## are removed by "make clean", but otherwise unused except during the -## parallel built. These will not be included in a tarball, because -## the SWIG-generated files will be removed from the distribution. - -STAMPS += $(DEPDIR)/uhd_swig-generate-* - ## Other cleaned files: dependency files generated by SWIG or this Makefile MOSTLYCLEANFILES += $(DEPDIR)/*.S* -## Add the .py and .cc files to the list of SWIG built sources. The -## .h file is sometimes built, but not always ... so that one has to -## be added manually by the including Makefile.am . - -# generating the py or scm file also generates the .cc or .h files, -# but dependencies work better without the .cc ort .h files listed. -# swig_built_sources += uhd_swig.py -# if GUILE -# swig_built_sources += gnuradio/uhd_swig.scm -# endif - ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including ## Makefile.swig . @@ -108,8 +90,6 @@ _uhd_swig_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ $(uhd_swig_la_swig_libadd) -# _uhd_swig_la_DEPENDENCIES = python/uhd_swig.lo - _uhd_swig_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ $(uhd_swig_la_swig_ldflags) @@ -123,14 +103,20 @@ uhd_swig_python_PYTHON = \ uhd_swig.py \ $(uhd_swig) +python/uhd_swig.cc: uhd_swig.py +uhd_swig.py: uhd_swig.i + +# Include the python dependencies for this file +-include python/uhd_swig.d +# end of PYTHON + if GUILE uhd_swig_scmlib_LTLIBRARIES = libguile-uhd_swig.la -libguile_uhd_swig_la_SOURCES = \ +libguile_uhd_swig_la_SOURCES = \ guile/uhd_swig.cc \ $(uhd_swig_la_swig_sources) nobase_uhd_swig_scm_DATA = gnuradio/uhd_swig.scm gnuradio/uhd_swig-primitive.scm -# Guile can use the same flags as python does libguile_uhd_swig_la_LIBADD = $(_uhd_swig_la_LIBADD) libguile_uhd_swig_la_LDFLAGS = $(_uhd_swig_la_LDFLAGS) libguile_uhd_swig_la_CXXFLAGS = $(_uhd_swig_la_CXXFLAGS) @@ -139,12 +125,9 @@ guile/uhd_swig.cc: gnuradio/uhd_swig.scm gnuradio/uhd_swig.scm: uhd_swig.i gnuradio/uhd_swig-primitive.scm: gnuradio/uhd_swig.scm +# Include the guile dependencies for this file -include guile/uhd_swig.d endif # end of GUILE -uhd_swig.lo: uhd_swig.py uhd_swig.scm -uhd_swig.py: uhd_swig.i - --include python/uhd_swig.d -- cgit From b7af0969843a7345770792939878b2678951470f Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 16 Nov 2010 14:00:38 -0800 Subject: UHD single source builds tags from packet metadata to ship downstream. Tag 1 contains the packet time Tag 2 contains the packet length --- gr-uhd/lib/uhd_single_usrp_source.cc | 61 +++++++++++++++++++++++++++--------- gr-uhd/lib/uhd_single_usrp_source.h | 4 +++ 2 files changed, 50 insertions(+), 15 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index 907e8be54..ded3cd16d 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -29,8 +29,10 @@ * 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 */ + :gr_sync_block("uhd single_usrp source", gr_make_io_signature(0, 0, 0), sig) +{ + d_num_packet_samps = 0; + d_tstamp_pair = pmt::pmt_cons(pmt::mp(0), pmt::mp(0)); } /*********************************************************************** @@ -131,25 +133,54 @@ public: ){ 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: + size_t total_samps = 0; + while(total_samps + 362 < noutput_items) { + size_t num_samps = _dev->get_device()->recv( + output_items, noutput_items, metadata, + _type, uhd::device::RECV_MODE_ONE_PACKET + ); + total_samps += num_samps; + + switch(metadata.error_code){ + case uhd::rx_metadata_t::ERROR_CODE_NONE: + //keep track of the number of accumulated samples in this packet + if (metadata.fragment_offset == 0) { + d_num_packet_samps = 0; + d_tstamp_pair = pmt::pmt_cons(pmt::mp(metadata.time_spec.get_full_secs()), + pmt::mp(metadata.time_spec.get_frac_secs())); + } + d_num_packet_samps += num_samps; + + //don't push on to the queue until we get the final fragment + if (!metadata.more_fragments) { + // Create tags with time and num samples + pmt::pmt_t tsamp, nsamp; + pmt::pmt_t nsamp_val = pmt::mp((int)d_num_packet_samps); + + + add_item_tag(0, nitems_written(0), + pmt::mp("packet_time_stamp"), + d_tstamp_pair, + pmt::mp("uhd_single_usrp_source")); + add_item_tag(0, nitems_written(0), + pmt::mp("num_packet_samples"), + nsamp_val, + pmt::mp("uhd_single_usrp_source")); + + } + 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: + + default: std::cout << boost::format( "UHD source block got error code 0x%x" ) % metadata.error_code << std::endl; return num_samps; - } + } + } } bool start(void){ diff --git a/gr-uhd/lib/uhd_single_usrp_source.h b/gr-uhd/lib/uhd_single_usrp_source.h index 495f8c611..2a011b2b3 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.h +++ b/gr-uhd/lib/uhd_single_usrp_source.h @@ -168,6 +168,10 @@ public: * \return the single usrp device object */ virtual uhd::usrp::single_usrp::sptr get_device(void) = 0; + + protected: + size_t d_num_packet_samps; + pmt::pmt_t d_tstamp_pair; }; #endif /* INCLUDED_UHD_SINGLE_USRP_SOURCE_H */ -- cgit From 8180bb1d7020e07c9b0a217820c68d07f0d98a74 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Tue, 16 Nov 2010 21:33:50 -0800 Subject: regenerated --- gr-uhd/swig/Makefile.swig.gen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen index 1ddbf0bd9..cf7351fe2 100644 --- a/gr-uhd/swig/Makefile.swig.gen +++ b/gr-uhd/swig/Makefile.swig.gen @@ -101,7 +101,7 @@ _uhd_swig_la_CXXFLAGS = \ uhd_swig_python_PYTHON = \ uhd_swig.py \ - $(uhd_swig) + $(uhd_swig_python) python/uhd_swig.cc: uhd_swig.py uhd_swig.py: uhd_swig.i -- cgit From 4eadee57c588940347027c7e7f99ac7e993874fd Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Wed, 17 Nov 2010 13:54:04 -0800 Subject: Add support for guile std::vector< std::complex >. --- gr-uhd/swig/uhd_swig.i | 2 -- 1 file changed, 2 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 8486b24a5..b3abf29be 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -42,8 +42,6 @@ // standard includes //////////////////////////////////////////////////////////////////////// %include "gnuradio.i" -%include "std_string.i" -%include "std_vector.i" namespace std { %template(StringVector) vector; -- cgit From f155f3a3f91f640eb7bb69ae76cb160c2812db54 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 17 Nov 2010 16:48:25 -0800 Subject: Some updates to uhd source with tags. --- gr-uhd/lib/uhd_single_usrp_source.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index ded3cd16d..6ea7c8af6 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -134,9 +134,10 @@ public: uhd::rx_metadata_t metadata; //not passed out of this block size_t total_samps = 0; - while(total_samps + 362 < noutput_items) { + while(total_samps + 362 < (size_t)noutput_items) { size_t num_samps = _dev->get_device()->recv( output_items, noutput_items, metadata, + //_type, uhd::device::RECV_MODE_FULL_BUFF _type, uhd::device::RECV_MODE_ONE_PACKET ); total_samps += num_samps; @@ -157,7 +158,6 @@ public: pmt::pmt_t tsamp, nsamp; pmt::pmt_t nsamp_val = pmt::mp((int)d_num_packet_samps); - add_item_tag(0, nitems_written(0), pmt::mp("packet_time_stamp"), d_tstamp_pair, @@ -166,7 +166,6 @@ public: pmt::mp("num_packet_samples"), nsamp_val, pmt::mp("uhd_single_usrp_source")); - } return num_samps; @@ -181,6 +180,7 @@ public: return num_samps; } } + return -1; } bool start(void){ -- cgit From 3f56b10b5eaef36643fd87044601ca47cd9fb707 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Wed, 17 Nov 2010 18:53:33 -0800 Subject: distcheck fix for gr-uhd --- gr-uhd/lib/Makefile.am | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index b4b1abfc6..eb2ba4a17 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -53,4 +53,12 @@ grinclude_HEADERS = \ uhd_single_usrp_source.h \ uhd_single_usrp_sink.h +# add the deprecated headers +grinclude_HEADERS += \ + uhd_mimo_source.h \ + uhd_mimo_sink.h \ + uhd_simple_source.h \ + uhd_simple_sink.h + + noinst_HEADERS = -- cgit From 8176675bcd887d760cc2413f9326d5515641d800 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 18 Nov 2010 12:51:45 -0800 Subject: Changing time pair in uhd source from a pmt pair to tuple. --- gr-uhd/lib/uhd_single_usrp_source.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index 6ea7c8af6..cdb25919e 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -32,7 +32,7 @@ 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) { d_num_packet_samps = 0; - d_tstamp_pair = pmt::pmt_cons(pmt::mp(0), pmt::mp(0)); + d_tstamp_pair = pmt::mp(pmt::mp(0), pmt::mp(0)); } /*********************************************************************** @@ -147,8 +147,8 @@ public: //keep track of the number of accumulated samples in this packet if (metadata.fragment_offset == 0) { d_num_packet_samps = 0; - d_tstamp_pair = pmt::pmt_cons(pmt::mp(metadata.time_spec.get_full_secs()), - pmt::mp(metadata.time_spec.get_frac_secs())); + d_tstamp_pair = pmt::mp(pmt::mp(metadata.time_spec.get_full_secs()), + pmt::mp(metadata.time_spec.get_frac_secs())); } d_num_packet_samps += num_samps; -- cgit From d74eacddbb8875479fef1d9ca75f36fca78df792 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Thu, 18 Nov 2010 23:40:16 -0800 Subject: Remove 868 useless warnings about "is deprecated". Perhaps a warning printed from the constructor would be more helpful and less distracting than cluttering the output of make with 868 warnings... --- gr-uhd/lib/uhd_mimo_sink.h | 2 +- gr-uhd/lib/uhd_mimo_source.h | 2 +- gr-uhd/lib/uhd_simple_sink.h | 2 +- gr-uhd/lib/uhd_simple_source.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_mimo_sink.h b/gr-uhd/lib/uhd_mimo_sink.h index 28a530b60..29e9298a9 100644 --- a/gr-uhd/lib/uhd_mimo_sink.h +++ b/gr-uhd/lib/uhd_mimo_sink.h @@ -37,7 +37,7 @@ boost::shared_ptr uhd_make_mimo_sink( /*********************************************************************** * DEPRECATED **********************************************************************/ -class UHD_DEPRECATED uhd_mimo_sink : public gr_sync_block{ +class /*UHD_DEPRECATED*/ uhd_mimo_sink : public gr_sync_block{ public: /*! diff --git a/gr-uhd/lib/uhd_mimo_source.h b/gr-uhd/lib/uhd_mimo_source.h index dc2927598..36735ae7e 100644 --- a/gr-uhd/lib/uhd_mimo_source.h +++ b/gr-uhd/lib/uhd_mimo_source.h @@ -37,7 +37,7 @@ boost::shared_ptr uhd_make_mimo_source( /*********************************************************************** * DEPRECATED **********************************************************************/ -class UHD_DEPRECATED uhd_mimo_source : public gr_sync_block{ +class /*UHD_DEPRECATED*/ uhd_mimo_source : public gr_sync_block{ public: /*! diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index b239e3f21..930487049 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -36,7 +36,7 @@ boost::shared_ptr uhd_make_simple_sink( /*********************************************************************** * DEPRECATED **********************************************************************/ -class UHD_DEPRECATED uhd_simple_sink : public gr_sync_block{ +class /*UHD_DEPRECATED*/ uhd_simple_sink : public gr_sync_block{ public: /*! diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index c524a024a..d9f8d252a 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -36,7 +36,7 @@ boost::shared_ptr uhd_make_simple_source( /*********************************************************************** * DEPRECATED **********************************************************************/ -class UHD_DEPRECATED uhd_simple_source : public gr_sync_block{ +class /*UHD_DEPRECATED*/ uhd_simple_source : public gr_sync_block{ public: /*! -- cgit From ff877cabe2384dc2155ef5af92ee8b959fd29806 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Fri, 19 Nov 2010 08:07:52 -0700 Subject: regenerated --- gr-uhd/swig/Makefile.swig.gen | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen index cf7351fe2..782800c9b 100644 --- a/gr-uhd/swig/Makefile.swig.gen +++ b/gr-uhd/swig/Makefile.swig.gen @@ -79,6 +79,7 @@ uhd_swig_swiginclude_HEADERS = \ uhd_swig.i \ $(uhd_swig_swiginclude_headers) +if PYTHON uhd_swig_pylib_LTLIBRARIES = \ _uhd_swig.la @@ -86,6 +87,10 @@ _uhd_swig_la_SOURCES = \ python/uhd_swig.cc \ $(uhd_swig_la_swig_sources) +uhd_swig_python_PYTHON = \ + uhd_swig.py \ + $(uhd_swig_python) + _uhd_swig_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ $(uhd_swig_la_swig_libadd) @@ -99,27 +104,34 @@ _uhd_swig_la_CXXFLAGS = \ -I$(top_builddir) \ $(uhd_swig_la_swig_cxxflags) -uhd_swig_python_PYTHON = \ - uhd_swig.py \ - $(uhd_swig_python) - python/uhd_swig.cc: uhd_swig.py uhd_swig.py: uhd_swig.i # Include the python dependencies for this file -include python/uhd_swig.d -# end of PYTHON + +endif # end of if python if GUILE -uhd_swig_scmlib_LTLIBRARIES = libguile-uhd_swig.la + +uhd_swig_scmlib_LTLIBRARIES = \ + libguile-uhd_swig.la libguile_uhd_swig_la_SOURCES = \ guile/uhd_swig.cc \ $(uhd_swig_la_swig_sources) -nobase_uhd_swig_scm_DATA = gnuradio/uhd_swig.scm gnuradio/uhd_swig-primitive.scm - -libguile_uhd_swig_la_LIBADD = $(_uhd_swig_la_LIBADD) -libguile_uhd_swig_la_LDFLAGS = $(_uhd_swig_la_LDFLAGS) -libguile_uhd_swig_la_CXXFLAGS = $(_uhd_swig_la_CXXFLAGS) +nobase_uhd_swig_scm_DATA = \ + gnuradio/uhd_swig.scm \ + gnuradio/uhd_swig-primitive.scm +libguile_uhd_swig_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(uhd_swig_la_swig_libadd) +libguile_uhd_swig_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(uhd_swig_la_swig_ldflags) +libguile_uhd_swig_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + -I$(top_builddir) \ + $(uhd_swig_la_swig_cxxflags) guile/uhd_swig.cc: gnuradio/uhd_swig.scm gnuradio/uhd_swig.scm: uhd_swig.i -- cgit From 64bb45e9f5fc64b24c0d1119ba3e293240f6a8f1 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 21 Nov 2010 19:42:34 -0500 Subject: Slightly better handling of tags. --- gr-uhd/lib/uhd_single_usrp_source.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index cdb25919e..de4b5cc08 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -24,6 +24,7 @@ #include #include #include +#include /*********************************************************************** * UHD Single USRP Source @@ -51,6 +52,8 @@ public: _type(io_type) { _dev = uhd::usrp::single_usrp::make(device_addr); + + d_tag_srcid = pmt::mp("uhd_single_usrp_source"); } void set_subdev_spec(const std::string &spec){ @@ -159,13 +162,13 @@ public: pmt::pmt_t nsamp_val = pmt::mp((int)d_num_packet_samps); add_item_tag(0, nitems_written(0), - pmt::mp("packet_time_stamp"), + gr_tags::key_time, d_tstamp_pair, - pmt::mp("uhd_single_usrp_source")); + d_tag_srcid); add_item_tag(0, nitems_written(0), pmt::mp("num_packet_samples"), nsamp_val, - pmt::mp("uhd_single_usrp_source")); + d_tag_srcid); } return num_samps; @@ -196,6 +199,7 @@ public: private: uhd::usrp::single_usrp::sptr _dev; const uhd::io_type_t _type; + pmt::pmt_t d_tag_srcid; }; -- cgit From d81a16ddca6e81b1278560b71f8064bd6e583e55 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 22 Nov 2010 20:19:55 -0800 Subject: uhd: remove changes to avoid merge conflict --- gr-uhd/lib/Makefile.am | 8 -------- gr-uhd/lib/uhd_mimo_sink.h | 2 +- gr-uhd/lib/uhd_mimo_source.h | 2 +- gr-uhd/lib/uhd_simple_sink.h | 2 +- gr-uhd/lib/uhd_simple_source.h | 2 +- 5 files changed, 4 insertions(+), 12 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index eb2ba4a17..b4b1abfc6 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -53,12 +53,4 @@ grinclude_HEADERS = \ uhd_single_usrp_source.h \ uhd_single_usrp_sink.h -# add the deprecated headers -grinclude_HEADERS += \ - uhd_mimo_source.h \ - uhd_mimo_sink.h \ - uhd_simple_source.h \ - uhd_simple_sink.h - - noinst_HEADERS = diff --git a/gr-uhd/lib/uhd_mimo_sink.h b/gr-uhd/lib/uhd_mimo_sink.h index 29e9298a9..28a530b60 100644 --- a/gr-uhd/lib/uhd_mimo_sink.h +++ b/gr-uhd/lib/uhd_mimo_sink.h @@ -37,7 +37,7 @@ boost::shared_ptr uhd_make_mimo_sink( /*********************************************************************** * DEPRECATED **********************************************************************/ -class /*UHD_DEPRECATED*/ uhd_mimo_sink : public gr_sync_block{ +class UHD_DEPRECATED uhd_mimo_sink : public gr_sync_block{ public: /*! diff --git a/gr-uhd/lib/uhd_mimo_source.h b/gr-uhd/lib/uhd_mimo_source.h index 36735ae7e..dc2927598 100644 --- a/gr-uhd/lib/uhd_mimo_source.h +++ b/gr-uhd/lib/uhd_mimo_source.h @@ -37,7 +37,7 @@ boost::shared_ptr uhd_make_mimo_source( /*********************************************************************** * DEPRECATED **********************************************************************/ -class /*UHD_DEPRECATED*/ uhd_mimo_source : public gr_sync_block{ +class UHD_DEPRECATED uhd_mimo_source : public gr_sync_block{ public: /*! diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h index 930487049..b239e3f21 100644 --- a/gr-uhd/lib/uhd_simple_sink.h +++ b/gr-uhd/lib/uhd_simple_sink.h @@ -36,7 +36,7 @@ boost::shared_ptr uhd_make_simple_sink( /*********************************************************************** * DEPRECATED **********************************************************************/ -class /*UHD_DEPRECATED*/ uhd_simple_sink : public gr_sync_block{ +class UHD_DEPRECATED uhd_simple_sink : public gr_sync_block{ public: /*! diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h index d9f8d252a..c524a024a 100644 --- a/gr-uhd/lib/uhd_simple_source.h +++ b/gr-uhd/lib/uhd_simple_source.h @@ -36,7 +36,7 @@ boost::shared_ptr uhd_make_simple_source( /*********************************************************************** * DEPRECATED **********************************************************************/ -class /*UHD_DEPRECATED*/ uhd_simple_source : public gr_sync_block{ +class UHD_DEPRECATED uhd_simple_source : public gr_sync_block{ public: /*! -- cgit From 655a7afcbcaf159e66a404b455a9581e0fe2cba3 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 19 Nov 2010 11:47:28 -0800 Subject: uhd: removed deprecated interfaces (simple and mimo) --- gr-uhd/lib/Makefile.am | 7 -- gr-uhd/lib/uhd_mimo_sink.cc | 161 ----------------------------------- gr-uhd/lib/uhd_mimo_sink.h | 145 ------------------------------- gr-uhd/lib/uhd_mimo_source.cc | 166 ------------------------------------ gr-uhd/lib/uhd_mimo_source.h | 145 ------------------------------- gr-uhd/lib/uhd_simple_sink.cc | 152 --------------------------------- gr-uhd/lib/uhd_simple_sink.h | 147 -------------------------------- gr-uhd/lib/uhd_simple_source.cc | 183 ---------------------------------------- gr-uhd/lib/uhd_simple_source.h | 147 -------------------------------- gr-uhd/swig/uhd_swig.i | 17 ---- 10 files changed, 1270 deletions(-) delete mode 100644 gr-uhd/lib/uhd_mimo_sink.cc delete mode 100644 gr-uhd/lib/uhd_mimo_sink.h delete mode 100644 gr-uhd/lib/uhd_mimo_source.cc delete mode 100644 gr-uhd/lib/uhd_mimo_source.h delete mode 100644 gr-uhd/lib/uhd_simple_sink.cc delete mode 100644 gr-uhd/lib/uhd_simple_sink.h delete mode 100644 gr-uhd/lib/uhd_simple_source.cc delete mode 100644 gr-uhd/lib/uhd_simple_source.h (limited to 'gr-uhd') diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index b4b1abfc6..099d0edbc 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -34,13 +34,6 @@ libgnuradio_uhd_la_SOURCES = \ uhd_single_usrp_source.cc \ uhd_single_usrp_sink.cc -# add the deprecated sources -libgnuradio_uhd_la_SOURCES += \ - uhd_mimo_source.cc \ - uhd_mimo_sink.cc \ - uhd_simple_source.cc \ - uhd_simple_sink.cc - libgnuradio_uhd_la_LIBADD = \ $(GNURADIO_CORE_LA) \ $(UHD_LIBS) diff --git a/gr-uhd/lib/uhd_mimo_sink.cc b/gr-uhd/lib/uhd_mimo_sink.cc deleted file mode 100644 index 03d310b1e..000000000 --- a/gr-uhd/lib/uhd_mimo_sink.cc +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -//#include "utils.h" - -/*********************************************************************** - * UHD Sink - **********************************************************************/ -uhd_mimo_sink::uhd_mimo_sink(gr_io_signature_sptr sig) -:gr_sync_block("uhd mimo sink", sig, gr_make_io_signature(0, 0, 0)){ - /* NOP */ -} - -/*********************************************************************** - * UHD Sink Impl - **********************************************************************/ -class uhd_mimo_sink_impl : public uhd_mimo_sink{ -public: - uhd_mimo_sink_impl( - size_t num_channels, - const std::string &args, - const uhd::io_type_t &type - ) : uhd_mimo_sink(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) - { - _first_run = false; - _dev = uhd::usrp::mimo_usrp::make(args); - _dev->set_time_unknown_pps(uhd::time_spec_t()); //TODO may want option to disable this - } - - ~uhd_mimo_sink_impl(void){ - //NOP - } - - void set_subdev_spec(size_t chan, const std::string &spec){ - return _dev->set_tx_subdev_spec(chan, spec); - } - - void set_samp_rate_all(double rate){ - _dev->set_tx_rate_all(rate); - //do_samp_rate_error_message(rate, get_samp_rate_all(), "TX"); - } - - double get_samp_rate_all(void){ - return _dev->get_tx_rate_all(); - } - - uhd::tune_result_t set_center_freq(size_t chan, double freq){ - uhd::tune_result_t tr = _dev->set_tx_freq(chan, freq); - //do_tune_freq_error_message(freq, _dev->get_tx_freq(chan), "TX"); - return tr; - } - - uhd::freq_range_t get_freq_range(size_t chan){ - return _dev->get_tx_freq_range(chan); - } - - void set_gain(size_t chan, float gain){ - return _dev->set_tx_gain(chan, gain); - } - - float get_gain(size_t chan){ - return _dev->get_tx_gain(chan); - } - - uhd::gain_range_t get_gain_range(size_t chan){ - return _dev->get_tx_gain_range(chan); - } - - void set_antenna(size_t chan, const std::string &ant){ - return _dev->set_tx_antenna(chan, ant); - } - - 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); - } - - 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); - } - - uhd::usrp::mimo_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 - ){ - //init the metadata on the first call to work - //and set the timespec with the current time + some offset - if (not _first_run){ - _first_run = true; - _metadata.start_of_burst = true; - _metadata.has_time_spec = true; - _metadata.time_spec = get_time_now() + uhd::time_spec_t(0, 0.01); //10ms offset in future - } - - //call to send with metadata slightly in the future (send-at) - size_t num_sent = _dev->get_device()->send( - input_items, noutput_items, _metadata, - _type, uhd::device::SEND_MODE_FULL_BUFF - ); - - //increment the send-at time by the number of samples sent - _metadata.time_spec += uhd::time_spec_t(0, num_sent, get_samp_rate_all()); - return num_sent; - } - -protected: - uhd::usrp::mimo_usrp::sptr _dev; - const uhd::io_type_t _type; - uhd::tx_metadata_t _metadata; - bool _first_run; -}; - -/*********************************************************************** - * Make UHD Sink - **********************************************************************/ -boost::shared_ptr uhd_make_mimo_sink( - size_t num_channels, - const std::string &args, - const uhd::io_type_t::tid_t &type -){ - return boost::shared_ptr( - new uhd_mimo_sink_impl(num_channels, args, type) - ); -} diff --git a/gr-uhd/lib/uhd_mimo_sink.h b/gr-uhd/lib/uhd_mimo_sink.h deleted file mode 100644 index 28a530b60..000000000 --- a/gr-uhd/lib/uhd_mimo_sink.h +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_UHD_MIMO_SINK_H -#define INCLUDED_UHD_MIMO_SINK_H - -#include -#include - -class uhd_mimo_sink; - -boost::shared_ptr uhd_make_mimo_sink( - size_t num_channels, - const std::string &args, - const uhd::io_type_t::tid_t &type -); - -/*********************************************************************** - * DEPRECATED - **********************************************************************/ -class UHD_DEPRECATED uhd_mimo_sink : public gr_sync_block{ -public: - - /*! - * Set the IO signature for this block. - * \param sig the input signature - */ - uhd_mimo_sink(gr_io_signature_sptr sig); - - /*! - * Set the subdevice specification. - * \param chan the channel number from 0 to N-1 - * \param spec the subdev spec markup string - */ - virtual void set_subdev_spec(size_t chan, const std::string &spec) = 0; - - /*! - * Set the sample rate for the usrp device (across all mboards). - * \param rate a new rate in Sps - */ - virtual void set_samp_rate_all(double rate) = 0; - - /*! - * Get the sample rate for the usrp device (across all mboards). - * This is the actual sample rate and may differ from the rate set. - * \return the actual rate in Sps - */ - virtual double get_samp_rate_all(void) = 0; - - /*! - * Tune the usrp device to the desired center frequency. - * \param chan the channel number from 0 to N-1 - * \param freq the desired frequency in Hz - * \return a tune result with the actual frequencies - */ - virtual uhd::tune_result_t set_center_freq(size_t chan, double freq) = 0; - - /*! - * Get the tunable frequency range. - * \param chan the channel number from 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 chan the channel number from 0 to N-1 - * \param gain the gain in dB - */ - virtual void set_gain(size_t chan, float gain) = 0; - - /*! - * Get the actual dboard gain setting. - * \param chan the channel number from 0 to N-1 - * \return the actual gain in dB - */ - virtual float get_gain(size_t chan) = 0; - - /*! - * Get the settable gain range. - * \param chan the channel number from 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 chan the channel number from 0 to N-1 - * \param ant the antenna string - */ - virtual void set_antenna(size_t chan, const std::string &ant) = 0; - - /*! - * Get the antenna in use. - * \param chan the channel number from 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 number from 0 to N-1 - * \return a vector of antenna strings - */ - virtual std::vector get_antennas(size_t chan) = 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 (across all mboards). - * \param time_spec the new time - */ - virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; - - /*! - * Get access to the underlying uhd device object. - * \return the mimo usrp device object - */ - virtual uhd::usrp::mimo_usrp::sptr get_device(void) = 0; -}; - -#endif /* INCLUDED_UHD_MIMO_SINK_H */ diff --git a/gr-uhd/lib/uhd_mimo_source.cc b/gr-uhd/lib/uhd_mimo_source.cc deleted file mode 100644 index abd70ba36..000000000 --- a/gr-uhd/lib/uhd_mimo_source.cc +++ /dev/null @@ -1,166 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -//#include "utils.h" - -/*********************************************************************** - * UHD Source - **********************************************************************/ -uhd_mimo_source::uhd_mimo_source(gr_io_signature_sptr sig) -:gr_sync_block("uhd mimo source", gr_make_io_signature(0, 0, 0), sig){ - /* NOP */ -} - -/*********************************************************************** - * UHD Source Impl - **********************************************************************/ -class uhd_mimo_source_impl : public uhd_mimo_source{ -public: - uhd_mimo_source_impl( - size_t num_channels, - const std::string &args, - const uhd::io_type_t &type - ) : uhd_mimo_source(gr_make_io_signature(num_channels, num_channels, type.size)), _type(type) - { - _dev = uhd::usrp::mimo_usrp::make(args); - set_streaming(false); - _dev->set_time_unknown_pps(uhd::time_spec_t()); //TODO may want option to disable this - } - - ~uhd_mimo_source_impl(void){ - set_streaming(false); - } - - void set_subdev_spec(size_t chan, const std::string &spec){ - return _dev->set_rx_subdev_spec(chan, spec); - } - - void set_samp_rate_all(double rate){ - _dev->set_rx_rate_all(rate); - //do_samp_rate_error_message(rate, get_samp_rate_all(), "RX"); - } - - double get_samp_rate_all(void){ - return _dev->get_rx_rate_all(); - } - - uhd::tune_result_t set_center_freq(size_t chan, double freq){ - uhd::tune_result_t tr = _dev->set_rx_freq(chan, freq); - //do_tune_freq_error_message(freq, _dev->get_rx_freq(chan), "RX"); - return tr; - } - - uhd::freq_range_t get_freq_range(size_t chan){ - return _dev->get_rx_freq_range(chan); - } - - void set_gain(size_t chan, float gain){ - return _dev->set_rx_gain(chan, gain); - } - - float get_gain(size_t chan){ - return _dev->get_rx_gain(chan); - } - - uhd::gain_range_t get_gain_range(size_t chan){ - return _dev->get_rx_gain_range(chan); - } - - void set_antenna(size_t chan, const std::string &ant){ - return _dev->set_rx_antenna(chan, ant); - } - - 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); - } - - 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); - } - - uhd::usrp::mimo_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 - ){ - //conditionally start streaming in the work call - //this prevents streaming before the runtime is ready - if (not _is_streaming) set_streaming(true); - - uhd::rx_metadata_t metadata; //not passed out of this block - - return _dev->get_device()->recv( - output_items, noutput_items, metadata, - _type, uhd::device::RECV_MODE_FULL_BUFF - ); - } - -protected: - uhd::usrp::mimo_usrp::sptr _dev; - const uhd::io_type_t _type; - bool _is_streaming; - - void set_streaming(bool enb){ - if (enb){ - //setup a stream command that starts streaming slightly in the future - static const double reasonable_delay = 0.01; //10 ms (order of magnitude >> 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(_dev->get_num_channels() * reasonable_delay); - _dev->issue_stream_cmd(stream_cmd); - } - else - _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); - _is_streaming = enb; - } -}; - -/*********************************************************************** - * Make UHD Source - **********************************************************************/ -boost::shared_ptr uhd_make_mimo_source( - size_t num_channels, - const std::string &args, - const uhd::io_type_t::tid_t &type -){ - return boost::shared_ptr( - new uhd_mimo_source_impl(num_channels, args, type) - ); -} diff --git a/gr-uhd/lib/uhd_mimo_source.h b/gr-uhd/lib/uhd_mimo_source.h deleted file mode 100644 index dc2927598..000000000 --- a/gr-uhd/lib/uhd_mimo_source.h +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_UHD_MIMO_SOURCE_H -#define INCLUDED_UHD_MIMO_SOURCE_H - -#include -#include - -class uhd_mimo_source; - -boost::shared_ptr uhd_make_mimo_source( - size_t num_channels, - const std::string &args, - const uhd::io_type_t::tid_t &type -); - -/*********************************************************************** - * DEPRECATED - **********************************************************************/ -class UHD_DEPRECATED uhd_mimo_source : public gr_sync_block{ -public: - - /*! - * Set the IO signature for this block. - * \param sig the output signature - */ - uhd_mimo_source(gr_io_signature_sptr sig); - - /*! - * Set the subdevice specification. - * \param chan the channel number from 0 to N-1 - * \param spec the subdev spec markup string - */ - virtual void set_subdev_spec(size_t chan, const std::string &spec) = 0; - - /*! - * Set the sample rate for the usrp device (across all mboards). - * \param rate a new rate in Sps - */ - virtual void set_samp_rate_all(double rate) = 0; - - /*! - * Get the sample rate for the usrp device (across all mboards). - * This is the actual sample rate and may differ from the rate set. - * \return the actual rate in Sps - */ - virtual double get_samp_rate_all(void) = 0; - - /*! - * Tune the usrp device to the desired center frequency. - * \param chan the channel number from 0 to N-1 - * \param freq the desired frequency in Hz - * \return a tune result with the actual frequencies - */ - virtual uhd::tune_result_t set_center_freq(size_t chan, double freq) = 0; - - /*! - * Get the tunable frequency range. - * \param chan the channel number from 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 chan the channel number from 0 to N-1 - * \param gain the gain in dB - */ - virtual void set_gain(size_t chan, float gain) = 0; - - /*! - * Get the actual dboard gain setting. - * \param chan the channel number from 0 to N-1 - * \return the actual gain in dB - */ - virtual float get_gain(size_t chan) = 0; - - /*! - * Get the settable gain range. - * \param chan the channel number from 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 chan the channel number from 0 to N-1 - * \param ant the antenna string - */ - virtual void set_antenna(size_t chan, const std::string &ant) = 0; - - /*! - * Get the antenna in use. - * \param chan the channel number from 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 number from 0 to N-1 - * \return a vector of antenna strings - */ - virtual std::vector get_antennas(size_t chan) = 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 (across all mboards). - * \param time_spec the new time - */ - virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; - - /*! - * Get access to the underlying uhd device object. - * \return the mimo usrp device object - */ - virtual uhd::usrp::mimo_usrp::sptr get_device(void) = 0; -}; - -#endif /* INCLUDED_UHD_MIMO_SOURCE_H */ diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc deleted file mode 100644 index d7b04465d..000000000 --- a/gr-uhd/lib/uhd_simple_sink.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -//#include "utils.h" - -/*********************************************************************** - * UHD Sink - **********************************************************************/ -uhd_simple_sink::uhd_simple_sink(gr_io_signature_sptr sig) -:gr_sync_block("uhd simple sink", sig, gr_make_io_signature(0, 0, 0)){ - /* NOP */ -} - -/*********************************************************************** - * UHD Sink Impl - **********************************************************************/ -class uhd_simple_sink_impl : public uhd_simple_sink{ -public: - uhd_simple_sink_impl( - const std::string &args, - const uhd::io_type_t &type - ) : uhd_simple_sink(gr_make_io_signature(1, 1, type.size)), _type(type) - { - _dev = uhd::usrp::simple_usrp::make(args); - } - - ~uhd_simple_sink_impl(void){ - //NOP - } - - 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); - //do_samp_rate_error_message(rate, get_samp_rate(), "TX"); - } - - double get_samp_rate(void){ - return _dev->get_tx_rate(); - } - - uhd::tune_result_t set_center_freq(double freq){ - uhd::tune_result_t tr = _dev->set_tx_freq(freq); - //do_tune_freq_error_message(freq, _dev->get_tx_freq(), "TX"); - return tr; - } - - uhd::freq_range_t get_freq_range(void){ - return _dev->get_tx_freq_range(); - } - - void set_gain(float gain){ - return _dev->set_tx_gain(gain); - } - - float get_gain(void){ - return _dev->get_tx_gain(); - } - - uhd::gain_range_t get_gain_range(void){ - return _dev->get_tx_gain_range(); - } - - void set_antenna(const std::string &ant){ - return _dev->set_tx_antenna(ant); - } - - std::string get_antenna(void){ - return _dev->get_tx_antenna(); - } - - std::vector get_antennas(void){ - return _dev->get_tx_antennas(); - } - - 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::simple_usrp::sptr get_device(void){ - return _dev; - } - -/*********************************************************************** - * Work - **********************************************************************/ - int work( - int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items - ){ - uhd::tx_metadata_t metadata; - metadata.start_of_burst = true; - - return _dev->get_device()->send( - input_items, noutput_items, metadata, - _type, uhd::device::SEND_MODE_FULL_BUFF - ); - } - -protected: - uhd::usrp::simple_usrp::sptr _dev; - const uhd::io_type_t _type; -}; - -/*********************************************************************** - * Make UHD Sink - **********************************************************************/ -boost::shared_ptr uhd_make_simple_sink( - const std::string &args, - const uhd::io_type_t::tid_t &type -){ - return boost::shared_ptr( - new uhd_simple_sink_impl(args, type) - ); -} diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h deleted file mode 100644 index b239e3f21..000000000 --- a/gr-uhd/lib/uhd_simple_sink.h +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_UHD_SIMPLE_SINK_H -#define INCLUDED_UHD_SIMPLE_SINK_H - -#include -#include - -class uhd_simple_sink; - -boost::shared_ptr uhd_make_simple_sink( - const std::string &args, - const uhd::io_type_t::tid_t &type -); - -/*********************************************************************** - * DEPRECATED - **********************************************************************/ -class UHD_DEPRECATED uhd_simple_sink : public gr_sync_block{ -public: - - /*! - * Set the IO signature for this block. - * \param sig the input signature - */ - uhd_simple_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 freq the desired frequency in Hz - * \return a tune result with the actual frequencies - */ - virtual uhd::tune_result_t set_center_freq(double freq) = 0; - - /*! - * Get the tunable frequency range. - * \return the frequency range in Hz - */ - virtual uhd::freq_range_t get_freq_range(void) = 0; - - /*! - * Set the gain for the dboard. - * \param gain the gain in dB - */ - virtual void set_gain(float gain) = 0; - - /*! - * Get the actual dboard gain setting. - * \return the actual gain in dB - */ - virtual float get_gain(void) = 0; - - /*! - * Get the settable gain range. - * \return the gain range in dB - */ - virtual uhd::gain_range_t get_gain_range(void) = 0; - - /*! - * Set the antenna to use. - * \param ant the antenna string - */ - virtual void set_antenna(const std::string &ant) = 0; - - /*! - * Get the antenna in use. - * \return the antenna string - */ - virtual std::string get_antenna(void) = 0; - - /*! - * Get a list of possible antennas. - * \return a vector of antenna strings - */ - virtual std::vector get_antennas(void) = 0; - - /*! - * Set the clock configuration. - * \param clock_config the new configuration - */ - virtual void set_clock_config(const uhd::clock_config_t &clock_config) = 0; - - /*! - * Get the current time registers. - * \return the current usrp time - */ - virtual uhd::time_spec_t get_time_now(void) = 0; - - /*! - * Set the time registers asap. - * \param time_spec the new time - */ - virtual void set_time_now(const uhd::time_spec_t &time_spec) = 0; - - /*! - * Set the time registers at the next pps. - * \param time_spec the new time - */ - virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; - - /*! - * Get access to the underlying uhd device object. - * \return the simple usrp device object - */ - virtual uhd::usrp::simple_usrp::sptr get_device(void) = 0; -}; - -#endif /* INCLUDED_UHD_SIMPLE_SINK_H */ diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc deleted file mode 100644 index d74c8414d..000000000 --- a/gr-uhd/lib/uhd_simple_source.cc +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -//#include "utils.h" - -/*********************************************************************** - * UHD Source - **********************************************************************/ -uhd_simple_source::uhd_simple_source(gr_io_signature_sptr sig) -:gr_sync_block("uhd simple source", gr_make_io_signature(0, 0, 0), sig){ - /* NOP */ -} - -/*********************************************************************** - * UHD Source Impl - **********************************************************************/ -class uhd_simple_source_impl : public uhd_simple_source{ -public: - uhd_simple_source_impl( - const std::string &args, - const uhd::io_type_t &type - ) : uhd_simple_source(gr_make_io_signature(1, 1, type.size)), _type(type) - { - _dev = uhd::usrp::simple_usrp::make(args); - set_streaming(false); - } - - ~uhd_simple_source_impl(void){ - set_streaming(false); - } - - 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); - //do_samp_rate_error_message(rate, get_samp_rate(), "RX"); - } - - double get_samp_rate(void){ - return _dev->get_rx_rate(); - } - - uhd::tune_result_t set_center_freq(double freq){ - uhd::tune_result_t tr = _dev->set_rx_freq(freq); - //do_tune_freq_error_message(freq, _dev->get_rx_freq(), "RX"); - return tr; - } - - uhd::freq_range_t get_freq_range(void){ - return _dev->get_rx_freq_range(); - } - - void set_gain(float gain){ - return _dev->set_rx_gain(gain); - } - - float get_gain(void){ - return _dev->get_rx_gain(); - } - - uhd::gain_range_t get_gain_range(void){ - return _dev->get_rx_gain_range(); - } - - void set_antenna(const std::string &ant){ - return _dev->set_rx_antenna(ant); - } - - std::string get_antenna(void){ - return _dev->get_rx_antenna(); - } - - std::vector get_antennas(void){ - return _dev->get_rx_antennas(); - } - - 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::simple_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 - ){ - //conditionally start streaming in the work call - //this prevents streaming before the runtime is ready - if (not _is_streaming) set_streaming(true); - - 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; - } - } - -private: - uhd::usrp::simple_usrp::sptr _dev; - const uhd::io_type_t _type; - bool _is_streaming; - - void set_streaming(bool enb){ - if (enb) - _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); - else - _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); - _is_streaming = enb; - } -}; - - -/*********************************************************************** - * Make UHD Source - **********************************************************************/ -boost::shared_ptr uhd_make_simple_source( - const std::string &args, - const uhd::io_type_t::tid_t &type -){ - return boost::shared_ptr( - new uhd_simple_source_impl(args, type) - ); -} diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h deleted file mode 100644 index c524a024a..000000000 --- a/gr-uhd/lib/uhd_simple_source.h +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_UHD_SIMPLE_SOURCE_H -#define INCLUDED_UHD_SIMPLE_SOURCE_H - -#include -#include - -class uhd_simple_source; - -boost::shared_ptr uhd_make_simple_source( - const std::string &args, - const uhd::io_type_t::tid_t &type -); - -/*********************************************************************** - * DEPRECATED - **********************************************************************/ -class UHD_DEPRECATED uhd_simple_source : public gr_sync_block{ -public: - - /*! - * Set the IO signature for this block. - * \param sig the output signature - */ - uhd_simple_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 freq the desired frequency in Hz - * \return a tune result with the actual frequencies - */ - virtual uhd::tune_result_t set_center_freq(double freq) = 0; - - /*! - * Get the tunable frequency range. - * \return the frequency range in Hz - */ - virtual uhd::freq_range_t get_freq_range(void) = 0; - - /*! - * Set the gain for the dboard. - * \param gain the gain in dB - */ - virtual void set_gain(float gain) = 0; - - /*! - * Get the actual dboard gain setting. - * \return the actual gain in dB - */ - virtual float get_gain(void) = 0; - - /*! - * Get the settable gain range. - * \return the gain range in dB - */ - virtual uhd::gain_range_t get_gain_range(void) = 0; - - /*! - * Set the antenna to use. - * \param ant the antenna string - */ - virtual void set_antenna(const std::string &ant) = 0; - - /*! - * Get the antenna in use. - * \return the antenna string - */ - virtual std::string get_antenna(void) = 0; - - /*! - * Get a list of possible antennas. - * \return a vector of antenna strings - */ - virtual std::vector get_antennas(void) = 0; - - /*! - * Set the clock configuration. - * \param clock_config the new configuration - */ - virtual void set_clock_config(const uhd::clock_config_t &clock_config) = 0; - - /*! - * Get the current time registers. - * \return the current usrp time - */ - virtual uhd::time_spec_t get_time_now(void) = 0; - - /*! - * Set the time registers asap. - * \param time_spec the new time - */ - virtual void set_time_now(const uhd::time_spec_t &time_spec) = 0; - - /*! - * Set the time registers at the next pps. - * \param time_spec the new time - */ - virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; - - /*! - * Get access to the underlying uhd device object. - * \return the simple usrp device object - */ - virtual uhd::usrp::simple_usrp::sptr get_device(void) = 0; -}; - -#endif /* INCLUDED_UHD_SIMPLE_SOURCE_H */ diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 3c6773374..695cf1cd2 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -53,11 +53,6 @@ namespace std { // block headers //////////////////////////////////////////////////////////////////////// %{ -#include //deprecated -#include //deprecated -#include //deprecated -#include //deprecated - #include #include #include @@ -90,18 +85,6 @@ namespace std { //////////////////////////////////////////////////////////////////////// // block magic //////////////////////////////////////////////////////////////////////// -GR_SWIG_BLOCK_MAGIC(uhd,mimo_source) //deprecated -%include //deprecated - -GR_SWIG_BLOCK_MAGIC(uhd,mimo_sink) //deprecated -%include //deprecated - -GR_SWIG_BLOCK_MAGIC(uhd,simple_source) //deprecated -%include //deprecated - -GR_SWIG_BLOCK_MAGIC(uhd,simple_sink) //deprecated -%include //deprecated - GR_SWIG_BLOCK_MAGIC(uhd,multi_usrp_source) %include -- cgit From b245c628f4f5e252740e0248a33c0266640cb0bb Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 21 Nov 2010 18:03:01 -0800 Subject: uhd: remove deprecated grc wrappers --- gr-uhd/grc/Makefile.am | 7 - gr-uhd/grc/uhd_block_tree.xml | 7 - gr-uhd/grc/uhd_mimo_sink.xml | 549 --------------------------------------- gr-uhd/grc/uhd_mimo_source.xml | 549 --------------------------------------- gr-uhd/grc/uhd_simple_sink.xml | 101 ------- gr-uhd/grc/uhd_simple_source.xml | 101 ------- 6 files changed, 1314 deletions(-) delete mode 100644 gr-uhd/grc/uhd_mimo_sink.xml delete mode 100644 gr-uhd/grc/uhd_mimo_source.xml delete mode 100644 gr-uhd/grc/uhd_simple_sink.xml delete mode 100644 gr-uhd/grc/uhd_simple_source.xml (limited to 'gr-uhd') diff --git a/gr-uhd/grc/Makefile.am b/gr-uhd/grc/Makefile.am index d424ca709..1106bdd23 100644 --- a/gr-uhd/grc/Makefile.am +++ b/gr-uhd/grc/Makefile.am @@ -39,13 +39,6 @@ dist_grcblocks_DATA = \ uhd_block_tree.xml \ $(BUILT_SOURCES) -# add the deprecated files -dist_grcblocks_DATA += \ - uhd_mimo_source.xml \ - uhd_mimo_sink.xml \ - uhd_simple_source.xml \ - uhd_simple_sink.xml - ######################################################################## # Rules for generating the source and sink xml wrappers ######################################################################## diff --git a/gr-uhd/grc/uhd_block_tree.xml b/gr-uhd/grc/uhd_block_tree.xml index e8c4f069d..f5d42b567 100644 --- a/gr-uhd/grc/uhd_block_tree.xml +++ b/gr-uhd/grc/uhd_block_tree.xml @@ -13,11 +13,4 @@ uhd_multi_usrp_source uhd_multi_usrp_sink - - UHD (DEPRECATED) - uhd_simple_source - uhd_simple_sink - uhd_mimo_source - uhd_mimo_sink - diff --git a/gr-uhd/grc/uhd_mimo_sink.xml b/gr-uhd/grc/uhd_mimo_sink.xml deleted file mode 100644 index 13865c913..000000000 --- a/gr-uhd/grc/uhd_mimo_sink.xml +++ /dev/null @@ -1,549 +0,0 @@ - - - UHD MIMO Sink (DEPRECATED) - uhd_mimo_sink - from gnuradio import uhd - uhd.mimo_sink($nchan, $args, uhd.io_type_t.$type.type) -self.$(id).set_samp_rate_all($samp_rate) -#if $nchan() > 0 -self.$(id).set_subdev_spec(0, $sd_spec0) -self.$(id).set_center_freq(0, $center_freq0) -self.$(id).set_gain(0, $gain0) - #if $ant0() -self.$(id).set_antenna(0, $ant0) - #end if -#end if -#if $nchan() > 1 -self.$(id).set_subdev_spec(1, $sd_spec1) -self.$(id).set_center_freq(1, $center_freq1) -self.$(id).set_gain(1, $gain1) - #if $ant1() -self.$(id).set_antenna(1, $ant1) - #end if -#end if -#if $nchan() > 2 -self.$(id).set_subdev_spec(2, $sd_spec2) -self.$(id).set_center_freq(2, $center_freq2) -self.$(id).set_gain(2, $gain2) - #if $ant2() -self.$(id).set_antenna(2, $ant2) - #end if -#end if -#if $nchan() > 3 -self.$(id).set_subdev_spec(3, $sd_spec3) -self.$(id).set_center_freq(3, $center_freq3) -self.$(id).set_gain(3, $gain3) - #if $ant3() -self.$(id).set_antenna(3, $ant3) - #end if -#end if -#if $nchan() > 4 -self.$(id).set_subdev_spec(4, $sd_spec4) -self.$(id).set_center_freq(4, $center_freq4) -self.$(id).set_gain(4, $gain4) - #if $ant4() -self.$(id).set_antenna(4, $ant4) - #end if -#end if -#if $nchan() > 5 -self.$(id).set_subdev_spec(5, $sd_spec5) -self.$(id).set_center_freq(5, $center_freq5) -self.$(id).set_gain(5, $gain5) - #if $ant5() -self.$(id).set_antenna(5, $ant5) - #end if -#end if -#if $nchan() > 6 -self.$(id).set_subdev_spec(6, $sd_spec6) -self.$(id).set_center_freq(6, $center_freq6) -self.$(id).set_gain(6, $gain6) - #if $ant6() -self.$(id).set_antenna(6, $ant6) - #end if -#end if -#if $nchan() > 7 -self.$(id).set_subdev_spec(7, $sd_spec7) -self.$(id).set_center_freq(7, $center_freq7) -self.$(id).set_gain(7, $gain7) - #if $ant7() -self.$(id).set_antenna(7, $ant7) - #end if -#end if - - set_samp_rate($samp_rate) - set_center_freq(0, $center_freq0) - set_gain(0, $gain0) - set_antenna(0, $ant0) - set_center_freq(1, $center_freq1) - set_gain(1, $gain1) - set_antenna(1, $ant1) - set_center_freq(2, $center_freq2) - set_gain(2, $gain2) - set_antenna(2, $ant2) - set_center_freq(3, $center_freq3) - set_gain(3, $gain3) - set_antenna(3, $ant3) - set_center_freq(4, $center_freq4) - set_gain(4, $gain4) - set_antenna(4, $ant4) - set_center_freq(5, $center_freq5) - set_gain(5, $gain5) - set_antenna(5, $ant5) - set_center_freq(6, $center_freq6) - set_gain(6, $gain6) - set_antenna(6, $ant6) - set_center_freq(7, $center_freq7) - set_gain(7, $gain7) - set_antenna(7, $ant7) - - Input Type - type - enum - - - - - Num Channels - nchan - 2 - int - - - - - - - - - - Args - args - addr=192.168.10.2 192.168.20.2 - string - - - Samp Rate (Sps) - samp_rate - samp_rate - real - - - - Ch0: Subdev Spec - sd_spec0 - - string - - #if not $nchan() > 0 - all - #elif $sd_spec0() - none - #else - part - #end if - - - - 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 - - - - - Ch1: Subdev Spec - sd_spec1 - - string - - #if not $nchan() > 1 - all - #elif $sd_spec1() - 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 - - - - - Ch2: Subdev Spec - sd_spec2 - - string - - #if not $nchan() > 2 - all - #elif $sd_spec2() - 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 - - - - - Ch3: Subdev Spec - sd_spec3 - - string - - #if not $nchan() > 3 - all - #elif $sd_spec3() - 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 - - - - - Ch4: Subdev Spec - sd_spec4 - - string - - #if not $nchan() > 4 - all - #elif $sd_spec4() - 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 - - - - - Ch5: Subdev Spec - sd_spec5 - - string - - #if not $nchan() > 5 - all - #elif $sd_spec5() - 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 - - - - - Ch6: Subdev Spec - sd_spec6 - - string - - #if not $nchan() > 6 - all - #elif $sd_spec6() - 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 - - - - - Ch7: Subdev Spec - sd_spec7 - - string - - #if not $nchan() > 7 - all - #elif $sd_spec7() - 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 - - - - 8 >= $nchan - $nchan >= 0 - - in - $type - $type.vlen - $nchan - - -The UHD Sink Block: - -Args: -Args is a delimited string used to locate UHD devices on your system. \ -If left blank, the first UHD device found will be used. \ -Used args to specify a specfic device. \ -USRP2 Example: addr=192.168.10.2 - -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. - -Antenna: -For subdevices/daughterboards 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. - - diff --git a/gr-uhd/grc/uhd_mimo_source.xml b/gr-uhd/grc/uhd_mimo_source.xml deleted file mode 100644 index 6167838b0..000000000 --- a/gr-uhd/grc/uhd_mimo_source.xml +++ /dev/null @@ -1,549 +0,0 @@ - - - UHD MIMO Source (DEPRECATED) - uhd_mimo_source - from gnuradio import uhd - uhd.mimo_source($nchan, $args, uhd.io_type_t.$type.type) -self.$(id).set_samp_rate_all($samp_rate) -#if $nchan() > 0 -self.$(id).set_subdev_spec(0, $sd_spec0) -self.$(id).set_center_freq(0, $center_freq0) -self.$(id).set_gain(0, $gain0) - #if $ant0() -self.$(id).set_antenna(0, $ant0) - #end if -#end if -#if $nchan() > 1 -self.$(id).set_subdev_spec(1, $sd_spec1) -self.$(id).set_center_freq(1, $center_freq1) -self.$(id).set_gain(1, $gain1) - #if $ant1() -self.$(id).set_antenna(1, $ant1) - #end if -#end if -#if $nchan() > 2 -self.$(id).set_subdev_spec(2, $sd_spec2) -self.$(id).set_center_freq(2, $center_freq2) -self.$(id).set_gain(2, $gain2) - #if $ant2() -self.$(id).set_antenna(2, $ant2) - #end if -#end if -#if $nchan() > 3 -self.$(id).set_subdev_spec(3, $sd_spec3) -self.$(id).set_center_freq(3, $center_freq3) -self.$(id).set_gain(3, $gain3) - #if $ant3() -self.$(id).set_antenna(3, $ant3) - #end if -#end if -#if $nchan() > 4 -self.$(id).set_subdev_spec(4, $sd_spec4) -self.$(id).set_center_freq(4, $center_freq4) -self.$(id).set_gain(4, $gain4) - #if $ant4() -self.$(id).set_antenna(4, $ant4) - #end if -#end if -#if $nchan() > 5 -self.$(id).set_subdev_spec(5, $sd_spec5) -self.$(id).set_center_freq(5, $center_freq5) -self.$(id).set_gain(5, $gain5) - #if $ant5() -self.$(id).set_antenna(5, $ant5) - #end if -#end if -#if $nchan() > 6 -self.$(id).set_subdev_spec(6, $sd_spec6) -self.$(id).set_center_freq(6, $center_freq6) -self.$(id).set_gain(6, $gain6) - #if $ant6() -self.$(id).set_antenna(6, $ant6) - #end if -#end if -#if $nchan() > 7 -self.$(id).set_subdev_spec(7, $sd_spec7) -self.$(id).set_center_freq(7, $center_freq7) -self.$(id).set_gain(7, $gain7) - #if $ant7() -self.$(id).set_antenna(7, $ant7) - #end if -#end if - - set_samp_rate($samp_rate) - set_center_freq(0, $center_freq0) - set_gain(0, $gain0) - set_antenna(0, $ant0) - set_center_freq(1, $center_freq1) - set_gain(1, $gain1) - set_antenna(1, $ant1) - set_center_freq(2, $center_freq2) - set_gain(2, $gain2) - set_antenna(2, $ant2) - set_center_freq(3, $center_freq3) - set_gain(3, $gain3) - set_antenna(3, $ant3) - set_center_freq(4, $center_freq4) - set_gain(4, $gain4) - set_antenna(4, $ant4) - set_center_freq(5, $center_freq5) - set_gain(5, $gain5) - set_antenna(5, $ant5) - set_center_freq(6, $center_freq6) - set_gain(6, $gain6) - set_antenna(6, $ant6) - set_center_freq(7, $center_freq7) - set_gain(7, $gain7) - set_antenna(7, $ant7) - - Input Type - type - enum - - - - - Num Channels - nchan - 2 - int - - - - - - - - - - Args - args - addr=192.168.10.2 192.168.20.2 - string - - - Samp Rate (Sps) - samp_rate - samp_rate - real - - - - Ch0: Subdev Spec - sd_spec0 - - string - - #if not $nchan() > 0 - all - #elif $sd_spec0() - none - #else - part - #end if - - - - 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 - - - - - Ch1: Subdev Spec - sd_spec1 - - string - - #if not $nchan() > 1 - all - #elif $sd_spec1() - 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 - - - - - Ch2: Subdev Spec - sd_spec2 - - string - - #if not $nchan() > 2 - all - #elif $sd_spec2() - 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 - - - - - Ch3: Subdev Spec - sd_spec3 - - string - - #if not $nchan() > 3 - all - #elif $sd_spec3() - 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 - - - - - Ch4: Subdev Spec - sd_spec4 - - string - - #if not $nchan() > 4 - all - #elif $sd_spec4() - 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 - - - - - Ch5: Subdev Spec - sd_spec5 - - string - - #if not $nchan() > 5 - all - #elif $sd_spec5() - 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 - - - - - Ch6: Subdev Spec - sd_spec6 - - string - - #if not $nchan() > 6 - all - #elif $sd_spec6() - 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 - - - - - Ch7: Subdev Spec - sd_spec7 - - string - - #if not $nchan() > 7 - all - #elif $sd_spec7() - 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 - - - - 8 >= $nchan - $nchan >= 0 - - out - $type - $type.vlen - $nchan - - -The UHD Source Block: - -Args: -Args is a delimited string used to locate UHD devices on your system. \ -If left blank, the first UHD device found will be used. \ -Used args to specify a specfic device. \ -USRP2 Example: addr=192.168.10.2 - -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. - -Antenna: -For subdevices/daughterboards 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. - - diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml deleted file mode 100644 index ee6051432..000000000 --- a/gr-uhd/grc/uhd_simple_sink.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - UHD Simple Sink (DEPRECATED) - uhd_simple_sink - from gnuradio import uhd - uhd.simple_sink($args, uhd.io_type_t.$type.type) -self.$(id).set_subdev_spec($sd_spec) -self.$(id).set_samp_rate($samp_rate) -self.$(id).set_center_freq($center_freq) -self.$(id).set_gain($gain) -#if $ant() -self.$(id).set_antenna($ant) -#end if - set_samp_rate($samp_rate) - set_center_freq($center_freq) - set_gain($gain) - set_antenna($ant) - - Input Type - type - enum - - - - - Args - args - - string - - - Subdev Spec - sd_spec - - string - #if $sd_spec() then 'none' else 'part'# - - - Samp Rate (Sps) - samp_rate - samp_rate - real - - - Center Freq (Hz) - center_freq - 0 - real - - - Gain (dB) - gain - 0 - real - - - Antenna - ant - string - #if $ant() == '' then 'part' else 'none'# - - - in - $type - $type.vlen - - -The UHD Sink Block: - -Args: -Args is a delimited string used to locate UHD devices on your system. \ -If left blank, the first UHD device found will be used. \ -Used args to specify a specfic device. \ -USRP2 Example: addr=192.168.10.2 - -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. - -Antenna: -For subdevices/daughterboards 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. - - diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml deleted file mode 100644 index 825981d66..000000000 --- a/gr-uhd/grc/uhd_simple_source.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - UHD Simple Source (DEPRECATED) - uhd_simple_source - from gnuradio import uhd - uhd.simple_source($args, uhd.io_type_t.$type.type) -self.$(id).set_subdev_spec($sd_spec) -self.$(id).set_samp_rate($samp_rate) -self.$(id).set_center_freq($center_freq) -self.$(id).set_gain($gain) -#if $ant() -self.$(id).set_antenna($ant) -#end if - set_samp_rate($samp_rate) - set_center_freq($center_freq) - set_gain($gain) - set_antenna($ant) - - Output Type - type - enum - - - - - Args - args - - string - - - Subdev Spec - sd_spec - - string - #if $sd_spec() then 'none' else 'part'# - - - Samp Rate (Sps) - samp_rate - samp_rate - real - - - Center Freq (Hz) - center_freq - 0 - real - - - Gain (dB) - gain - 0 - real - - - Antenna - ant - string - #if $ant() == '' then 'part' else 'none'# - - - out - $type - $type.vlen - - -The UHD Source Block: - -Args: -Args is a delimited string used to locate UHD devices on your system. \ -If left blank, the first UHD device found will be used. \ -Used args to specify a specfic device. \ -USRP2 Example: addr=192.168.10.2 - -Sample rate: -The sample rate is the number of samples per second output 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. - -Antenna: -For subdevices/daughterboards 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. - - -- cgit From ac0b247d245dcc9cfd3e376c0e0ab2b6f18376d4 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Tue, 23 Nov 2010 23:34:10 -0800 Subject: Add uhd.scm wrapper for uhd_swig.scm --- gr-uhd/swig/Makefile.am | 9 ++++++--- gr-uhd/swig/gnuradio/uhd.scm | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 gr-uhd/swig/gnuradio/uhd.scm (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am index 744dd8efe..abf38b293 100644 --- a/gr-uhd/swig/Makefile.am +++ b/gr-uhd/swig/Makefile.am @@ -20,6 +20,7 @@ # include $(top_srcdir)/Makefile.common +include $(top_srcdir)/Makefile.swig AM_CPPFLAGS = \ $(STD_DEFINES_AND_INCLUDES) \ @@ -28,7 +29,11 @@ AM_CPPFLAGS = \ $(UHD_CFLAGS) \ -I$(top_srcdir)/gr-uhd/lib -if PYTHON +if GUILE +nobase_guile_DATA = \ + gnuradio/uhd.scm +endif + # ---------------------------------------------------------------- # The SWIG library # TESTS = run_tests @@ -54,7 +59,6 @@ uhd_swig_python = \ # additional SWIG files to be installed uhd_swig_swiginclude_headers = -include $(top_srcdir)/Makefile.swig uhd_swig_swig_args = \ $(UHD_CFLAGS) \ @@ -65,4 +69,3 @@ BUILT_SOURCES = $(swig_built_sources) # Do not distribute the output of SWIG no_dist_files = $(swig_built_sources) -endif diff --git a/gr-uhd/swig/gnuradio/uhd.scm b/gr-uhd/swig/gnuradio/uhd.scm new file mode 100644 index 000000000..1999bbb0f --- /dev/null +++ b/gr-uhd/swig/gnuradio/uhd.scm @@ -0,0 +1,26 @@ +;;; +;;; Copyright 2010 Free Software Foundation, Inc. +;;; +;;; This file is part of GNU Radio +;;; +;;; GNU Radio is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3, or (at your option) +;;; any later version. +;;; +;;; GNU Radio is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . +;;; + +;;; Semi bogus module that just reexports the uhd_swig module + +(define-module (gnuradio uhd) + #:use-module (gnuradio uhd_swig) + #:duplicates (merge-generics replace check)) + +(re-export-all '(gnuradio uhd_swig)) -- cgit From 4f578fca338f749c075c46f1a5f16ea5218c9f31 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Wed, 24 Nov 2010 00:06:38 -0800 Subject: use export-safely --- gr-uhd/swig/gnuradio/uhd.scm | 1 + 1 file changed, 1 insertion(+) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/gnuradio/uhd.scm b/gr-uhd/swig/gnuradio/uhd.scm index 1999bbb0f..906aef2a6 100644 --- a/gr-uhd/swig/gnuradio/uhd.scm +++ b/gr-uhd/swig/gnuradio/uhd.scm @@ -20,6 +20,7 @@ ;;; Semi bogus module that just reexports the uhd_swig module (define-module (gnuradio uhd) + #:use-module (gnuradio export-safely) #:use-module (gnuradio uhd_swig) #:duplicates (merge-generics replace check)) -- cgit From d692a41f98e7b888c745efbb9fcbbb0400f39025 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Wed, 24 Nov 2010 17:29:11 -0800 Subject: Major Makefile.am housecleaning. Passes distcheck. Move all occurrences of swig_built_sources out of Makefile.am's. Move all SWIG related use of BUILT_SOURCES out of Makefile.am's. Clean up 'if PYTHON' conditionalization in gr-* Still left to do: fix Makefile.swig CLEANFILES and no_dist_files such that they remove exactly the generated files. --- gr-uhd/grc/Makefile.am | 4 ++-- gr-uhd/swig/Makefile.am | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/Makefile.am b/gr-uhd/grc/Makefile.am index d424ca709..6a336c893 100644 --- a/gr-uhd/grc/Makefile.am +++ b/gr-uhd/grc/Makefile.am @@ -31,7 +31,7 @@ generated_uhd_single_usrp_blocks = \ uhd_single_usrp_source.xml \ uhd_single_usrp_sink.xml -BUILT_SOURCES = \ +BUILT_SOURCES += \ $(generated_uhd_multi_usrp_blocks) \ $(generated_uhd_single_usrp_blocks) @@ -49,7 +49,7 @@ dist_grcblocks_DATA += \ ######################################################################## # Rules for generating the source and sink xml wrappers ######################################################################## -EXTRA_DIST = \ +EXTRA_DIST += \ $(srcdir)/gen_uhd_multi_usrp_blocks_xml.py \ $(srcdir)/gen_uhd_single_usrp_blocks_xml.py diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am index abf38b293..11c0cabb2 100644 --- a/gr-uhd/swig/Makefile.am +++ b/gr-uhd/swig/Makefile.am @@ -22,6 +22,8 @@ include $(top_srcdir)/Makefile.common include $(top_srcdir)/Makefile.swig +EXTRA_DIST += $(nobase_guile_DATA) + AM_CPPFLAGS = \ $(STD_DEFINES_AND_INCLUDES) \ $(PYTHON_CPPFLAGS) \ @@ -59,13 +61,6 @@ 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 - -# add some of the variables generated inside the Makefile.swig.gen -BUILT_SOURCES = $(swig_built_sources) - -# Do not distribute the output of SWIG -no_dist_files = $(swig_built_sources) -- cgit From 401465831199fa8e29f36d604d9004020a657e72 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Wed, 24 Nov 2010 18:35:20 -0800 Subject: Update .gitignore's --- gr-uhd/swig/gnuradio/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 gr-uhd/swig/gnuradio/.gitignore (limited to 'gr-uhd') diff --git a/gr-uhd/swig/gnuradio/.gitignore b/gr-uhd/swig/gnuradio/.gitignore new file mode 100644 index 000000000..820cedd8c --- /dev/null +++ b/gr-uhd/swig/gnuradio/.gitignore @@ -0,0 +1,2 @@ +uhd_swig-primitive.scm +uhd_swig.scm -- cgit From b005e7d9f481ed39591d97ef697621368e6505c0 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Wed, 24 Nov 2010 19:08:21 -0800 Subject: Update .gitignore's --- gr-uhd/swig/.gitignore | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/.gitignore b/gr-uhd/swig/.gitignore index 02d25cc00..8a421846d 100644 --- a/gr-uhd/swig/.gitignore +++ b/gr-uhd/swig/.gitignore @@ -2,3 +2,5 @@ /uhd_swig.py /Makefile /Makefile.in +/guile +/python -- cgit From ceb0c70b353be63b133e6ba830ea1882a2e0ea9d Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 30 Nov 2010 07:44:15 -0500 Subject: Swapping out preset keys until I work out some of their issues. --- gr-uhd/lib/uhd_single_usrp_source.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index de4b5cc08..c33c8c0b0 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -162,7 +162,8 @@ public: pmt::pmt_t nsamp_val = pmt::mp((int)d_num_packet_samps); add_item_tag(0, nitems_written(0), - gr_tags::key_time, + //gr_tags::key_time, + pmt::pmt_string_to_symbol("time"), d_tstamp_pair, d_tag_srcid); add_item_tag(0, nitems_written(0), -- cgit From 775bd35cde0b42f3aaab76f4014e5915783ecb44 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 30 Nov 2010 12:08:16 -0500 Subject: uhd: added libdir to UHD CFLAGS (shared by lib and swig) --- gr-uhd/swig/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am index 183e6b587..fd496fc7b 100644 --- a/gr-uhd/swig/Makefile.am +++ b/gr-uhd/swig/Makefile.am @@ -25,8 +25,7 @@ AM_CPPFLAGS = \ $(STD_DEFINES_AND_INCLUDES) \ $(PYTHON_CPPFLAGS) \ $(WITH_INCLUDES) \ - $(UHD_CFLAGS) \ - -I$(top_srcdir)/gr-uhd/lib + $(UHD_CFLAGS) if PYTHON # ---------------------------------------------------------------- -- cgit From 389d93f465b2114959aa86931d6b473634950e46 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 1 Dec 2010 10:53:32 -0500 Subject: uhd: default channel params to zero for single source and sink blocks --- gr-uhd/lib/uhd_single_usrp_sink.cc | 18 +++++++++--------- gr-uhd/lib/uhd_single_usrp_source.cc | 18 +++++++++--------- gr-uhd/swig/Makefile.am | 4 +--- 3 files changed, 19 insertions(+), 21 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc index 622f506b5..a38bd05d6 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -63,40 +63,40 @@ public: } uhd::tune_result_t set_center_freq( - const uhd::tune_request_t tune_request, size_t chan + const uhd::tune_request_t tune_request, size_t chan = 0 ){ return _dev->set_tx_freq(tune_request, chan); } - uhd::freq_range_t get_freq_range(size_t chan){ + uhd::freq_range_t get_freq_range(size_t chan = 0){ return _dev->get_tx_freq_range(chan); } - void set_gain(float gain, size_t chan){ + void set_gain(float gain, size_t chan = 0){ return _dev->set_tx_gain(gain, chan); } - float get_gain(size_t chan){ + float get_gain(size_t chan = 0){ return _dev->get_tx_gain(chan); } - uhd::gain_range_t get_gain_range(size_t chan){ + uhd::gain_range_t get_gain_range(size_t chan = 0){ return _dev->get_tx_gain_range(chan); } - void set_antenna(const std::string &ant, size_t chan){ + void set_antenna(const std::string &ant, size_t chan = 0){ return _dev->set_tx_antenna(ant, chan); } - std::string get_antenna(size_t chan){ + std::string get_antenna(size_t chan = 0){ return _dev->get_tx_antenna(chan); } - std::vector get_antennas(size_t chan){ + std::vector get_antennas(size_t chan = 0){ return _dev->get_tx_antennas(chan); } - void set_bandwidth(double bandwidth, size_t chan){ + void set_bandwidth(double bandwidth, size_t chan = 0){ return _dev->set_tx_bandwidth(bandwidth, chan); } diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index c33c8c0b0..ac8cd07fc 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -69,40 +69,40 @@ public: } uhd::tune_result_t set_center_freq( - const uhd::tune_request_t tune_request, size_t chan + const uhd::tune_request_t tune_request, size_t chan = 0 ){ return _dev->set_rx_freq(tune_request, chan); } - uhd::freq_range_t get_freq_range(size_t chan){ + uhd::freq_range_t get_freq_range(size_t chan = 0){ return _dev->get_rx_freq_range(chan); } - void set_gain(float gain, size_t chan){ + void set_gain(float gain, size_t chan = 0){ return _dev->set_rx_gain(gain, chan); } - float get_gain(size_t chan){ + float get_gain(size_t chan = 0){ return _dev->get_rx_gain(chan); } - uhd::gain_range_t get_gain_range(size_t chan){ + uhd::gain_range_t get_gain_range(size_t chan = 0){ return _dev->get_rx_gain_range(chan); } - void set_antenna(const std::string &ant, size_t chan){ + void set_antenna(const std::string &ant, size_t chan = 0){ return _dev->set_rx_antenna(ant, chan); } - std::string get_antenna(size_t chan){ + std::string get_antenna(size_t chan = 0){ return _dev->get_rx_antenna(chan); } - std::vector get_antennas(size_t chan){ + std::vector get_antennas(size_t chan = 0){ return _dev->get_rx_antennas(chan); } - void set_bandwidth(double bandwidth, size_t chan){ + void set_bandwidth(double bandwidth, size_t chan = 0){ return _dev->set_rx_bandwidth(bandwidth, chan); } diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am index fd496fc7b..9eb3eab11 100644 --- a/gr-uhd/swig/Makefile.am +++ b/gr-uhd/swig/Makefile.am @@ -56,9 +56,7 @@ uhd_swig_swiginclude_headers = include $(top_srcdir)/Makefile.swig # FIXME better way to set this? -STD_SWIG_PYTHON_ARGS += \ - $(UHD_CFLAGS) \ - -I$(top_srcdir)/gr-uhd/lib +STD_SWIG_PYTHON_ARGS += $(UHD_CFLAGS) # add some of the variables generated inside the Makefile.swig.gen BUILT_SOURCES = $(swig_built_sources) -- cgit From 7d8f756d11189d9378a1bbeb921baabc9c0bf643 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 1 Dec 2010 15:31:41 -0500 Subject: uhd: replaced CFLAGS with CPPFLAGS variable, and fixed swig args FIXME --- gr-uhd/lib/Makefile.am | 2 +- gr-uhd/swig/Makefile.am | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index 099d0edbc..1bcfbbbdc 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -24,7 +24,7 @@ include $(top_srcdir)/Makefile.common AM_CPPFLAGS = \ $(STD_DEFINES_AND_INCLUDES) \ $(WITH_INCLUDES) \ - $(UHD_CFLAGS) + $(UHD_CPPFLAGS) lib_LTLIBRARIES = libgnuradio-uhd.la diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am index 9eb3eab11..33a690a7b 100644 --- a/gr-uhd/swig/Makefile.am +++ b/gr-uhd/swig/Makefile.am @@ -25,7 +25,9 @@ AM_CPPFLAGS = \ $(STD_DEFINES_AND_INCLUDES) \ $(PYTHON_CPPFLAGS) \ $(WITH_INCLUDES) \ - $(UHD_CFLAGS) + $(UHD_CPPFLAGS) + +uhd_swig_swig_args = $(UHD_CPPFLAGS) if PYTHON # ---------------------------------------------------------------- @@ -55,9 +57,6 @@ uhd_swig_swiginclude_headers = include $(top_srcdir)/Makefile.swig -# FIXME better way to set this? -STD_SWIG_PYTHON_ARGS += $(UHD_CFLAGS) - # add some of the variables generated inside the Makefile.swig.gen BUILT_SOURCES = $(swig_built_sources) -- cgit From e92f2cb6166631f3248ff846376693306eb8f6f1 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Wed, 1 Dec 2010 14:39:38 -0800 Subject: WITH_INCLUDES _must_ be last --- gr-uhd/swig/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am index 33a690a7b..b201f676b 100644 --- a/gr-uhd/swig/Makefile.am +++ b/gr-uhd/swig/Makefile.am @@ -24,8 +24,8 @@ include $(top_srcdir)/Makefile.common AM_CPPFLAGS = \ $(STD_DEFINES_AND_INCLUDES) \ $(PYTHON_CPPFLAGS) \ - $(WITH_INCLUDES) \ - $(UHD_CPPFLAGS) + $(UHD_CPPFLAGS) \ + $(WITH_INCLUDES) uhd_swig_swig_args = $(UHD_CPPFLAGS) -- cgit From 0b5f66113f43d2ba94a1ca741b5ce65e1f9f2c02 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Fri, 3 Dec 2010 23:30:54 -0800 Subject: Rename libguile- to libguile-gnuradio- to match guile library naming convention. The stuff in gnuradio-core ends up with funky names, but that could be fixed by renaming gnuradio_core_filter.i -> core_filter.i etc. --- gr-uhd/swig/uhd_swig.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 7344f7a72..c7664157b 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -122,7 +122,7 @@ static const size_t ALL_MBOARDS; #if SWIGGUILE %scheme %{ -(load-extension "libguile-uhd_swig" "scm_init_gnuradio_uhd_swig_module") +(load-extension "libguile-gnuradio-uhd_swig" "scm_init_gnuradio_uhd_swig_module") %} %goops %{ -- cgit From 6df0423fe1880f5c33daa333604552ea68ac9593 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Fri, 3 Dec 2010 23:34:24 -0800 Subject: Regenerated Makefile.swig.gen's --- gr-uhd/swig/Makefile.swig.gen | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen index 782800c9b..b73ccd3c4 100644 --- a/gr-uhd/swig/Makefile.swig.gen +++ b/gr-uhd/swig/Makefile.swig.gen @@ -115,20 +115,20 @@ endif # end of if python if GUILE uhd_swig_scmlib_LTLIBRARIES = \ - libguile-uhd_swig.la -libguile_uhd_swig_la_SOURCES = \ + libguile-gnuradio-uhd_swig.la +libguile_gnuradio_uhd_swig_la_SOURCES = \ guile/uhd_swig.cc \ $(uhd_swig_la_swig_sources) nobase_uhd_swig_scm_DATA = \ gnuradio/uhd_swig.scm \ gnuradio/uhd_swig-primitive.scm -libguile_uhd_swig_la_LIBADD = \ +libguile_gnuradio_uhd_swig_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ $(uhd_swig_la_swig_libadd) -libguile_uhd_swig_la_LDFLAGS = \ +libguile_gnuradio_uhd_swig_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ $(uhd_swig_la_swig_ldflags) -libguile_uhd_swig_la_CXXFLAGS = \ +libguile_gnuradio_uhd_swig_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ -I$(top_builddir) \ $(uhd_swig_la_swig_cxxflags) -- cgit From 7a9c22348819bd5db3b77c5c3dffb318d5c1ecf7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 5 Dec 2010 19:22:22 -0500 Subject: uhd: removed default value chan=0 in the cc files --- gr-uhd/lib/uhd_single_usrp_sink.cc | 18 +++++++++--------- gr-uhd/lib/uhd_single_usrp_source.cc | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc index a38bd05d6..622f506b5 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -63,40 +63,40 @@ public: } uhd::tune_result_t set_center_freq( - const uhd::tune_request_t tune_request, size_t chan = 0 + 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 = 0){ + uhd::freq_range_t get_freq_range(size_t chan){ return _dev->get_tx_freq_range(chan); } - void set_gain(float gain, size_t chan = 0){ + void set_gain(float gain, size_t chan){ return _dev->set_tx_gain(gain, chan); } - float get_gain(size_t chan = 0){ + float get_gain(size_t chan){ return _dev->get_tx_gain(chan); } - uhd::gain_range_t get_gain_range(size_t chan = 0){ + 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 = 0){ + void set_antenna(const std::string &ant, size_t chan){ return _dev->set_tx_antenna(ant, chan); } - std::string get_antenna(size_t chan = 0){ + std::string get_antenna(size_t chan){ return _dev->get_tx_antenna(chan); } - std::vector get_antennas(size_t chan = 0){ + std::vector get_antennas(size_t chan){ return _dev->get_tx_antennas(chan); } - void set_bandwidth(double bandwidth, size_t chan = 0){ + void set_bandwidth(double bandwidth, size_t chan){ return _dev->set_tx_bandwidth(bandwidth, chan); } diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index ac8cd07fc..c33c8c0b0 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -69,40 +69,40 @@ public: } uhd::tune_result_t set_center_freq( - const uhd::tune_request_t tune_request, size_t chan = 0 + 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 = 0){ + uhd::freq_range_t get_freq_range(size_t chan){ return _dev->get_rx_freq_range(chan); } - void set_gain(float gain, size_t chan = 0){ + void set_gain(float gain, size_t chan){ return _dev->set_rx_gain(gain, chan); } - float get_gain(size_t chan = 0){ + float get_gain(size_t chan){ return _dev->get_rx_gain(chan); } - uhd::gain_range_t get_gain_range(size_t chan = 0){ + 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 = 0){ + void set_antenna(const std::string &ant, size_t chan){ return _dev->set_rx_antenna(ant, chan); } - std::string get_antenna(size_t chan = 0){ + std::string get_antenna(size_t chan){ return _dev->get_rx_antenna(chan); } - std::vector get_antennas(size_t chan = 0){ + std::vector get_antennas(size_t chan){ return _dev->get_rx_antennas(chan); } - void set_bandwidth(double bandwidth, size_t chan = 0){ + void set_bandwidth(double bandwidth, size_t chan){ return _dev->set_rx_bandwidth(bandwidth, chan); } -- cgit From cdca1c917626f7c63f820da921a17187efc92cd5 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 5 Dec 2010 19:24:15 -0500 Subject: uhd: reverting tag changes on uhd single usrp source, there seems to be issues with the work() logic --- gr-uhd/lib/uhd_single_usrp_source.cc | 66 ++++++++---------------------------- 1 file changed, 15 insertions(+), 51 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index c33c8c0b0..907e8be54 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -24,16 +24,13 @@ #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) -{ - d_num_packet_samps = 0; - d_tstamp_pair = pmt::mp(pmt::mp(0), pmt::mp(0)); +:gr_sync_block("uhd single_usrp source", gr_make_io_signature(0, 0, 0), sig){ + /* NOP */ } /*********************************************************************** @@ -52,8 +49,6 @@ public: _type(io_type) { _dev = uhd::usrp::single_usrp::make(device_addr); - - d_tag_srcid = pmt::mp("uhd_single_usrp_source"); } void set_subdev_spec(const std::string &spec){ @@ -136,55 +131,25 @@ public: ){ uhd::rx_metadata_t metadata; //not passed out of this block - size_t total_samps = 0; - while(total_samps + 362 < (size_t)noutput_items) { - size_t num_samps = _dev->get_device()->recv( - output_items, noutput_items, metadata, - //_type, uhd::device::RECV_MODE_FULL_BUFF - _type, uhd::device::RECV_MODE_ONE_PACKET - ); - total_samps += num_samps; - - switch(metadata.error_code){ - case uhd::rx_metadata_t::ERROR_CODE_NONE: - //keep track of the number of accumulated samples in this packet - if (metadata.fragment_offset == 0) { - d_num_packet_samps = 0; - d_tstamp_pair = pmt::mp(pmt::mp(metadata.time_spec.get_full_secs()), - pmt::mp(metadata.time_spec.get_frac_secs())); - } - d_num_packet_samps += num_samps; - - //don't push on to the queue until we get the final fragment - if (!metadata.more_fragments) { - // Create tags with time and num samples - pmt::pmt_t tsamp, nsamp; - pmt::pmt_t nsamp_val = pmt::mp((int)d_num_packet_samps); - - add_item_tag(0, nitems_written(0), - //gr_tags::key_time, - pmt::pmt_string_to_symbol("time"), - d_tstamp_pair, - d_tag_srcid); - add_item_tag(0, nitems_written(0), - pmt::mp("num_packet_samples"), - nsamp_val, - d_tag_srcid); - } - return num_samps; - - case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW: + 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: + + default: std::cout << boost::format( "UHD source block got error code 0x%x" ) % metadata.error_code << std::endl; return num_samps; - } - } - return -1; + } } bool start(void){ @@ -200,7 +165,6 @@ public: private: uhd::usrp::single_usrp::sptr _dev; const uhd::io_type_t _type; - pmt::pmt_t d_tag_srcid; }; -- cgit From 051aa2f5bc9f2311bb81669eb4326fd906592a1d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 9 Dec 2010 13:56:35 -0800 Subject: uhd: update notes in grc blocks for addressing scheme --- gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py | 7 +++---- gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py index 112d88159..5902fa855 100755 --- a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py @@ -84,7 +84,7 @@ self.\$(id).set_bandwidth(\$bw$(n), $n) Device Addr dev_addr - addr=192.168.10.2 + addr0=192.168.10.2, addr1=192.168.10.3 string \#if \$dev_addr() @@ -173,9 +173,8 @@ The UHD Multi 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. \\ -Used args to specify a specfic device. -USRP2 Example: addr=192.168.10.2 192.168.10.3 +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. diff --git a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py index 7337c71d7..66728fe28 100755 --- a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py @@ -160,7 +160,7 @@ 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. \\ -Used args to specify a specfic device. +Use the device address to specify a specific device. USRP2 Example: addr=192.168.10.2 USRP1 Example: serial=12345678 -- cgit From 08907ee94fb6c34531d57b988324c67c26c8b747 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Fri, 10 Dec 2010 16:15:40 -0800 Subject: Use load-extension-global instead of load-extension --- gr-uhd/swig/uhd_swig.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 079f8120e..80a6a588a 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -105,7 +105,7 @@ static const size_t ALL_MBOARDS; #if SWIGGUILE %scheme %{ -(load-extension "libguile-gnuradio-uhd_swig" "scm_init_gnuradio_uhd_swig_module") +(load-extension-global "libguile-gnuradio-uhd_swig" "scm_init_gnuradio_uhd_swig_module") %} %goops %{ -- cgit From 1047775464c1bb8a86e727487551e2b14abd476e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 13 Dec 2010 12:21:35 -0500 Subject: gr_uhd: Quick fix for make distcheck failures if UHD is not installed. --- gr-uhd/swig/Makefile.swig.gen | 10 +++++++++- gr-uhd/swig/uhd_swig.i | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.swig.gen b/gr-uhd/swig/Makefile.swig.gen index 3804461a4..f764332f2 100644 --- a/gr-uhd/swig/Makefile.swig.gen +++ b/gr-uhd/swig/Makefile.swig.gen @@ -200,7 +200,15 @@ $(DEPDIR)/uhd_swig-generate-stamp: ## Call SWIG to generate the various output files; special ## post-processing on 'mingw32' host OS for the dependency file. ## - if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(uhd_swig_swig_args) \ + +## If UHD was installed, defined GR_HAVE_UHD for swigging headers +if GR_DEFINE_HAVE_UHD + MY_SWIG_PYTHON_ARGS = $(STD_SWIG_PYTHON_ARGS) -DGR_HAVE_UHD +else + MY_SWIG_PYTHON_ARGS = $(STD_SWIG_PYTHON_ARGS) +endif + + if $(SWIG) $(MY_SWIG_PYTHON_ARGS) $(uhd_swig_swig_args) \ -MD -MF $(DEPDIR)/uhd_swig.Std \ -module uhd_swig -o uhd_swig.cc $(WHAT); then \ if test $(host_os) = mingw32; then \ diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 695cf1cd2..4acf2dc83 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -20,6 +20,10 @@ * Boston, MA 02110-1301, USA. */ +// Defined during configure; avoids trying to locate +// header files if UHD was not installed. +#ifdef GR_HAVE_UHD + //////////////////////////////////////////////////////////////////////// // Language independent exception handler //////////////////////////////////////////////////////////////////////// @@ -104,3 +108,6 @@ GR_SWIG_BLOCK_MAGIC(uhd,single_usrp_sink) static const size_t ALL_MBOARDS = uhd::usrp::multi_usrp::ALL_MBOARDS; %} static const size_t ALL_MBOARDS; + +#endif + -- cgit From 440b0e3bdd81282a83805693c8eb822ee6815f72 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 26 Dec 2010 14:03:29 -0500 Subject: gr-uhd: Fixing makefile to define GR_HAVE_UHD for swig. This was lost in the makefile updates with the guile work. This is a better place/fix, anyway. --- gr-uhd/swig/Makefile.am | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am index 3b7b3cc60..f227ac015 100644 --- a/gr-uhd/swig/Makefile.am +++ b/gr-uhd/swig/Makefile.am @@ -65,3 +65,9 @@ uhd_swig_swiginclude_headers = uhd_swig_swig_args = \ $(UHD_CFLAGS) \ -I$(top_srcdir)/gr-uhd/lib + +## If UHD was installed, defined GR_HAVE_UHD for swigging headers +if GR_DEFINE_HAVE_UHD + uhd_swig_swig_args += -DGR_HAVE_UHD +endif + -- cgit From b8f174ce7eae1cfe8deda0353da4557a238730c9 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Mon, 27 Dec 2010 22:37:30 -0800 Subject: Add minimal Python and Guile QA code to gr-uhd. --- gr-uhd/swig/.gitignore | 2 ++ gr-uhd/swig/Makefile.am | 15 +++++++++++++-- gr-uhd/swig/qa_uhd.py | 40 ++++++++++++++++++++++++++++++++++++++++ gr-uhd/swig/run_guile_tests.in | 14 ++++++++++++++ gr-uhd/swig/run_tests.in | 10 ++++++++++ gr-uhd/swig/uhd.test | 37 +++++++++++++++++++++++++++++++++++++ 6 files changed, 116 insertions(+), 2 deletions(-) create mode 100755 gr-uhd/swig/qa_uhd.py create mode 100644 gr-uhd/swig/run_guile_tests.in create mode 100644 gr-uhd/swig/run_tests.in create mode 100644 gr-uhd/swig/uhd.test (limited to 'gr-uhd') diff --git a/gr-uhd/swig/.gitignore b/gr-uhd/swig/.gitignore index 8a421846d..8afaca254 100644 --- a/gr-uhd/swig/.gitignore +++ b/gr-uhd/swig/.gitignore @@ -4,3 +4,5 @@ /Makefile.in /guile /python +/run_guile_tests +/run_tests diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am index f227ac015..e93571a66 100644 --- a/gr-uhd/swig/Makefile.am +++ b/gr-uhd/swig/Makefile.am @@ -22,7 +22,12 @@ include $(top_srcdir)/Makefile.common include $(top_srcdir)/Makefile.swig -EXTRA_DIST += $(nobase_guile_DATA) +TESTS = +EXTRA_DIST += run_tests.in run_guile_tests.in $(nobase_guile_DATA) +DISTCLEANFILES += run_tests run_guile_tests + +noinst_PYTHON = qa_uhd.py +noinst_GUILE = uhd.test AM_CPPFLAGS = \ $(STD_DEFINES_AND_INCLUDES) \ @@ -39,7 +44,6 @@ endif # ---------------------------------------------------------------- # The SWIG library -# TESTS = run_tests TOP_SWIG_IFILES = \ uhd_swig.i @@ -71,3 +75,10 @@ if GR_DEFINE_HAVE_UHD uhd_swig_swig_args += -DGR_HAVE_UHD endif +if PYTHON +TESTS += run_tests +endif + +if GUILE +TESTS += run_guile_tests +endif diff --git a/gr-uhd/swig/qa_uhd.py b/gr-uhd/swig/qa_uhd.py new file mode 100755 index 000000000..2973d04cd --- /dev/null +++ b/gr-uhd/swig/qa_uhd.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +# +# Copyright 2005,2008,2010 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import uhd_swig + +class test_uhd(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_000_nop (self): + """Just see if we can import the module... + They may not have a UHD device connected, etc. Don't try to run anything""" + pass + +if __name__ == '__main__': + gr_unittest.run(test_uhd, "test_uhd.xml") diff --git a/gr-uhd/swig/run_guile_tests.in b/gr-uhd/swig/run_guile_tests.in new file mode 100644 index 000000000..5d08b0dd5 --- /dev/null +++ b/gr-uhd/swig/run_guile_tests.in @@ -0,0 +1,14 @@ +#!/bin/sh + +. @top_builddir@/setup_guile_test_env + +# 1st argument is absolute path to hand coded guile source directory +# 2nd argument is absolute path to component C++ shared library build directory +# 3nd argument is absolute path to component SWIG build directory + +add_local_paths \ + @srcdir@ \ + @abs_builddir@ \ + @abs_builddir@ + +@GUILE@ -e main -c '(use-modules (gnuradio test-suite guile-test))' -t @srcdir@ diff --git a/gr-uhd/swig/run_tests.in b/gr-uhd/swig/run_tests.in new file mode 100644 index 000000000..195e71316 --- /dev/null +++ b/gr-uhd/swig/run_tests.in @@ -0,0 +1,10 @@ +#!/bin/sh + +# 1st parameter is absolute path to component source directory +# 2nd parameter is absolute path to component build directory +# 3rd parameter is path to Python QA directory + +@top_builddir@/run_tests.sh \ + @abs_top_srcdir@/gr-uhd \ + @abs_top_builddir@/gr-uhd \ + @srcdir@ diff --git a/gr-uhd/swig/uhd.test b/gr-uhd/swig/uhd.test new file mode 100644 index 000000000..adc51c884 --- /dev/null +++ b/gr-uhd/swig/uhd.test @@ -0,0 +1,37 @@ +;;; -*- Scheme -*- +;;; +;;; Copyright 2010 Free Software Foundation, Inc. +;;; +;;; This file is part of GNU Radio +;;; +;;; GNU Radio is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3, or (at your option) +;;; any later version. +;;; +;;; GNU Radio is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . +;;; + +;;; If you're using Emacs's Scheme mode: +;;; (put 'with-test-prefix 'scheme-indent-function 1) + +;;; See the comments in gnuradio/test-suite/lib.scm for info on writing tests. +;;; See also the very end of the file, where the test-equal, test-eqv +;;; and test-eq macros are defined. + +(define-module (test-module) + #:use-module (oop goops) + #:use-module (gnuradio core) + #:use-module (gnuradio test-suite lib) + #:duplicates (merge-generics replace check)) + +;;; Just see if we can import the module... +;;; They may not have a UHD device attached, powered up etc. + +(use-modules (gnuradio uhd)) -- cgit From c6dfc4ce9227001a371457a39d0e44528b1f6827 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 30 Dec 2010 17:19:51 -0500 Subject: Adding tags back into UHD source. If a packet received from a UHD source has a timestamp, we create a tag from it and pass it down the line. If no timestamp, produce no tags. This should not affect behavior of the UHD single source for those not dealing with tags. --- gr-uhd/lib/uhd_single_usrp_source.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index 907e8be54..45f852a3e 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -49,6 +49,7 @@ public: _type(io_type) { _dev = uhd::usrp::single_usrp::make(device_addr); + d_tag_srcid = pmt::mp("uhd_single_usrp_source"); } void set_subdev_spec(const std::string &spec){ @@ -138,7 +139,16 @@ public: switch(metadata.error_code){ case uhd::rx_metadata_t::ERROR_CODE_NONE: - return num_samps; + 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 @@ -165,6 +175,7 @@ public: private: uhd::usrp::single_usrp::sptr _dev; const uhd::io_type_t _type; + pmt::pmt_t d_tag_srcid; }; -- cgit From f0d2f41a77107fd5e194e196f93ecba4d6fe2df9 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 30 Dec 2010 19:42:33 -0800 Subject: uhd: multi device, set timestamps without SOB on every burst in the work function --- gr-uhd/lib/uhd_multi_usrp_sink.cc | 39 ++++++++++++++++++++++---------------- gr-uhd/lib/uhd_single_usrp_sink.cc | 3 +-- 2 files changed, 24 insertions(+), 18 deletions(-) (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 ee16e2928..a1d0a2584 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.cc +++ b/gr-uhd/lib/uhd_multi_usrp_sink.cc @@ -56,6 +56,7 @@ public: void set_samp_rate(double rate){ _dev->set_tx_rate(rate); + _sample_rate = this->get_samp_rate(); } double get_samp_rate(void){ @@ -128,28 +129,31 @@ public: gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ){ - uhd::tx_metadata_t metadata; - metadata.start_of_burst = true; + //send a mid-burst packet with time spec + _metadata.start_of_burst = false; + _metadata.end_of_burst = false; + _metadata.has_time_spec = true; - return _dev->get_device()->send( - input_items, noutput_items, metadata, + 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 so data will be sync'd. + //Set at a time in the near future to avoid late packets. bool start(void){ - uhd::tx_metadata_t metadata; - metadata.start_of_burst = true; - metadata.has_time_spec = true; - //TODO: Time in the near future, must be less than source time in future - //because ethernet pause frames with throttle stream commands. - //It will be fixed with the invention of host-based flow control. - metadata.time_spec = get_time_now() + uhd::time_spec_t(0.05); + _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, + gr_vector_const_void_star(_nchan), 0, _metadata, _type, uhd::device::SEND_MODE_ONE_PACKET, 1.0 ); return true; @@ -158,11 +162,12 @@ public: //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; + _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, + gr_vector_const_void_star(_nchan), 0, _metadata, _type, uhd::device::SEND_MODE_ONE_PACKET, 1.0 ); return true; @@ -172,6 +177,8 @@ protected: uhd::usrp::multi_usrp::sptr _dev; const uhd::io_type_t _type; size_t _nchan; + uhd::tx_metadata_t _metadata; + double _sample_rate; }; /*********************************************************************** diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc index 622f506b5..8ac2ae0fd 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -128,8 +128,7 @@ public: gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ){ - uhd::tx_metadata_t metadata; - metadata.start_of_burst = true; + uhd::tx_metadata_t metadata; //send a mid-burst packet return _dev->get_device()->send( input_items, noutput_items, metadata, -- cgit From 5e00de56713729b7c366884d3a1e31ffa3423b13 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 5 Jan 2011 12:46:39 -0800 Subject: uhd: removed ranges template stuff, added some python polish in __init__.py --- gr-uhd/swig/__init__.py | 6 ++++++ gr-uhd/swig/uhd_swig.i | 11 ----------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 0fdacb796..6d09f19f0 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -30,6 +30,12 @@ from uhd_swig import * # Add other content from pure-Python modules here ######################################################################## +#make the meta-range printable in python +meta_range_t.__str__ = lambda s: s.to_pp_string().strip() + +class freq_range_t(meta_range_t): pass #a typedef for the user +class gain_range_t(meta_range_t): pass #a typedef for the user + class tune_request_t(tune_request_t, float): """ Make the python tune request object inherit from float diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 76f44a491..cf4ecf920 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -73,17 +73,6 @@ namespace std { %include %include -//Re-create range typedefs here with %template as they are not imported. -//Replicate all the levels of templated inheritance so swig understands. - -%template(float_range_t) uhd::range_t; -%template(_float_range_vector_t) std::vector >; -%template(gain_range_t) uhd::meta_range_t; - -%template(double_range_t) uhd::range_t; -%template(_double_range_vector_t) std::vector >; -%template(freq_range_t) uhd::meta_range_t; - //////////////////////////////////////////////////////////////////////// // block magic //////////////////////////////////////////////////////////////////////// -- cgit From c63edcbe834c0929a7e0c7907f7c79ffc3fc5667 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 5 Jan 2011 16:19:19 -0800 Subject: uhd: swig + python tweaks to uhd types --- gr-uhd/swig/__init__.py | 9 ++++++++- gr-uhd/swig/uhd_swig.i | 12 ++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 6d09f19f0..a8082bc34 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -30,7 +30,8 @@ from uhd_swig import * # Add other content from pure-Python modules here ######################################################################## -#make the meta-range printable in python +#make the ranges printable in python +range_t.__str__ = lambda s: s.to_pp_string().strip() meta_range_t.__str__ = lambda s: s.to_pp_string().strip() class freq_range_t(meta_range_t): pass #a typedef for the user @@ -44,3 +45,9 @@ class tune_request_t(tune_request_t, float): """ def __new__(self, *args): return float.__new__(self) def __float__(self): return self.target_freq + +######################################################################## +# Create aliases for global attributes to avoid the "_t" +######################################################################## +for attr in globals().keys(): + if attr.endswith('_t'): globals()[attr[:-2]] = globals()[attr] diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index cf4ecf920..5628a1203 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -24,6 +24,8 @@ // header files if UHD was not installed. #ifdef GR_HAVE_UHD +#define GR_UHD_API + //////////////////////////////////////////////////////////////////////// // Language independent exception handler //////////////////////////////////////////////////////////////////////// @@ -47,10 +49,6 @@ //////////////////////////////////////////////////////////////////////// %include "gnuradio.i" -namespace std { - %template(StringVector) vector; -} - //////////////////////////////////////////////////////////////////////// // block headers //////////////////////////////////////////////////////////////////////// @@ -61,6 +59,12 @@ namespace std { #include %} +//////////////////////////////////////////////////////////////////////// +// templated types +//////////////////////////////////////////////////////////////////////// +%template(string_vector_t) std::vector; +%template(range_vector_t) std::vector; + //////////////////////////////////////////////////////////////////////// // used types //////////////////////////////////////////////////////////////////////// -- cgit From cf33e1e5f75c627907811e07e4c3c7a6b6175e8a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 5 Jan 2011 16:22:47 -0800 Subject: uhd: added export macros (not used now) and updated copyright dates --- gr-uhd/lib/Makefile.am | 3 ++- gr-uhd/lib/gr_uhd_api.h | 33 +++++++++++++++++++++++++++++++++ gr-uhd/lib/uhd_multi_usrp_sink.h | 7 ++++--- gr-uhd/lib/uhd_multi_usrp_source.h | 7 ++++--- gr-uhd/lib/uhd_single_usrp_sink.h | 7 ++++--- gr-uhd/lib/uhd_single_usrp_source.h | 7 ++++--- gr-uhd/swig/__init__.py | 2 +- gr-uhd/swig/uhd_swig.i | 2 +- 8 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 gr-uhd/lib/gr_uhd_api.h (limited to 'gr-uhd') diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index 1bcfbbbdc..7ddb45cb3 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/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 # @@ -41,6 +41,7 @@ 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 \ diff --git a/gr-uhd/lib/gr_uhd_api.h b/gr-uhd/lib/gr_uhd_api.h new file mode 100644 index 000000000..a9b99fd87 --- /dev/null +++ b/gr-uhd/lib/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/lib/uhd_multi_usrp_sink.h b/gr-uhd/lib/uhd_multi_usrp_sink.h index 370e59d0e..4a92cba6c 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.h +++ b/gr-uhd/lib/uhd_multi_usrp_sink.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,18 +22,19 @@ #ifndef INCLUDED_UHD_MULTI_USRP_SINK_H #define INCLUDED_UHD_MULTI_USRP_SINK_H +#include #include #include class uhd_multi_usrp_sink; -boost::shared_ptr uhd_make_multi_usrp_sink( +GR_UHD_API boost::shared_ptr uhd_make_multi_usrp_sink( const std::string &device_addr, const uhd::io_type_t::tid_t &io_type, size_t num_channels ); -class uhd_multi_usrp_sink : public gr_sync_block{ +class GR_UHD_API uhd_multi_usrp_sink : public gr_sync_block{ public: /*! diff --git a/gr-uhd/lib/uhd_multi_usrp_source.h b/gr-uhd/lib/uhd_multi_usrp_source.h index b3cbdae1f..841f8fb44 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.h +++ b/gr-uhd/lib/uhd_multi_usrp_source.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,18 +22,19 @@ #ifndef INCLUDED_UHD_MULTI_USRP_SOURCE_H #define INCLUDED_UHD_MULTI_USRP_SOURCE_H +#include #include #include class uhd_multi_usrp_source; -boost::shared_ptr uhd_make_multi_usrp_source( +GR_UHD_API boost::shared_ptr uhd_make_multi_usrp_source( const std::string &device_addr, const uhd::io_type_t::tid_t &io_type, size_t num_channels ); -class uhd_multi_usrp_source : public gr_sync_block{ +class GR_UHD_API uhd_multi_usrp_source : public gr_sync_block{ public: /*! diff --git a/gr-uhd/lib/uhd_single_usrp_sink.h b/gr-uhd/lib/uhd_single_usrp_sink.h index a4c4e6452..432798a6d 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.h +++ b/gr-uhd/lib/uhd_single_usrp_sink.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,18 +22,19 @@ #ifndef INCLUDED_UHD_SINGLE_USRP_SINK_H #define INCLUDED_UHD_SINGLE_USRP_SINK_H +#include #include #include class uhd_single_usrp_sink; -boost::shared_ptr uhd_make_single_usrp_sink( +GR_UHD_API boost::shared_ptr uhd_make_single_usrp_sink( const std::string &device_addr, const uhd::io_type_t::tid_t &io_type, size_t num_channels = 1 ); -class uhd_single_usrp_sink : public gr_sync_block{ +class GR_UHD_API uhd_single_usrp_sink : public gr_sync_block{ public: /*! diff --git a/gr-uhd/lib/uhd_single_usrp_source.h b/gr-uhd/lib/uhd_single_usrp_source.h index 2a011b2b3..9b7255533 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.h +++ b/gr-uhd/lib/uhd_single_usrp_source.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,18 +22,19 @@ #ifndef INCLUDED_UHD_SINGLE_USRP_SOURCE_H #define INCLUDED_UHD_SINGLE_USRP_SOURCE_H +#include #include #include class uhd_single_usrp_source; -boost::shared_ptr uhd_make_single_usrp_source( +GR_UHD_API boost::shared_ptr uhd_make_single_usrp_source( const std::string &device_addr, const uhd::io_type_t::tid_t &io_type, size_t num_channels = 1 ); -class uhd_single_usrp_source : public gr_sync_block{ +class GR_UHD_API uhd_single_usrp_source : public gr_sync_block{ public: /*! diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index a8082bc34..157733880 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -1,5 +1,5 @@ # -# Copyright 2010 Free Software Foundation, Inc. +# Copyright 2010-2011 Free Software Foundation, Inc. # # This file is part of GNU Radio # diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 5628a1203..89f82e9f4 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * -- cgit From dfcc8cc28d8e5d0ca1de62b1622438be2439ebd1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 5 Jan 2011 19:08:26 -0800 Subject: uhd: use the actual device and io types, do hacks in the init.py, also use clock config convenience --- gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py | 16 ++++------- gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py | 14 ++++------ gr-uhd/lib/uhd_multi_usrp_sink.cc | 8 +++--- gr-uhd/lib/uhd_multi_usrp_sink.h | 4 +-- gr-uhd/lib/uhd_multi_usrp_source.cc | 8 +++--- gr-uhd/lib/uhd_multi_usrp_source.h | 4 +-- gr-uhd/lib/uhd_single_usrp_sink.cc | 8 +++--- gr-uhd/lib/uhd_single_usrp_sink.h | 4 +-- gr-uhd/lib/uhd_single_usrp_source.cc | 8 +++--- gr-uhd/lib/uhd_single_usrp_source.h | 4 +-- gr-uhd/swig/__init__.py | 41 ++++++++++++++++++++++++++-- gr-uhd/swig/uhd_swig.i | 21 ++++++++++---- 12 files changed, 89 insertions(+), 51 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py index 5902fa855..9f413f2a8 100755 --- a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -Copyright 2010 Free Software Foundation, Inc. +Copyright 2010-2011 Free Software Foundation, Inc. This file is part of GNU Radio @@ -27,16 +27,12 @@ MAIN_TMPL = """\ from gnuradio import uhd uhd.multi_usrp_$(sourk)( device_addr=\$dev_addr, - io_type=uhd.io_type_t.\$type.type, + io_type=uhd.io_type.\$type.type, num_channels=\$nchan, ) \#if \$sync() -_clk_cfg = uhd.clock_config_t() -_clk_cfg.ref_source = uhd.clock_config_t.REF_SMA -_clk_cfg.pps_source = uhd.clock_config_t.PPS_SMA -_clk_cfg.pps_polarity = uhd.clock_config_t.PPS_POS -self.\$(id).set_clock_config(_clk_cfg, uhd.ALL_MBOARDS); -self.\$(id).set_time_unknown_pps(uhd.time_spec_t()) +self.\$(id).set_clock_config(uhd.clock_config.external(), uhd.ALL_MBOARDS); +self.\$(id).setime_unknown_pps(uhd.time_spec()) \#end if #for $m in range($max_mboards) \#if \$num_mboards() > $m and \$sd_spec$(m)() @@ -201,8 +197,8 @@ If the requested rate is not possible, the UHD block will print an error at runt Center frequency: The center frequency is the overall frequency of the RF chain. \\ For greater control of how the UHD tunes elements in the RF chain, \\ -pass a tune_request_t object rather than a simple target frequency. -Tuning with an LO offset example: uhd.tune_request_t(freq, lo_off) +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. \\ diff --git a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py index 66728fe28..4de21c989 100755 --- a/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_single_usrp_blocks_xml.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -Copyright 2010 Free Software Foundation, Inc. +Copyright 2010-2011 Free Software Foundation, Inc. This file is part of GNU Radio @@ -27,15 +27,11 @@ MAIN_TMPL = """\ from gnuradio import uhd uhd.single_usrp_$(sourk)( device_addr=\$dev_addr, - io_type=uhd.io_type_t.\$type.type, + io_type=uhd.io_type.\$type.type, num_channels=\$nchan, ) \#if \$ref_clk() -_clk_cfg = uhd.clock_config_t() -_clk_cfg.ref_source = uhd.clock_config_t.REF_SMA -_clk_cfg.pps_source = uhd.clock_config_t.PPS_SMA -_clk_cfg.pps_polarity = uhd.clock_config_t.PPS_POS -self.\$(id).set_clock_config(_clk_cfg); +self.\$(id).set_clock_config(uhd.clock_config.external()); \#end if \#if \$sd_spec() self.\$(id).set_subdev_spec(\$sd_spec) @@ -180,8 +176,8 @@ If the requested rate is not possible, the UHD block will print an error at runt Center frequency: The center frequency is the overall frequency of the RF chain. \\ For greater control of how the UHD tunes elements in the RF chain, \\ -pass a tune_request_t object rather than a simple target frequency. -Tuning with an LO offset example: uhd.tune_request_t(freq, lo_off) +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. \\ diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.cc b/gr-uhd/lib/uhd_multi_usrp_sink.cc index a1d0a2584..7e81f8dea 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.cc +++ b/gr-uhd/lib/uhd_multi_usrp_sink.cc @@ -1,5 +1,5 @@ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -37,7 +37,7 @@ uhd_multi_usrp_sink::uhd_multi_usrp_sink(gr_io_signature_sptr sig) class uhd_multi_usrp_sink_impl : public uhd_multi_usrp_sink{ public: uhd_multi_usrp_sink_impl( - const std::string &device_addr, + const uhd::device_addr_t &device_addr, const uhd::io_type_t &io_type, size_t num_channels ): @@ -185,8 +185,8 @@ protected: * Make UHD Multi USRP Sink **********************************************************************/ boost::shared_ptr uhd_make_multi_usrp_sink( - const std::string &device_addr, - const uhd::io_type_t::tid_t &io_type, + const uhd::device_addr_t &device_addr, + const uhd::io_type_t &io_type, size_t num_channels ){ return boost::shared_ptr( diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.h b/gr-uhd/lib/uhd_multi_usrp_sink.h index 4a92cba6c..208e2c55d 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.h +++ b/gr-uhd/lib/uhd_multi_usrp_sink.h @@ -29,8 +29,8 @@ class uhd_multi_usrp_sink; GR_UHD_API boost::shared_ptr uhd_make_multi_usrp_sink( - const std::string &device_addr, - const uhd::io_type_t::tid_t &io_type, + const uhd::device_addr_t &device_addr, + const uhd::io_type_t &io_type, size_t num_channels ); diff --git a/gr-uhd/lib/uhd_multi_usrp_source.cc b/gr-uhd/lib/uhd_multi_usrp_source.cc index 029a763e3..770314057 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.cc +++ b/gr-uhd/lib/uhd_multi_usrp_source.cc @@ -1,5 +1,5 @@ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -39,7 +39,7 @@ uhd_multi_usrp_source::uhd_multi_usrp_source(gr_io_signature_sptr sig) class uhd_multi_usrp_source_impl : public uhd_multi_usrp_source{ public: uhd_multi_usrp_source_impl( - const std::string &device_addr, + const uhd::device_addr_t &device_addr, const uhd::io_type_t &io_type, size_t num_channels ): @@ -177,8 +177,8 @@ private: * Make UHD Multi USRP Source **********************************************************************/ boost::shared_ptr uhd_make_multi_usrp_source( - const std::string &device_addr, - const uhd::io_type_t::tid_t &io_type, + const uhd::device_addr_t &device_addr, + const uhd::io_type_t &io_type, size_t num_channels ){ return boost::shared_ptr( diff --git a/gr-uhd/lib/uhd_multi_usrp_source.h b/gr-uhd/lib/uhd_multi_usrp_source.h index 841f8fb44..ff77d9d9e 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.h +++ b/gr-uhd/lib/uhd_multi_usrp_source.h @@ -29,8 +29,8 @@ class uhd_multi_usrp_source; GR_UHD_API boost::shared_ptr uhd_make_multi_usrp_source( - const std::string &device_addr, - const uhd::io_type_t::tid_t &io_type, + const uhd::device_addr_t &device_addr, + const uhd::io_type_t &io_type, size_t num_channels ); diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc index 8ac2ae0fd..7b47827d6 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -1,5 +1,5 @@ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -37,7 +37,7 @@ uhd_single_usrp_sink::uhd_single_usrp_sink(gr_io_signature_sptr sig) class uhd_single_usrp_sink_impl : public uhd_single_usrp_sink{ public: uhd_single_usrp_sink_impl( - const std::string &device_addr, + const uhd::device_addr_t &device_addr, const uhd::io_type_t &io_type, size_t num_channels ): @@ -172,8 +172,8 @@ protected: * Make UHD Single USRP Sink **********************************************************************/ boost::shared_ptr uhd_make_single_usrp_sink( - const std::string &device_addr, - const uhd::io_type_t::tid_t &io_type, + const uhd::device_addr_t &device_addr, + const uhd::io_type_t &io_type, size_t num_channels ){ return boost::shared_ptr( diff --git a/gr-uhd/lib/uhd_single_usrp_sink.h b/gr-uhd/lib/uhd_single_usrp_sink.h index 432798a6d..c6e92c1e6 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.h +++ b/gr-uhd/lib/uhd_single_usrp_sink.h @@ -29,8 +29,8 @@ class uhd_single_usrp_sink; GR_UHD_API boost::shared_ptr uhd_make_single_usrp_sink( - const std::string &device_addr, - const uhd::io_type_t::tid_t &io_type, + const uhd::device_addr_t &device_addr, + const uhd::io_type_t &io_type, size_t num_channels = 1 ); diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index 45f852a3e..547b950dc 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -1,5 +1,5 @@ /* - * Copyright 2010 Free Software Foundation, Inc. + * Copyright 2010-2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -39,7 +39,7 @@ uhd_single_usrp_source::uhd_single_usrp_source(gr_io_signature_sptr sig) class uhd_single_usrp_source_impl : public uhd_single_usrp_source{ public: uhd_single_usrp_source_impl( - const std::string &device_addr, + const uhd::device_addr_t &device_addr, const uhd::io_type_t &io_type, size_t num_channels ): @@ -183,8 +183,8 @@ private: * Make UHD Single USRP Source **********************************************************************/ boost::shared_ptr uhd_make_single_usrp_source( - const std::string &device_addr, - const uhd::io_type_t::tid_t &io_type, + const uhd::device_addr_t &device_addr, + const uhd::io_type_t &io_type, size_t num_channels ){ return boost::shared_ptr( diff --git a/gr-uhd/lib/uhd_single_usrp_source.h b/gr-uhd/lib/uhd_single_usrp_source.h index 9b7255533..298c00dc2 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.h +++ b/gr-uhd/lib/uhd_single_usrp_source.h @@ -29,8 +29,8 @@ class uhd_single_usrp_source; GR_UHD_API boost::shared_ptr uhd_make_single_usrp_source( - const std::string &device_addr, - const uhd::io_type_t::tid_t &io_type, + const uhd::device_addr_t &device_addr, + const uhd::io_type_t &io_type, size_t num_channels = 1 ); diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 157733880..0991f5b6b 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -27,13 +27,15 @@ from uhd_swig import * ######################################################################## -# Add other content from pure-Python modules here +# Make types with to_string functions printable ######################################################################## - -#make the ranges printable in python range_t.__str__ = lambda s: s.to_pp_string().strip() meta_range_t.__str__ = lambda s: s.to_pp_string().strip() +device_addr_t.__str__ = lambda s: s.to_pp_string().strip() +######################################################################## +# Add other content from pure-Python modules here +######################################################################## class freq_range_t(meta_range_t): pass #a typedef for the user class gain_range_t(meta_range_t): pass #a typedef for the user @@ -46,8 +48,41 @@ class tune_request_t(tune_request_t, float): def __new__(self, *args): return float.__new__(self) def __float__(self): return self.target_freq +class device_addr_t(device_addr_t, str): + """ + Make the python tune request object inherit from string + so that it can be passed in GRC as a string parameter. + The type checking in GRC will accept the device address. + Define the set/get item special methods for dict access. + """ + def __new__(self, *args): return str.__new__(self) + def __getitem__(self, key): return self.get(key) + def __setitem__(self, key, val): self.set(key, val) + ######################################################################## # Create aliases for global attributes to avoid the "_t" ######################################################################## for attr in globals().keys(): if attr.endswith('_t'): globals()[attr[:-2]] = globals()[attr] + +######################################################################## +# Cast constructor args (FIXME swig handle overloads?) +######################################################################## +for attr in ( + 'single_usrp_source', 'single_usrp_sink', + 'multi_usrp_source', 'multi_usrp_sink' +): + def constructor_factory(old_constructor): + def constructor_interceptor(*args, **kwargs): + args = list(args) + kwargs = dict(kwargs) + for index, key, cast in ( + (0, 'device_addr', device_addr), + (1, 'io_type', io_type), + ): + if len(args) > index: args[index] = cast(args[index]) + if kwargs.has_key(key): kwargs[key] = cast(kwargs[key]) + return old_constructor(*args, **kwargs) + return constructor_interceptor + import uhd_swig + globals()[attr] = constructor_factory(getattr(uhd_swig, attr)) diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index 89f82e9f4..e25dbce90 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -60,21 +60,32 @@ %} //////////////////////////////////////////////////////////////////////// -// templated types +// used types //////////////////////////////////////////////////////////////////////// %template(string_vector_t) std::vector; -%template(range_vector_t) std::vector; -//////////////////////////////////////////////////////////////////////// -// used types -//////////////////////////////////////////////////////////////////////// %include + %include + +%include +%template(string_string_dict_t) uhd::dict; //define after dict + +%include + +%include + +%template(range_vector_t) std::vector; //define before range %include + %include + %include + %include + %include + %include //////////////////////////////////////////////////////////////////////// -- cgit From 69ae2c9b1eca4c69d9007b146aa54fd1b75fcd28 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 5 Jan 2011 20:15:10 -0800 Subject: uhd: make the repr and str installation more generic --- gr-uhd/swig/__init__.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 0991f5b6b..18b5dfefc 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -26,13 +26,6 @@ ######################################################################## from uhd_swig import * -######################################################################## -# Make types with to_string functions printable -######################################################################## -range_t.__str__ = lambda s: s.to_pp_string().strip() -meta_range_t.__str__ = lambda s: s.to_pp_string().strip() -device_addr_t.__str__ = lambda s: s.to_pp_string().strip() - ######################################################################## # Add other content from pure-Python modules here ######################################################################## @@ -61,9 +54,13 @@ class device_addr_t(device_addr_t, str): ######################################################################## # Create aliases for global attributes to avoid the "_t" +# Install the __str__ and __repr__ handlers if applicable ######################################################################## for attr in globals().keys(): - if attr.endswith('_t'): globals()[attr[:-2]] = globals()[attr] + myobj = globals()[attr] + if hasattr(myobj, 'to_string'): myobj.__repr__ = lambda s: s.to_string().strip() + if hasattr(myobj, 'to_pp_string'): myobj.__str__ = lambda s: s.to_pp_string().strip() + if attr.endswith('_t'): globals()[attr[:-2]] = myobj ######################################################################## # Cast constructor args (FIXME swig handle overloads?) -- cgit From b5556476aee35c5a77d1e255eb54d60028d8490e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 12 Jan 2011 14:24:13 -0800 Subject: uhd: replace gain floats with doubles to reflect new uhd api --- gr-uhd/lib/uhd_multi_usrp_sink.cc | 4 ++-- gr-uhd/lib/uhd_multi_usrp_sink.h | 4 ++-- gr-uhd/lib/uhd_multi_usrp_source.cc | 4 ++-- gr-uhd/lib/uhd_multi_usrp_source.h | 4 ++-- gr-uhd/lib/uhd_single_usrp_sink.cc | 4 ++-- gr-uhd/lib/uhd_single_usrp_sink.h | 4 ++-- gr-uhd/lib/uhd_single_usrp_source.cc | 4 ++-- gr-uhd/lib/uhd_single_usrp_source.h | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) (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 7e81f8dea..32039e44a 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.cc +++ b/gr-uhd/lib/uhd_multi_usrp_sink.cc @@ -73,11 +73,11 @@ public: return _dev->get_tx_freq_range(chan); } - void set_gain(float gain, size_t chan){ + void set_gain(double gain, size_t chan){ return _dev->set_tx_gain(gain, chan); } - float get_gain(size_t chan){ + double get_gain(size_t chan){ return _dev->get_tx_gain(chan); } diff --git a/gr-uhd/lib/uhd_multi_usrp_sink.h b/gr-uhd/lib/uhd_multi_usrp_sink.h index 208e2c55d..4866f2cbb 100644 --- a/gr-uhd/lib/uhd_multi_usrp_sink.h +++ b/gr-uhd/lib/uhd_multi_usrp_sink.h @@ -97,14 +97,14 @@ public: * \param gain the gain in dB * \param chan the channel index 0 to N-1 */ - virtual void set_gain(float gain, size_t chan) = 0; + 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 float get_gain(size_t chan) = 0; + virtual double get_gain(size_t chan) = 0; /*! * Get the settable gain range. diff --git a/gr-uhd/lib/uhd_multi_usrp_source.cc b/gr-uhd/lib/uhd_multi_usrp_source.cc index 770314057..181cf1eb4 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.cc +++ b/gr-uhd/lib/uhd_multi_usrp_source.cc @@ -73,11 +73,11 @@ public: return _dev->get_rx_freq_range(chan); } - void set_gain(float gain, size_t chan){ + void set_gain(double gain, size_t chan){ return _dev->set_rx_gain(gain, chan); } - float get_gain(size_t chan){ + double get_gain(size_t chan){ return _dev->get_rx_gain(chan); } diff --git a/gr-uhd/lib/uhd_multi_usrp_source.h b/gr-uhd/lib/uhd_multi_usrp_source.h index ff77d9d9e..9cbec52aa 100644 --- a/gr-uhd/lib/uhd_multi_usrp_source.h +++ b/gr-uhd/lib/uhd_multi_usrp_source.h @@ -97,14 +97,14 @@ public: * \param gain the gain in dB * \param chan the channel index 0 to N-1 */ - virtual void set_gain(float gain, size_t chan) = 0; + 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 float get_gain(size_t chan) = 0; + virtual double get_gain(size_t chan) = 0; /*! * Get the settable gain range. diff --git a/gr-uhd/lib/uhd_single_usrp_sink.cc b/gr-uhd/lib/uhd_single_usrp_sink.cc index 7b47827d6..d9aaac893 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.cc +++ b/gr-uhd/lib/uhd_single_usrp_sink.cc @@ -72,11 +72,11 @@ public: return _dev->get_tx_freq_range(chan); } - void set_gain(float gain, size_t chan){ + void set_gain(double gain, size_t chan){ return _dev->set_tx_gain(gain, chan); } - float get_gain(size_t chan){ + double get_gain(size_t chan){ return _dev->get_tx_gain(chan); } diff --git a/gr-uhd/lib/uhd_single_usrp_sink.h b/gr-uhd/lib/uhd_single_usrp_sink.h index c6e92c1e6..4929d0f13 100644 --- a/gr-uhd/lib/uhd_single_usrp_sink.h +++ b/gr-uhd/lib/uhd_single_usrp_sink.h @@ -96,14 +96,14 @@ public: * \param gain the gain in dB * \param chan the channel index 0 to N-1 */ - virtual void set_gain(float gain, size_t chan = 0) = 0; + 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 float get_gain(size_t chan = 0) = 0; + virtual double get_gain(size_t chan = 0) = 0; /*! * Get the settable gain range. diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index 547b950dc..ddd4ad275 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -74,11 +74,11 @@ public: return _dev->get_rx_freq_range(chan); } - void set_gain(float gain, size_t chan){ + void set_gain(double gain, size_t chan){ return _dev->set_rx_gain(gain, chan); } - float get_gain(size_t chan){ + double get_gain(size_t chan){ return _dev->get_rx_gain(chan); } diff --git a/gr-uhd/lib/uhd_single_usrp_source.h b/gr-uhd/lib/uhd_single_usrp_source.h index 298c00dc2..c7ff18770 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.h +++ b/gr-uhd/lib/uhd_single_usrp_source.h @@ -96,14 +96,14 @@ public: * \param gain the gain in dB * \param chan the channel index 0 to N-1 */ - virtual void set_gain(float gain, size_t chan = 0) = 0; + 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 float get_gain(size_t chan = 0) = 0; + virtual double get_gain(size_t chan = 0) = 0; /*! * Get the settable gain range. -- cgit From 81d3460c5c6a950c8b734f192aa62cd1f8718d7c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 12 Jan 2011 15:20:13 -0800 Subject: uhd: swig up the device discovery --- gr-uhd/swig/__init__.py | 21 +++++++++++---------- gr-uhd/swig/uhd_swig.i | 5 +++++ 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 18b5dfefc..1a9f8358d 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -21,6 +21,17 @@ # The presence of this file turns this directory into a Python package +######################################################################## +# Create aliases for uhd swig attributes to avoid the "_t" +# Install the __str__ and __repr__ handlers if applicable +######################################################################## +import uhd_swig +for attr in dir(uhd_swig): + myobj = getattr(uhd_swig, attr) + if hasattr(myobj, 'to_string'): myobj.__repr__ = lambda s: s.to_string().strip() + if hasattr(myobj, 'to_pp_string'): myobj.__str__ = lambda s: s.to_pp_string().strip() + if attr.endswith('_t'): setattr(uhd_swig, attr[:-2], myobj) + ######################################################################## # Add SWIG generated code to this namespace ######################################################################## @@ -52,16 +63,6 @@ class device_addr_t(device_addr_t, str): def __getitem__(self, key): return self.get(key) def __setitem__(self, key, val): self.set(key, val) -######################################################################## -# Create aliases for global attributes to avoid the "_t" -# Install the __str__ and __repr__ handlers if applicable -######################################################################## -for attr in globals().keys(): - myobj = globals()[attr] - if hasattr(myobj, 'to_string'): myobj.__repr__ = lambda s: s.to_string().strip() - if hasattr(myobj, 'to_pp_string'): myobj.__str__ = lambda s: s.to_pp_string().strip() - if attr.endswith('_t'): globals()[attr[:-2]] = myobj - ######################################################################## # Cast constructor args (FIXME swig handle overloads?) ######################################################################## diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index e25dbce90..3c317beb4 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -88,6 +88,11 @@ %include +%include + +%include +%template(device_addr_vector_t) std::vector; + //////////////////////////////////////////////////////////////////////// // block magic //////////////////////////////////////////////////////////////////////// -- cgit From d429522b8cc0916c0dd8167284e9f7373f8c1663 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 14 Jan 2011 11:15:59 -0800 Subject: uhd: move tags functionality into its own sub-class that is enabled by preferences remove private variables from header interface subclassed single source impl with overloaded work function --- gr-uhd/lib/uhd_single_usrp_source.cc | 82 ++++++++++++++++++++++++++++++------ gr-uhd/lib/uhd_single_usrp_source.h | 4 -- 2 files changed, 69 insertions(+), 17 deletions(-) (limited to 'gr-uhd') diff --git a/gr-uhd/lib/uhd_single_usrp_source.cc b/gr-uhd/lib/uhd_single_usrp_source.cc index ddd4ad275..5a26d44b1 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.cc +++ b/gr-uhd/lib/uhd_single_usrp_source.cc @@ -49,7 +49,6 @@ public: _type(io_type) { _dev = uhd::usrp::single_usrp::make(device_addr); - d_tag_srcid = pmt::mp("uhd_single_usrp_source"); } void set_subdev_spec(const std::string &spec){ @@ -125,7 +124,7 @@ public: /*********************************************************************** * Work **********************************************************************/ - int work( + virtual int work( int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items @@ -139,16 +138,7 @@ public: switch(metadata.error_code){ case uhd::rx_metadata_t::ERROR_CODE_NONE: - 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; + return num_samps; case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW: //ignore overflows and try work again @@ -172,9 +162,68 @@ public: return true; } -private: +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; }; @@ -182,11 +231,18 @@ private: /*********************************************************************** * 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 index c7ff18770..262f6696c 100644 --- a/gr-uhd/lib/uhd_single_usrp_source.h +++ b/gr-uhd/lib/uhd_single_usrp_source.h @@ -169,10 +169,6 @@ public: * \return the single usrp device object */ virtual uhd::usrp::single_usrp::sptr get_device(void) = 0; - - protected: - size_t d_num_packet_samps; - pmt::pmt_t d_tstamp_pair; }; #endif /* INCLUDED_UHD_SINGLE_USRP_SOURCE_H */ -- cgit From 34fc10385fbe41ba5475b21135c802e9660235ad Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 25 Jan 2011 01:16:31 -0800 Subject: uhd: typo fix setime_unknown_pps -> set_time_unknown_pps in grc xml generator --- gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gr-uhd') diff --git a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py index 9f413f2a8..fc44501de 100755 --- a/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py +++ b/gr-uhd/grc/gen_uhd_multi_usrp_blocks_xml.py @@ -32,7 +32,7 @@ MAIN_TMPL = """\ ) \#if \$sync() self.\$(id).set_clock_config(uhd.clock_config.external(), uhd.ALL_MBOARDS); -self.\$(id).setime_unknown_pps(uhd.time_spec()) +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)() -- cgit 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)