Merge "feat: Add timeuncNs in PQWM1 message"

This commit is contained in:
qctecmdr 2019-05-02 14:14:59 -07:00 committed by Gerrit - the friendly Code Review server
commit 9b6103421b
5 changed files with 46 additions and 20 deletions

View file

@ -36,7 +36,8 @@ using ::android::hardware::hidl_vec;
#define GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG (180)
#define GNSS_DEBUG_UNKNOWN_UTC_TIME (1483228800000LL) // 1/1/2017 00:00 GMT
#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC (1.57783680E17) // 5 years in ns
#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN (999) // 999 ns
#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX (1.57783680E17) // 5 years in ns
#define GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC (2.0e5) // ppm
GnssDebug::GnssDebug(Gnss* gnss) : mGnss(gnss)
@ -125,9 +126,10 @@ Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb)
if (data.time.timeEstimate < GNSS_DEBUG_UNKNOWN_UTC_TIME) {
data.time.timeEstimate = GNSS_DEBUG_UNKNOWN_UTC_TIME;
}
if (data.time.timeUncertaintyNs <= 0 ||
data.time.timeUncertaintyNs > (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC;
if (data.time.timeUncertaintyNs <= 0) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN;
} else if (data.time.timeUncertaintyNs > GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX;
}
if (data.time.frequencyUncertaintyNsPerSec <= 0 ||
data.time.frequencyUncertaintyNsPerSec > (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC) {

View file

@ -41,7 +41,8 @@ using ::android::hardware::gnss::V2_0::IGnssDebug;
#define GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG (180)
#define GNSS_DEBUG_UNKNOWN_UTC_TIME (1483228800000LL) // 1/1/2017 00:00 GMT
#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC (1.57783680E17) // 5 years in ns
#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN (999) // 999 ns
#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX (1.57783680E17) // 5 years in ns
#define GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC (2.0e5) // ppm
GnssDebug::GnssDebug(Gnss* gnss) : mGnss(gnss)
@ -130,9 +131,10 @@ Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb)
if (data.time.timeEstimate < GNSS_DEBUG_UNKNOWN_UTC_TIME) {
data.time.timeEstimate = GNSS_DEBUG_UNKNOWN_UTC_TIME;
}
if (data.time.timeUncertaintyNs <= 0 ||
data.time.timeUncertaintyNs > (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC;
if (data.time.timeUncertaintyNs <= 0) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN;
} else if (data.time.timeUncertaintyNs > GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX;
}
if (data.time.frequencyUncertaintyNsPerSec <= 0 ||
data.time.frequencyUncertaintyNsPerSec > (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC) {
@ -247,9 +249,11 @@ Return<void> GnssDebug::getDebugData_2_0(getDebugData_2_0_cb _hidl_cb)
if (data.time.timeEstimate < GNSS_DEBUG_UNKNOWN_UTC_TIME) {
data.time.timeEstimate = GNSS_DEBUG_UNKNOWN_UTC_TIME;
}
if (data.time.timeUncertaintyNs <= 0 ||
data.time.timeUncertaintyNs > (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC;
if (data.time.timeUncertaintyNs <= 0) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN;
}
else if (data.time.timeUncertaintyNs > GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX) {
data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX;
}
if (data.time.frequencyUncertaintyNsPerSec <= 0 ||
data.time.frequencyUncertaintyNsPerSec > (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC) {

View file

@ -126,6 +126,7 @@ public:
uint32_t mBdsBpAmpQ; // x1C
uint32_t mGalBpAmpI; // x1D
uint32_t mGalBpAmpQ; // x1E
uint64_t mTimeUncNs; // x1F
};
// parser
@ -157,7 +158,6 @@ private:
eAgcGlo = 20,
eAgcBds = 21,
eAgcGal = 22,
eMax0 = eAgcGal,
eLeapSeconds = 23,
eLeapSecUnc = 24,
eGloBpAmpI = 25,
@ -166,6 +166,8 @@ private:
eBdsBpAmpQ = 28,
eGalBpAmpI = 29,
eGalBpAmpQ = 30,
eMax0 = eGalBpAmpQ,
eTimeUncNs = 31,
eMax
};
SystemStatusPQWM1 mM1;
@ -201,6 +203,7 @@ public:
inline uint32_t getBdsBpAmpQ() { return mM1.mBdsBpAmpQ; }
inline uint32_t getGalBpAmpI() { return mM1.mGalBpAmpI; }
inline uint32_t getGalBpAmpQ() { return mM1.mGalBpAmpQ; }
inline uint64_t getTimeUncNs() { return mM1.mTimeUncNs; }
SystemStatusPQWM1parser(const char *str_in, uint32_t len_in)
: SystemStatusNmeaBase(str_in, len_in)
@ -245,6 +248,9 @@ public:
mM1.mGalBpAmpI = atoi(mField[eGalBpAmpI].c_str());
mM1.mGalBpAmpQ = atoi(mField[eGalBpAmpQ].c_str());
}
if (mField.size() > eTimeUncNs) {
mM1.mTimeUncNs = strtoull(mField[eTimeUncNs].c_str(), nullptr, 10);
}
}
inline SystemStatusPQWM1& get() { return mM1;} //getparser
@ -715,7 +721,8 @@ SystemStatusTimeAndClock::SystemStatusTimeAndClock(const SystemStatusPQWM1& nmea
mClockFreqBias(nmea.mClockFreqBias),
mClockFreqBiasUnc(nmea.mClockFreqBiasUnc),
mLeapSeconds(nmea.mLeapSeconds),
mLeapSecUnc(nmea.mLeapSecUnc)
mLeapSecUnc(nmea.mLeapSecUnc),
mTimeUncNs(nmea.mTimeUncNs)
{
}
@ -729,7 +736,8 @@ bool SystemStatusTimeAndClock::equals(const SystemStatusTimeAndClock& peer)
(mClockFreqBias != peer.mClockFreqBias) ||
(mClockFreqBiasUnc != peer.mClockFreqBiasUnc) ||
(mLeapSeconds != peer.mLeapSeconds) ||
(mLeapSecUnc != peer.mLeapSecUnc)) {
(mLeapSecUnc != peer.mLeapSecUnc) ||
(mTimeUncNs != peer.mTimeUncNs)) {
return false;
}
return true;
@ -737,7 +745,7 @@ bool SystemStatusTimeAndClock::equals(const SystemStatusTimeAndClock& peer)
void SystemStatusTimeAndClock::dump()
{
LOC_LOGV("TimeAndClock: u=%ld:%ld g=%d:%d v=%d ts=%d tu=%d b=%d bu=%d ls=%d lu=%d",
LOC_LOGV("TimeAndClock: u=%ld:%ld g=%d:%d v=%d ts=%d tu=%d b=%d bu=%d ls=%d lu=%d un=%" PRIu64,
mUtcTime.tv_sec, mUtcTime.tv_nsec,
mGpsWeek,
mGpsTowMs,
@ -747,7 +755,8 @@ void SystemStatusTimeAndClock::dump()
mClockFreqBias,
mClockFreqBiasUnc,
mLeapSeconds,
mLeapSecUnc);
mLeapSecUnc,
mTimeUncNs);
return;
}

View file

@ -116,6 +116,7 @@ public:
int32_t mClockFreqBiasUnc;
int32_t mLeapSeconds;
int32_t mLeapSecUnc;
uint64_t mTimeUncNs;
inline SystemStatusTimeAndClock() :
mGpsWeek(0),
mGpsTowMs(0),
@ -125,7 +126,8 @@ public:
mClockFreqBias(0),
mClockFreqBiasUnc(0),
mLeapSeconds(0),
mLeapSecUnc(0) {}
mLeapSecUnc(0),
mTimeUncNs(0ULL) {}
inline SystemStatusTimeAndClock(const SystemStatusPQWM1& nmea);
bool equals(const SystemStatusTimeAndClock& peer);
void dump(void);

View file

@ -4383,9 +4383,18 @@ bool GnssAdapter::getDebugReport(GnssDebugReport& r)
(int64_t)(reports.mTimeAndClock.back().mLeapSeconds))*1000ULL +
(int64_t)(reports.mTimeAndClock.back().mGpsTowMs);
r.mTime.timeUncertaintyNs =
((float)(reports.mTimeAndClock.back().mTimeUnc) +
(float)(reports.mTimeAndClock.back().mLeapSecUnc))*1000.0f;
if (reports.mTimeAndClock.back().mTimeUncNs > 0) {
// TimeUncNs value is available
r.mTime.timeUncertaintyNs =
(float)(reports.mTimeAndClock.back().mLeapSecUnc)*1000.0f +
(float)(reports.mTimeAndClock.back().mTimeUncNs);
} else {
// fall back to legacy TimeUnc
r.mTime.timeUncertaintyNs =
((float)(reports.mTimeAndClock.back().mTimeUnc) +
(float)(reports.mTimeAndClock.back().mLeapSecUnc))*1000.0f;
}
r.mTime.frequencyUncertaintyNsPerSec =
(float)(reports.mTimeAndClock.back().mClockFreqBiasUnc);
LOC_LOGV("getDebugReport - timeestimate=%" PRIu64 " unc=%f frequnc=%f",