From 07c07dd2f1f40000df04987fbbc85d78861d7c17 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Mon, 2 Aug 2021 23:59:49 +0200 Subject: [PATCH 1/4] add getBeiDouDate and note some more leap second errors --- navmon.cc | 17 ++++++++++++++--- navmon.hh | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/navmon.cc b/navmon.cc index a686243..edb5839 100644 --- a/navmon.cc +++ b/navmon.cc @@ -292,22 +292,33 @@ std::string makeSatPartialName(const SatID& satid) return fmt::sprintf("%c%02d", getGNSSChar(satid.gnss), satid.sv); } +int g_dtLS{18}, g_dtLSBeidou{4}; + void getGPSDateFromUTC(time_t t, int& wn, int& tow) { t -= 315964800; - t += 18; + t += 18; // XXXXXX LEAP SECOND wn = t/(7*86400); tow = t%(7*86400); } void getGalDateFromUTC(time_t t, int& wn, int& tow) { t -= 935280000; - t += 18; + t += 18; // XXXXXXX LEAP SECOND wn = t/(7*86400); tow = t%(7*86400); } -int g_dtLS{18}, g_dtLSBeidou{4}; +void getBeiDouDateFromUTC(time_t t, int&wn, int& sow) +{ + // Week number count started from zero at 00:00:00 on Jan. 1, 2006 of BDT + t -= 1136070000; + t+= g_dtLSBeidou; + wn = t/(7*86400); + sow = t%(7*86400); +} + + uint64_t utcFromGST(int wn, int tow) { return (935280000 + wn * 7*86400 + tow - g_dtLS); diff --git a/navmon.hh b/navmon.hh index 54d64a3..748686d 100644 --- a/navmon.hh +++ b/navmon.hh @@ -80,7 +80,7 @@ double utcFromGPS(int wn, double tow); void getGPSDateFromUTC(time_t t, int& wn, int& tow); void getGalDateFromUTC(time_t t, int& wn, int& tow); - +void getBeiDouDateFromUTC(time_t t, int&wn, int& sow); std::string makeHexDump(const std::string& str); std::string makeHexDump(const std::basic_string& str); From 616e71270df5879b754f007eb3ad019588fcad74 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 3 Aug 2021 00:00:10 +0200 Subject: [PATCH 2/4] make gndate do BeiDou week numbers etc --- gndate.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gndate.cc b/gndate.cc index 662c397..b027d95 100644 --- a/gndate.cc +++ b/gndate.cc @@ -14,7 +14,7 @@ try string date; int galwn{-1}; bool doProgOutput{false}; - bool doGPSWN{false}, doGALWN{false}, doVERSION{false}, doUTC{false}; + bool doGPSWN{false}, doGALWN{false}, doBEIDOUWN{false}, doVERSION{false}, doUTC{false}; app.add_flag("--version", doVERSION, "show program version and copyright"); app.add_option("--date,-d", date, "yyyy-mm-dd hh:mm[:ss] hh:mm yyyymmdd hhmm"); app.add_option("--date-gal-wn", galwn, "Give data for this Galileo week number"); @@ -62,11 +62,18 @@ try getGalDateFromUTC(now, wn, tow); cout< Date: Tue, 3 Aug 2021 00:00:29 +0200 Subject: [PATCH 3/4] parse BeiDou leap second data --- beidou.hh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/beidou.hh b/beidou.hh index 0276a6f..3d021bc 100644 --- a/beidou.hh +++ b/beidou.hh @@ -228,7 +228,8 @@ struct BeidouMessage : GPSLikeEphemeris // 2^-30 2^-50 int a0gps, a1gps, a0gal, a1gal, a0glo, a1glo, a0utc, a1utc; - int8_t deltaTLS; + int8_t deltaTLS, deltaTLSF; + uint8_t wnLSF, dn; // in Beidou the offset is a0utc + SOW * a1utc std::pair getUTCOffset(int tow) const @@ -268,6 +269,9 @@ struct BeidouMessage : GPSLikeEphemeris a0utc = bbits(91, 32); a1utc = bbits(131, 24); deltaTLS = bbits(31+12+1+7, 8); + deltaTLSF = bbits(61+6, 8); + wnLSF = bbits(61+6+8, 8); + dn = bbits(151+12, 8); } else { alma.sqrtA = bbitu(51, 24); From e1b8225ddb8d3eeb8eca56fe4960b531680a0bd4 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 3 Aug 2021 00:00:47 +0200 Subject: [PATCH 4/4] get navdump to print beidou leap second data --- navdump.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/navdump.cc b/navdump.cc index c3ed38a..ca456c6 100644 --- a/navdump.cc +++ b/navdump.cc @@ -883,8 +883,6 @@ try cout<<" best-tle-match "<