From 76c8b7fa24ea6c1bba84d7116b12dc0e4c5cacf6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 30 Dec 2010 16:41:38 -0800 Subject: usrp2: implemented get time last pps renamed the enum for the pps time added calls to single and multi wrappers set time unknown pps now simpler removed peek64 stuff from host + fw please test --- host/lib/usrp/multi_usrp.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'host/lib/usrp/multi_usrp.cpp') diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 876f1a3fc..2245983ee 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -117,26 +117,31 @@ public: return _mboard(0)[MBOARD_PROP_TIME_NOW].as(); } + time_spec_t get_time_last_pps(void){ + return _mboard(0)[MBOARD_PROP_TIME_PPS].as(); + } + void set_time_next_pps(const time_spec_t &time_spec){ for (size_t m = 0; m < get_num_mboards(); m++){ - _mboard(m)[MBOARD_PROP_TIME_NEXT_PPS] = time_spec; + _mboard(m)[MBOARD_PROP_TIME_PPS] = time_spec; } } 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; - 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; - 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 << " 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){ + if (get_time_last_pps() != time_start_last_pps) break; + if ((get_time_now() - time_start) > time_spec_t(1.1)){ + throw std::runtime_error( + "The time at the last PPS has not changed.\n" + "Board 0 may not be getting a PPS signal.\n" + ); + } } - std::cout << " 3) set times next pps (synchronously)" << std::endl; + std::cout << " 2) set times next pps (synchronously)" << std::endl; set_time_next_pps(time_spec); boost::this_thread::sleep(boost::posix_time::seconds(1)); -- cgit v1.2.3 From 7b0b2924d52bbbcb4660cad5d8070074426011ce Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 30 Dec 2010 17:26:58 -0800 Subject: uhd: removed SOB always from tx examples, use the multi usrp set unknown pps in the test app --- host/examples/test_pps_input.cpp | 37 +++++++------------------------------ host/examples/tx_from_file.cpp | 2 +- host/examples/tx_timed_samples.cpp | 2 +- host/examples/tx_waveforms.cpp | 2 +- host/lib/usrp/multi_usrp.cpp | 2 +- 5 files changed, 11 insertions(+), 34 deletions(-) (limited to 'host/lib/usrp/multi_usrp.cpp') diff --git a/host/examples/test_pps_input.cpp b/host/examples/test_pps_input.cpp index 4b2bb62a3..273c73df0 100644 --- a/host/examples/test_pps_input.cpp +++ b/host/examples/test_pps_input.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -31,7 +31,6 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //variables to be set by po std::string args; - double seconds; //setup the program options po::options_description desc("Allowed options"); @@ -52,35 +51,13 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //create a usrp device std::cout << std::endl; std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl; - uhd::usrp::single_usrp::sptr sdev = uhd::usrp::single_usrp::make(args); + uhd::usrp::multi_usrp::sptr sdev = uhd::usrp::multi_usrp::make(args); uhd::device::sptr dev = sdev->get_device(); std::cout << boost::format("Using Device: %s") % sdev->get_pp_string() << std::endl; - //set a known time value - std::cout << "Set time to known value (100.0) without regard to pps:" << std::endl; - sdev->set_time_now(uhd::time_spec_t(100.0)); - boost::this_thread::sleep(boost::posix_time::seconds(1)); - std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_real_secs()) << std::endl; - - //store the time to see if PPS resets it - seconds = sdev->get_time_now().get_real_secs(); - - //set a known time at next PPS, check that time increments - uhd::time_spec_t time_spec = uhd::time_spec_t(0.0); - std::cout << "Set time to known value (0.0) at next pps:" << std::endl; - sdev->set_time_next_pps(time_spec); - boost::this_thread::sleep(boost::posix_time::seconds(1)); - std::cout << boost::format("Reading time 1 second later: %f\n") % (sdev->get_time_now().get_real_secs()) << std::endl; - - //finished - if (seconds > sdev->get_time_now().get_real_secs()){ - std::cout << std::endl << "Success!" << std::endl << std::endl; - return 0; - } else { - std::cout << std::endl << "Failed!" << std::endl << std::endl - << "If you expected PPS to work:" << std::endl - << "\tsee Device App Notes for PPS level information" - << std::endl << std::endl; - return -1; - } + //set the time at an unknown pps (will throw if no pps) + std::cout << std::endl << "Attempt to detect the PPS and set the time..." << std::endl << std::endl; + sdev->set_time_unknown_pps(uhd::time_spec_t(0.0)); + std::cout << std::endl << "Success!" << std::endl << std::endl; + return 0; } diff --git a/host/examples/tx_from_file.cpp b/host/examples/tx_from_file.cpp index 9611cf47c..40ce6db6b 100644 --- a/host/examples/tx_from_file.cpp +++ b/host/examples/tx_from_file.cpp @@ -102,7 +102,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ size_t num_packets = (total_num_samps+samps_per_packet-1)/samps_per_packet; for (size_t i = 0; i < num_packets; i++){ //setup the metadata flags and time spec - md.start_of_burst = true; //always SOB (good for continuous streaming) + md.start_of_burst = (i == 0); //only first packet has SOB md.end_of_burst = (i == num_packets-1); //only last packet has EOB md.has_time_spec = (i == 0); //only first packet has time md.time_spec = uhd::time_spec_t(seconds_in_future); diff --git a/host/examples/tx_timed_samples.cpp b/host/examples/tx_timed_samples.cpp index 799da37e0..ef0cd8212 100644 --- a/host/examples/tx_timed_samples.cpp +++ b/host/examples/tx_timed_samples.cpp @@ -89,7 +89,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ for (size_t i = 0; i < num_packets; i++){ //setup the metadata flags and time spec uhd::tx_metadata_t md; - md.start_of_burst = true; //always SOB (good for continuous streaming) + md.start_of_burst = (i == 0); //only first packet has SOB md.end_of_burst = (i == num_packets-1); //only last packet has EOB md.has_time_spec = (i == 0); //only first packet has time md.time_spec = uhd::time_spec_t(seconds_in_future); diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index 50982cf88..751b79cf5 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -142,7 +142,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //setup the metadata flags uhd::tx_metadata_t md; - md.start_of_burst = true; //always SOB (good for continuous streaming) + md.start_of_burst = false; //never SOB when continuous md.end_of_burst = false; //send the data in multiple packets diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 2245983ee..5610bcd3f 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -135,8 +135,8 @@ public: if (get_time_last_pps() != time_start_last_pps) break; if ((get_time_now() - time_start) > time_spec_t(1.1)){ throw std::runtime_error( - "The time at the last PPS has not changed.\n" "Board 0 may not be getting a PPS signal.\n" + "The time at the last PPS has not changed.\n" ); } } -- cgit v1.2.3