From a4aa89ed5d73b6afa5d2d28d8f2b6cc206baf22d Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Fri, 8 Apr 2011 14:59:46 -0700 Subject: USRP2: Added GPS time support to the sensors interface. gps_time sensor returns epoch time as time_t. Untested. --- host/include/uhd/usrp/gps_ctrl.hpp | 6 ++++++ host/lib/usrp/gps_ctrl.cpp | 4 ++++ host/lib/usrp/usrp2/mboard_impl.cpp | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'host') diff --git a/host/include/uhd/usrp/gps_ctrl.hpp b/host/include/uhd/usrp/gps_ctrl.hpp index 21d400b3b..bd679b165 100644 --- a/host/include/uhd/usrp/gps_ctrl.hpp +++ b/host/include/uhd/usrp/gps_ctrl.hpp @@ -42,6 +42,12 @@ public: * \return current GPS time and date as boost::posix_time::ptime object */ virtual ptime get_time(void) = 0; + + /*! + * Get the epoch time (as time_t, which is int) + * \return current GPS time and date as time_t + */ + virtual time_t get_epoch_time(void) = 0; /*! * Tell you if there's a supported GPS connected or not diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index ff8e9cee6..ace56e7ed 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -172,6 +172,10 @@ public: } return now; } + + time_t get_epoch_time(void) { + return (get_time() - boost::posix_time::from_time_t(0)).total_seconds(); + } bool gps_detected(void) { return (gps_type != GPS_TYPE_NONE); diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 520ee49a6..7a756087a 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -372,7 +372,11 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ else if(key.name == "ref_locked") { val = sensor_value_t("Ref", this->get_ref_locked(), "locked", "unlocked"); return; - } else { + } + else if(key.name == "gps_time") { + val = sensor_value_t("GPS time", int(_gps_ctrl->get_epoch_time()), "seconds"); + } + else { UHD_THROW_PROP_GET_ERROR(); } break; -- cgit v1.2.3