diff options
Diffstat (limited to 'host/examples')
-rw-r--r-- | host/examples/network_relay.cpp | 14 | ||||
-rw-r--r-- | host/examples/test_dboard_coercion.cpp | 18 | ||||
-rw-r--r-- | host/examples/test_messages.cpp | 2 |
3 files changed, 16 insertions, 18 deletions
diff --git a/host/examples/network_relay.cpp b/host/examples/network_relay.cpp index bb09296b3..a12c38ff8 100644 --- a/host/examples/network_relay.cpp +++ b/host/examples/network_relay.cpp @@ -34,6 +34,7 @@ typedef boost::shared_ptr<asio::ip::udp::socket> socket_type; static const size_t insane_mtu = 9000; boost::mutex spawn_mutex; +boost::condition_variable thread_spawned; #if defined(UHD_PLATFORM_MACOS) //limit buffer resize on macos or it will error @@ -100,14 +101,11 @@ public: } std::cout << "spawning relay threads... " << _port << std::endl; + boost::unique_lock<boost::mutex> lock(spawn_mutex); _thread_group.create_thread(boost::bind(&udp_relay_type::server_thread, this)); - spawn_mutex.lock(); - spawn_mutex.lock(); - spawn_mutex.unlock(); + thread_spawned.wait(lock); _thread_group.create_thread(boost::bind(&udp_relay_type::client_thread, this)); - spawn_mutex.lock(); - spawn_mutex.lock(); - spawn_mutex.unlock(); + thread_spawned.wait(lock); std::cout << " done!" << std::endl << std::endl; } @@ -128,7 +126,7 @@ private: void server_thread(void){ uhd::set_thread_priority_safe(); std::cout << " entering server_thread..." << std::endl; - spawn_mutex.unlock(); + thread_spawned.notify_one(); std::vector<char> buff(insane_mtu); while (not boost::this_thread::interruption_requested()){ if (wait_for_recv_ready(_server_socket->native())){ @@ -154,7 +152,7 @@ private: void client_thread(void){ uhd::set_thread_priority_safe(); std::cout << " entering client_thread..." << std::endl; - spawn_mutex.unlock(); + thread_spawned.notify_one(); std::vector<char> buff(insane_mtu); while (not boost::this_thread::interruption_requested()){ if (wait_for_recv_ready(_client_socket->native())){ diff --git a/host/examples/test_dboard_coercion.cpp b/host/examples/test_dboard_coercion.cpp index cfc745147..bbe6f70dd 100644 --- a/host/examples/test_dboard_coercion.cpp +++ b/host/examples/test_dboard_coercion.cpp @@ -53,7 +53,7 @@ std::string return_USRP_config_string(uhd::usrp::multi_usrp::sptr usrp, bool tes if(test_tx){ if(tx_info.get("tx_serial") != "") tx_serial = tx_info.get("tx_serial"); - else tx_serial = "no serial"; + else tx_serial = "no serial"; tx_subdev_name = tx_info.get("tx_subdev_name"); tx_subdev_spec = tx_info.get("tx_subdev_spec"); @@ -121,7 +121,7 @@ std::string tx_test(uhd::usrp::multi_usrp::sptr usrp, bool test_gain, bool verbo gains.push_back(current_gain); current_gain++; } - if(gain_end != *gains.end()) gains.push_back(gain_end); + if(gain_end != gains.back()) gains.push_back(gain_end); } @@ -182,19 +182,19 @@ std::string tx_test(uhd::usrp::multi_usrp::sptr usrp, bool test_gain, bool verbo } if(test_gain){ - + //Testing for successful gain tune for(std::vector<double>::iterator g = gains.begin(); g != gains.end(); ++g){ usrp->set_tx_gain(*g); boost::this_thread::sleep(boost::posix_time::microseconds(1000)); - + double actual_gain = usrp->get_tx_gain(); if(*g == 0.0){ if(actual_gain == 0.0){ if(verbose) std::cout << boost::format("TX gain successfully set to %5.2f at TX frequency %s.") % *g % return_MHz_string(*f) << std::endl; - } + } else{ if(verbose) std::cout << boost::format("TX gain set to %5.2f instead of %5.2f at TX frequency %s.") % actual_gain % *g % return_MHz_string(*f) << std::endl; std::vector<double> bad_gain_freq; @@ -313,7 +313,7 @@ std::string rx_test(uhd::usrp::multi_usrp::sptr usrp, bool test_gain, bool verbo gains.push_back(current_gain); current_gain++; } - if(gain_end != *gains.end()) gains.push_back(gain_end); + if(gain_end != gains.back()) gains.push_back(gain_end); } @@ -518,7 +518,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "REF must equal internal, external, or mimo." << std::endl; return ~0; } - + if(vm.count("tx") + vm.count("rx") == 0){ std::cout << desc << std::endl; std::cout << "Specify --tx to test for TX frequency coercion\n" @@ -557,12 +557,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::sensor_value_t mimo_locked = usrp->get_mboard_sensor("mimo_locked",0); std::cout << boost::format("Checking MIMO lock: %s ...") % mimo_locked.to_pp_string() << std::endl; UHD_ASSERT_THROW(mimo_locked.to_bool()); - } + } if ((ref == "external") and (std::find(sensor_names.begin(), sensor_names.end(), "ref_locked") != sensor_names.end())) { uhd::sensor_value_t ref_locked = usrp->get_mboard_sensor("ref_locked",0); std::cout << boost::format("Checking REF lock: %s ...") % ref_locked.to_pp_string() << std::endl; UHD_ASSERT_THROW(ref_locked.to_bool()); - } + } usrp_config = return_USRP_config_string(usrp, test_tx, test_rx); if(test_tx) tx_results = tx_test(usrp, test_tx_gain, verbose); if(test_rx) rx_results = rx_test(usrp, test_rx_gain, verbose); diff --git a/host/examples/test_messages.cpp b/host/examples/test_messages.cpp index e39a8bd30..0815d0b1c 100644 --- a/host/examples/test_messages.cpp +++ b/host/examples/test_messages.cpp @@ -84,7 +84,7 @@ bool test_late_command_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streame * Issue a stream command with num samps and more. * We expect to get an inline broken chain message. */ -bool test_broken_chain_message(uhd::usrp::multi_usrp::sptr usrp, uhd::rx_streamer::sptr rx_stream, uhd::tx_streamer::sptr){ +bool test_broken_chain_message(uhd::usrp::multi_usrp::sptr usrp __attribute__ ((unused)), uhd::rx_streamer::sptr rx_stream, uhd::tx_streamer::sptr){ std::cout << "Test broken chain message... " << std::flush; uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_MORE); |