From e5b5fbe509c035e9aabd11901aa16f84b8cbc942 Mon Sep 17 00:00:00 2001 From: Jeff Moe Date: Thu, 16 Jun 2022 11:31:05 -0600 Subject: [PATCH] ublox E6 patch based on ptudor --- galileo.cc | 5 ++ galileo.hh | 1 + html/doalles.js | 8 ++- html/index.html | 3 + navparse.cc | 6 +- ubx.cc | 12 ++++ ubx.hh | 1 + ubxtool.cc | 149 +++++++++++++++++++++++++++++++++++++++++------- 8 files changed, 161 insertions(+), 24 deletions(-) diff --git a/galileo.cc b/galileo.cc index 51eedd7..48ea135 100644 --- a/galileo.cc +++ b/galileo.cc @@ -25,6 +25,11 @@ bool getTOWFromInav(std::basic_string_view inav, uint32_t *satTOW, uint return false; } +bool getTOWFromFnav(std::basic_string_view fnav, uint32_t *satTOW, uint16_t *wn) +{ + return false; +} + int GalileoMessage::parseFnav(std::basic_string_view page) { const uint8_t* ptr = &page[0]; diff --git a/galileo.hh b/galileo.hh index 32326d8..b98d975 100644 --- a/galileo.hh +++ b/galileo.hh @@ -7,6 +7,7 @@ #include "bits.hh" bool getTOWFromInav(std::basic_string_view inav, uint32_t *satTOW, uint16_t *wn); +bool getTOWFromFnav(std::basic_string_view fnav, uint32_t *satTOW, uint16_t *wn); struct GalileoMessage : GPSLikeEphemeris { diff --git a/html/doalles.js b/html/doalles.js index cc848d6..04791b0 100644 --- a/html/doalles.js +++ b/html/doalles.js @@ -303,6 +303,8 @@ function updateSats() wantIt = true; if(d3.select("#GPSL2C").property("checked") && arr[n].gnssid==0 && arr[n].sigid == 4) wantIt = true; + if(d3.select("#GPSL5").property("checked") && arr[n].gnssid==0 && arr[n].sigid == 6) + wantIt = true; if(d3.select("#BeiDouB1I").property("checked") && arr[n].gnssid==3 && arr[n].sigid == 0) wantIt = true; if(d3.select("#BeiDouB2I").property("checked") && arr[n].gnssid==3 && arr[n].sigid == 2) @@ -311,6 +313,10 @@ function updateSats() wantIt = true; if(d3.select("#GlonassL2").property("checked") && arr[n].gnssid==6 && arr[n].sigid == 2) wantIt = true; + if(d3.select("#NAVICL5").property("checked") && arr[n].gnssid==98 && arr[n].sigid == 6) + wantIt = true; + if(d3.select("#QZSSL5").property("checked") && arr[n].gnssid==99 && arr[n].sigid == 6) + wantIt = true; if(!wantIt) continue; @@ -383,7 +389,7 @@ function setButtonSetting(name) localStorage.setItem("want"+name, d3.select("#"+name).property("checked")); } -var modes=["GalE1", "GalE5b", "GPSL1CA", "GPSL2C", "BeiDouB1I", "BeiDouB2I", "GlonassL1", "GlonassL2"]; +var modes=["GalE1", "GalE5b", "GalE5a", "GPSL1CA", "GPSL2C", "GPSL5", "BeiDouB1I", "BeiDouB2I", "GlonassL1", "GlonassL2", "NAVICL5", "QZSSL5"]; function setButtonSettings() { diff --git a/html/index.html b/html/index.html index 2d97961..57f86ca 100644 --- a/html/index.html +++ b/html/index.html @@ -18,6 +18,9 @@       + + +
diff --git a/navparse.cc b/navparse.cc index 8a24c85..d6ce9a1 100644 --- a/navparse.cc +++ b/navparse.cc @@ -872,7 +872,7 @@ try item["observed"] = false; - for(uint32_t sigid : {0,1,5}) { + for(uint32_t sigid : {0,1,5,6}) { if(auto iter = svstats.find({2, (uint32_t)ae.first, sigid}); iter != svstats.end()) { if(iter->second.completeIOD()) { @@ -937,7 +937,7 @@ try item["eph-latitude"]= 180*longlat.second/M_PI; item["observed"] = false; - for(uint32_t sigid : {0,1,4}) { + for(uint32_t sigid : {0,1,4,6}) { if(auto iter = svstats.find({0, (uint32_t)ae.first, sigid}); iter != svstats.end()) { if(time(0) - nanoTime(0, iter->second.wn(), iter->second.tow())/1000000000 < 300) item["observed"] = true; @@ -1928,6 +1928,8 @@ try int sigid = nmm.rd().sigid(); if(gnssid==2 && sigid == 0) sigid = 1; + if(gnssid==2 && sigid == 4) + sigid = 3; SatID id{(uint32_t)gnssid, (uint32_t)sv, (uint32_t)sigid}; auto& perrecv = g_svstats[id].perrecv[nmm.sourceid()]; diff --git a/ubx.cc b/ubx.cc index 387d4bd..1af4f4a 100644 --- a/ubx.cc +++ b/ubx.cc @@ -163,3 +163,15 @@ basic_string getSBASFromSFRBXMsg(std::basic_string_view msg) return payload; } + +basic_string getFnavFromSFRBXMsg(std::basic_string_view msg) +{ + // byte order adjustment + std::basic_string payload; + for(unsigned int i = 0 ; i < (msg.size() - 8) / 4; ++i) + for(int j=1; j <= 4; ++j) + payload.append(1, msg[8 + (i+1) * 4 -j]); + + + return payload; +} diff --git a/ubx.hh b/ubx.hh index f1b3ec4..3476833 100644 --- a/ubx.hh +++ b/ubx.hh @@ -17,6 +17,7 @@ std::basic_string getGPSFromSFRBXMsg(std::basic_string_view ms std::basic_string getGlonassFromSFRBXMsg(std::basic_string_view msg); std::basic_string getBeidouFromSFRBXMsg(std::basic_string_view msg); std::basic_string getSBASFromSFRBXMsg(std::basic_string_view msg); +std::basic_string getFnavFromSFRBXMsg(std::basic_string_view msg); struct CRCMismatch{}; struct TrkSatStat diff --git a/ubxtool.cc b/ubxtool.cc index 62c3469..9760e01 100644 --- a/ubxtool.cc +++ b/ubxtool.cc @@ -56,6 +56,8 @@ static int getBaudrate(int baud) { if(baud==115200) return B115200; + else if(baud==460800) + return B460800; else if(baud==57600) return B57600; else if(baud==38400) @@ -72,6 +74,8 @@ static int getBaudrateFromSymbol(int baud) { if(baud==B115200) return 115200; + else if(baud==B460800) + return 460800; else if(baud==B57600) return 57600; else if(baud==B38400) @@ -293,13 +297,14 @@ bool sendAndWaitForUBXAckNack(int fd, int seconds, basic_string_view ms -bool version9 = false; +bool version9_L2_E5b = false; +bool version9_L5_E5a = false; void enableUBXMessageOnPort(int fd, uint8_t ubxClass, uint8_t ubxType, uint8_t port, uint8_t rate=1) { for(int n=0 ; n < 5; ++n) { try { basic_string payload; - if(version9) { + if(version9_L2_E5b || version9_L5_E5a) { payload= basic_string({ubxClass, ubxType, rate}); } else { @@ -503,6 +508,7 @@ int main(int argc, char** argv) bool doGPS{true}, doGalileo{true}, doGlonass{false}, doBeidou{false}, doReset{false}, doWait{true}, doRTSCTS{true}, doSBAS{false}; + bool doQZSS(false), doNAVIC(false); bool doFakeFix{false}; bool doKeepNMEA{false}; bool doSTDOUT=false; @@ -528,6 +534,9 @@ int main(int argc, char** argv) app.add_flag("--glonass,-r", doGlonass, "Enable Glonass reception"); app.add_flag("--galileo,-e", doGalileo, "Enable Galileo reception"); app.add_flag("--sbas,-s", doSBAS, "Enable SBAS (EGNOS/WAAS/etc) reception"); + app.add_flag("--zed-e5a", version9_L5_E5a, "Enable uBlox ZED F9T-10B support for L5 signals"); + app.add_flag("--navic", doNAVIC, "Enable NAVIC reception"); + app.add_flag("--qzss", doQZSS, "Enable QZSS reception"); app.add_option("--rtscts", doRTSCTS, "Set hardware handshaking"); app.add_flag("--stdout", doSTDOUT, "Emit output to stdout"); auto pn = app.add_option("--port,-p", portName, "Device or file to read serial from"); @@ -593,7 +602,7 @@ int main(int argc, char** argv) baudrate = getBaudrateFromSymbol(g_baudval); if(doFakeFix) // hack - version9 = true; + version9_L2_E5b = true; bool m8t = false; string hwversion; @@ -647,7 +656,9 @@ int main(int argc, char** argv) cerr< msg; - if(version9) { + if(version9_L2_E5b) { cmd = 0x8a; msg = buildUbxMessage(0x06, cmd, {0x00, 0x01, 0x00, 0x00, 0x01,0x00,0x03,0x20, 1, // survey in mode @@ -930,12 +999,7 @@ int main(int argc, char** argv) if (doDEBUG) { cerr< reserved1, reserved2, sar, spare, crc; auto inav = getInavFromSFRBXMsg(payload, reserved1, reserved2, sar, spare, crc); unsigned int wtype = getbitu(&inav[0], 0, 6); @@ -1474,6 +1549,30 @@ int main(int argc, char** argv) nmm.mutable_gi()->set_spare((const char*)&spare[0], spare.size()); ns.emitNMM( nmm); + } + else if(sigid == 3) { + auto fnav = getFnavFromSFRBXMsg(payload); + uint32_t satTOW; + int msgTOW{0}; + if(getTOWFromFnav(fnav, &satTOW, &g_galwn)) { // 0, 6, 5 + msgTOW = satTOW; + curCycleTOW = satTOW - (satTOW %30); + } + auto gstr = getFnavFromSFRBXMsg(payload); + NavMonMessage nmm; + nmm.set_localutcseconds(g_gnssutc.tv_sec); + nmm.set_localutcnanoseconds(g_gnssutc.tv_nsec); + nmm.set_sourceid(g_srcid); + nmm.set_type(NavMonMessage::GalileoFnavType); + nmm.mutable_gf()->set_gnssid(id.first); + nmm.mutable_gf()->set_gnsssv(id.second); + nmm.mutable_gf()->set_sigid(sigid); + nmm.mutable_gf()->set_contents(string((char*)gstr.c_str(), gstr.size())); + nmm.mutable_gf()->set_gnsswn(g_galwn); + nmm.mutable_gf()->set_gnsstow(msgTOW); + + ns.emitNMM( nmm); + } } else if(id.first==3) { auto gstr = getGlonassFromSFRBXMsg(payload); @@ -1571,7 +1670,7 @@ int main(int argc, char** argv) } else if(msg.getClass() == 1 && msg.getType() == 0x35) { // UBX-NAV-SAT - if(version9) // we have UBX-NAV-SIG + if(version9_L2_E5b || version9_L5_E5a) continue; // if (doDEBUG) { cerr<