#include #include #include #include #include "fmt/format.h" #include "fmt/printf.h" #include #include #include #include #include #include #include #include "ubx.hh" #include "bits.hh" #include "minivec.hh" #include "navmon.pb.h" #include "ephemeris.hh" #include "gps.hh" #include "glonass.hh" #include "beidou.hh" #include "galileo.hh" #include "navmon.hh" #include "tle.hh" #include using namespace std; static std::string humanTime(time_t t) { struct tm tm={0}; gmtime_r(&t, &tm); char buffer[80]; strftime(buffer, sizeof(buffer), "%a, %d %b %Y %T %z", &tm); return buffer; } string beidouHealth(int in) { string ret; if(in == 256) { return "NO CLOCK"; } if(in==511) { return "NO SAT"; } if(in & (1<<7)) ret += "B1I abnormal "; if(in & (1<<6)) ret += "B2I abnormal "; if(in & (1<<5)) ret += "B3I abnormal "; if(in & (1<<1)) ret += "navigation abnormal "; if(ret.empty()) return "OK"; return ret; } int main(int argc, char** argv) try { TLERepo tles; // tles.parseFile("active.txt"); tles.parseFile("galileo.txt"); tles.parseFile("glo-ops.txt"); tles.parseFile("gps-ops.txt"); tles.parseFile("beidou.txt"); ofstream almanac("almanac.txt"); ofstream iodstream("iodstream.csv"); iodstream << "timestamp gnssid sv iodnav t0e age" << endl; for(;;) { char bert[4]; int res = readn2(0, bert, 4); if( res != 4) { cerr<<"EOF, res = "< inav((uint8_t*)nmm.gi().contents().c_str(), nmm.gi().contents().size()); static map gms; static map, GalileoMessage> gmwtypes; static map oldgm4s; int sv = nmm.gi().gnsssv(); GalileoMessage& gm = gms[sv]; int wtype = gm.parse(inav); gm.tow = nmm.gi().gnsstow(); gmwtypes[{nmm.gi().gnsssv(), wtype}] = gm; cout << "gal inav for "<=7 && wtype<=10) cout<<" ioda "<((uint8_t*)nmm.gpsi().contents().c_str(), nmm.gpsi().contents().size())); struct GPSState gs; uint8_t page; int frame=parseGPSMessage(cond, gs, &page); cout<<"GPS "< oldgs1s; cout << "gpshealth = "<<(int)gs.gpshealth<<", wn "<second.t0c != gs.t0c) { auto oldOffset = getAtomicOffset(gs.tow, iter->second); auto newOffset = getAtomicOffset(gs.tow, gs); cout<<" Timejump: "<second) )<<" seconds, old t0c "<second.t0c; } oldgs1s[sv] = gs; } else if(frame == 2) { cout << "t0e = "<second.t0e << " " <second.t0e); } cout<<"\n"; } else if(nmm.type() == NavMonMessage::BeidouInavTypeD1) { int sv = nmm.bid1().gnsssv(); auto cond = getCondensedBeidouMessage(std::basic_string((uint8_t*)nmm.bid1().contents().c_str(), nmm.bid1().contents().size())); uint8_t pageno; static map bms; auto& bm = bms[sv]; int fraid = bm.parse(cond, &pageno); cout<<"BeiDou "< msgs; if(msgs[sv].wn>= 0 && msgs[sv].t0c != bm.t0c) { auto oldOffset = msgs[sv].getAtomicOffset(bm.sow); auto newOffset = bm.getAtomicOffset(bm.sow); cout<<" Timejump: "<((uint8_t*)nmm.bid2().contents().c_str(), nmm.bid2().contents().size())); BeidouMessage bm; uint8_t pageno; int fraid = bm.parse(cond, &pageno); cout<<"BeiDou "< gms; auto& gm = gms[nmm.gloi().gnsssv()]; int strno = gm.parse(std::basic_string((uint8_t*)nmm.gloi().contents().c_str(), nmm.gloi().contents().size())); cout<<"Glonass R"< "; cout << "("<