summaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/dboard/db_dbsrx2.cpp2
-rw-r--r--host/lib/usrp/gps_ctrl.cpp11
-rw-r--r--host/lib/usrp/multi_usrp.cpp6
-rw-r--r--host/lib/usrp/usrp1/clock_ctrl.cpp8
-rw-r--r--host/lib/usrp/usrp1/codec_ctrl.cpp47
-rw-r--r--host/lib/usrp/usrp1/dsp_impl.cpp6
-rw-r--r--host/lib/usrp/usrp1/io_impl.cpp10
-rw-r--r--host/lib/usrp/usrp1/mboard_impl.cpp30
-rw-r--r--host/lib/usrp/usrp1/usrp1_ctrl.cpp10
-rw-r--r--host/lib/usrp/usrp1/usrp1_iface.cpp23
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp6
-rw-r--r--host/lib/usrp/usrp2/codec_ctrl.cpp6
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp16
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp11
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp10
-rw-r--r--host/lib/usrp/usrp_e100/io_impl.cpp5
-rw-r--r--host/lib/utils/log.cpp3
-rw-r--r--host/lib/utils/msg.cpp8
18 files changed, 108 insertions, 110 deletions
diff --git a/host/lib/usrp/dboard/db_dbsrx2.cpp b/host/lib/usrp/dboard/db_dbsrx2.cpp
index 0769b3aa1..aaced7a5d 100644
--- a/host/lib/usrp/dboard/db_dbsrx2.cpp
+++ b/host/lib/usrp/dboard/db_dbsrx2.cpp
@@ -134,7 +134,7 @@ private:
if (i + start_addr >= status_addr){
_max2112_read_regs.set_reg(i + start_addr, regs_vector[i]);
/*
- if(dbsrx2_debug) std::cerr << boost::format(
+ UHD_LOGV(always) << boost::format(
"DBSRX2: set reg 0x%02x, value 0x%04x"
) % int(i + start_addr) % int(_max2112_read_regs.get_reg(i + start_addr)) << std::endl;
*/
diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp
index de97710f2..3bee26340 100644
--- a/host/lib/usrp/gps_ctrl.cpp
+++ b/host/lib/usrp/gps_ctrl.cpp
@@ -16,6 +16,7 @@
//
#include <uhd/usrp/gps_ctrl.hpp>
+#include <uhd/utils/msg.hpp>
#include <uhd/exception.hpp>
#include <boost/cstdint.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
@@ -67,14 +68,14 @@ public:
//otherwise, we can try some other common baud rates looking to see if a GPS is connected (todo, later)
if((gps_type == GPS_TYPE_NONE) && i_heard_something_weird) {
- std::cout << "GPS invalid reply \"" << reply << "\", assuming none available" << std::endl;
+ UHD_MSG(error) << "GPS invalid reply \"" << reply << "\", assuming none available" << std::endl;
}
bool found_gprmc = false;
switch(gps_type) {
case GPS_TYPE_JACKSON_LABS:
- std::cout << "Found a Jackson Labs GPS" << std::endl;
+ UHD_MSG(status) << "Found a Jackson Labs GPS" << std::endl;
//issue some setup stuff so it spits out the appropriate data
//none of these should issue replies so we don't bother looking for them
//we have to sleep between commands because the JL device, despite not acking, takes considerable time to process each command.
@@ -93,7 +94,7 @@ public:
// break;
case GPS_TYPE_GENERIC_NMEA:
- if(gps_type == GPS_TYPE_GENERIC_NMEA) std::cout << "Found a generic NMEA GPS device" << std::endl;
+ if(gps_type == GPS_TYPE_GENERIC_NMEA) UHD_MSG(status) << "Found a generic NMEA GPS device" << std::endl;
found_gprmc = false;
//here we loop around looking for a GPRMC packet. if we don't get one, we don't have a usable GPS.
timeout = GPS_TIMEOUT_TRIES;
@@ -106,8 +107,8 @@ public:
boost::this_thread::sleep(boost::posix_time::milliseconds(200));
}
if(!found_gprmc) {
- if(gps_type == GPS_TYPE_JACKSON_LABS) std::cout << "Firefly GPS not locked or warming up." << std::endl;
- else std::cout << "GPS does not output GPRMC packets. Cannot retrieve time." << std::endl;
+ if(gps_type == GPS_TYPE_JACKSON_LABS) UHD_MSG(error) << "Firefly GPS not locked or warming up." << std::endl;
+ else UHD_MSG(error) << "GPS does not output GPRMC packets. Cannot retrieve time." << std::endl;
gps_type = GPS_TYPE_NONE;
}
break;
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp
index 2b32602da..64f82e559 100644
--- a/host/lib/usrp/multi_usrp.cpp
+++ b/host/lib/usrp/multi_usrp.cpp
@@ -18,6 +18,7 @@
#include <uhd/usrp/multi_usrp.hpp>
#include <uhd/usrp/tune_helper.hpp>
#include <uhd/usrp/mboard_iface.hpp>
+#include <uhd/utils/msg.hpp>
#include <uhd/exception.hpp>
#include <uhd/utils/msg.hpp>
#include <uhd/utils/gain_group.hpp>
@@ -29,7 +30,6 @@
#include <boost/thread.hpp>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
-#include <iostream>
#include <cmath>
using namespace uhd;
@@ -188,7 +188,7 @@ public:
}
void set_time_unknown_pps(const time_spec_t &time_spec){
- std::cout << " 1) catch time transition at pps edge" << std::endl;
+ UHD_MSG(status) << " 1) catch time transition at pps edge" << std::endl;
time_spec_t time_start = get_time_now();
time_spec_t time_start_last_pps = get_time_last_pps();
while(true){
@@ -202,7 +202,7 @@ public:
}
}
- std::cout << " 2) set times next pps (synchronously)" << std::endl;
+ UHD_MSG(status) << " 2) set times next pps (synchronously)" << std::endl;
set_time_next_pps(time_spec);
boost::this_thread::sleep(boost::posix_time::seconds(1));
diff --git a/host/lib/usrp/usrp1/clock_ctrl.cpp b/host/lib/usrp/usrp1/clock_ctrl.cpp
index 154e6a316..9edc010dd 100644
--- a/host/lib/usrp/usrp1/clock_ctrl.cpp
+++ b/host/lib/usrp/usrp1/clock_ctrl.cpp
@@ -16,9 +16,9 @@
//
#include "clock_ctrl.hpp"
+#include <uhd/utils/msg.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>
-#include <iostream>
using namespace uhd;
@@ -36,14 +36,14 @@ public:
this->set_master_clock_freq(default_master_clock_rate);
try{
if (not _iface->mb_eeprom["mcr"].empty()){
- std::cout << "Read FPGA clock rate from EEPROM setting." << std::endl;
+ UHD_MSG(status) << "Read FPGA clock rate from EEPROM setting." << std::endl;
const double master_clock_rate = boost::lexical_cast<double>(_iface->mb_eeprom["mcr"]);
- std::cout << boost::format("Initializing FPGA clock to %fMHz...") % (master_clock_rate/1e6) << std::endl;
+ UHD_MSG(status) << boost::format("Initializing FPGA clock to %fMHz...") % (master_clock_rate/1e6) << std::endl;
this->set_master_clock_freq(master_clock_rate);
}
}
catch(const std::exception &e){
- std::cerr << "Error setting FPGA clock rate from EEPROM: " << e.what() << std::endl;
+ UHD_MSG(error) << "Error setting FPGA clock rate from EEPROM: " << e.what() << std::endl;
}
}
diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp
index 9df29da0e..64a93ede5 100644
--- a/host/lib/usrp/usrp1/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp1/codec_ctrl.cpp
@@ -19,6 +19,7 @@
#include "usrp_commands.h"
#include "clock_ctrl.hpp"
#include "ad9862_regs.hpp"
+#include <uhd/utils/log.hpp>
#include <uhd/types/dict.hpp>
#include <uhd/exception.hpp>
#include <uhd/utils/algorithm.hpp>
@@ -28,13 +29,10 @@
#include <boost/tuple/tuple.hpp>
#include <boost/math/special_functions/round.hpp>
#include <boost/assign/list_of.hpp>
-#include <iostream>
#include <iomanip>
using namespace uhd;
-static const bool codec_debug = false;
-
const gain_range_t usrp1_codec_ctrl::tx_pga_gain_range(-20, 0, double(0.1));
const gain_range_t usrp1_codec_ctrl::rx_pga_gain_range(0, 20, 1);
@@ -283,11 +281,10 @@ void usrp1_codec_ctrl_impl::send_reg(boost::uint8_t addr)
{
boost::uint32_t reg = _ad9862_regs.get_write_reg(addr);
- if (codec_debug) {
- std::cout.fill('0');
- std::cout << "codec control write reg: 0x";
- std::cout << std::setw(8) << std::hex << reg << std::endl;
- }
+ UHD_LOGV(often)
+ << "codec control write reg: 0x"
+ << std::setw(8) << std::hex << reg << std::endl
+ ;
_iface->write_spi(_spi_slave,
spi_config_t::EDGE_RISE, reg, 16);
}
@@ -296,20 +293,18 @@ void usrp1_codec_ctrl_impl::recv_reg(boost::uint8_t addr)
{
boost::uint32_t reg = _ad9862_regs.get_read_reg(addr);
- if (codec_debug) {
- std::cout.fill('0');
- std::cout << "codec control read reg: 0x";
- std::cout << std::setw(8) << std::hex << reg << std::endl;
- }
+ UHD_LOGV(often)
+ << "codec control read reg: 0x"
+ << std::setw(8) << std::hex << reg << std::endl
+ ;
boost::uint32_t ret = _iface->read_spi(_spi_slave,
spi_config_t::EDGE_RISE, reg, 16);
- if (codec_debug) {
- std::cout.fill('0');
- std::cout << "codec control read ret: 0x";
- std::cout << std::setw(8) << std::hex << ret << std::endl;
- }
+ UHD_LOGV(often)
+ << "codec control read ret: 0x"
+ << std::setw(8) << std::hex << ret << std::endl
+ ;
_ad9862_regs.set_reg(addr, boost::uint16_t(ret));
}
@@ -392,14 +387,14 @@ void usrp1_codec_ctrl_impl::set_duc_freq(double freq)
double coarse_freq = coarse_tune(codec_rate, freq);
double fine_freq = fine_tune(codec_rate / 4, freq - coarse_freq);
- if (codec_debug) {
- std::cout << "ad9862 tuning result:" << std::endl;
- std::cout << " requested: " << freq << std::endl;
- std::cout << " actual: " << coarse_freq + fine_freq << std::endl;
- std::cout << " coarse freq: " << coarse_freq << std::endl;
- std::cout << " fine freq: " << fine_freq << std::endl;
- std::cout << " codec rate: " << codec_rate << std::endl;
- }
+ UHD_LOG
+ << "ad9862 tuning result:" << std::endl
+ << " requested: " << freq << std::endl
+ << " actual: " << coarse_freq + fine_freq << std::endl
+ << " coarse freq: " << coarse_freq << std::endl
+ << " fine freq: " << fine_freq << std::endl
+ << " codec rate: " << codec_rate << std::endl
+ ;
this->send_reg(20);
this->send_reg(21);
diff --git a/host/lib/usrp/usrp1/dsp_impl.cpp b/host/lib/usrp/usrp1/dsp_impl.cpp
index 8152c4e34..9f1e4975a 100644
--- a/host/lib/usrp/usrp1/dsp_impl.cpp
+++ b/host/lib/usrp/usrp1/dsp_impl.cpp
@@ -17,13 +17,13 @@
#include "usrp1_impl.hpp"
#include "fpga_regs_standard.h"
+#include <uhd/utils/msg.hpp>
#include <uhd/usrp/dsp_utils.hpp>
#include <uhd/usrp/dsp_props.hpp>
#include <boost/bind.hpp>
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/assign/list_of.hpp>
-#include <iostream>
#include <cmath>
using namespace uhd;
@@ -104,7 +104,7 @@ void usrp1_impl::rx_dsp_set(const wax::obj &key_, const wax::obj &val, size_t wh
size_t rate = size_t(_clock_ctrl->get_master_clock_freq() / val.as<double>());
if ((rate & 0x01) || (rate < 4) || (rate > 256)) {
- std::cerr << "Decimation must be even and between 4 and 256"
+ UHD_MSG(error) << "Decimation must be even and between 4 and 256"
<< std::endl;
return;
}
@@ -202,7 +202,7 @@ void usrp1_impl::tx_dsp_set(const wax::obj &key_, const wax::obj &val, size_t wh
size_t rate = size_t(_clock_ctrl->get_master_clock_freq() * 2 / val.as<double>());
if ((rate & 0x01) || (rate < 8) || (rate > 512)) {
- std::cerr << "Interpolation rate must be even and between 8 and 512"
+ UHD_MSG(error) << "Interpolation rate must be even and between 8 and 512"
<< std::endl;
return;
}
diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp
index 8fb639c4a..22d078e70 100644
--- a/host/lib/usrp/usrp1/io_impl.cpp
+++ b/host/lib/usrp/usrp1/io_impl.cpp
@@ -18,6 +18,7 @@
#include "../../transport/vrt_packet_handler.hpp"
#include "usrp_commands.h"
#include "usrp1_impl.hpp"
+#include <uhd/utils/msg.hpp>
#include <uhd/utils/safe_call.hpp>
#include <uhd/utils/thread_priority.hpp>
#include <uhd/transport/bounded_buffer.hpp>
@@ -26,7 +27,6 @@
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
-#include <iostream>
using namespace uhd;
using namespace uhd::usrp;
@@ -306,8 +306,8 @@ size_t usrp1_impl::send(
VRQ_GET_STATUS, 0, GS_TX_UNDERRUN,
&underflow, sizeof(underflow)
);
- if (ret < 0) std::cerr << "USRP: underflow check failed" << std::endl;
- else if (underflow) std::cerr << "U" << std::flush;
+ if (ret < 0) UHD_MSG(error) << "USRP: underflow check failed" << std::endl;
+ else if (underflow) UHD_MSG(fastpath) << "U";
}
return num_samps_sent;
@@ -370,8 +370,8 @@ size_t usrp1_impl::recv(
VRQ_GET_STATUS, 0, GS_RX_OVERRUN,
&overflow, sizeof(overflow)
);
- if (ret < 0) std::cerr << "USRP: overflow check failed" << std::endl;
- else if (overflow) std::cerr << "O" << std::flush;
+ if (ret < 0) UHD_MSG(error) << "USRP: overflow check failed" << std::endl;
+ else if (overflow) UHD_MSG(fastpath) << "O";
}
return num_samps_recvd;
diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp
index aa9ce244b..cd04e7351 100644
--- a/host/lib/usrp/usrp1/mboard_impl.cpp
+++ b/host/lib/usrp/usrp1/mboard_impl.cpp
@@ -20,6 +20,8 @@
#include "fpga_regs_standard.h"
#include "fpga_regs_common.h"
#include "usrp_i2c_addr.h"
+#include <uhd/utils/msg.hpp>
+#include <uhd/utils/log.hpp>
#include <uhd/usrp/misc_utils.hpp>
#include <uhd/usrp/mboard_props.hpp>
#include <uhd/usrp/dboard_props.hpp>
@@ -31,13 +33,10 @@
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
#include <boost/thread/thread.hpp>
-#include <iostream>
using namespace uhd;
using namespace uhd::usrp;
-static const bool usrp1_mboard_verbose = false;
-
/***********************************************************************
* Calculate the RX mux value:
* The I and Q mux values are intentionally reversed to flip I and Q
@@ -231,13 +230,13 @@ void usrp1_impl::mboard_init(void)
// Set default for TX format to 16-bit I&Q
_iface->poke32(FR_TX_FORMAT, 0x00000000);
- if (usrp1_mboard_verbose){
- std::cout << "USRP1 Capabilities" << std::endl;
- std::cout << " number of duc's: " << get_num_ddcs() << std::endl;
- std::cout << " number of ddc's: " << get_num_ducs() << std::endl;
- std::cout << " rx halfband: " << has_rx_halfband() << std::endl;
- std::cout << " tx halfband: " << has_tx_halfband() << std::endl;
- }
+ UHD_LOG
+ << "USRP1 Capabilities" << std::endl
+ << " number of duc's: " << get_num_ddcs() << std::endl
+ << " number of ddc's: " << get_num_ducs() << std::endl
+ << " rx halfband: " << has_rx_halfband() << std::endl
+ << " tx halfband: " << has_tx_halfband() << std::endl
+ ;
}
/***********************************************************************
@@ -331,7 +330,7 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val)
if(key.type() == typeid(std::string)) {
if(key.as<std::string>() == "load_eeprom") {
std::string usrp1_eeprom_image = val.as<std::string>();
- std::cout << "USRP1 EEPROM image: " << usrp1_eeprom_image << std::endl;
+ UHD_MSG(status) << "USRP1 EEPROM image: " << usrp1_eeprom_image << std::endl;
_ctrl_transport->usrp_load_eeprom(val.as<std::string>());
}
return;
@@ -378,10 +377,11 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val)
return;
case MBOARD_PROP_CLOCK_RATE:
- std::cerr << "Helpful message:" << std::endl;
- std::cerr << " I see that you are setting the master clock rate from the API." << std::endl;
- std::cerr << " You may find it more convenient to burn this setting into the EEPROM." << std::endl;
- std::cerr << " See the application notes for USRP1 for further instructions." << std::endl;
+ UHD_MSG(warning)
+ << "I see that you are setting the master clock rate from the API.\n"
+ << "You may find it more convenient to burn this setting into the EEPROM.\n"
+ << "See the application notes for USRP1 for further instructions.\n"
+ ;
_clock_ctrl->set_master_clock_freq(val.as<double>());
return;
diff --git a/host/lib/usrp/usrp1/usrp1_ctrl.cpp b/host/lib/usrp/usrp1/usrp1_ctrl.cpp
index c6be28f5f..96dc5d80c 100644
--- a/host/lib/usrp/usrp1/usrp1_ctrl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_ctrl.cpp
@@ -17,11 +17,11 @@
#include "usrp1_ctrl.hpp"
#include "usrp_commands.h"
+#include <uhd/utils/msg.hpp>
#include <uhd/exception.hpp>
#include <uhd/transport/usb_control.hpp>
#include <boost/functional/hash.hpp>
#include <boost/thread/thread.hpp>
-#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
@@ -162,7 +162,7 @@ public:
unsigned char reset_n = 0;
//hit the reset line
- if (load_img_msg) std::cout << "Loading firmware image: " << filestring << "..." << std::flush;
+ if (load_img_msg) UHD_MSG(status) << "Loading firmware image: " << filestring << "..." << std::flush;
usrp_control_write(FX2_FIRMWARE_LOAD, 0xe600, 0, &reset_y, 1);
while (!file.eof()) {
@@ -187,7 +187,7 @@ public:
//wait for things to settle
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
- if (load_img_msg) std::cout << " done" << std::endl;
+ if (load_img_msg) UHD_MSG(status) << " done" << std::endl;
return;
}
//type anything else is unhandled
@@ -228,7 +228,7 @@ public:
const int ep0_size = 64;
unsigned char buf[ep0_size];
- if (load_img_msg) std::cout << "Loading FPGA image: " << filestring << "..." << std::flush;
+ if (load_img_msg) UHD_MSG(status) << "Loading FPGA image: " << filestring << "..." << std::flush;
std::ifstream file;
file.open(filename, std::ios::in | std::ios::binary);
if (not file.good()) {
@@ -259,7 +259,7 @@ public:
usrp_fpga_reset(false); //done loading, take fpga out of reset
file.close();
- if (load_img_msg) std::cout << " done" << std::endl;
+ if (load_img_msg) UHD_MSG(status) << " done" << std::endl;
}
void usrp_load_eeprom(std::string filestring)
diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp
index 8f10df751..d7e8f601f 100644
--- a/host/lib/usrp/usrp1/usrp1_iface.cpp
+++ b/host/lib/usrp/usrp1/usrp1_iface.cpp
@@ -17,19 +17,17 @@
#include "usrp1_iface.hpp"
#include "usrp_commands.h"
+#include <uhd/utils/log.hpp>
#include <uhd/exception.hpp>
#include <uhd/utils/byteswap.hpp>
#include <boost/format.hpp>
#include <stdexcept>
-#include <iostream>
#include <iomanip>
using namespace uhd;
using namespace uhd::usrp;
using namespace uhd::transport;
-static const bool iface_debug = false;
-
class usrp1_iface_impl : public usrp1_iface{
public:
/*******************************************************************
@@ -53,12 +51,11 @@ public:
{
boost::uint32_t swapped = uhd::htonx(value);
- if (iface_debug) {
- std::cout.fill('0');
- std::cout << "poke32(";
- std::cout << std::dec << std::setw(2) << addr << ", 0x";
- std::cout << std::hex << std::setw(8) << value << ")" << std::endl;
- }
+ UHD_LOGV(always)
+ << "poke32("
+ << std::dec << std::setw(2) << addr << ", 0x"
+ << std::hex << std::setw(8) << value << ")" << std::endl
+ ;
boost::uint8_t w_index_h = SPI_ENABLE_FPGA & 0xff;
boost::uint8_t w_index_l = (SPI_FMT_MSB | SPI_FMT_HDR_1) & 0xff;
@@ -129,8 +126,8 @@ public:
bytes.size());
// TODO throw and catch i2c failures during eeprom read
- if (iface_debug && (ret < 0))
- std::cerr << "USRP: failed i2c write: " << ret << std::endl;
+ if (ret < 0)
+ UHD_LOGV(often) << "USRP: failed i2c write: " << ret << std::endl;
}
byte_vector_t read_i2c(boost::uint8_t addr, size_t num_bytes)
@@ -143,8 +140,8 @@ public:
num_bytes);
// TODO throw and catch i2c failures during eeprom read
- if (iface_debug && ((ret < 0) || (unsigned)ret < (num_bytes))) {
- std::cerr << "USRP: failed i2c read: " << ret << std::endl;
+ if (ret < 0 or (unsigned)ret < num_bytes) {
+ UHD_LOGV(often) << "USRP: failed i2c read: " << ret << std::endl;
return byte_vector_t(num_bytes, 0xff);
}
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index b7cd95a82..182705034 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -19,6 +19,7 @@
#include "usrp1_ctrl.hpp"
#include "fpga_regs_standard.h"
#include "usrp_spi_defs.h"
+#include <uhd/utils/log.hpp>
#include <uhd/utils/safe_call.hpp>
#include <uhd/transport/usb_control.hpp>
#include <uhd/usrp/device_props.hpp>
@@ -32,7 +33,6 @@
#include <boost/filesystem.hpp>
#include <boost/thread/thread.hpp>
#include <boost/lexical_cast.hpp>
-#include <iostream>
using namespace uhd;
using namespace uhd::usrp;
@@ -84,7 +84,7 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
);
return usrp1_addrs;
}
- //std::cout << "USRP1 firmware image: " << usrp1_fw_image << std::endl;
+ UHD_LOG << "USRP1 firmware image: " << usrp1_fw_image << std::endl;
usb_control::sptr control;
try{control = usb_control::make(handle);}
@@ -128,7 +128,7 @@ static device::sptr usrp1_make(const device_addr_t &device_addr){
std::string usrp1_fpga_image = find_image_path(
device_addr.get("fpga", "usrp1_fpga.rbf")
);
- //std::cout << "USRP1 FPGA image: " << usrp1_fpga_image << std::endl;
+ UHD_LOG << "USRP1 FPGA image: " << usrp1_fpga_image << std::endl;
//try to match the given device address with something on the USB bus
std::vector<usb_device_handle::sptr> device_list =
diff --git a/host/lib/usrp/usrp2/codec_ctrl.cpp b/host/lib/usrp/usrp2/codec_ctrl.cpp
index 0fdcedf62..796888b8f 100644
--- a/host/lib/usrp/usrp2/codec_ctrl.cpp
+++ b/host/lib/usrp/usrp2/codec_ctrl.cpp
@@ -19,12 +19,10 @@
#include "ad9777_regs.hpp"
#include "ads62p44_regs.hpp"
#include "usrp2_regs.hpp"
+#include <uhd/utils/log.hpp>
#include <uhd/exception.hpp>
#include <boost/cstdint.hpp>
#include <boost/foreach.hpp>
-#include <iostream>
-
-static const bool codec_ctrl_debug = false;
using namespace uhd;
@@ -167,7 +165,7 @@ private:
void send_ad9777_reg(boost::uint8_t addr){
boost::uint16_t reg = _ad9777_regs.get_write_reg(addr);
- if (codec_ctrl_debug) std::cout << "send_ad9777_reg: " << std::hex << reg << std::endl;
+ UHD_LOGV(always) << "send_ad9777_reg: " << std::hex << reg << std::endl;
_iface->write_spi(
SPI_SS_AD9777, spi_config_t::EDGE_RISE,
reg, 16
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index 005be7ce4..33f249599 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -18,6 +18,8 @@
#include "../../transport/vrt_packet_handler.hpp"
#include "usrp2_impl.hpp"
#include "usrp2_regs.hpp"
+#include <uhd/utils/log.hpp>
+#include <uhd/utils/msg.hpp>
#include <uhd/exception.hpp>
#include <uhd/usrp/mboard_props.hpp>
#include <uhd/utils/byteswap.hpp>
@@ -266,15 +268,15 @@ void usrp2_impl::io_impl::recv_pirate_loop(
}
//print the famous U, and push the metadata into the message queue
- if (metadata.event_code & underflow_flags) std::cerr << "U" << std::flush;
- //else std::cout << "metadata.event_code " << metadata.event_code << std::endl;
+ if (metadata.event_code & underflow_flags) UHD_MSG(fastpath) << "U";
+ //else UHD_MSG(often) << "metadata.event_code " << metadata.event_code << std::endl;
async_msg_fifo.push_with_pop_on_full(metadata);
}
else{
//TODO unknown received packet, may want to print error...
}
}catch(const std::exception &e){
- std::cerr << "Error (usrp2 recv pirate loop): " << e.what() << std::endl;
+ UHD_MSG(error) << "Error (usrp2 recv pirate loop): " << e.what() << std::endl;
}
}
}
@@ -314,13 +316,13 @@ void usrp2_impl::update_xport_channel_mapping(void){
subdev_spec_t rx_subdev_spec = _mboards[i]->get_link()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>();
for (size_t j = 0; j < rx_subdev_spec.size(); j++){
_io_impl->recv_map.push_back(i*usrp2_mboard_impl::MAX_NUM_DSPS+j);
- //std::cout << "recv_map.back() " << _io_impl->recv_map.back() << std::endl;
+ UHD_LOG << "recv_map.back() " << _io_impl->recv_map.back() << std::endl;
}
subdev_spec_t tx_subdev_spec = _mboards[i]->get_link()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>();
for (size_t j = 0; j < tx_subdev_spec.size(); j++){
_io_impl->send_map.push_back(i*usrp2_mboard_impl::MAX_NUM_DSPS+j);
- //std::cout << "send_map.back() " << _io_impl->send_map.back() << std::endl;
+ UHD_LOG << "send_map.back() " << _io_impl->send_map.back() << std::endl;
}
}
@@ -395,7 +397,7 @@ static UHD_INLINE void extract_packet_info(
//handle the packet count / sequence number
if ((prev_info.packet_count+1)%16 != next_info.packet_count){
- std::cerr << "O" << std::flush; //report overflow (drops in the kernel)
+ UHD_MSG(fastpath) << "O"; //report overflow (drops in the kernel)
}
time = extract_time_spec(next_info);
@@ -504,7 +506,7 @@ size_t usrp2_impl::get_max_recv_samps_per_packet(void) const{
}
void usrp2_impl::handle_overflow(size_t chan){
- std::cerr << "O" << std::flush;
+ UHD_MSG(fastpath) << "O";
ldiv_t indexes = ldiv(chan, usrp2_mboard_impl::NUM_RX_DSPS);
_mboards.at(indexes.quot)->handle_overflow(indexes.rem);
}
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index d4ae27763..daccc0865 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -18,6 +18,8 @@
#include "usrp2_impl.hpp"
#include "usrp2_regs.hpp"
#include "fw_common.h"
+#include <uhd/utils/log.hpp>
+#include <uhd/utils/msg.hpp>
#include <uhd/utils/safe_call.hpp>
#include <uhd/exception.hpp>
#include <uhd/usrp/gps_ctrl.hpp>
@@ -29,7 +31,6 @@
#include <uhd/types/sensors.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/bind.hpp>
-#include <iostream>
static const double mimo_clock_delay_usrp2_rev4 = 4.18e-9;
static const double mimo_clock_delay_usrp_n2xx = 3.55e-9;
@@ -81,19 +82,19 @@ usrp2_mboard_impl::usrp2_mboard_impl(
}
//construct transports for dsp and async errors
- std::cout << "Making transport for DSP0..." << std::endl;
+ UHD_LOG << "Making transport for DSP0..." << std::endl;
device.dsp_xports.push_back(udp_zero_copy::make(
device_addr["addr"], BOOST_STRINGIZE(USRP2_UDP_DSP0_PORT), device_addr
));
init_xport(device.dsp_xports.back());
- std::cout << "Making transport for DSP1..." << std::endl;
+ UHD_LOG << "Making transport for DSP1..." << std::endl;
device.dsp_xports.push_back(udp_zero_copy::make(
device_addr["addr"], BOOST_STRINGIZE(USRP2_UDP_DSP1_PORT), device_addr
));
init_xport(device.dsp_xports.back());
- std::cout << "Making transport for ERR0..." << std::endl;
+ UHD_LOG << "Making transport for ERR0..." << std::endl;
device.err_xports.push_back(udp_zero_copy::make(
device_addr["addr"], BOOST_STRINGIZE(USRP2_UDP_ERR0_PORT), device_addr_t()
));
@@ -141,7 +142,7 @@ usrp2_mboard_impl::usrp2_mboard_impl(
else {
_mimo_clocking_mode_is_master = (_iface->peek32(_iface->regs.status) & (1 << 8)) != 0;
}
- std::cout << boost::format("mboard%d MIMO %s") % _index %
+ UHD_MSG(status) << boost::format("mboard%d MIMO %s") % _index %
(_mimo_clocking_mode_is_master?"master":"slave") << std::endl;
//init the clock config
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index 558bcab2a..4eb5508e2 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -17,6 +17,8 @@
#include "usrp2_impl.hpp"
#include "fw_common.h"
+#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>
@@ -31,7 +33,6 @@
#include <boost/bind.hpp>
#include <boost/asio/ip/address_v4.hpp>
#include <boost/asio.hpp> //used for htonl and ntohl
-#include <iostream>
#include <vector>
using namespace uhd;
@@ -102,7 +103,6 @@ static device_addrs_t usrp2_find(const device_addr_t &hint_){
const usrp2_ctrl_data_t *ctrl_data_in = reinterpret_cast<const usrp2_ctrl_data_t *>(usrp2_ctrl_data_in_mem);
while(true){
size_t len = udp_transport->recv(asio::buffer(usrp2_ctrl_data_in_mem));
- //std::cout << len << "\n";
if (len > offsetof(usrp2_ctrl_data_t, data) and ntohl(ctrl_data_in->id) == USRP2_CTRL_ID_WAZZUP_DUDE){
//make a boost asio ipv4 with the raw addr in host byte order
@@ -189,7 +189,6 @@ static mtu_result_t determine_mtu(const std::string &addr, const mtu_result_t &u
while (min_recv_mtu < max_recv_mtu){
size_t test_mtu = (max_recv_mtu/2 + min_recv_mtu/2 + 3) & ~3;
- //std::cout << "recv_mtu " << mtu.recv_mtu << std::endl;
ctrl_data->id = htonl(USRP2_CTRL_ID_HOLLER_AT_ME_BRO);
ctrl_data->proto_ver = htonl(USRP2_FW_COMPAT_NUM);
@@ -206,7 +205,6 @@ static mtu_result_t determine_mtu(const std::string &addr, const mtu_result_t &u
while (min_send_mtu < max_send_mtu){
size_t test_mtu = (max_send_mtu/2 + min_send_mtu/2 + 3) & ~3;
- //std::cout << "send_mtu " << mtu.send_mtu << std::endl;
ctrl_data->id = htonl(USRP2_CTRL_ID_HOLLER_AT_ME_BRO);
ctrl_data->proto_ver = htonl(USRP2_FW_COMPAT_NUM);
@@ -262,8 +260,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);
- std::cout << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu << std::endl;
- std::cout << boost::format("Current send frame size: %d bytes") % mtu.send_mtu << std::endl;
+ 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;
}
catch(const uhd::not_implemented_error &){
//just ignore this error, makes older fw work...
diff --git a/host/lib/usrp/usrp_e100/io_impl.cpp b/host/lib/usrp/usrp_e100/io_impl.cpp
index 7e775dfd8..aa6e7c485 100644
--- a/host/lib/usrp/usrp_e100/io_impl.cpp
+++ b/host/lib/usrp/usrp_e100/io_impl.cpp
@@ -28,7 +28,6 @@
#include <boost/thread/thread.hpp>
#include <boost/thread/barrier.hpp>
#include <sstream>
-#include <iostream>
using namespace uhd;
using namespace uhd::usrp;
@@ -158,7 +157,7 @@ void usrp_e100_impl::io_impl::recv_pirate_loop(
metadata.event_code = vrt_packet_handler::get_context_code<async_metadata_t::event_code_t>(vrt_hdr, if_packet_info);
//print the famous U, and push the metadata into the message queue
- if (metadata.event_code & underflow_flags) std::cerr << "U" << std::flush;
+ if (metadata.event_code & underflow_flags) UHD_MSG(fastpath) << "U";
async_msg_fifo.push_with_pop_on_full(metadata);
continue;
}
@@ -224,7 +223,7 @@ void usrp_e100_impl::issue_stream_cmd(const stream_cmd_t &stream_cmd){
}
void usrp_e100_impl::handle_overrun(size_t){
- std::cerr << "O"; //the famous OOOOOOOOOOO
+ UHD_MSG(fastpath) << "O"; //the famous OOOOOOOOOOO
if (_io_impl->continuous_streaming){
this->issue_stream_cmd(stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
}
diff --git a/host/lib/utils/log.cpp b/host/lib/utils/log.cpp
index d99ce01c4..f67a14411 100644
--- a/host/lib/utils/log.cpp
+++ b/host/lib/utils/log.cpp
@@ -140,7 +140,7 @@ private:
//! set the log level from a string that is either a digit or an enum name
void _set_log_level(const std::string &log_level_str){
const uhd::_log::verbosity_t log_level = uhd::_log::verbosity_t(log_level_str[0]-'0');
- if (std::isdigit(log_level_str[0]) and log_level >= uhd::_log::always and log_level <= uhd::_log::very_rarely){
+ if (std::isdigit(log_level_str[0]) and log_level >= uhd::_log::always and log_level <= uhd::_log::never){
_log_level = log_level;
}
#define if_lls_equal(name) else if(log_level_str == #name) _log_level = uhd::_log::name
@@ -149,6 +149,7 @@ private:
if_lls_equal(regularly);
if_lls_equal(rarely);
if_lls_equal(very_rarely);
+ if_lls_equal(never);
}
//available stream objects
diff --git a/host/lib/utils/msg.cpp b/host/lib/utils/msg.cpp
index de6d4c8fa..0eaca05a5 100644
--- a/host/lib/utils/msg.cpp
+++ b/host/lib/utils/msg.cpp
@@ -71,16 +71,23 @@ void uhd::msg::register_handler(const handler_t &handler){
static void default_msg_handler(uhd::msg::type_t type, const std::string &msg){
switch(type){
+ case uhd::msg::fastpath:
+ std::cerr << msg << std::flush;
+ break;
+
case uhd::msg::status:
msg_to_cout(msg);
+ UHD_LOG << "Status message" << std::endl << msg;
break;
case uhd::msg::warning:
msg_to_cerr("UHD Warning", msg);
+ UHD_LOG << "Warning message" << std::endl << msg;
break;
case uhd::msg::error:
msg_to_cerr("UHD Error", msg);
+ UHD_LOG << "Error message" << std::endl << msg;
break;
}
}
@@ -99,7 +106,6 @@ uhd::msg::_msg::_msg(const type_t type){
uhd::msg::_msg::~_msg(void){
msg_handler(msg_type, msg_ss.str());
- UHD_LOG << "Message " << char(msg_type) << std::endl << msg_ss.str();
msg_ss.str(""); //clear for next call
msg_mutex.unlock();
}