From bf8984bac6551dc2a98d615431fb6c9b4bfb9f4e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 3 Nov 2011 20:03:44 -0700 Subject: uhd: rebase tweaks + update on command feature --- gr-uhd/include/gr_uhd_usrp_sink.h | 19 +++++++++++++++++++ gr-uhd/include/gr_uhd_usrp_source.h | 19 +++++++++++++++++++ gr-uhd/lib/gr_uhd_usrp_sink.cc | 18 +++++++++++++++++- gr-uhd/lib/gr_uhd_usrp_source.cc | 29 ++++++++++++++++++++++++++--- 4 files changed, 81 insertions(+), 4 deletions(-) diff --git a/gr-uhd/include/gr_uhd_usrp_sink.h b/gr-uhd/include/gr_uhd_usrp_sink.h index ea703faa8..ce76ec03b 100644 --- a/gr-uhd/include/gr_uhd_usrp_sink.h +++ b/gr-uhd/include/gr_uhd_usrp_sink.h @@ -418,6 +418,25 @@ public: */ virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0; + /*! + * Set the time at which the control commands will take effect. + * + * A timed command will back-pressure all subsequent timed commands, + * assuming that the subsequent commands occur within the time-window. + * If the time spec is late, the command will be activated upon arrival. + * + * \param time_spec the time at which the next command will activate + * \param mboard which motherboard to set the config + */ + virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = 0) = 0; + + /*! + * Clear the command time so future commands are sent ASAP. + * + * \param mboard which motherboard to set the config + */ + virtual void clear_command_time(size_t mboard = 0) = 0; + /*! * Get access to the underlying uhd dboard iface object. * \return the dboard_iface object diff --git a/gr-uhd/include/gr_uhd_usrp_source.h b/gr-uhd/include/gr_uhd_usrp_source.h index 5830487bc..e9fc41b93 100644 --- a/gr-uhd/include/gr_uhd_usrp_source.h +++ b/gr-uhd/include/gr_uhd_usrp_source.h @@ -425,6 +425,25 @@ public: */ virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0; + /*! + * Set the time at which the control commands will take effect. + * + * A timed command will back-pressure all subsequent timed commands, + * assuming that the subsequent commands occur within the time-window. + * If the time spec is late, the command will be activated upon arrival. + * + * \param time_spec the time at which the next command will activate + * \param mboard which motherboard to set the config + */ + virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = 0) = 0; + + /*! + * Clear the command time so future commands are sent ASAP. + * + * \param mboard which motherboard to set the config + */ + virtual void clear_command_time(size_t mboard = 0) = 0; + /*! * Get access to the underlying uhd dboard iface object. * \return the dboard_iface object diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc index cb17119b7..05237100c 100644 --- a/gr-uhd/lib/gr_uhd_usrp_sink.cc +++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc @@ -56,7 +56,7 @@ public: gr_make_io_signature(0, 0, 0) ), _stream_args(stream_args), - _nchan(stream_args.channels.size()) + _nchan(std::max(1, stream_args.channels.size())) { if (stream_args.cpu_format == "fc32") _type = boost::make_shared(uhd::io_type_t::COMPLEX_FLOAT32); if (stream_args.cpu_format == "sc16") _type = boost::make_shared(uhd::io_type_t::COMPLEX_INT16); @@ -254,6 +254,22 @@ public: return _dev->set_time_unknown_pps(time_spec); } + void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard){ + #ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API + return _dev->set_command_time(time_spec, mboard); + #else + throw std::runtime_error("not implemented in this version"); + #endif + } + + void clear_command_time(size_t mboard){ + #ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API + return _dev->clear_command_time(mboard); + #else + throw std::runtime_error("not implemented in this version"); + #endif + } + uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan){ return _dev->get_tx_dboard_iface(chan); } diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc index 421adafe1..953ef6995 100644 --- a/gr-uhd/lib/gr_uhd_usrp_source.cc +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -56,7 +56,7 @@ public: args_to_io_sig(stream_args) ), _stream_args(stream_args), - _nchan(stream_args.channels.size()), + _nchan(std::max(1, stream_args.channels.size())), _stream_now(_nchan == 1), _tag_now(false) { @@ -266,6 +266,22 @@ public: return _dev->set_time_unknown_pps(time_spec); } + void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard){ + #ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API + return _dev->set_command_time(time_spec, mboard); + #else + throw std::runtime_error("not implemented in this version"); + #endif + } + + void clear_command_time(size_t mboard){ + #ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API + return _dev->clear_command_time(mboard); + #else + throw std::runtime_error("not implemented in this version"); + #endif + } + uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan){ return _dev->get_rx_dboard_iface(chan); } @@ -370,10 +386,17 @@ public: outputs.push_back(&buffs[i].front()); } while (true){ + #ifdef GR_UHD_USE_STREAM_API + const size_t bpi = uhd::convert::get_bytes_per_item(_stream_args.cpu_format); + const size_t num_samps = _rx_stream->recv( + outputs, nbytes/bpi, _metadata, 0.0 + ); + #else const size_t num_samps = _dev->get_device()->recv( - outputs, nbytes/_type.size, _metadata, - _type, uhd::device::RECV_MODE_FULL_BUFF, 0.0 + outputs, nbytes/_type->size, _metadata, + *_type, uhd::device::RECV_MODE_FULL_BUFF, 0.0 ); + #endif if (_metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break; } } -- cgit