diff options
Diffstat (limited to 'host/lib/usrp/usrp2/usrp2_impl.cpp')
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.cpp | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index ee2434fab..7d8f59fb8 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -19,7 +19,7 @@ #include "fw_common.h" #include "apply_corrections.hpp" #include <uhd/utils/log.hpp> -#include <uhd/utils/msg.hpp> + #include <uhd/exception.hpp> #include <uhd/transport/if_addrs.hpp> #include <uhd/transport/udp_zero_copy.hpp> @@ -29,7 +29,6 @@ #include <uhd/utils/byteswap.hpp> #include <uhd/utils/safe_call.hpp> #include <boost/format.hpp> -#include <boost/foreach.hpp> #include <boost/lexical_cast.hpp> #include <boost/bind.hpp> #include <boost/assign/list_of.hpp> @@ -54,7 +53,7 @@ device_addrs_t usrp2_find(const device_addr_t &hint_){ if (hints.size() > 1){ device_addrs_t found_devices; std::string error_msg; - BOOST_FOREACH(const device_addr_t &hint_i, hints){ + for(const device_addr_t &hint_i: hints){ device_addrs_t found_devices_i = usrp2_find(hint_i); if (found_devices_i.size() != 1) error_msg += str(boost::format( "Could not resolve device hint \"%s\" to a single device." @@ -81,7 +80,7 @@ device_addrs_t usrp2_find(const device_addr_t &hint_){ //if no address was specified, send a broadcast on each interface if (not hint.has_key("addr")){ - BOOST_FOREACH(const if_addrs_t &if_addrs, get_if_addrs()){ + for(const if_addrs_t &if_addrs: get_if_addrs()){ //avoid the loopback device if (if_addrs.inet == asio::ip::address_v4::loopback().to_string()) continue; @@ -106,7 +105,7 @@ device_addrs_t usrp2_find(const device_addr_t &hint_){ udp_transport = udp_simple::make_broadcast(hint["addr"], BOOST_STRINGIZE(USRP2_UDP_CTRL_PORT)); } catch(const std::exception &e){ - UHD_MSG(error) << boost::format("Cannot open UDP transport on %s\n%s") % hint["addr"] % e.what() << std::endl; + UHD_LOGGER_ERROR("USRP2") << boost::format("Cannot open UDP transport on %s\n%s") % hint["addr"] % e.what() ; return usrp2_addrs; //dont throw, but return empty address so caller can insert } @@ -120,11 +119,11 @@ device_addrs_t usrp2_find(const device_addr_t &hint_){ } catch(const std::exception &ex) { - UHD_MSG(error) << "USRP2 Network discovery error " << ex.what() << std::endl; + UHD_LOGGER_ERROR("USRP2") << "USRP2 Network discovery error " << ex.what() ; } catch(...) { - UHD_MSG(error) << "USRP2 Network discovery unknown error " << std::endl; + UHD_LOGGER_ERROR("USRP2") << "USRP2 Network discovery unknown error " ; } //loop and recieve until the timeout @@ -284,7 +283,7 @@ static zero_copy_if::sptr make_xport( //only copy hints that contain the filter word device_addr_t filtered_hints; - BOOST_FOREACH(const std::string &key, hints.keys()){ + for(const std::string &key: hints.keys()){ if (key.find(filter) == std::string::npos) continue; filtered_hints[key] = hints[key]; } @@ -319,7 +318,7 @@ static zero_copy_if::sptr make_xport( usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : device_addr(_device_addr) { - UHD_MSG(status) << "Opening a USRP2/N-Series device..." << std::endl; + UHD_LOGGER_INFO("USRP2") << "Opening a USRP2/N-Series device..."; //setup the dsp transport hints (default to a large recv buff) if (not device_addr.has_key("recv_buff_size")){ @@ -356,8 +355,8 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : device_addr["recv_frame_size"] = boost::lexical_cast<std::string>(mtu.recv_mtu); device_addr["send_frame_size"] = boost::lexical_cast<std::string>(mtu.send_mtu); - UHD_MSG(status) << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu << std::endl; - UHD_MSG(status) << boost::format("Current send frame size: %d bytes") % mtu.send_mtu << std::endl; + UHD_LOGGER_INFO("USRP2") << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu; + UHD_LOGGER_INFO("USRP2") << boost::format("Current send frame size: %d bytes") % mtu.send_mtu; } catch(const uhd::not_implemented_error &){ //just ignore this error, makes older fw work... @@ -412,7 +411,7 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : // handle case where the MB EEPROM is not programmed if (fpga_major == USRP2_FPGA_COMPAT_NUM or fpga_major == N200_FPGA_COMPAT_NUM) { - UHD_MSG(warning) << "Unable to identify device - assuming USRP2/N-Series device" << std::endl; + UHD_LOGGER_WARNING("USRP2") << "Unable to identify device - assuming USRP2/N-Series device" ; expected_fpga_compat_num = fpga_major; } } @@ -433,19 +432,19 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : //////////////////////////////////////////////////////////////// // construct transports for RX and TX DSPs //////////////////////////////////////////////////////////////// - UHD_LOG << "Making transport for RX DSP0..." << std::endl; + UHD_LOGGER_DEBUG("USRP2") << "Making transport for RX DSP0..." ; _mbc[mb].rx_dsp_xports.push_back(make_xport( addr, BOOST_STRINGIZE(USRP2_UDP_RX_DSP0_PORT), device_args_i, "recv" )); - UHD_LOG << "Making transport for RX DSP1..." << std::endl; + UHD_LOGGER_DEBUG("USRP2") << "Making transport for RX DSP1..." ; _mbc[mb].rx_dsp_xports.push_back(make_xport( addr, BOOST_STRINGIZE(USRP2_UDP_RX_DSP1_PORT), device_args_i, "recv" )); - UHD_LOG << "Making transport for TX DSP0..." << std::endl; + UHD_LOGGER_DEBUG("USRP2") << "Making transport for TX DSP0..." ; _mbc[mb].tx_dsp_xport = make_xport( addr, BOOST_STRINGIZE(USRP2_UDP_TX_DSP0_PORT), device_args_i, "send" ); - UHD_LOG << "Making transport for Control..." << std::endl; + UHD_LOGGER_DEBUG("USRP2") << "Making transport for Control..." ; _mbc[mb].fifo_ctrl_xport = make_xport( addr, BOOST_STRINGIZE(USRP2_UDP_FIFO_CRTL_PORT), device_addr_t(), "" ); @@ -536,18 +535,18 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : //otherwise if not disabled, look for the internal GPSDO if (_mbc[mb].iface->peekfw(U2_FW_REG_HAS_GPSDO) != dont_look_for_gpsdo) { - UHD_MSG(status) << "Detecting internal GPSDO.... " << std::flush; + UHD_LOGGER_INFO("USRP2") << "Detecting internal GPSDO.... "; try{ _mbc[mb].gps = gps_ctrl::make(udp_simple::make_uart(udp_simple::make_connected( addr, BOOST_STRINGIZE(USRP2_UDP_UART_GPS_PORT) ))); } catch(std::exception &e){ - UHD_MSG(error) << "An error occurred making GPSDO control: " << e.what() << std::endl; + UHD_LOGGER_ERROR("USRP2") << "An error occurred making GPSDO control: " << e.what() ; } if (_mbc[mb].gps and _mbc[mb].gps->gps_detected()) { - BOOST_FOREACH(const std::string &name, _mbc[mb].gps->get_sensors()) + for(const std::string &name: _mbc[mb].gps->get_sensors()) { _tree->create<sensor_value_t>(mb_path / "sensors" / name) .set_publisher(boost::bind(&gps_ctrl::get_sensor, _mbc[mb].gps, name)); @@ -743,12 +742,12 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : //bind frontend corrections to the dboard freq props const fs_path db_tx_fe_path = mb_path / "dboards" / "A" / "tx_frontends"; - BOOST_FOREACH(const std::string &name, _tree->list(db_tx_fe_path)){ + for(const std::string &name: _tree->list(db_tx_fe_path)){ _tree->access<double>(db_tx_fe_path / name / "freq" / "value") .add_coerced_subscriber(boost::bind(&usrp2_impl::set_tx_fe_corrections, this, mb, _1)); } const fs_path db_rx_fe_path = mb_path / "dboards" / "A" / "rx_frontends"; - BOOST_FOREACH(const std::string &name, _tree->list(db_rx_fe_path)){ + for(const std::string &name: _tree->list(db_rx_fe_path)){ _tree->access<double>(db_rx_fe_path / name / "freq" / "value") .add_coerced_subscriber(boost::bind(&usrp2_impl::set_rx_fe_corrections, this, mb, _1)); } @@ -759,14 +758,14 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : //do some post-init tasks this->update_rates(); - BOOST_FOREACH(const std::string &mb, _mbc.keys()){ + for(const std::string &mb: _mbc.keys()){ fs_path root = "/mboards/" + mb; //reset cordic rates and their properties to zero - BOOST_FOREACH(const std::string &name, _tree->list(root / "rx_dsps")){ + for(const std::string &name: _tree->list(root / "rx_dsps")){ _tree->access<double>(root / "rx_dsps" / name / "freq" / "value").set(0.0); } - BOOST_FOREACH(const std::string &name, _tree->list(root / "tx_dsps")){ + for(const std::string &name: _tree->list(root / "tx_dsps")){ _tree->access<double>(root / "tx_dsps" / name / "freq" / "value").set(0.0); } @@ -778,7 +777,7 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : //GPS installed: use external ref, time, and init time spec if (_mbc[mb].gps and _mbc[mb].gps->gps_detected()){ _mbc[mb].time64->enable_gpsdo(); - UHD_MSG(status) << "Setting references to the internal GPSDO" << std::endl; + UHD_LOGGER_INFO("USRP2") << "Setting references to the internal GPSDO" ; _tree->access<std::string>(root / "time_source/value").set("gpsdo"); _tree->access<std::string>(root / "clock_source/value").set("gpsdo"); } @@ -787,7 +786,7 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) : } usrp2_impl::~usrp2_impl(void){UHD_SAFE_CALL( - BOOST_FOREACH(const std::string &mb, _mbc.keys()){ + for(const std::string &mb: _mbc.keys()){ _mbc[mb].tx_dsp->set_updates(0, 0); } )} |