diff options
Diffstat (limited to 'host/examples')
25 files changed, 120 insertions, 84 deletions
diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index 6854fa43d..cb2cf251c 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -15,7 +15,7 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/convert.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp> @@ -23,7 +23,6 @@  #include <boost/format.hpp>  #include <boost/thread/thread.hpp>  #include <boost/algorithm/string.hpp> -#include <boost/lexical_cast.hpp>  //#include <boost/atomic.hpp>  #include <iostream>  #include <complex> @@ -406,11 +405,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){          boost::split(channel_strings, rx_channel_list, boost::is_any_of("\"',"));          for (size_t ch = 0; ch < channel_strings.size(); ch++) { -            size_t chan = boost::lexical_cast<int>(channel_strings[ch]); +            size_t chan = std::stoul(channel_strings[ch]);              if (chan >= usrp->get_rx_num_channels()) {                  throw std::runtime_error("Invalid channel(s) specified.");              } else { -                rx_channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); +                rx_channel_nums.push_back(std::stoul(channel_strings[ch]));              }          }      } @@ -423,11 +422,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){          boost::split(channel_strings, tx_channel_list, boost::is_any_of("\"',"));          for (size_t ch = 0; ch < channel_strings.size(); ch++) { -            size_t chan = boost::lexical_cast<int>(channel_strings[ch]); +            size_t chan = std::stoul(channel_strings[ch]);              if (chan >= usrp->get_tx_num_channels()) {                  throw std::runtime_error("Invalid channel(s) specified.");              } else { -                tx_channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); +                tx_channel_nums.push_back(std::stoul(channel_strings[ch]));              }          }      } @@ -452,7 +451,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){          uhd::stream_args_t stream_args(rx_cpu, rx_otw);          stream_args.channels = rx_channel_nums;          uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); -        thread_group.create_thread(boost::bind(&benchmark_rx_rate, usrp, rx_cpu, rx_stream, random_nsamps, boost::ref(burst_timer_elapsed))); +        auto rx_thread = thread_group.create_thread(boost::bind(&benchmark_rx_rate, usrp, rx_cpu, rx_stream, random_nsamps, boost::ref(burst_timer_elapsed))); +        uhd::set_thread_name(rx_thread, "bmark_rx_stream");      }      //spawn the transmit test thread @@ -462,8 +462,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){          uhd::stream_args_t stream_args(tx_cpu, tx_otw);          stream_args.channels = tx_channel_nums;          uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); -        thread_group.create_thread(boost::bind(&benchmark_tx_rate, usrp, tx_cpu, tx_stream, boost::ref(burst_timer_elapsed), random_nsamps)); -        thread_group.create_thread(boost::bind(&benchmark_tx_rate_async_helper, tx_stream, boost::ref(burst_timer_elapsed))); +        auto tx_thread = thread_group.create_thread(boost::bind(&benchmark_tx_rate, usrp, tx_cpu, tx_stream, boost::ref(burst_timer_elapsed), random_nsamps)); +        uhd::set_thread_name(tx_thread, "bmark_tx_stream"); +        auto tx_async_thread = thread_group.create_thread(boost::bind(&benchmark_tx_rate_async_helper, tx_stream, boost::ref(burst_timer_elapsed))); +        uhd::set_thread_name(tx_async_thread, "bmark_tx_helper");      }      //sleep for the required duration diff --git a/host/examples/gpio.cpp b/host/examples/gpio.cpp index 02c73e96b..b3edc81d3 100644 --- a/host/examples/gpio.cpp +++ b/host/examples/gpio.cpp @@ -73,7 +73,7 @@  // mask - a mask indicating which bits in the specified attribute register are  //          to be changed (default is all bits). -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <uhd/convert.hpp> @@ -129,7 +129,7 @@ void output_reg_values(      for (int i = num_bits - 1; i >= 0; i--)          std::cout << (boost::format(" %2d") % i);      std::cout << std::endl; -    BOOST_FOREACH(std::string &attr, attrs) +    for(std::string &attr:  attrs)      {          std::cout << (boost::format("%10s:%s")              % attr % to_bit_string(uint32_t(usrp->get_gpio_attr(bank, attr)), num_bits)) diff --git a/host/examples/init_usrp/CMakeLists.txt b/host/examples/init_usrp/CMakeLists.txt index 4ce51125f..139f9b853 100644 --- a/host/examples/init_usrp/CMakeLists.txt +++ b/host/examples/init_usrp/CMakeLists.txt @@ -46,6 +46,25 @@ find_package(UHD "3.8.0" REQUIRED)  #find_package(UHD 3.8.1 EXACT REQUIRED)  ### Configure Compiler ######################################################## +IF(CMAKE_VERSION VERSION_LESS "3.1") +    IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") +        SET(CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}") +    ELSEIF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") +        IF("${IS_APPLE}" STREQUAL "") +            SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") +        ELSE() +            SET(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ ${CMAKE_CXX_FLAGS}") +        ENDIF() +    ENDIF() +ELSE() +    SET(CMAKE_CXX_STANDARD 11) +ENDIF() + +IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") +    SET(CMAKE_EXE_LINKER_FLAGS "-lthr ${CMAKE_EXE_LINKER_FLAGS}") +    SET(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}") +ENDIF() +  include_directories(      ${Boost_INCLUDE_DIRS}      ${UHD_INCLUDE_DIRS} diff --git a/host/examples/init_usrp/init_usrp.cpp b/host/examples/init_usrp/init_usrp.cpp index c0a211767..46650a583 100644 --- a/host/examples/init_usrp/init_usrp.cpp +++ b/host/examples/init_usrp/init_usrp.cpp @@ -20,7 +20,7 @@  // The program itself only initializes a USRP. For more elaborate examples,  // have a look at the files in host/examples/. -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <boost/program_options.hpp> diff --git a/host/examples/latency_test.cpp b/host/examples/latency_test.cpp index 8d8ead412..eac5c1071 100644 --- a/host/examples/latency_test.cpp +++ b/host/examples/latency_test.cpp @@ -15,7 +15,7 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <boost/program_options.hpp> diff --git a/host/examples/network_relay.cpp b/host/examples/network_relay.cpp index 7e354934a..c21b2696e 100644 --- a/host/examples/network_relay.cpp +++ b/host/examples/network_relay.cpp @@ -15,7 +15,7 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <boost/program_options.hpp>  #include <boost/thread/condition_variable.hpp> diff --git a/host/examples/rx_ascii_art_dft.cpp b/host/examples/rx_ascii_art_dft.cpp index 55b4eeebe..d8733ddd0 100644 --- a/host/examples/rx_ascii_art_dft.cpp +++ b/host/examples/rx_ascii_art_dft.cpp @@ -15,7 +15,7 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include "ascii_art_dft.hpp" //implementation diff --git a/host/examples/rx_multi_samples.cpp b/host/examples/rx_multi_samples.cpp index a50b5f0e0..9212ba4b0 100644 --- a/host/examples/rx_multi_samples.cpp +++ b/host/examples/rx_multi_samples.cpp @@ -15,13 +15,12 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <boost/program_options.hpp>  #include <boost/format.hpp>  #include <boost/thread.hpp> -#include <boost/lexical_cast.hpp>  #include <boost/algorithm/string.hpp>  #include <iostream>  #include <complex> @@ -118,11 +117,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){      std::vector<size_t> channel_nums;      boost::split(channel_strings, channel_list, boost::is_any_of("\"',"));      for(size_t ch = 0; ch < channel_strings.size(); ch++){ -        size_t chan = boost::lexical_cast<int>(channel_strings[ch]); +        size_t chan = std::stoi(channel_strings[ch]);          if(chan >= usrp->get_rx_num_channels()){              throw std::runtime_error("Invalid channel(s) specified.");          } -        else channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); +        else channel_nums.push_back(std::stoi(channel_strings[ch]));      }      //create a receive streamer diff --git a/host/examples/rx_samples_c.c b/host/examples/rx_samples_c.c index d269e29b7..b453a684e 100644 --- a/host/examples/rx_samples_c.c +++ b/host/examples/rx_samples_c.c @@ -53,7 +53,7 @@ int main(int argc, char* argv[])      double freq = 500e6;      double rate = 1e6;      double gain = 5.0; -    char* device_args = ""; +    char* device_args = NULL;      size_t channel = 0;      char* filename = "out.dat";      size_t n_samples = 1000000; @@ -105,6 +105,9 @@ int main(int argc, char* argv[])          }      } +    if (!device_args) +            device_args = strdup(""); +      // Create USRP      uhd_usrp_handle usrp;      fprintf(stderr, "Creating USRP with args \"%s\"...\n", device_args); @@ -279,7 +282,7 @@ int main(int argc, char* argv[])          uhd_usrp_free(&usrp);      free_option_strings: -        if(strcmp(device_args,"")){ +        if(device_args) {              free(device_args);          }          if(custom_filename){ diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp index 934dce586..f3de9f5de 100644 --- a/host/examples/rx_samples_to_file.cpp +++ b/host/examples/rx_samples_to_file.cpp @@ -16,7 +16,7 @@  //  #include <uhd/types/tune_request.hpp> -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <uhd/exception.hpp> @@ -37,6 +37,7 @@ template<typename samp_type> void recv_to_file(      uhd::usrp::multi_usrp::sptr usrp,      const std::string &cpu_format,      const std::string &wire_format, +    const std::string &channel,      const std::string &file,      size_t samps_per_buff,      unsigned long long num_requested_samples, @@ -50,6 +51,9 @@ template<typename samp_type> void recv_to_file(      unsigned long long num_total_samps = 0;      //create a receive streamer      uhd::stream_args_t stream_args(cpu_format,wire_format); +    std::vector<size_t> channel_nums; +    channel_nums.push_back(boost::lexical_cast<size_t>(channel)); +    stream_args.channels = channel_nums;      uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);      uhd::rx_metadata_t md; @@ -209,7 +213,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){      uhd::set_thread_priority_safe();      //variables to be set by po -    std::string args, file, type, ant, subdev, ref, wirefmt; +    std::string args, file, type, ant, subdev, ref, wirefmt, channel;      size_t total_num_samps, spb;      double rate, freq, gain, bw, total_time, setup_time; @@ -229,9 +233,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){          ("gain", po::value<double>(&gain), "gain for the RF chain")          ("ant", po::value<std::string>(&ant), "antenna selection")          ("subdev", po::value<std::string>(&subdev), "subdevice specification") +        ("channel", po::value<std::string>(&channel)->default_value("0"), "which channel to use")          ("bw", po::value<double>(&bw), "analog frontend filter bandwidth in Hz")          ("ref", po::value<std::string>(&ref)->default_value("internal"), "reference source (internal, external, mimo)") -        ("wirefmt", po::value<std::string>(&wirefmt)->default_value("sc16"), "wire format (sc8 or sc16)") +        ("wirefmt", po::value<std::string>(&wirefmt)->default_value("sc16"), "wire format (sc8, sc16 or s16)")          ("setup", po::value<double>(&setup_time)->default_value(1.0), "seconds of setup time")          ("progress", "periodically display short-term bandwidth")          ("stats", "show average bandwidth on exit") @@ -329,12 +334,19 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){      }  #define recv_to_file_args(format) \ -    (usrp, format, wirefmt, file, spb, total_num_samps, total_time, bw_summary, stats, null, enable_size_map, continue_on_bad_packet) +    (usrp, format, wirefmt, channel, file, spb, total_num_samps, total_time, bw_summary, stats, null, enable_size_map, continue_on_bad_packet)      //recv to file -    if (type == "double") recv_to_file<std::complex<double> >recv_to_file_args("fc64"); -    else if (type == "float") recv_to_file<std::complex<float> >recv_to_file_args("fc32"); -    else if (type == "short") recv_to_file<std::complex<short> >recv_to_file_args("sc16"); -    else throw std::runtime_error("Unknown type " + type); +    if (wirefmt == "s16") { +        if (type == "double") recv_to_file<double>recv_to_file_args("f64"); +        else if (type == "float") recv_to_file<float>recv_to_file_args("f32"); +        else if (type == "short") recv_to_file<short>recv_to_file_args("s16"); +        else throw std::runtime_error("Unknown type " + type); +    } else { +        if (type == "double") recv_to_file<std::complex<double> >recv_to_file_args("fc64"); +        else if (type == "float") recv_to_file<std::complex<float> >recv_to_file_args("fc32"); +        else if (type == "short") recv_to_file<std::complex<short> >recv_to_file_args("sc16"); +        else throw std::runtime_error("Unknown type " + type); +    }      //finished      std::cout << std::endl << "Done!" << std::endl << std::endl; diff --git a/host/examples/rx_samples_to_udp.cpp b/host/examples/rx_samples_to_udp.cpp index a3f5624ca..409e40a56 100644 --- a/host/examples/rx_samples_to_udp.cpp +++ b/host/examples/rx_samples_to_udp.cpp @@ -16,7 +16,7 @@  //  #include <uhd/types/tune_request.hpp> -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <uhd/transport/udp_simple.hpp> diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index 20abd92fe..4b348e672 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -15,7 +15,7 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <boost/program_options.hpp> @@ -72,11 +72,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){      std::vector<size_t> channel_nums;      boost::split(channel_strings, channel_list, boost::is_any_of("\"',"));      for(size_t ch = 0; ch < channel_strings.size(); ch++){ -        size_t chan = boost::lexical_cast<int>(channel_strings[ch]); +        size_t chan = std::stoi(channel_strings[ch]);          if(chan >= usrp->get_tx_num_channels() or chan >= usrp->get_rx_num_channels()){              throw std::runtime_error("Invalid channel(s) specified.");          } -        else channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); +        else channel_nums.push_back(std::stoi(channel_strings[ch]));      }      //set the rx sample rate diff --git a/host/examples/sync_to_gps.cpp b/host/examples/sync_to_gps.cpp index 3a9b5c7e4..006574cff 100644 --- a/host/examples/sync_to_gps.cpp +++ b/host/examples/sync_to_gps.cpp @@ -15,7 +15,7 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <boost/format.hpp> diff --git a/host/examples/test_clock_synch.cpp b/host/examples/test_clock_synch.cpp index b1af6790b..1756cdbb9 100644 --- a/host/examples/test_clock_synch.cpp +++ b/host/examples/test_clock_synch.cpp @@ -27,7 +27,7 @@  #include <uhd/types/time_spec.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <uhd/utils/safe_main.hpp> -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  namespace po = boost::program_options; diff --git a/host/examples/test_dboard_coercion.cpp b/host/examples/test_dboard_coercion.cpp index 81c45fcb3..307728214 100644 --- a/host/examples/test_dboard_coercion.cpp +++ b/host/examples/test_dboard_coercion.cpp @@ -15,7 +15,7 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <boost/program_options.hpp> @@ -102,7 +102,7 @@ std::string coercion_test(uhd::usrp::multi_usrp::sptr usrp, std::string type, in      std::cout << boost::format("\nTesting %s coercion...") % type << std::endl; -    BOOST_FOREACH(const uhd::range_t &range, freq_ranges){ +    for(const uhd::range_t &range:  freq_ranges){          double freq_begin = range.start();          double freq_end = range.stop(); @@ -152,7 +152,7 @@ std::string coercion_test(uhd::usrp::multi_usrp::sptr usrp, std::string type, in      bool has_sensor = (std::find(dboard_sensor_names.begin(), dboard_sensor_names.end(), "lo_locked")) != dboard_sensor_names.end(); -    BOOST_FOREACH(double freq, freqs){ +    for(double freq:  freqs){          //Testing for successful frequency tune          if(type == "TX") usrp->set_tx_freq(freq,chan); @@ -212,7 +212,7 @@ std::string coercion_test(uhd::usrp::multi_usrp::sptr usrp, std::string type, in              //Testing for successful gain tune -            BOOST_FOREACH(double gain, gains){ +            for(double gain:  gains){                  if(type == "TX") usrp->set_tx_gain(gain,chan);                  else usrp->set_rx_gain(gain,chan); @@ -266,7 +266,7 @@ std::string coercion_test(uhd::usrp::multi_usrp::sptr usrp, std::string type, in      }      else{          results += "USRP did not successfully tune to the following frequencies: "; -        BOOST_FOREACH(double bad_freq, bad_tune_freqs){ +        for(double bad_freq:  bad_tune_freqs){              if(bad_freq != *bad_tune_freqs.begin()) results += ", ";              results += MHz_str(bad_freq);          } @@ -282,7 +282,7 @@ std::string coercion_test(uhd::usrp::multi_usrp::sptr usrp, std::string type, in          }          else{              results += "LO did not lock at the following frequencies: "; -            BOOST_FOREACH(double bad_freq, no_lock_freqs){ +            for(double bad_freq:  no_lock_freqs){                  if(bad_freq != *no_lock_freqs.begin()) results += ", ";                  results += MHz_str(bad_freq);              } @@ -298,7 +298,7 @@ std::string coercion_test(uhd::usrp::multi_usrp::sptr usrp, std::string type, in          }          else{              results += "USRP did not successfully set gain under the following circumstances:"; -            BOOST_FOREACH(double_pair bad_pair, bad_gain_vals){ +            for(double_pair bad_pair:  bad_gain_vals){                  double bad_freq = bad_pair.first;                  double bad_gain = bad_pair.second;                  results += str(boost::format("\nFrequency: %s, Gain: %5.2f") % MHz_str(bad_freq) % bad_gain); diff --git a/host/examples/test_messages.cpp b/host/examples/test_messages.cpp index 43b035d19..5047db0c5 100644 --- a/host/examples/test_messages.cpp +++ b/host/examples/test_messages.cpp @@ -16,14 +16,13 @@  //  #include <uhd/config.hpp> -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/utils/static.hpp>  #include <uhd/types/stream_cmd.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <boost/assign/list_of.hpp>  #include <boost/program_options.hpp> -#include <boost/foreach.hpp>  #include <boost/bind.hpp>  #include <boost/format.hpp>  #include <cstdlib> @@ -330,7 +329,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){      //init result counts      uhd::dict<std::string, size_t> failures, successes; -    BOOST_FOREACH(const std::string &key, tests.keys()){ +    for(const std::string &key:  tests.keys()){          failures[key] = 0;          successes[key] = 0;      } @@ -352,7 +351,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){      //print the result summary      bool any_failure = false;      std::cout << std::endl << "Summary:" << std::endl << std::endl; -    BOOST_FOREACH(const std::string &key, tests.keys()){ +    for(const std::string &key:  tests.keys()){          std::cout << boost::format(              "%s   ->   %3u successes, %3u failures"          ) % key % successes[key] % failures[key] << std::endl; diff --git a/host/examples/test_pps_input.cpp b/host/examples/test_pps_input.cpp index 3e6c4ba9d..ef166f31c 100644 --- a/host/examples/test_pps_input.cpp +++ b/host/examples/test_pps_input.cpp @@ -15,7 +15,7 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <boost/program_options.hpp> diff --git a/host/examples/test_timed_commands.cpp b/host/examples/test_timed_commands.cpp index 3da4bc707..8c6e039dc 100644 --- a/host/examples/test_timed_commands.cpp +++ b/host/examples/test_timed_commands.cpp @@ -15,7 +15,7 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <boost/program_options.hpp> diff --git a/host/examples/twinrx_freq_hopping.cpp b/host/examples/twinrx_freq_hopping.cpp index 878129d92..1e9000b76 100644 --- a/host/examples/twinrx_freq_hopping.cpp +++ b/host/examples/twinrx_freq_hopping.cpp @@ -18,7 +18,7 @@  // FFT conversion  #include "ascii_art_dft.hpp" -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp> diff --git a/host/examples/tx_bursts.cpp b/host/examples/tx_bursts.cpp index 5ee00d5cd..406b76c41 100644 --- a/host/examples/tx_bursts.cpp +++ b/host/examples/tx_bursts.cpp @@ -15,13 +15,12 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <boost/program_options.hpp>  #include <boost/thread/thread.hpp>  #include <boost/format.hpp> -#include <boost/lexical_cast.hpp>  #include <boost/algorithm/string.hpp>  #include <csignal>  #include <iostream> @@ -86,11 +85,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){      std::vector<size_t> channel_nums;      boost::split(channel_strings, channel_list, boost::is_any_of("\"',"));      for(size_t ch = 0; ch < channel_strings.size(); ch++){ -        size_t chan = boost::lexical_cast<int>(channel_strings[ch]); +        size_t chan = std::stoi(channel_strings[ch]);          if(chan >= usrp->get_tx_num_channels()){              throw std::runtime_error("Invalid channel(s) specified.");          } -        else channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); +        else channel_nums.push_back(std::stoi(channel_strings[ch]));      }      //set the tx sample rate diff --git a/host/examples/tx_samples_c.c b/host/examples/tx_samples_c.c index 333c7e820..6b120516b 100644 --- a/host/examples/tx_samples_c.c +++ b/host/examples/tx_samples_c.c @@ -57,7 +57,7 @@ int main(int argc, char* argv[]){      double freq = 2e9;      double rate = 1e6;      double gain = 0; -    char* device_args; +    char* device_args = NULL;      size_t channel = 0;      uint64_t total_num_samps = 0;      bool verbose = false; @@ -106,9 +106,9 @@ int main(int argc, char* argv[]){          fprintf(stderr, "Unable to set thread priority. Continuing anyway.\n");      } -    if (device_args == NULL){ -        device_args = ""; -    } +    if (!device_args) +        device_args = strdup(""); +      // Create USRP      uhd_usrp_handle usrp;      fprintf(stderr, "Creating USRP with args \"%s\"...\n", device_args); @@ -249,9 +249,8 @@ int main(int argc, char* argv[]){          uhd_usrp_free(&usrp);      free_option_strings: -        if(device_args != NULL){ +        if(device_args)              free(device_args); -        }      fprintf(stderr, (return_code ? "Failure\n" : "Success\n")); diff --git a/host/examples/tx_samples_from_file.cpp b/host/examples/tx_samples_from_file.cpp index cc7e963d5..7ef6ecfe9 100644 --- a/host/examples/tx_samples_from_file.cpp +++ b/host/examples/tx_samples_from_file.cpp @@ -16,7 +16,7 @@  //  #include <uhd/types/tune_request.hpp> -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <boost/program_options.hpp> @@ -33,17 +33,11 @@ static bool stop_signal_called = false;  void sig_int_handler(int){stop_signal_called = true;}  template<typename samp_type> void send_from_file( -    uhd::usrp::multi_usrp::sptr usrp, -    const std::string &cpu_format, -    const std::string &wire_format, +    uhd::tx_streamer::sptr tx_stream,      const std::string &file,      size_t samps_per_buff  ){ -    //create a transmit streamer -    uhd::stream_args_t stream_args(cpu_format, wire_format); -    uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); -      uhd::tx_metadata_t md;      md.start_of_burst = false;      md.end_of_burst = false; @@ -69,7 +63,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){      uhd::set_thread_priority_safe();      //variables to be set by po -    std::string args, file, type, ant, subdev, ref, wirefmt; +    std::string args, file, type, ant, subdev, ref, wirefmt, channel;      size_t spb;      double rate, freq, gain, bw, delay, lo_off; @@ -91,6 +85,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){          ("ref", po::value<std::string>(&ref)->default_value("internal"), "reference source (internal, external, mimo)")          ("wirefmt", po::value<std::string>(&wirefmt)->default_value("sc16"), "wire format (sc8 or sc16)")          ("delay", po::value<double>(&delay)->default_value(0.0), "specify a delay between repeated transmission of file") +        ("channel", po::value<std::string>(&channel)->default_value("0"), "which channel to use")          ("repeat", "repeatedly transmit file")          ("int-n", "tune USRP with integer-n tuning")      ; @@ -186,11 +181,22 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){          std::cout << "Press Ctrl + C to stop streaming..." << std::endl;      } +    //create a transmit streamer +    std::string cpu_format; +    std::vector<size_t> channel_nums; +    if (type == "double") cpu_format = "fc64"; +    else if (type == "float") cpu_format = "fc32"; +    else if (type == "short") cpu_format = "sc16"; +    uhd::stream_args_t stream_args(cpu_format, wirefmt); +    channel_nums.push_back(boost::lexical_cast<size_t>(channel)); +    stream_args.channels = channel_nums; +    uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args); +      //send from file      do{ -        if (type == "double") send_from_file<std::complex<double> >(usrp, "fc64", wirefmt, file, spb); -        else if (type == "float") send_from_file<std::complex<float> >(usrp, "fc32", wirefmt, file, spb); -        else if (type == "short") send_from_file<std::complex<short> >(usrp, "sc16", wirefmt, file, spb); +        if (type == "double") send_from_file<std::complex<double> >(tx_stream, file, spb); +        else if (type == "float") send_from_file<std::complex<float> >(tx_stream, file, spb); +        else if (type == "short") send_from_file<std::complex<short> >(tx_stream, file, spb);          else throw std::runtime_error("Unknown type " + type);          if(repeat and delay != 0.0) boost::this_thread::sleep(boost::posix_time::milliseconds(delay)); diff --git a/host/examples/tx_timed_samples.cpp b/host/examples/tx_timed_samples.cpp index 667ae66a9..a8f4acfeb 100644 --- a/host/examples/tx_timed_samples.cpp +++ b/host/examples/tx_timed_samples.cpp @@ -15,7 +15,7 @@  // along with this program.  If not, see <http://www.gnu.org/licenses/>.  // -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <boost/program_options.hpp> diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index b2a8f944c..4e824cf43 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -16,21 +16,20 @@  //  #include "wavetable.hpp" -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/utils/static.hpp>  #include <uhd/usrp/multi_usrp.hpp>  #include <uhd/exception.hpp>  #include <boost/program_options.hpp>  #include <boost/math/special_functions/round.hpp> -#include <boost/foreach.hpp>  #include <boost/format.hpp>  #include <boost/thread.hpp> -#include <boost/lexical_cast.hpp>  #include <boost/algorithm/string.hpp>  #include <stdint.h>  #include <iostream>  #include <csignal> +#include <string>  namespace po = boost::program_options; @@ -94,11 +93,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){      std::vector<size_t> channel_nums;      boost::split(channel_strings, channel_list, boost::is_any_of("\"',"));      for(size_t ch = 0; ch < channel_strings.size(); ch++){ -        size_t chan = boost::lexical_cast<int>(channel_strings[ch]); +        size_t chan = std::stoi(channel_strings[ch]);          if(chan >= usrp->get_tx_num_channels())              throw std::runtime_error("Invalid channel(s) specified.");          else -            channel_nums.push_back(boost::lexical_cast<int>(channel_strings[ch])); +            channel_nums.push_back(std::stoi(channel_strings[ch]));      } @@ -213,7 +212,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){      //Check Ref and LO Lock detect      std::vector<std::string> sensor_names; -    const size_t tx_sensor_chan = channel_list.empty() ? 0 : boost::lexical_cast<size_t>(channel_list[0]); +    const size_t tx_sensor_chan = channel_nums.empty() ? 0 : channel_nums[0];      sensor_names = usrp->get_tx_sensor_names(tx_sensor_chan);      if (std::find(sensor_names.begin(), sensor_names.end(), "lo_locked") != sensor_names.end()) {          uhd::sensor_value_t lo_locked = usrp->get_tx_sensor("lo_locked", tx_sensor_chan); diff --git a/host/examples/txrx_loopback_to_file.cpp b/host/examples/txrx_loopback_to_file.cpp index eb2cd72a3..fedaed7da 100644 --- a/host/examples/txrx_loopback_to_file.cpp +++ b/host/examples/txrx_loopback_to_file.cpp @@ -17,7 +17,7 @@  #include "wavetable.hpp"  #include <uhd/types/tune_request.hpp> -#include <uhd/utils/thread_priority.hpp> +#include <uhd/utils/thread.hpp>  #include <uhd/utils/safe_main.hpp>  #include <uhd/utils/static.hpp>  #include <uhd/usrp/multi_usrp.hpp> @@ -26,7 +26,6 @@  #include <boost/program_options.hpp>  #include <boost/math/special_functions/round.hpp>  #include <boost/format.hpp> -#include <boost/lexical_cast.hpp>  #include <boost/algorithm/string.hpp>  #include <boost/filesystem.hpp>  #include <iostream> @@ -267,21 +266,21 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){      std::vector<size_t> tx_channel_nums;      boost::split(tx_channel_strings, tx_channels, boost::is_any_of("\"',"));      for(size_t ch = 0; ch < tx_channel_strings.size(); ch++){ -        size_t chan = boost::lexical_cast<int>(tx_channel_strings[ch]); +        size_t chan = std::stoi(tx_channel_strings[ch]);          if(chan >= tx_usrp->get_tx_num_channels()){              throw std::runtime_error("Invalid TX channel(s) specified.");          } -        else tx_channel_nums.push_back(boost::lexical_cast<int>(tx_channel_strings[ch])); +        else tx_channel_nums.push_back(std::stoi(tx_channel_strings[ch]));      }      std::vector<std::string> rx_channel_strings;      std::vector<size_t> rx_channel_nums;      boost::split(rx_channel_strings, rx_channels, boost::is_any_of("\"',"));      for(size_t ch = 0; ch < rx_channel_strings.size(); ch++){ -        size_t chan = boost::lexical_cast<int>(rx_channel_strings[ch]); +        size_t chan = std::stoi(rx_channel_strings[ch]);          if(chan >= rx_usrp->get_rx_num_channels()){              throw std::runtime_error("Invalid RX channel(s) specified.");          } -        else rx_channel_nums.push_back(boost::lexical_cast<int>(rx_channel_strings[ch])); +        else rx_channel_nums.push_back(std::stoi(rx_channel_strings[ch]));      }      //Lock mboard clocks  | 
