From 1467e88d1916af392a831cb4be6a162df4a78a4f Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 29 Nov 2018 17:32:46 -0800 Subject: examples: rfnoc_radio_loopback: Clean up example - Remove unnecessary Boostisms - Remove unecessary thread priority (this example doesn't actually do anything that requires high thread priority) - Used auto in some places to increase readability - Fixed some compiler warnings No functional changes. --- host/examples/rfnoc_radio_loopback.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'host/examples/rfnoc_radio_loopback.cpp') diff --git a/host/examples/rfnoc_radio_loopback.cpp b/host/examples/rfnoc_radio_loopback.cpp index a9a8232f2..8e0ca9443 100644 --- a/host/examples/rfnoc_radio_loopback.cpp +++ b/host/examples/rfnoc_radio_loopback.cpp @@ -9,19 +9,17 @@ // run a loopback. #include -#include #include #include -#include #include #include -#include #include #include +#include +#include namespace po = boost::program_options; using uhd::rfnoc::radio_ctrl; -using uhd::rfnoc::block_ctrl; /**************************************************************************** * SIGINT handling @@ -32,9 +30,8 @@ void sig_int_handler(int){stop_signal_called = true;} /**************************************************************************** * main ***************************************************************************/ -int UHD_SAFE_MAIN(int argc, char *argv[]){ - uhd::set_thread_priority_safe(); - +int UHD_SAFE_MAIN(int argc, char *argv[]) +{ //variables to be set by po std::string args, rx_args, tx_args, rx_ant, tx_ant, rx_blockid, tx_blockid, ref; size_t total_num_samps, spp, rx_chan, tx_chan, tx_delay; @@ -86,7 +83,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ // Create a device session std::cout << std::endl; std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl; - uhd::device3::sptr dev = boost::dynamic_pointer_cast(uhd::device::make(args)); + auto dev = boost::dynamic_pointer_cast(uhd::device::make(args)); if (not dev) { std::cout << "Error: Could not find an RFNoC-compatible device." << std::endl; return EXIT_FAILURE; @@ -103,8 +100,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ << std::endl; return EXIT_FAILURE; } - radio_ctrl::sptr rx_radio_ctrl = dev->get_block_ctrl(rx_blockid); - radio_ctrl::sptr tx_radio_ctrl = dev->get_block_ctrl(tx_blockid); + auto rx_radio_ctrl = dev->get_block_ctrl(rx_blockid); + auto tx_radio_ctrl = dev->get_block_ctrl(tx_blockid); // Configure Rx radio std::cout << "Configuring Rx radio..." << std::endl; @@ -171,7 +168,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ rx_radio_ctrl->set_rx_streamer(true, rx_chan); // Allow for some setup time - boost::this_thread::sleep(boost::posix_time::seconds(setup_time)); + std::this_thread::sleep_for( + std::chrono::milliseconds(int64_t(setup_time * 1000))); // Arm SIGINT handler std::signal(SIGINT, &sig_int_handler); @@ -181,9 +179,6 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ const double buffer_time = 1.0; // seconds total_time = (1.0/rate) * total_num_samps + buffer_time; } - long total_time_milliseconds = total_time * 1000; - boost::posix_time::ptime start_time = boost::posix_time::microsec_clock::local_time(); - boost::posix_time::time_duration elapsed; // Start streaming uhd::stream_cmd_t stream_cmd((total_num_samps == 0)? @@ -199,7 +194,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ // Wait until we can exit while (not stop_signal_called) { - boost::this_thread::sleep_for(boost::chrono::milliseconds(100)); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + // FIXME honour --duration } // Stop radio -- cgit v1.2.3