diff options
Diffstat (limited to 'host/lib/usrp/usrp1/io_impl.cpp')
| -rw-r--r-- | host/lib/usrp/usrp1/io_impl.cpp | 33 | 
1 files changed, 18 insertions, 15 deletions
| diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp index 920023dad..7cb38548f 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -22,7 +22,7 @@  #include "../../transport/super_send_packet_handler.hpp"  #include "usrp1_calc_mux.hpp"  #include "usrp1_impl.hpp" -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp>  #include <uhd/utils/tasks.hpp>  #include <uhd/utils/safe_call.hpp>  #include <uhd/transport/bounded_buffer.hpp> @@ -32,6 +32,7 @@  #include <boost/bind.hpp>  #include <boost/format.hpp>  #include <boost/make_shared.hpp> +#include <atomic>  #define bmFR_RX_FORMAT_SHIFT_SHIFT 0  #define bmFR_RX_FORMAT_WIDTH_SHIFT 4 @@ -147,12 +148,14 @@ struct usrp1_impl::io_impl{      io_impl(zero_copy_if::sptr data_transport):          data_transport(data_transport),          curr_buff(offset_send_buffer(data_transport->get_send_buff())), -        omsb(boost::bind(&usrp1_impl::io_impl::commit_send_buff, this, _1, _2, _3)) +        omsb(boost::bind(&usrp1_impl::io_impl::commit_send_buff, this, _1, _2, _3)), +        vandal_loop_exit(false)      {          /* NOP */      }      ~io_impl(void){ +        vandal_loop_exit = true;          UHD_SAFE_CALL(flush_send_buff();)      } @@ -175,6 +178,7 @@ struct usrp1_impl::io_impl{          return omsb.get_new(curr_buff, next_buff);      } +    std::atomic<bool> vandal_loop_exit;      task::sptr vandal_task;      boost::system_time last_send_time;  }; @@ -247,7 +251,7 @@ void usrp1_impl::io_init(void){      //create a new vandal thread to poll xerflow conditions      _io_impl->vandal_task = task::make(boost::bind( -        &usrp1_impl::vandal_conquest_loop, this +        &usrp1_impl::vandal_conquest_loop, this, std::ref(_io_impl->vandal_loop_exit)      ));  } @@ -271,7 +275,7 @@ void usrp1_impl::tx_stream_on_off(bool enb){   * On an overflow, interleave an inline message into recv and print.   * This procedure creates "soft" inline and async user messages.   */ -void usrp1_impl::vandal_conquest_loop(void){ +void usrp1_impl::vandal_conquest_loop(std::atomic<bool> &exit_loop){      //initialize the async metadata      async_metadata_t async_metadata; @@ -285,7 +289,7 @@ void usrp1_impl::vandal_conquest_loop(void){      inline_metadata.error_code = rx_metadata_t::ERROR_CODE_OVERFLOW;      //start the polling loop... -    try{ while (not boost::this_thread::interruption_requested()){ +    try{ while (not exit_loop){          uint8_t underflow = 0, overflow = 0;          //shutoff transmit if it has been too long since send() was called @@ -305,19 +309,18 @@ void usrp1_impl::vandal_conquest_loop(void){          if (_tx_enabled and underflow){              async_metadata.time_spec = _soft_time_ctrl->get_time();              _soft_time_ctrl->get_async_queue().push_with_pop_on_full(async_metadata); -            UHD_MSG(fastpath) << "U"; +            UHD_LOG_FASTPATH("U")          }          if (_rx_enabled and overflow){              inline_metadata.time_spec = _soft_time_ctrl->get_time();              _soft_time_ctrl->get_inline_queue().push_with_pop_on_full(inline_metadata); -            UHD_MSG(fastpath) << "O"; +            UHD_LOG_FASTPATH("O")          }          boost::this_thread::sleep(boost::posix_time::milliseconds(50));      }} -    catch(const boost::thread_interrupted &){} //normal exit condition      catch(const std::exception &e){ -        UHD_MSG(error) << "The vandal caught an unexpected exception " << e.what() << std::endl; +        UHD_LOGGER_ERROR("USRP1") << "The vandal caught an unexpected exception " << e.what() ;      }  } @@ -439,7 +442,7 @@ void usrp1_impl::update_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){      //set the mux and set the number of rx channels      std::vector<mapping_pair_t> mapping; -    BOOST_FOREACH(const subdev_spec_pair_t &pair, spec){ +    for(const subdev_spec_pair_t &pair:  spec){          const std::string conn = _tree->access<std::string>(str(boost::format(              "/mboards/0/dboards/%s/rx_frontends/%s/connection"          ) % pair.db_name % pair.sd_name)).get(); @@ -459,7 +462,7 @@ void usrp1_impl::update_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){      //set the mux and set the number of tx channels      std::vector<mapping_pair_t> mapping; -    BOOST_FOREACH(const subdev_spec_pair_t &pair, spec){ +    for(const subdev_spec_pair_t &pair:  spec){          const std::string conn = _tree->access<std::string>(str(boost::format(              "/mboards/0/dboards/%s/tx_frontends/%s/connection"          ) % pair.db_name % pair.sd_name)).get(); @@ -500,11 +503,11 @@ double usrp1_impl::update_rx_samp_rate(size_t dspno, const double samp_rate){      const size_t div = this->has_rx_halfband()? 2 : 1;      const size_t rate = boost::math::iround(_master_clock_rate/this->get_rx_dsp_host_rates().clip(samp_rate, true)); -    if (rate < 8 and this->has_rx_halfband()) UHD_MSG(warning) << +    if (rate < 8 and this->has_rx_halfband()) UHD_LOGGER_WARNING("USRP1") <<          "USRP1 cannot achieve decimations below 8 when the half-band filter is present.\n"          "The usrp1_fpga_4rx.rbf file is a special FPGA image without RX half-band filters.\n"          "To load this image, set the device address key/value pair: fpga=usrp1_fpga_4rx.rbf\n" -    << std::endl; +    ;      if (dspno == 0){ //only care if dsp0 is set since its homogeneous          bool s = this->disable_rx(); @@ -548,10 +551,10 @@ double usrp1_impl::update_tx_samp_rate(size_t dspno, const double samp_rate){  void usrp1_impl::update_rates(void){      const fs_path mb_path = "/mboards/0";      this->update_tick_rate(_master_clock_rate); -    BOOST_FOREACH(const std::string &name, _tree->list(mb_path / "rx_dsps")){ +    for(const std::string &name:  _tree->list(mb_path / "rx_dsps")){          _tree->access<double>(mb_path / "rx_dsps" / name / "rate" / "value").update();      } -    BOOST_FOREACH(const std::string &name, _tree->list(mb_path / "tx_dsps")){ +    for(const std::string &name:  _tree->list(mb_path / "tx_dsps")){          _tree->access<double>(mb_path / "tx_dsps" / name / "rate" / "value").update();      }  } | 
