diff options
Diffstat (limited to 'host/lib/usrp/b200')
-rw-r--r-- | host/lib/usrp/b200/b200_iface.cpp | 34 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_image_loader.cpp | 5 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_impl.cpp | 63 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_io_impl.cpp | 18 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_uart.cpp | 5 |
5 files changed, 65 insertions, 60 deletions
diff --git a/host/lib/usrp/b200/b200_iface.cpp b/host/lib/usrp/b200/b200_iface.cpp index 6f9bdd330..3d969dfa6 100644 --- a/host/lib/usrp/b200/b200_iface.cpp +++ b/host/lib/usrp/b200/b200_iface.cpp @@ -19,7 +19,7 @@ #include "../../utils/ihex.hpp" #include <uhd/config.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/utils/log.hpp> #include <uhd/exception.hpp> #include <boost/functional/hash.hpp> @@ -211,9 +211,10 @@ public: void load_firmware(const std::string filestring, UHD_UNUSED(bool force) = false) { - if (load_img_msg) - UHD_MSG(status) << "Loading firmware image: " - << filestring << "..." << std::flush; + if (load_img_msg) { + UHD_LOGGER_INFO("B200") << "Loading firmware image: " + << filestring << "..."; + } ihex_reader file_reader(filestring); try { @@ -227,7 +228,6 @@ public: throw uhd::io_error(str(boost::format("Could not load firmware: \n%s") % e.what())); } - UHD_MSG(status) << std::endl; //TODO //usrp_set_firmware_hash(hash); //set hash before reset @@ -446,8 +446,10 @@ public: wait_count++; } while(fx3_state != FX3_STATE_FPGA_READY); - if (load_img_msg) UHD_MSG(status) << "Loading FPGA image: " \ - << filestring << "..." << std::flush; + if (load_img_msg) { + UHD_LOGGER_INFO("B200") << "Loading FPGA image: " + << filestring << "..."; + } bytes_to_xfer = 1; ret = fx3_control_write(B200_VREQ_FPGA_START, 0, 0, out_buff, bytes_to_xfer, 1000); @@ -485,15 +487,20 @@ public: else if (nwritten != transfer_count) throw uhd::io_error((boost::format("load_fpga: short write while transferring bitstream to FX3 (expecting: %d, returned: %d)") % transfer_count % nwritten).str()); + const size_t LOG_GRANULARITY = 10; // %. Keep this an integer divisor of 100. if (load_img_msg) { - if (bytes_sent == 0) UHD_MSG(status) << " 0%" << std::flush; - const size_t percent_before = size_t((bytes_sent*100)/file_size); + if (bytes_sent == 0) UHD_LOGGER_DEBUG("B200") << " 0%" << std::flush; + const size_t percent_before = + size_t((bytes_sent*100)/file_size) - + (size_t((bytes_sent*100)/file_size) % LOG_GRANULARITY); bytes_sent += transfer_count; - const size_t percent_after = size_t((bytes_sent*100)/file_size); + const size_t percent_after = + size_t((bytes_sent*100)/file_size) - + (size_t((bytes_sent*100)/file_size) % LOG_GRANULARITY); if (percent_before != percent_after) { - UHD_MSG(status) << "\b\b\b\b" << std::setw(3) << percent_after << "%" << std::flush; + UHD_LOGGER_DEBUG("B200") << std::setw(3) << percent_after << "%"; } } } @@ -515,8 +522,9 @@ public: usrp_set_fpga_hash(hash); - if (load_img_msg) - UHD_MSG(status) << "\b\b\b\b done" << std::endl; + if (load_img_msg) { + UHD_LOGGER_DEBUG("B200") << "FPGA image loaded!"; + } return 0; } diff --git a/host/lib/usrp/b200/b200_image_loader.cpp b/host/lib/usrp/b200/b200_image_loader.cpp index b9c2c0caf..af79a59fc 100644 --- a/host/lib/usrp/b200/b200_image_loader.cpp +++ b/host/lib/usrp/b200/b200_image_loader.cpp @@ -16,7 +16,6 @@ // #include <boost/assign.hpp> -#include <boost/foreach.hpp> #include <boost/lexical_cast.hpp> #include <uhd/exception.hpp> @@ -45,7 +44,7 @@ static b200_iface::sptr get_b200_iface(const image_loader::image_loader_args_t& mboard_eeprom_t eeprom; // Internal use if(dev_handles.size() > 0){ - BOOST_FOREACH(usb_device_handle::sptr dev_handle, dev_handles){ + for(usb_device_handle::sptr dev_handle: dev_handles){ if(dev_handle->firmware_loaded()){ iface = b200_iface::make(usb_control::make(dev_handle,0)); eeprom = mboard_eeprom_t(*iface, "B200"); @@ -74,7 +73,7 @@ static b200_iface::sptr get_b200_iface(const image_loader::image_loader_args_t& std::string err_msg = "Could not resolve given args to a single B2XX device.\n" "Applicable devices:\n"; - BOOST_FOREACH(usb_device_handle::sptr dev_handle, applicable_dev_handles){ + for(usb_device_handle::sptr dev_handle: applicable_dev_handles){ eeprom = mboard_eeprom_t(*b200_iface::make(usb_control::make(dev_handle,0)), "B200"); err_msg += str(boost::format(" * %s (serial=%s)\n") % B2XX_STR_NAMES.get(get_b200_product(dev_handle, mb_eeprom), "B2XX") diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index e2a0e0b70..a513e1336 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -19,7 +19,7 @@ #include "b200_regs.hpp" #include <uhd/config.hpp> #include <uhd/transport/usb_control.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/utils/cast.hpp> #include <uhd/exception.hpp> #include <uhd/utils/static.hpp> @@ -60,7 +60,7 @@ public: } } clocking_mode_t get_clocking_mode() { - return AD9361_XTAL_N_CLK_PATH; + return clocking_mode_t::AD9361_XTAL_N_CLK_PATH; } digital_interface_mode_t get_digital_interface_mode() { return AD9361_DDR_FDD_LVCMOS; @@ -88,7 +88,7 @@ public: } } clocking_mode_t get_clocking_mode() { - return AD9361_XTAL_N_CLK_PATH; + return clocking_mode_t::AD9361_XTAL_N_CLK_PATH; } digital_interface_mode_t get_digital_interface_mode() { return AD9361_DDR_FDD_LVCMOS; @@ -172,7 +172,7 @@ static device_addrs_t b200_find(const device_addr_t &hint) //Return an empty list of addresses when an address or resource is specified, //since an address and resource is intended for a different, non-USB, device. - BOOST_FOREACH(device_addr_t hint_i, separate_device_addr(hint)) { + for(device_addr_t hint_i: separate_device_addr(hint)) { if (hint_i.has_key("addr") || hint_i.has_key("resource")) return b200_addrs; } @@ -182,7 +182,7 @@ static device_addrs_t b200_find(const device_addr_t &hint) // so that re-enumeration after fw load can occur successfully. // This requirement is a courtesy of libusb1.0 on windows. size_t found = 0; - BOOST_FOREACH(usb_device_handle::sptr handle, get_b200_device_handles(hint)) { + for(usb_device_handle::sptr handle: get_b200_device_handles(hint)) { //extract the firmware path for the b200 std::string b200_fw_image; try{ @@ -190,10 +190,10 @@ static device_addrs_t b200_find(const device_addr_t &hint) b200_fw_image = uhd::find_image_path(b200_fw_image, STR(UHD_IMAGES_DIR)); // FIXME } catch(uhd::exception &e){ - UHD_MSG(warning) << e.what(); + UHD_LOGGER_WARNING("B200") << e.what(); return b200_addrs; } - UHD_LOG << "the firmware image: " << b200_fw_image << std::endl; + UHD_LOGGER_DEBUG("B200") << "the firmware image: " << b200_fw_image ; usb_control::sptr control; try{control = usb_control::make(handle, 0);} @@ -213,7 +213,7 @@ static device_addrs_t b200_find(const device_addr_t &hint) //search for the device until found or timeout while (boost::get_system_time() < timeout_time and b200_addrs.empty() and found != 0) { - BOOST_FOREACH(usb_device_handle::sptr handle, get_b200_device_handles(hint)) + for(usb_device_handle::sptr handle: get_b200_device_handles(hint)) { usb_control::sptr control; try{control = usb_control::make(handle, 0);} @@ -261,7 +261,7 @@ static device::sptr b200_make(const device_addr_t &device_addr) return device::sptr(new b200_impl(device_addr, handle)); } catch (const uhd::usb_error &) { - UHD_MSG(status) << "Detected bad USB state; resetting." << std::endl; + UHD_LOGGER_INFO("B200") << "Detected bad USB state; resetting." ; libusb::device_handle::sptr dev_handle(libusb::device_handle::get_cached_handle( boost::static_pointer_cast<libusb::special_handle>(handle)->get_device() )); @@ -344,7 +344,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s std::vector<usb_device_handle::sptr> device_list = usb_device_handle::get_device_list(vid_pid_pair_list); //locate the matching handle in the device list - BOOST_FOREACH(usb_device_handle::sptr dev_handle, device_list) { + for(usb_device_handle::sptr dev_handle: device_list) { try { if (dev_handle->get_serial() == device_addr["serial"]){ handle = dev_handle; @@ -390,7 +390,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s _revision = boost::lexical_cast<size_t>(mb_eeprom["revision"]); } - UHD_MSG(status) << "Detected Device: " << B2XX_STR_NAMES[_product] << std::endl; + UHD_LOGGER_INFO("B200") << "Detected Device: " << B2XX_STR_NAMES[_product] ; _gpsdo_capable = (not (_product == B200MINI or _product == B205MINI)); @@ -437,7 +437,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s // Create control transport //////////////////////////////////////////////////////////////////// uint8_t usb_speed = _iface->get_usb_speed(); - UHD_MSG(status) << "Operating over USB " << (int) usb_speed << "." << std::endl; + UHD_LOGGER_INFO("B200") << "Operating over USB " << (int) usb_speed << "." ; const std::string min_frame_size = (usb_speed == 3) ? "1024" : "512"; device_addr_t ctrl_xport_args; @@ -488,19 +488,18 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s if ((_local_ctrl->peek32(RB32_CORE_STATUS) & 0xff) != B200_GPSDO_ST_NONE) { - UHD_MSG(status) << "Detecting internal GPSDO.... " << std::flush; + UHD_LOGGER_INFO("B200") << "Detecting internal GPSDO.... " << std::flush; try { _gps = gps_ctrl::make(_async_task_data->gpsdo_uart); } catch(std::exception &e) { - UHD_MSG(error) << "An error occurred making GPSDO control: " << e.what() << std::endl; + UHD_LOGGER_ERROR("B200") << "An error occurred making GPSDO control: " << e.what(); } if (_gps and _gps->gps_detected()) { - //UHD_MSG(status) << "found" << std::endl; - BOOST_FOREACH(const std::string &name, _gps->get_sensors()) + for(const std::string &name: _gps->get_sensors()) { _tree->create<sensor_value_t>(mb_path / "sensors" / name) .set_publisher(boost::bind(&gps_ctrl::get_sensor, _gps, name)); @@ -553,7 +552,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //////////////////////////////////////////////////////////////////// // Init codec - turns on clocks //////////////////////////////////////////////////////////////////// - UHD_MSG(status) << "Initialize CODEC control..." << std::endl; + UHD_LOGGER_INFO("B200") << "Initialize CODEC control..." ; ad9361_params::sptr client_settings; if (_product == B200MINI or _product == B205MINI) { client_settings = boost::make_shared<b2xxmini_ad9361_client_t>(); @@ -610,7 +609,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //////////////////////////////////////////////////////////////////// // setup radio control //////////////////////////////////////////////////////////////////// - UHD_MSG(status) << "Initialize Radio control..." << std::endl; + UHD_LOGGER_INFO("B200") << "Initialize Radio control..." ; const size_t num_radio_chains = ((_local_ctrl->peek32(RB32_CORE_STATUS) >> 8) & 0xff); UHD_ASSERT_THROW(num_radio_chains > 0); UHD_ASSERT_THROW(num_radio_chains <= 2); @@ -621,7 +620,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s this->setup_radio(i); //now test each radio module's connection to the codec interface - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) { _codec_mgr->loopback_self_test( boost::bind( @@ -641,7 +640,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s .add_coerced_subscriber(boost::bind(&b200_impl::sync_times, this)); _tree->create<time_spec_t>(mb_path / "time" / "pps") .set_publisher(boost::bind(&time_core_3000::get_time_last_pps, _radio_perifs[0].time64)); - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) { _tree->access<time_spec_t>(mb_path / "time" / "pps") .add_coerced_subscriber(boost::bind(&time_core_3000::set_time_next_pps, perif.time64, _1)); @@ -670,7 +669,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s // front panel gpio //////////////////////////////////////////////////////////////////// _radio_perifs[0].fp_gpio = gpio_atr_3000::make(_radio_perifs[0].ctrl, TOREG(SR_FP_GPIO), RB32_FP_GPIO); - BOOST_FOREACH(const gpio_attr_map_t::value_type attr, gpio_attr_map) + for(const gpio_attr_map_t::value_type attr: gpio_attr_map) { _tree->create<uint32_t>(mb_path / "gpio" / "FP0" / attr.second) .set(0) @@ -692,7 +691,7 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //////////////////////////////////////////////////////////////////// // Init the clock rate and the auto mcr appropriately if (not device_addr.has_key("master_clock_rate")) { - UHD_MSG(status) << "Setting master clock rate selection to 'automatic'." << std::endl; + UHD_LOGGER_INFO("B200") << "Setting master clock rate selection to 'automatic'." ; } // We can automatically choose a master clock rate, but not if the user specifies one const double default_tick_rate = device_addr.cast<double>("master_clock_rate", ad936x_manager::DEFAULT_TICK_RATE); @@ -701,11 +700,11 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s //subdev spec contains full width of selections subdev_spec_t rx_spec, tx_spec; - BOOST_FOREACH(const std::string &fe, _tree->list(mb_path / "dboards" / "A" / "rx_frontends")) + for(const std::string &fe: _tree->list(mb_path / "dboards" / "A" / "rx_frontends")) { rx_spec.push_back(subdev_spec_pair_t("A", fe)); } - BOOST_FOREACH(const std::string &fe, _tree->list(mb_path / "dboards" / "A" / "tx_frontends")) + for(const std::string &fe: _tree->list(mb_path / "dboards" / "A" / "tx_frontends")) { tx_spec.push_back(subdev_spec_pair_t("A", fe)); } @@ -830,7 +829,7 @@ void b200_impl::setup_radio(const size_t dspno) // create RF frontend interfacing //////////////////////////////////////////////////////////////////// static const std::vector<direction_t> dirs = boost::assign::list_of(RX_DIRECTION)(TX_DIRECTION); - BOOST_FOREACH(direction_t dir, dirs) { + for(direction_t dir: dirs) { const std::string x = (dir == RX_DIRECTION) ? "rx" : "tx"; const std::string key = std::string(((dir == RX_DIRECTION) ? "RX" : "TX")) + std::string(((dspno == _fe1) ? "1" : "2")); const fs_path rf_fe_path @@ -874,7 +873,7 @@ void b200_impl::setup_radio(const size_t dspno) void b200_impl::register_loopback_self_test(wb_iface::sptr iface) { bool test_fail = false; - UHD_MSG(status) << "Performing register loopback test... " << std::flush; + UHD_LOGGER_INFO("B200") << "Performing register loopback test... " << std::flush; size_t hash = size_t(time(NULL)); for (size_t i = 0; i < 100; i++) { @@ -883,7 +882,7 @@ void b200_impl::register_loopback_self_test(wb_iface::sptr iface) test_fail = iface->peek32(RB32_TEST) != uint32_t(hash); if (test_fail) break; //exit loop on any failure } - UHD_MSG(status) << ((test_fail)? "fail" : "pass") << std::endl; + UHD_LOGGER_INFO("B200") << ((test_fail)? "fail" : "pass") ; } /*********************************************************************** @@ -919,20 +918,20 @@ void b200_impl::enforce_tick_rate_limits(size_t chan_count, double tick_rate, co double b200_impl::set_tick_rate(const double new_tick_rate) { - UHD_MSG(status) << (boost::format("Asking for clock rate %.6f MHz... ") % (new_tick_rate/1e6)) << std::flush; + UHD_LOGGER_INFO("B200") << (boost::format("Asking for clock rate %.6f MHz... ") % (new_tick_rate/1e6)) << std::flush; check_tick_rate_with_current_streamers(new_tick_rate); // Defined in b200_io_impl.cpp // Make sure the clock rate is actually changed before doing // the full Monty of setting regs and loopback tests etc. if (std::abs(new_tick_rate - _tick_rate) < 1.0) { - UHD_MSG(status) << "OK" << std::endl; + UHD_LOGGER_INFO("B200") << "OK" ; return _tick_rate; } _tick_rate = _codec_ctrl->set_clock_rate(new_tick_rate); - UHD_MSG(status) << std::endl << (boost::format("Actually got clock rate %.6f MHz.") % (_tick_rate/1e6)) << std::endl; + UHD_LOGGER_INFO("B200") << (boost::format("Actually got clock rate %.6f MHz.") % (_tick_rate/1e6)) ; - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) { perif.time64->set_tick_rate(_tick_rate); perif.time64->self_test(); @@ -1088,7 +1087,7 @@ void b200_impl::update_time_source(const std::string &source) void b200_impl::set_time(const uhd::time_spec_t& t) { - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) perif.time64->set_time_sync(t); _local_ctrl->poke32(TOREG(SR_CORE_SYNC), 1 << 2 | uint32_t(_time_source)); _local_ctrl->poke32(TOREG(SR_CORE_SYNC), _time_source); diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp index 0a00b9402..7366b06f5 100644 --- a/host/lib/usrp/b200/b200_io_impl.cpp +++ b/host/lib/usrp/b200/b200_io_impl.cpp @@ -45,7 +45,7 @@ void b200_impl::check_tick_rate_with_current_streamers(double rate) size_t b200_impl::max_chan_count(const std::string &direction /* = "" */) { size_t max_count = 0; - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) { if ((direction == "RX" or direction.empty()) and not perif.rx_streamer.expired()) { boost::shared_ptr<sph::recv_packet_streamer> rx_streamer = @@ -97,7 +97,7 @@ void b200_impl::set_auto_tick_rate( for (int i = 0; i < 2; i++) { // Loop through rx and tx std::string dir = (i == 0) ? "tx" : "rx"; // We assume all 'set' DSPs are being used. - BOOST_FOREACH(const std::string &dsp_no, _tree->list(str(boost::format("/mboards/0/%s_dsps") % dir))) { + for(const std::string &dsp_no: _tree->list(str(boost::format("/mboards/0/%s_dsps") % dir))) { fs_path dsp_path = str(boost::format("/mboards/0/%s_dsps/%s") % dir % dsp_no); if (dsp_path == tree_dsp_path) { continue; @@ -135,9 +135,9 @@ void b200_impl::set_auto_tick_rate( _tree->access<double>("/mboards/0/tick_rate").set(new_rate); } } catch (const uhd::value_error &) { - UHD_MSG(warning) - << "Cannot automatically determine an appropriate tick rate for these sampling rates." << std::endl - << "Consider using different sampling rates, or manually specify a suitable master clock rate." << std::endl; + UHD_LOGGER_WARNING("B200") + << "Cannot automatically determine an appropriate tick rate for these sampling rates." + << "Consider using different sampling rates, or manually specify a suitable master clock rate." ; return; // Let the others handle this } } @@ -146,14 +146,14 @@ void b200_impl::update_tick_rate(const double new_tick_rate) { check_tick_rate_with_current_streamers(new_tick_rate); - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) { boost::shared_ptr<sph::recv_packet_streamer> my_streamer = boost::dynamic_pointer_cast<sph::recv_packet_streamer>(perif.rx_streamer.lock()); if (my_streamer) my_streamer->set_tick_rate(new_tick_rate); perif.framer->set_tick_rate(new_tick_rate); } - BOOST_FOREACH(radio_perifs_t &perif, _radio_perifs) + for(radio_perifs_t &perif: _radio_perifs) { boost::shared_ptr<sph::send_packet_streamer> my_streamer = boost::dynamic_pointer_cast<sph::send_packet_streamer>(perif.tx_streamer.lock()); @@ -356,7 +356,7 @@ boost::optional<uhd::msg_task::msg_type_t> b200_impl::handle_async_task( } catch(const std::exception &ex) { - UHD_MSG(error) << "Error parsing ctrl packet: " << ex.what() << std::endl; + UHD_LOGGER_ERROR("B200") << "Error parsing ctrl packet: " << ex.what(); break; } @@ -370,7 +370,7 @@ boost::optional<uhd::msg_task::msg_type_t> b200_impl::handle_async_task( //doh! default: - UHD_MSG(error) << "Got a ctrl packet with unknown SID " << sid << std::endl; + UHD_LOGGER_ERROR("B200") << "Got a ctrl packet with unknown SID " << sid; } return boost::none; } diff --git a/host/lib/usrp/b200/b200_uart.cpp b/host/lib/usrp/b200/b200_uart.cpp index 3c49ebf2a..143600c51 100644 --- a/host/lib/usrp/b200/b200_uart.cpp +++ b/host/lib/usrp/b200/b200_uart.cpp @@ -20,10 +20,9 @@ #include <uhd/transport/bounded_buffer.hpp> #include <uhd/transport/vrt_if_packet.hpp> #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/types/time_spec.hpp> #include <uhd/exception.hpp> -#include <boost/foreach.hpp> using namespace uhd; using namespace uhd::transport; @@ -69,7 +68,7 @@ struct b200_uart_impl : b200_uart void write_uart(const std::string &buff) { - BOOST_FOREACH(const char ch, buff) + for(const char ch: buff) { this->send_char(ch); } |