diff --git a/Makefile b/Makefile index 4c5dc91..b890760 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CXXFLAGS:= -std=gnu++17 -Wall -O3 -MMD -MP -ggdb -fno-omit-frame-pointer -Iext/fmt-5.2.1/include/ +CXXFLAGS:= -std=gnu++17 -Wall -O3 -MMD -MP -ggdb -fno-omit-frame-pointer -Iext/fmt-5.2.1/include/ -Iext/powerblog/ext/simplesocket -Iext/powerblog/ext/ PROGRAMS = ubxparse ubxdisplay minread @@ -9,8 +9,10 @@ all: $(PROGRAMS) clean: rm -f *~ *.o *.d ext/*/*.o $(PROGRAMS) -ubxparse: ubxparse.o ext/fmt-5.2.1/src/format.o - g++ -std=gnu++17 $^ -o $@ -pthread -lncurses +H2OPP=ext/powerblog/h2o-pp.o +SIMPLESOCKETS=ext/powerblog/ext/simplesocket/swrappers.o ext/powerblog/ext/simplesocket/sclasses.o ext/powerblog/ext/simplesocket/comboaddress.o +ubxparse: ubxparse.o ext/fmt-5.2.1/src/format.o $(H2OPP) $(SIMPLESOCKETS) + g++ -std=gnu++17 $^ -o $@ -pthread -lncurses -L/usr/local/lib -lh2o-evloop -lssl -lcrypto -lz ubxdisplay: ubxdisplay.o ext/fmt-5.2.1/src/format.o g++ -std=gnu++17 $^ -o $@ -pthread -lncurses diff --git a/ubxparse.cc b/ubxparse.cc index 4d4f597..70694d1 100644 --- a/ubxparse.cc +++ b/ubxparse.cc @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include "ext/powerblog/h2o-pp.hh" using namespace std; struct EofException{}; @@ -156,6 +159,8 @@ struct SVIOD int16_t cuc{0}, cus{0}, crc{0}, crs{0}, cic{0}, cis{0}; uint8_t sisa; + + uint32_t wn{0}, tow{0}; bool complete() const { return words[1] && words[2] && words[3] && words[4]; @@ -208,7 +213,8 @@ struct SVStat bool disturb1{false}, disturb2{false}, disturb3{false}, disturb4{false}, disturb5{false}; uint16_t wn{0}; uint32_t tow{0}; // "last seen" - uint32_t a0{0}, a1{0}; + uint32_t a0{0}, a1{0}, t0t{0}, wn0t{0}; + int16_t el{-1}, db{-1}; map iods; void addWord(std::basic_string_view page); bool completeIOD() const; @@ -248,7 +254,16 @@ SVIOD SVStat::liveIOD() const void SVStat::addWord(std::basic_string_view page) { uint8_t wtype = getbitu(&page[0], 0, 6); - if(wtype >=1 && wtype <= 4) { // ephemeris + + + if(wtype == 0) { + if(getbitu(&page[0], 6,2) == 2) { + wn = getbitu(&page[0], 96, 12); + tow = getbitu(&page[0], 108, 20); + } + + } + else if(wtype >=1 && wtype <= 4) { // ephemeris uint16_t iod = getbitu(&page[0], 6, 10); iods[iod].addWord(page); @@ -271,7 +286,18 @@ void SVStat::addWord(std::basic_string_view page) tow = getbitu(&page[0], 85, 20); // cout<<"Setting tow to "< (" + << x << ", "<< y <<", "<< z<<") " << sqrt(ourx*ourx + oury*oury + ourz*ourz) <<" - " << sqrt(x*x+y*y+z*z) < 2 ? argv[2] : "./html/"); + + int port = argc > 1 ? atoi(argv[1]) : 29599; + std::thread ws([&h2s, port]() { + auto actx = h2s.addContext(); + h2s.addListener(ComboAddress("::", port), actx); + cout<<"Listening on port "<< port < strs; boost::split(strs,line,boost::is_any_of(",")); for(unsigned int n=4; n + 4 < strs.size(); n += 4) { + g_svstats[atoi(strs[n].c_str())].el = atoi(strs[n+1].c_str()); + if(g_svstats[atoi(strs[n].c_str())].el >= 0) + g_svstats[atoi(strs[n].c_str())].db = atoi(strs[n+3].c_str()); + else + g_svstats[atoi(strs[n].c_str())].db = -1; + /* cout<<"sv "<