From 2400a166f0d30a4769a469cca64ac3615c893a9e Mon Sep 17 00:00:00 2001 From: bert hubert Date: Thu, 9 Jul 2020 20:40:38 +0100 Subject: [PATCH] make ubxtool enable TIMEGPS/TIMEGAL etc by default, but make sure we disable GNSSes we are not looking for, strange numbers come out otherwise --- ubxtool.cc | 129 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 80 insertions(+), 49 deletions(-) diff --git a/ubxtool.cc b/ubxtool.cc index 1bb2d1f..c750253 100644 --- a/ubxtool.cc +++ b/ubxtool.cc @@ -946,18 +946,18 @@ int main(int argc, char** argv) if (doDEBUG) { cerr< itows; + if(doGlonass) + itows.push_back(glo.itow); + if(doGalileo) + itows.push_back(gal.itow); + if(doBeidou) + itows.push_back(bds.itow); + if(doGPS) + itows.push_back(gps.itow); + + if(itows.empty()) return; - + if(itows[0] == 0) + return; + + for(const auto& itow : itows) + if(itow != itows[0]) + return; + NavMonMessage nmm; nmm.set_sourceid(g_srcid); nmm.set_localutcseconds(g_gnssutc.tv_sec); @@ -1028,47 +1045,61 @@ int main(int argc, char** argv) nmm.set_type(NavMonMessage::TimeOffsetType); nmm.mutable_to()->set_itow(gps.itow); - auto no = nmm.mutable_to()->add_offsets(); - no->set_gnssid(0); - no->set_offsetns(gps.ftow); - no->set_tacc(gps.tAcc); - no->set_tow(gps.itow); // this is for consistency - no->set_leaps(gps.leapS); - no->set_wn(gps.week); - no->set_valid(gps.valid); - - no = nmm.mutable_to()->add_offsets(); - no->set_gnssid(2); - no->set_offsetns(gal.fGalTow); - no->set_tacc(gal.tAcc); - no->set_leaps(gal.leapS); - no->set_wn(gal.galWno); - no->set_valid(gal.valid); - no->set_tow(gal.galTow); + NavMonMessage::GNSSOffset* no; + if(doGPS) { + no = nmm.mutable_to()->add_offsets(); + no->set_gnssid(0); + no->set_offsetns(gps.ftow); + no->set_tacc(gps.tAcc); + no->set_tow(gps.itow); // this is for consistency + no->set_leaps(gps.leapS); + no->set_wn(gps.week); + no->set_valid(gps.valid); + } - no = nmm.mutable_to()->add_offsets(); - no->set_gnssid(3); - no->set_offsetns(bds.fSow); - no->set_tacc(bds.tAcc); - no->set_leaps(bds.leapS); - no->set_wn(bds.week); - no->set_valid(bds.valid); - no->set_tow(bds.sow); - - no = nmm.mutable_to()->add_offsets(); - no->set_gnssid(6); - no->set_offsetns(glo.fTod); - no->set_tacc(glo.tAcc); - no->set_nt(glo.nT); - no->set_n4(glo.n4); - no->set_valid(glo.valid); - no->set_tow(glo.tod); - + if(doGalileo) { + no = nmm.mutable_to()->add_offsets(); + no->set_gnssid(2); + no->set_offsetns(gal.fGalTow); + no->set_tacc(gal.tAcc); + no->set_leaps(gal.leapS); + no->set_wn(gal.galWno); + no->set_valid(gal.valid); + no->set_tow(gal.galTow); + } + + if(doBeidou) { + no = nmm.mutable_to()->add_offsets(); + no->set_gnssid(3); + no->set_offsetns(bds.fSow); + no->set_tacc(bds.tAcc); + no->set_leaps(bds.leapS); + no->set_wn(bds.week); + no->set_valid(bds.valid); + no->set_tow(bds.sow); + } + + if(doGlonass) { + no = nmm.mutable_to()->add_offsets(); + no->set_gnssid(6); + no->set_offsetns(glo.fTod); + no->set_tacc(glo.tAcc); + no->set_nt(glo.nT); + no->set_n4(glo.n4); + no->set_valid(glo.valid); + no->set_tow(glo.tod); + } ns.emitNMM(nmm); gal.itow = 0; + gps.itow = 0; + glo.itow = 0; + bds.itow = 0; } } tstate; + tstate.doGPS = doGPS; tstate.doGalileo = doGalileo; tstate.doGlonass = doGlonass; + tstate.doBeidou = doBeidou; + for(;;) { try { auto [msg, timestamp] = getUBXMessage(fd, nullptr); @@ -1833,13 +1864,13 @@ int main(int argc, char** argv) else if(msg.getClass() == 0x01 && msg.getType() == 0x24) { // UBX-NAV-TIMEBDS memcpy(&tstate.bds, &payload[0], sizeof(TIMEBDS)); - // cerr << "TIMEBDS itow: "<