From bca5edb57979983a9eb8d6cd1016961552ad217c Mon Sep 17 00:00:00 2001 From: michael-west Date: Wed, 25 Jun 2014 14:56:20 -0700 Subject: Fix for BUG #492: UHD: set_time_unknown_pps() fails with GPSDO installed - Added polling for PPS time change after setting time from GPSDO. --- host/lib/usrp/usrp2/usrp2_impl.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'host/lib/usrp/usrp2') diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 918f3e892..7c478d8e1 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -35,6 +35,7 @@ #include #include #include //used for htonl and ntohl +#include using namespace uhd; using namespace uhd::usrp; @@ -760,7 +761,13 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ _tree->access(root / "time_source/value").set("gpsdo"); _tree->access(root / "clock_source/value").set("gpsdo"); UHD_MSG(status) << "Initializing time to the internal GPSDO" << std::endl; - _mbc[mb].time64->set_time_next_pps(time_spec_t(time_t(_mbc[mb].gps->get_sensor("gps_time").to_int()+1))); + const time_t tp = time_t(_mbc[mb].gps->get_sensor("gps_time").to_int()+1); + _tree->access(root / "time" / "pps").set(time_spec_t(tp)); + + //wait for next PPS edge (timeout after 1 second) + time_spec_t pps_time = _tree->access(root / "time" / "pps").get(); + for (size_t i = 0; i < 10 && _tree->access(root / "time" / "pps").get() == pps_time; i++) + boost::this_thread::sleep(boost::posix_time::milliseconds(100)); } } -- cgit v1.2.3