From 7819e2ea06f44871d820f8027afc63656aa86f3a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 12 Jul 2010 13:55:23 -0700 Subject: uhd: added checking for time deviation after sync. Prints error. --- host/lib/usrp/mimo_usrp.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'host/lib') diff --git a/host/lib/usrp/mimo_usrp.cpp b/host/lib/usrp/mimo_usrp.cpp index fd8225074..b40f98226 100644 --- a/host/lib/usrp/mimo_usrp.cpp +++ b/host/lib/usrp/mimo_usrp.cpp @@ -125,20 +125,33 @@ public: void set_time_unknown_pps(const time_spec_t &time_spec){ std::cout << "Set time with unknown pps edge:" << std::endl; - std::cout << " 1) set times next pps (race condition)" << std::endl; + std::cout << " 1) set times next pps (race condition)" << std::endl; set_time_next_pps(time_spec); boost::this_thread::sleep(boost::posix_time::seconds(1)); - std::cout << " 2) catch seconds rollover at pps edge" << std::endl; + std::cout << " 2) catch seconds rollover at pps edge" << std::endl; time_t last_secs = 0, curr_secs = 0; while(curr_secs == last_secs){ last_secs = curr_secs; curr_secs = get_time_now().get_full_secs(); } - std::cout << " 3) set times next pps (synchronously)" << std::endl; + std::cout << " 3) set times next pps (synchronously)" << std::endl; set_time_next_pps(time_spec); boost::this_thread::sleep(boost::posix_time::seconds(1)); + + //verify that the time registers are read to be within a few RTT + for (size_t i = 1; i < get_num_channels(); i++){ + time_spec_t time_0 = _mboards.front()[MBOARD_PROP_TIME_NOW].as(); + time_spec_t time_i = _mboards.at(i)[MBOARD_PROP_TIME_NOW].as(); + if (time_i < time_0 or (time_i - time_0) > time_spec_t(0.01)){ //10 ms: greater than RTT but not too big + std::cerr << boost::format( + "Error: time deviation between board %d and board 0.\n" + " Board 0 time is %f seconds.\n" + " Board %d time is %f seconds.\n" + ) % i % time_0.get_real_secs() % i % time_i.get_real_secs() << std::endl; + } + } } void issue_stream_cmd(const stream_cmd_t &stream_cmd){ -- cgit v1.2.3 From 508af598a1b32345a53522b4d6d71e021f448347 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 12 Jul 2010 20:39:21 -0700 Subject: uhd: switch statements to handle error code, default md to error code none --- host/examples/benchmark_rx_rate.cpp | 15 ++++++++++----- host/examples/rx_timed_samples.cpp | 22 +++++++++++++++++----- host/lib/transport/vrt_packet_handler.hpp | 3 ++- 3 files changed, 29 insertions(+), 11 deletions(-) (limited to 'host/lib') diff --git a/host/examples/benchmark_rx_rate.cpp b/host/examples/benchmark_rx_rate.cpp index a63337b38..2bde3865d 100644 --- a/host/examples/benchmark_rx_rate.cpp +++ b/host/examples/benchmark_rx_rate.cpp @@ -62,13 +62,18 @@ static inline void test_device( uhd::io_type_t::COMPLEX_FLOAT32, uhd::device::RECV_MODE_ONE_PACKET ); - if (num_rx_samps == 0 and md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT){ - std::cerr << "Unexpected timeout on recv, exit test..." << std::endl; + + //handle the error codes + switch(md.error_code){ + case uhd::rx_metadata_t::ERROR_CODE_NONE: + case uhd::rx_metadata_t::ERROR_CODE_OVERRUN: + break; + + default: + std::cerr << "Unexpected error on recv, exit test..." << std::endl; return; } - if (num_rx_samps == 0 and md.error_code != uhd::rx_metadata_t::ERROR_CODE_OVERRUN){ - std::cerr << "Unexpected error on recv, continuing..." << std::endl; - } + if (not md.has_time_spec){ std::cerr << "Metadata missing time spec, exit test..." << std::endl; return; diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index 95f805007..3b9acbb2c 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -92,20 +92,32 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::io_type_t::COMPLEX_FLOAT32, uhd::device::RECV_MODE_ONE_PACKET ); - if (num_rx_samps == 0 and num_acc_samps > 0){ + + //handle the error codes + switch(md.error_code){ + case uhd::rx_metadata_t::ERROR_CODE_NONE: + break; + + case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT: + if (num_acc_samps == 0) continue; std::cout << boost::format( - "Got error code 0x%x before all samples received, possible packet loss, exiting loop..." + "Got timeout before all samples received, possible packet loss, exiting loop..." ) % md.error_code << std::endl; - break; + goto done_loop; + + default: + std::cout << boost::format( + "Got error code 0x%x, exiting loop..." + ) % md.error_code << std::endl; + goto done_loop; } - if (num_rx_samps == 0) continue; //wait for packets with contents if(verbose) std::cout << boost::format( "Got packet: %u samples, %u full secs, %f frac secs" ) % num_rx_samps % md.time_spec.get_full_secs() % md.time_spec.get_frac_secs() << std::endl; num_acc_samps += num_rx_samps; - } + } done_loop: //finished std::cout << std::endl << "Done!" << std::endl << std::endl; diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp index 6623957ac..fdcff24b8 100644 --- a/host/lib/transport/vrt_packet_handler.hpp +++ b/host/lib/transport/vrt_packet_handler.hpp @@ -146,6 +146,8 @@ namespace vrt_packet_handler{ const handle_overrun_t &handle_overrun, size_t vrt_header_offset_words32 ){ + metadata.error_code = uhd::rx_metadata_t::ERROR_CODE_NONE; + //perform a receive if no rx data is waiting to be copied if (state.size_of_copy_buffs == 0){ state.fragment_offset_in_samps = 0; @@ -171,7 +173,6 @@ namespace vrt_packet_handler{ metadata.has_time_spec = false; metadata.start_of_burst = false; metadata.end_of_burst = false; - metadata.error_code = uhd::rx_metadata_t::ERROR_CODE_NONE; } //extract the number of samples available to copy -- cgit v1.2.3 From a507bc0b4fa2428ae5ebec9fe145e8143289f3d0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 14 Jul 2010 11:56:22 -0700 Subject: usrp2: disable buffer resize on platforms that cry about it --- host/lib/transport/udp_zero_copy_asio.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'host/lib') diff --git a/host/lib/transport/udp_zero_copy_asio.cpp b/host/lib/transport/udp_zero_copy_asio.cpp index 98451f188..bfbcf62d8 100644 --- a/host/lib/transport/udp_zero_copy_asio.cpp +++ b/host/lib/transport/udp_zero_copy_asio.cpp @@ -161,10 +161,13 @@ template static void resize_buff_helper( ) % name % MIN_SOCK_BUFF_SIZE << std::endl; } + //only enable on platforms that are happy with the large buffer resize + #if defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32) //otherwise, ensure that the buffer is at least the minimum size else if (udp_trans->get_buff_size() < MIN_SOCK_BUFF_SIZE){ resize_buff_helper(udp_trans, MIN_SOCK_BUFF_SIZE, name); } + #endif /*defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32)*/ } udp_zero_copy::sptr udp_zero_copy::make( -- cgit v1.2.3