On 03/30/2018 04:00 PM, Eric W via USRP-users wrote:
Hi all - I have an Octoclock-G. I'm trying to get confirmation on
what get_sensor("gps_time") actually returns.
I guess it's not number of seconds since the GPS epoch (Jan 6 1980),
as I had assumed from the tag "gps_time".
It looks more like Unix seconds. So, seconds since the Jan 1 1970
epoch (UTC epoch).
Is that right, and if so, how are leap seconds handled? If it uses the
Unix epoch then I would guess it is also subtracting leap seconds, but
that's just a guess..
If indeed it is returning Unix time, then I believe this would be
correct (for now, until the next leap sec):
gpsSeconds = get_sensor("gps_time") - 315964782;
Our code looks something like:
uhd::device_addr_t dev_addr_octoclock;
dev_addr_octoclock["addr0"] = "192.168.13.1";
uhd::usrp_clock::multi_usrp_clock::sptr octoclock =
uhd::usrp_clock::multi_usrp_clock::make(dev_addr_octoclock);
signed gps_time = octoclock->get_sensor("gps_time",0).to_int();
Thanks much,
Eric
_______________________________________________
USRP-users mailing list
[email protected]
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
The relevant code in gps_ctrl.cpp is here:
struct tm raw_date;
raw_date.tm_year = std::stoi(datestr.substr(4, 2)) + 2000 -
1900; // years since 1900
raw_date.tm_mon = std::stoi(datestr.substr(2, 2)) - 1; //
months since january (0-11)
raw_date.tm_mday = std::stoi(datestr.substr(0, 2)); // dom
(1-31)
raw_date.tm_hour = std::stoi(timestr.substr(0, 2));
raw_date.tm_min = std::stoi(timestr.substr(2, 2));
raw_date.tm_sec = std::stoi(timestr.substr(4,2));
gps_time = boost::posix_time::ptime_from_tm(raw_date);
It's using boost::posix_time which is necessarily based on the Unix epoch.
So, "gps_time" is "Posix Time based on the time given by the GPS receiver".
_______________________________________________
USRP-users mailing list
[email protected]
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com