aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/b200
diff options
context:
space:
mode:
authorAndrej Rode <andrej.rode@ettus.com>2017-02-07 16:37:25 -0800
committerMartin Braun <martin.braun@ettus.com>2017-02-20 17:13:15 -0800
commit21aad77c9ca07f4271136b9241f5adb00a6bb908 (patch)
tree636ffe3ab2296e9afa661d3a12eb359224cd3254 /host/lib/usrp/b200
parent2b33f2bb4c01d4306fd46f78edf6e355a03e2ed7 (diff)
downloaduhd-21aad77c9ca07f4271136b9241f5adb00a6bb908.tar.gz
uhd-21aad77c9ca07f4271136b9241f5adb00a6bb908.tar.bz2
uhd-21aad77c9ca07f4271136b9241f5adb00a6bb908.zip
utils: introduce new logging API and remove msg API
Diffstat (limited to 'host/lib/usrp/b200')
-rw-r--r--host/lib/usrp/b200/b200_iface.cpp14
-rw-r--r--host/lib/usrp/b200/b200_impl.cpp33
-rw-r--r--host/lib/usrp/b200/b200_io_impl.cpp10
-rw-r--r--host/lib/usrp/b200/b200_uart.cpp2
4 files changed, 29 insertions, 30 deletions
diff --git a/host/lib/usrp/b200/b200_iface.cpp b/host/lib/usrp/b200/b200_iface.cpp
index 6f9bdd330..81752b28f 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>
@@ -212,7 +212,7 @@ public:
void load_firmware(const std::string filestring, UHD_UNUSED(bool force) = false)
{
if (load_img_msg)
- UHD_MSG(status) << "Loading firmware image: "
+ UHD_LOGGER_INFO("B200") << "Loading firmware image: "
<< filestring << "..." << std::flush;
ihex_reader file_reader(filestring);
@@ -227,7 +227,7 @@ public:
throw uhd::io_error(str(boost::format("Could not load firmware: \n%s") % e.what()));
}
- UHD_MSG(status) << std::endl;
+ UHD_LOGGER_INFO("B200") ;
//TODO
//usrp_set_firmware_hash(hash); //set hash before reset
@@ -446,7 +446,7 @@ public:
wait_count++;
} while(fx3_state != FX3_STATE_FPGA_READY);
- if (load_img_msg) UHD_MSG(status) << "Loading FPGA image: " \
+ if (load_img_msg) UHD_LOGGER_INFO("B200") << "Loading FPGA image: " \
<< filestring << "..." << std::flush;
bytes_to_xfer = 1;
@@ -487,13 +487,13 @@ public:
if (load_img_msg)
{
- if (bytes_sent == 0) UHD_MSG(status) << " 0%" << std::flush;
+ if (bytes_sent == 0) UHD_LOGGER_INFO("B200") << " 0%" << std::flush;
const size_t percent_before = size_t((bytes_sent*100)/file_size);
bytes_sent += transfer_count;
const size_t percent_after = size_t((bytes_sent*100)/file_size);
if (percent_before != percent_after)
{
- UHD_MSG(status) << "\b\b\b\b" << std::setw(3) << percent_after << "%" << std::flush;
+ UHD_LOGGER_INFO("B200") << "\b\b\b\b" << std::setw(3) << percent_after << "%" << std::flush;
}
}
}
@@ -516,7 +516,7 @@ public:
usrp_set_fpga_hash(hash);
if (load_img_msg)
- UHD_MSG(status) << "\b\b\b\b done" << std::endl;
+ UHD_LOGGER_INFO("B200") << "\b\b\b\b done" ;
return 0;
}
diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp
index fd87cf24a..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>
@@ -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);}
@@ -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()
));
@@ -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,18 +488,17 @@ 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;
for(const std::string &name: _gps->get_sensors())
{
_tree->create<sensor_value_t>(mb_path / "sensors" / 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);
@@ -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);
@@ -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,18 +918,18 @@ 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)) ;
for(radio_perifs_t &perif: _radio_perifs)
{
diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp
index 09aaff7ed..7366b06f5 100644
--- a/host/lib/usrp/b200/b200_io_impl.cpp
+++ b/host/lib/usrp/b200/b200_io_impl.cpp
@@ -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
}
}
@@ -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 016dd4ca3..143600c51 100644
--- a/host/lib/usrp/b200/b200_uart.cpp
+++ b/host/lib/usrp/b200/b200_uart.cpp
@@ -20,7 +20,7 @@
#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>