diff options
Diffstat (limited to 'gr-uhd')
-rwxr-xr-x | gr-uhd/apps/uhd_fft.py | 35 | ||||
-rwxr-xr-x | gr-uhd/apps/uhd_siggen.py | 30 | ||||
-rwxr-xr-x | gr-uhd/apps/uhd_siggen_gui.py | 6 | ||||
-rw-r--r-- | gr-uhd/include/gr_uhd_usrp_sink.h | 41 | ||||
-rw-r--r-- | gr-uhd/include/gr_uhd_usrp_source.h | 52 | ||||
-rw-r--r-- | gr-uhd/lib/CMakeLists.txt | 3 | ||||
-rw-r--r-- | gr-uhd/lib/Makefile.am | 5 | ||||
-rw-r--r-- | gr-uhd/lib/gr_uhd_amsg_source.cc | 4 | ||||
-rw-r--r-- | gr-uhd/lib/gr_uhd_common.h | 42 | ||||
-rw-r--r-- | gr-uhd/lib/gr_uhd_usrp_sink.cc | 49 | ||||
-rw-r--r-- | gr-uhd/lib/gr_uhd_usrp_source.cc | 81 | ||||
-rw-r--r-- | gr-uhd/swig/__init__.py | 2 | ||||
-rw-r--r-- | gr-uhd/swig/uhd_swig.i | 10 |
13 files changed, 335 insertions, 25 deletions
diff --git a/gr-uhd/apps/uhd_fft.py b/gr-uhd/apps/uhd_fft.py index 18edc8f867..2f2b0ebfa9 100755 --- a/gr-uhd/apps/uhd_fft.py +++ b/gr-uhd/apps/uhd_fft.py @@ -31,6 +31,7 @@ import numpy try: from gnuradio.wxgui import stdgui2, form, slider + from gnuradio.wxgui import forms from gnuradio.wxgui import fftsink2, waterfallsink2, scopesink2 import wx except ImportError: @@ -195,6 +196,35 @@ class app_top_block(stdgui2.std_top_block): min=int(glow), max=int(ghigh), callback=self.set_gain) + try: + mboard_id = self.u.get_usrp_info().get("mboard_id").split(" ")[0] + mboard_serial = self.u.get_usrp_info().get("mboard_serial") + if mboard_serial == "": + mboard_serial = "no serial" + dboard_id = self.u.get_usrp_info().get("rx_id").split(" ")[0].split(",")[0] + dboard_serial = self.u.get_usrp_info().get("rx_serial") + if dboard_serial == "": + dboard_serial = "no serial" + subdev = self.u.get_subdev_spec() + antenna = self.u.get_antenna() + + usrp_config_val = "%s (%s), %s (%s, %s, %s)" % (mboard_id, mboard_serial, dboard_id, dboard_serial, subdev, antenna) + except: + usrp_config_val = "Not implemented in this version." + + uhd_box = forms.static_box_sizer(parent=self.panel, + label="UHD (%s)" % (uhd.get_version_string()), + orient=wx.HORIZONTAL) + usrp_config_form = forms.static_text( + parent=self.panel, + sizer=uhd_box, + value=usrp_config_val, + label="USRP", + converter=forms.str_converter(), + ) + vbox.Add(uhd_box, 0, wx.EXPAND) + vbox.AddSpacer(5) + hbox.Add((5,0), 0, 0) vbox.Add(hbox, 0, wx.EXPAND) @@ -232,8 +262,10 @@ class app_top_block(stdgui2.std_top_block): myform['dspfreq'] = form.static_float_field( parent=panel, sizer=hbox, label="DSP Freq.") - hbox.Add((5,0), 0) + vbox.AddSpacer(5) + vbox.Add(hbox, 0, wx.EXPAND) + vbox.AddSpacer(5) def set_freq(self, target_freq): """ @@ -248,6 +280,7 @@ class app_top_block(stdgui2.std_top_block): self.myform['freq'].set_value(self.u.get_center_freq()) self.myform['rffreq'].set_value(r.actual_rf_freq) self.myform['dspfreq'].set_value(r.actual_dsp_freq) + if not self.options.oscilloscope: self.scope.set_baseband_freq(target_freq) return True diff --git a/gr-uhd/apps/uhd_siggen.py b/gr-uhd/apps/uhd_siggen.py index e1af586aef..add8d1bf37 100755 --- a/gr-uhd/apps/uhd_siggen.py +++ b/gr-uhd/apps/uhd_siggen.py @@ -107,12 +107,36 @@ class top_block(gr.top_block, pubsub): if(options.antenna): self._u.set_antenna(options.antenna, 0) - self.publish(DESC_KEY, lambda: str(self._u)) + # Setup USRP Configuration value + try: + usrp_info = self._u.get_usrp_info() + mboard_id = usrp_info.get("mboard_id").split(" ")[0] + mboard_serial = usrp_info.get("mboard_serial") + if mboard_serial == "": + mboard_serial = "no serial" + dboard_id = usrp_info.get("tx_id").split(" ")[0].split(",")[0] + dboard_serial = usrp_info.get("tx_serial") + if dboard_serial == "": + dboard_serial = "no serial" + subdev = self._u.get_subdev_spec() + antenna = self._u.get_antenna() + + desc_key_str = "Motherboard: %s [%s]\n" % (mboard_id, mboard_serial) + desc_key_str += "Daughterboard: %s [%s]\n" % (dboard_id, dboard_serial) + desc_key_str += "Subdev: %s\n" % subdev + desc_key_str += "Antenna: %s" % antenna + except: + desc_key_str = "USRP configuration output not implemented in this version" + + self.publish(DESC_KEY, lambda: desc_key_str) self.publish(FREQ_RANGE_KEY, self._u.get_freq_range) self.publish(GAIN_RANGE_KEY, self._u.get_gain_range) self.publish(GAIN_KEY, self._u.get_gain) - if self._verbose: - print str(self._u) + + print "UHD Signal Generator" + print "Version: %s" % uhd.get_version_string() + print "\nUsing USRP configuration:" + print desc_key_str + "\n" # Direct asynchronous notifications to callback function if options.show_async_msg: diff --git a/gr-uhd/apps/uhd_siggen_gui.py b/gr-uhd/apps/uhd_siggen_gui.py index 2ef6ea40f6..1f6a73c2c6 100755 --- a/gr-uhd/apps/uhd_siggen_gui.py +++ b/gr-uhd/apps/uhd_siggen_gui.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2009,2011 Free Software Foundation, Inc. +# Copyright 2009,2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ # import wx -from gnuradio import gr +from gnuradio import gr, uhd from gnuradio.gr.pubsub import pubsub from gnuradio.wxgui import gui, forms import uhd_siggen @@ -269,7 +269,7 @@ class app_gui(pubsub): # UHD status ################################################## u2_hbox = forms.static_box_sizer(parent=self.panel, - label="UHD Status", + label="UHD (%s)" % (uhd.get_version_string()), orient=wx.HORIZONTAL, bold=True) self.vbox.Add(u2_hbox, 0, wx.EXPAND) diff --git a/gr-uhd/include/gr_uhd_usrp_sink.h b/gr-uhd/include/gr_uhd_usrp_sink.h index ce76ec03b0..dffdf810f7 100644 --- a/gr-uhd/include/gr_uhd_usrp_sink.h +++ b/gr-uhd/include/gr_uhd_usrp_sink.h @@ -1,5 +1,5 @@ /* - * Copyright 2010-2011 Free Software Foundation, Inc. + * Copyright 2010-2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -118,12 +118,42 @@ class GR_UHD_API uhd_usrp_sink : virtual public gr_sync_block{ public: /*! + * Set the start time for outgoing samples. + * To control when samples are transmitted, + * set this value before starting the flow graph. + * The value is cleared after each run. + * When not specified, the start time will be: + * - Immediately for the one channel case + * - in the near future for multi-channel + * + * \param time the absolute time for transmission to begin + */ + virtual void set_start_time(const uhd::time_spec_t &time) = 0; + + /*! + * Returns identifying information about this USRP's configuration. + * Returns motherboard ID, name, and serial. + * Returns daughterboard TX ID, subdev name, and serial. + * \param chan channel index 0 to N-1 + * \return TX info + */ + virtual uhd::dict<std::string, std::string> get_usrp_info(size_t chan = 0) = 0; + + /*! * Set the frontend 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; + + /*! + * Get the TX frontend specification. + * \param mboard the motherboard index 0 to M-1 + * \return the frontend specification in use + */ + virtual std::string get_subdev_spec (size_t mboard = 0) = 0; + /*! * Set the sample rate for the usrp device. * \param rate a new rate in Sps @@ -448,6 +478,15 @@ public: * \return the multi usrp device object */ virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0; + + /*! + * Perform write on the user configuration register bus. These only exist if + * the user has implemented custom setting registers in the device FPGA. + * \param addr 8-bit register address + * \param data 32-bit register value + * \param mboard which motherboard to set the user register + */ + virtual void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard = 0) = 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 index c33eb2a6fa..64e9fb0982 100644 --- a/gr-uhd/include/gr_uhd_usrp_source.h +++ b/gr-uhd/include/gr_uhd_usrp_source.h @@ -110,6 +110,28 @@ class GR_UHD_API uhd_usrp_source : virtual public gr_sync_block{ public: /*! + * Set the start time for incoming samples. + * To control when samples are received, + * set this value before starting the flow graph. + * The value is cleared after each run. + * When not specified, the start time will be: + * - Immediately for the one channel case + * - in the near future for multi-channel + * + * \param time the absolute time for reception to begin + */ + virtual void set_start_time(const uhd::time_spec_t &time) = 0; + + /*! + * Returns identifying information about this USRP's configuration. + * Returns motherboard ID, name, and serial. + * Returns daughterboard RX ID, subdev name, and serial. + * \param chan channel index 0 to N-1 + * \return RX info + */ + virtual uhd::dict<std::string, std::string> get_usrp_info(size_t chan = 0) = 0; + + /*! * Set the frontend specification. * \param spec the subdev spec markup string * \param mboard the motherboard index 0 to M-1 @@ -117,6 +139,13 @@ public: virtual void set_subdev_spec(const std::string &spec, size_t mboard = 0) = 0; /*! + * Get the RX frontend specification. + * \param mboard the motherboard index 0 to M-1 + * \return the frontend specification in use + */ + virtual std::string get_subdev_spec(size_t mboard = 0) = 0; + + /*! * Set the sample rate for the usrp device. * \param rate a new rate in Sps */ @@ -457,13 +486,34 @@ public: virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0; /*! + * Perform write on the user configuration register bus. These only exist if + * the user has implemented custom setting registers in the device FPGA. + * \param addr 8-bit register address + * \param data 32-bit register value + * \param mboard which motherboard to set the user register + */ + virtual void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard = 0) = 0; + + /*! * Convenience function for finite data acquisition. * This is not to be used with the scheduler; rather, * one can request samples from the USRP in python. - * //TODO multi-channel * //TODO assumes fc32 + * \param nsamps the number of samples + * \return a vector of complex float samples */ virtual std::vector<std::complex<float> > finite_acquisition(const size_t nsamps) = 0; + + /*! + * Convenience function for finite data acquisition. + * This is the multi-channel version of finite_acquisition; + * This is not to be used with the scheduler; rather, + * one can request samples from the USRP in python. + * //TODO assumes fc32 + * \param nsamps the number of samples per channel + * \return a vector of buffers, where each buffer represents a channel + */ + virtual std::vector<std::vector<std::complex<float> > > finite_acquisition_v(const size_t nsamps) = 0; }; #endif /* INCLUDED_GR_UHD_USRP_SOURCE_H */ diff --git a/gr-uhd/lib/CMakeLists.txt b/gr-uhd/lib/CMakeLists.txt index 432ed1ab67..1f44b06307 100644 --- a/gr-uhd/lib/CMakeLists.txt +++ b/gr-uhd/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011-2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,6 +23,7 @@ include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${GR_UHD_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} ) include_directories(${UHD_INCLUDE_DIRS}) diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index c322c61245..41ce79d87a 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2010-2011 Free Software Foundation, Inc. +# Copyright 2010-2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -25,6 +25,7 @@ AM_CPPFLAGS = \ $(STD_DEFINES_AND_INCLUDES) \ $(WITH_INCLUDES) \ $(UHD_CPPFLAGS) \ + -I$(srcdir) \ -Dgnuradio_uhd_EXPORTS lib_LTLIBRARIES = libgnuradio-uhd.la @@ -40,4 +41,4 @@ libgnuradio_uhd_la_LIBADD = \ libgnuradio_uhd_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) -noinst_HEADERS = +noinst_HEADERS = gr_uhd_common.h diff --git a/gr-uhd/lib/gr_uhd_amsg_source.cc b/gr-uhd/lib/gr_uhd_amsg_source.cc index 08941584bd..67e402f6b9 100644 --- a/gr-uhd/lib/gr_uhd_amsg_source.cc +++ b/gr-uhd/lib/gr_uhd_amsg_source.cc @@ -1,5 +1,5 @@ /* - * Copyright 2011 Free Software Foundation, Inc. + * Copyright 2011-2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,6 +22,7 @@ #include <gr_uhd_amsg_source.h> #include <boost/bind.hpp> #include <gruel/thread.h> +#include "gr_uhd_common.h" /*********************************************************************** * UHD Asynchronous Message Source Impl @@ -87,6 +88,7 @@ boost::shared_ptr<uhd_amsg_source> uhd_make_amsg_source( const uhd::device_addr_t &device_addr, gr_msg_queue_sptr msgq ){ + gr_uhd_check_abi(); return boost::shared_ptr<uhd_amsg_source>( new uhd_amsg_source_impl(device_addr, msgq) ); diff --git a/gr-uhd/lib/gr_uhd_common.h b/gr-uhd/lib/gr_uhd_common.h new file mode 100644 index 0000000000..940f176924 --- /dev/null +++ b/gr-uhd/lib/gr_uhd_common.h @@ -0,0 +1,42 @@ +/* + * Copyright 2012 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_COMMON_H +#define INCLUDED_GR_UHD_COMMON_H + +#include <uhd/version.hpp> +#include <boost/format.hpp> +#include <stdexcept> + +static inline void gr_uhd_check_abi(void){ + #ifdef UHD_VERSION_ABI_STRING + if (std::string(UHD_VERSION_ABI_STRING) == uhd::get_abi_string()) return; + throw std::runtime_error(str(boost::format( + "\nGR-UHD detected ABI compatibility mismatch with UHD library.\n" + "GR-UHD was build against ABI: %s,\n" + "but UHD library reports ABI: %s\n" + "Suggestion: install an ABI compatible version of UHD,\n" + "or rebuild GR-UHD component against this ABI version.\n" + ) % UHD_VERSION_ABI_STRING % uhd::get_abi_string())); + #endif +} + +#endif /* INCLUDED_GR_UHD_COMMON_H */ diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc index 05237100c8..7528176643 100644 --- a/gr-uhd/lib/gr_uhd_usrp_sink.cc +++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc @@ -1,5 +1,5 @@ /* - * Copyright 2010-2011 Free Software Foundation, Inc. + * Copyright 2010-2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,6 +23,7 @@ #include <gr_io_signature.h> #include <stdexcept> #include <boost/make_shared.hpp> +#include "gr_uhd_common.h" static const pmt::pmt_t SOB_KEY = pmt::pmt_string_to_symbol("tx_sob"); static const pmt::pmt_t EOB_KEY = pmt::pmt_string_to_symbol("tx_eob"); @@ -56,17 +57,31 @@ public: gr_make_io_signature(0, 0, 0) ), _stream_args(stream_args), - _nchan(std::max<size_t>(1, stream_args.channels.size())) + _nchan(std::max<size_t>(1, stream_args.channels.size())), + _stream_now(_nchan == 1), + _start_time_set(false) { if (stream_args.cpu_format == "fc32") _type = boost::make_shared<uhd::io_type_t>(uhd::io_type_t::COMPLEX_FLOAT32); if (stream_args.cpu_format == "sc16") _type = boost::make_shared<uhd::io_type_t>(uhd::io_type_t::COMPLEX_INT16); _dev = uhd::usrp::multi_usrp::make(device_addr); } + uhd::dict<std::string, std::string> get_usrp_info(size_t chan){ + #ifdef UHD_USRP_MULTI_USRP_GET_USRP_INFO_API + return _dev->get_usrp_tx_info(chan); + #else + throw std::runtime_error("not implemented in this version"); + #endif + } + void set_subdev_spec(const std::string &spec, size_t mboard){ return _dev->set_tx_subdev_spec(spec, mboard); } + std::string get_subdev_spec(size_t mboard){ + return _dev->get_tx_subdev_spec(mboard).to_string(); + } + void set_samp_rate(double rate){ _dev->set_tx_rate(rate); _sample_rate = this->get_samp_rate(); @@ -278,6 +293,15 @@ public: return _dev; } + void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard){ + #ifdef UHD_USRP_MULTI_USRP_USER_REGS_API + _dev->set_user_register(addr, data, mboard); + #else + throw std::runtime_error("not implemented in this version"); + #endif + } + + /*********************************************************************** * Work **********************************************************************/ @@ -372,6 +396,12 @@ public: } } + void set_start_time(const uhd::time_spec_t &time){ + _start_time = time; + _start_time_set = true; + _stream_now = false; + } + //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){ @@ -381,8 +411,14 @@ public: _metadata.start_of_burst = true; _metadata.end_of_burst = false; - _metadata.has_time_spec = _nchan > 1; - _metadata.time_spec = get_time_now() + uhd::time_spec_t(0.01); + _metadata.has_time_spec = not _stream_now; + if (_start_time_set){ + _start_time_set = false; //cleared for next run + _metadata.time_spec = _start_time; + } + else{ + _metadata.time_spec = get_time_now() + uhd::time_spec_t(0.01); + } #ifdef GR_UHD_USE_STREAM_API _tx_stream->send( @@ -423,9 +459,13 @@ private: uhd::tx_streamer::sptr _tx_stream; #endif size_t _nchan; + bool _stream_now; uhd::tx_metadata_t _metadata; double _sample_rate; + uhd::time_spec_t _start_time; + bool _start_time_set; + //stream tags related stuff std::vector<gr_tag_t> _tags; }; @@ -456,6 +496,7 @@ boost::shared_ptr<uhd_usrp_sink> uhd_make_usrp_sink( const uhd::device_addr_t &device_addr, const uhd::stream_args_t &stream_args ){ + gr_uhd_check_abi(); return boost::shared_ptr<uhd_usrp_sink>( new uhd_usrp_sink_impl(device_addr, stream_args) ); diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc index c599b2b3d0..d06983cd31 100644 --- a/gr-uhd/lib/gr_uhd_usrp_source.cc +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -25,6 +25,7 @@ #include <iostream> #include <boost/format.hpp> #include <boost/make_shared.hpp> +#include "gr_uhd_common.h" static const pmt::pmt_t TIME_KEY = pmt::pmt_string_to_symbol("rx_time"); @@ -58,7 +59,8 @@ public: _stream_args(stream_args), _nchan(std::max<size_t>(1, stream_args.channels.size())), _stream_now(_nchan == 1), - _tag_now(false) + _tag_now(false), + _start_time_set(false) { if (stream_args.cpu_format == "fc32") _type = boost::make_shared<uhd::io_type_t>(uhd::io_type_t::COMPLEX_FLOAT32); if (stream_args.cpu_format == "sc16") _type = boost::make_shared<uhd::io_type_t>(uhd::io_type_t::COMPLEX_INT16); @@ -68,10 +70,22 @@ public: _dev = uhd::usrp::multi_usrp::make(device_addr); } + uhd::dict<std::string, std::string> get_usrp_info(size_t chan){ + #ifdef UHD_USRP_MULTI_USRP_GET_USRP_INFO_API + return _dev->get_usrp_rx_info(chan); + #else + throw std::runtime_error("not implemented in this version"); + #endif + } + void set_subdev_spec(const std::string &spec, size_t mboard){ return _dev->set_rx_subdev_spec(spec, mboard); } + std::string get_subdev_spec(size_t mboard){ + return _dev->get_rx_subdev_spec(mboard).to_string(); + } + void set_samp_rate(double rate){ _dev->set_rx_rate(rate); } @@ -290,6 +304,14 @@ public: return _dev; } + void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard){ + #ifdef UHD_USRP_MULTI_USRP_USER_REGS_API + _dev->set_user_register(addr, data, mboard); + #else + throw std::runtime_error("not implemented in this version"); + #endif + } + /*********************************************************************** * Work **********************************************************************/ @@ -363,6 +385,12 @@ public: return num_samps; } + void set_start_time(const uhd::time_spec_t &time){ + _start_time = time; + _start_time_set = true; + _stream_now = false; + } + bool start(void){ #ifdef GR_UHD_USE_STREAM_API _rx_stream = _dev->get_rx_stream(_stream_args); @@ -372,7 +400,13 @@ public: 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 = _stream_now; - stream_cmd.time_spec = get_time_now() + uhd::time_spec_t(reasonable_delay); + if (_start_time_set){ + _start_time_set = false; //cleared for next run + stream_cmd.time_spec = _start_time; + } + else{ + stream_cmd.time_spec = get_time_now() + uhd::time_spec_t(reasonable_delay); + } _dev->issue_stream_cmd(stream_cmd); _tag_now = true; return true; @@ -410,17 +444,48 @@ public: } std::vector<std::complex<float> > finite_acquisition(const size_t nsamps){ + if (_nchan != 1) throw std::runtime_error("finite_acquisition: usrp source has multiple channels, call finite_acquisition_v"); + return finite_acquisition_v(nsamps).front(); + } + + std::vector<std::vector<std::complex<float> > > finite_acquisition_v(const size_t nsamps){ #ifdef GR_UHD_USE_STREAM_API + + //kludgy way to ensure rx streamer exsists + if (!_rx_stream){ + this->start(); + this->stop(); + } + + //flush so there is no queued-up data + this->flush(); + + //create a multi-dimensional container to hold an array of sample buffers + std::vector<std::vector<std::complex<float> > > samps(_nchan, std::vector<std::complex<float> >(nsamps)); + + //load the void* vector of buffer pointers + std::vector<void *> buffs(_nchan); + for (size_t i = 0; i < _nchan; i++){ + buffs[i] = &samps[i].front(); + } + + //tell the device to stream a finite amount uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); cmd.num_samps = nsamps; - cmd.stream_now = true; + cmd.stream_now = _stream_now; + static const double reasonable_delay = 0.1; //order of magnitude over RTT + cmd.time_spec = get_time_now() + uhd::time_spec_t(reasonable_delay); _dev->issue_stream_cmd(cmd); - std::vector<std::complex<float> > samps(nsamps); + //receive samples until timeout const size_t actual_num_samps = _rx_stream->recv( - &samps.front(), nsamps, _metadata, 0.1 + buffs, nsamps, _metadata, 1.0 ); - samps.resize(actual_num_samps); + + //resize the resulting sample buffers + for (size_t i = 0; i < _nchan; i++){ + samps[i].resize(actual_num_samps); + } return samps; #else @@ -440,6 +505,9 @@ private: bool _stream_now, _tag_now; uhd::rx_metadata_t _metadata; pmt::pmt_t _id; + + uhd::time_spec_t _start_time; + bool _start_time_set; }; @@ -469,6 +537,7 @@ boost::shared_ptr<uhd_usrp_source> uhd_make_usrp_source( const uhd::device_addr_t &device_addr, const uhd::stream_args_t &stream_args ){ + gr_uhd_check_abi(); return boost::shared_ptr<uhd_usrp_source>( new uhd_usrp_source_impl(device_addr, stream_args) ); diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 82dbdd9e75..b4045e77fb 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -1,5 +1,5 @@ # -# Copyright 2010-2011 Free Software Foundation, Inc. +# Copyright 2010-2012 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 0b2f9febc5..729719dcbd 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010-2011 Free Software Foundation, Inc. + * Copyright 2010-2012 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -125,6 +125,14 @@ static const size_t ALL_MBOARDS = uhd::usrp::multi_usrp::ALL_MBOARDS; %} static const size_t ALL_MBOARDS; +%{ +#include <uhd/version.hpp> +std::string get_version_string(void){ + return uhd::get_version_string(); +} +%} +std::string get_version_string(void); + #if SWIGGUILE %scheme %{ (load-extension-global "libguile-gnuradio-uhd_swig" "scm_init_gnuradio_uhd_swig_module") |