diff options
author | Tom Rondeau | 2011-04-08 15:37:29 -0400 |
---|---|---|
committer | Tom Rondeau | 2011-04-08 15:37:29 -0400 |
commit | 21b64f070a3eb38ab044529a6ddd9cd6b6d0a2cb (patch) | |
tree | 4e72909a051b0a4ac428252d15f34b53bcc986b6 /gr-uhd | |
parent | d7093fd06d0ec37f6ba2841d202fe90f4fa3661e (diff) | |
parent | 5c358afd00347f5da7a59dd73ea79cd3df26659d (diff) | |
download | gnuradio-21b64f070a3eb38ab044529a6ddd9cd6b6d0a2cb.tar.gz gnuradio-21b64f070a3eb38ab044529a6ddd9cd6b6d0a2cb.tar.bz2 gnuradio-21b64f070a3eb38ab044529a6ddd9cd6b6d0a2cb.zip |
Merge branch 'master' into constell_obj
Conflicts:
gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h
gr-audio-oss/src/Makefile.swig.gen
gr-audio/swig/Makefile.swig.gen
Diffstat (limited to 'gr-uhd')
-rw-r--r-- | gr-uhd/grc/gen_uhd_usrp_blocks.py | 3 | ||||
-rw-r--r-- | gr-uhd/include/gr_uhd_usrp_sink.h | 8 | ||||
-rw-r--r-- | gr-uhd/include/gr_uhd_usrp_source.h | 8 | ||||
-rw-r--r-- | gr-uhd/lib/Makefile.am | 2 | ||||
-rw-r--r-- | gr-uhd/lib/gr_uhd_usrp_sink.cc | 24 | ||||
-rw-r--r-- | gr-uhd/lib/gr_uhd_usrp_source.cc | 55 | ||||
-rw-r--r-- | gr-uhd/swig/uhd_swig.i | 2 |
7 files changed, 52 insertions, 50 deletions
diff --git a/gr-uhd/grc/gen_uhd_usrp_blocks.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py index 831d69fc4..8596e14a6 100644 --- a/gr-uhd/grc/gen_uhd_usrp_blocks.py +++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py @@ -65,7 +65,7 @@ self.\$(id).set_bandwidth(\$bw$(n), $n) <callback>set_bandwidth(\$bw$(n), $n)</callback> #end for <param> - <name>Input Type</name> + <name>$(direction.title())put Type</name> <key>type</key> <type>enum</type> <option> @@ -140,6 +140,7 @@ self.\$(id).set_bandwidth(\$bw$(n), $n) <key>num_mboards</key> <value>1</value> <type>int</type> + <hide>part</hide> #for $m in range(1, $max_mboards+1) <option> <name>$(m)</name> diff --git a/gr-uhd/include/gr_uhd_usrp_sink.h b/gr-uhd/include/gr_uhd_usrp_sink.h index 557cb2cdb..0475957de 100644 --- a/gr-uhd/include/gr_uhd_usrp_sink.h +++ b/gr-uhd/include/gr_uhd_usrp_sink.h @@ -34,16 +34,10 @@ GR_UHD_API boost::shared_ptr<uhd_usrp_sink> uhd_make_usrp_sink( size_t num_channels ); -class GR_UHD_API uhd_usrp_sink : public gr_sync_block{ +class GR_UHD_API uhd_usrp_sink : virtual 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 diff --git a/gr-uhd/include/gr_uhd_usrp_source.h b/gr-uhd/include/gr_uhd_usrp_source.h index 3b36bf45d..038f9a91e 100644 --- a/gr-uhd/include/gr_uhd_usrp_source.h +++ b/gr-uhd/include/gr_uhd_usrp_source.h @@ -34,16 +34,10 @@ GR_UHD_API boost::shared_ptr<uhd_usrp_source> uhd_make_usrp_source( size_t num_channels ); -class GR_UHD_API uhd_usrp_source : public gr_sync_block{ +class GR_UHD_API uhd_usrp_source : virtual 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 diff --git a/gr-uhd/lib/Makefile.am b/gr-uhd/lib/Makefile.am index d93b243e2..c27682f7f 100644 --- a/gr-uhd/lib/Makefile.am +++ b/gr-uhd/lib/Makefile.am @@ -37,6 +37,6 @@ libgnuradio_uhd_la_LIBADD = \ $(GNURADIO_CORE_LA) \ $(UHD_LIBS) -libgnuradio_uhd_la_LDFLAGS = $(LTVERSIONFLAGS) +libgnuradio_uhd_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) noinst_HEADERS = diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc index 4598e54c2..d44af25ab 100644 --- a/gr-uhd/lib/gr_uhd_usrp_sink.cc +++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc @@ -24,14 +24,6 @@ #include <stdexcept> /*********************************************************************** - * 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{ @@ -41,11 +33,14 @@ public: 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 - )), + gr_sync_block( + "gr uhd usrp sink", + gr_make_io_signature(num_channels, num_channels, io_type.size), + gr_make_io_signature(0, 0, 0) + ), _type(io_type), - _nchan(num_channels) + _nchan(num_channels), + _has_time_spec(_nchan > 1) { _dev = uhd::usrp::multi_usrp::make(device_addr); } @@ -172,7 +167,7 @@ public: //send a mid-burst packet with time spec _metadata.start_of_burst = false; _metadata.end_of_burst = false; - _metadata.has_time_spec = true; + _metadata.has_time_spec = _has_time_spec; size_t num_sent = _dev->get_device()->send( input_items, noutput_items, _metadata, @@ -189,7 +184,7 @@ public: bool start(void){ _metadata.start_of_burst = true; _metadata.end_of_burst = false; - _metadata.has_time_spec = true; + _metadata.has_time_spec = _has_time_spec; _metadata.time_spec = get_time_now() + uhd::time_spec_t(0.01); _dev->get_device()->send( @@ -217,6 +212,7 @@ protected: uhd::usrp::multi_usrp::sptr _dev; const uhd::io_type_t _type; size_t _nchan; + bool _has_time_spec; uhd::tx_metadata_t _metadata; double _sample_rate; }; diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc index 09cced567..fed8e6624 100644 --- a/gr-uhd/lib/gr_uhd_usrp_source.cc +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -26,14 +26,6 @@ #include <boost/format.hpp> /*********************************************************************** - * 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{ @@ -43,10 +35,15 @@ public: 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) + gr_sync_block( + "gr uhd usrp source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(num_channels, num_channels, io_type.size) + ), + _type(io_type), + _nchan(num_channels), + _stream_now(_nchan == 1), + _tmp_buffs(_nchan) { _dev = uhd::usrp::multi_usrp::make(device_addr); } @@ -169,16 +166,16 @@ public: gr_vector_const_void_star &input_items, gr_vector_void_star &output_items ){ - uhd::rx_metadata_t metadata; //not passed out of this block - + //wait for a packet to become available size_t num_samps = _dev->get_device()->recv( - output_items, noutput_items, metadata, - _type, uhd::device::RECV_MODE_FULL_BUFF, 1.0 + output_items, noutput_items, _metadata, + _type, uhd::device::RECV_MODE_ONE_PACKET, 1.0 ); - switch(metadata.error_code){ + //handle possible errors conditions + switch(_metadata.error_code){ case uhd::rx_metadata_t::ERROR_CODE_NONE: - return num_samps; + break; case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW: //ignore overflows and try work again @@ -187,16 +184,30 @@ public: default: std::cout << boost::format( "UHD source block got error code 0x%x" - ) % metadata.error_code << std::endl; + ) % _metadata.error_code << std::endl; return num_samps; } + + //advance the pointers and count by num_samps + noutput_items -= num_samps; + for (size_t i = 0; i < _nchan; i++){ + _tmp_buffs[i] = static_cast<char *>(output_items[i]) + num_samps*_type.size; + } + + //receive all available packets without timeout + num_samps += _dev->get_device()->recv( + _tmp_buffs, noutput_items, _metadata, + _type, uhd::device::RECV_MODE_FULL_BUFF, 0.0 + ); + + 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.stream_now = _stream_now; stream_cmd.time_spec = get_time_now() + uhd::time_spec_t(reasonable_delay); _dev->issue_stream_cmd(stream_cmd); return true; @@ -210,6 +221,10 @@ public: private: uhd::usrp::multi_usrp::sptr _dev; const uhd::io_type_t _type; + size_t _nchan; + bool _stream_now; + gr_vector_void_star _tmp_buffs; + uhd::rx_metadata_t _metadata; }; diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index b814471b2..3ffcc7aea 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -66,6 +66,7 @@ %include <uhd/utils/pimpl.hpp> +%ignore uhd::dict::operator[]; //ignore warnings about %extend %include <uhd/types/dict.hpp> %template(string_string_dict_t) uhd::dict<std::string, std::string>; //define after dict @@ -88,6 +89,7 @@ %include <uhd/types/metadata.hpp> +%ignore uhd::device::register_device; //causes compile to choke in MSVC %include <uhd/device.hpp> %template(device_addr_vector_t) std::vector<uhd::device_addr_t>; |