From ef79c0e21c45a0617f52acbb364c9cc495e233ff Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 16 Aug 2019 10:51:29 +0200 Subject: [PATCH 1/4] Fix OpenBSD/clang errors; fix Makefile to use CXX and add some include paths. --- Makefile | 10 +++++----- ephemeris.hh | 7 ++++--- navnexus.cc | 3 ++- navparse.cc | 6 ++++-- ubxtool.cc | 9 ++++----- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index ffcf525..30600e3 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/ -Iext/powerblog/ext/simplesocket -Iext/powerblog/ext/ +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/ -I/usr/local/include PROGRAMS = navparse ubxtool navnexus navrecv navdump @@ -16,19 +16,19 @@ navparse: navparse.o ext/fmt-5.2.1/src/format.o $(H2OPP) $(SIMPLESOCKETS) minicu $(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lh2o-evloop -lssl -lcrypto -lz -lcurl -lprotobuf # -lwslay navdump: navdump.o ext/fmt-5.2.1/src/format.o bits.o navmon.pb.o - $(CXX) -std=gnu++17 $^ -o $@ -pthread -lprotobuf + $(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lprotobuf navnexus: navnexus.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) ubx.o bits.o navmon.pb.o storage.o - $(CXX) -std=gnu++17 $^ -o $@ -pthread -lprotobuf + $(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lprotobuf navrecv: navrecv.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) navmon.pb.o storage.o - $(CXX) -std=gnu++17 $^ -o $@ -pthread -lprotobuf + $(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lprotobuf navmon.pb.cc: navmon.proto protoc --cpp_out=./ navmon.proto ubxtool: navmon.pb.o ubxtool.o ubx.o bits.o ext/fmt-5.2.1/src/format.o galileo.o gps.o - $(CXX) -std=gnu++17 $^ -o $@ -lprotobuf + $(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -lprotobuf diff --git a/ephemeris.hh b/ephemeris.hh index fd207cd..107d608 100644 --- a/ephemeris.hh +++ b/ephemeris.hh @@ -1,13 +1,14 @@ #pragma once #include "minivec.hh" -void getCoordinates(int wn, double tow, const auto& iod, Point* p, bool quiet=true) +template +void getCoordinates(int wn, double tow, const T& iod, Point* p, bool quiet=true) { using namespace std; // here goes - constexpr double mu = 3.986004418 * pow(10.0, 14.0); - constexpr double omegaE = 7.2921151467 * pow(10.0, -5); + const double mu = 3.986004418 * pow(10.0, 14.0); + const double omegaE = 7.2921151467 * pow(10.0, -5); double sqrtA = 1.0*iod.sqrtA / (1ULL<<19); double deltan = M_PI * 1.0*iod.deltan / (1LL<<43); diff --git a/navnexus.cc b/navnexus.cc index fa6d9a0..8e92a0e 100644 --- a/navnexus.cc +++ b/navnexus.cc @@ -14,6 +14,7 @@ #include #include "storage.hh" #include +#include using namespace std; @@ -45,7 +46,7 @@ vector getSources() } if(result->d_name[0] != '.') { uint64_t src; - if(sscanf(result->d_name, "%08lx", &src)==1) + if(sscanf(result->d_name, "%08" PRIx64, &src)==1) ret.push_back(src); } } diff --git a/navparse.cc b/navparse.cc index 2fbcb20..2a29640 100644 --- a/navparse.cc +++ b/navparse.cc @@ -348,14 +348,16 @@ struct InfluxPusher explicit InfluxPusher(std::string_view dbname) : d_dbname(dbname) { } - void addValue( const pair,SVStat>& ent, string_view name, auto value) + template + void addValue( const pair,SVStat>& ent, string_view name, T value) { d_buffer+= string(name)+",gnssid="+to_string(ent.first.first)+ +",sv=" +to_string(ent.first.second)+" value="+to_string(value)+ " "+to_string(nanoTime(ent.first.first, ent.second.wn, ent.second.tow))+"\n"; checkSend(); } - void addValue(pair id, string_view name, auto value) + template + void addValue(pair id, string_view name, T value) { if(g_svstats[id].wn ==0 && g_svstats[id].tow == 0) return; diff --git a/ubxtool.cc b/ubxtool.cc index caeccb8..f81582b 100644 --- a/ubxtool.cc +++ b/ubxtool.cc @@ -28,8 +28,7 @@ using namespace std; uint16_t g_srcid{2}; -#define BAUDRATE B921600 -#define MODEMDEVICE "/dev/ttyACM0" +#define BAUDRATE B115200 namespace { struct EofException{}; @@ -427,7 +426,7 @@ int main(int argc, char** argv) tm.tm_sec = pvt.sec; uint32_t satt = timegm(&tm); - double satutc = timegm(&tm) + pvt.nano/1000000000.0; // negative is no problem here + //double satutc = timegm(&tm) + pvt.nano/1000000000.0; // negative is no problem here if(pvt.nano < 0) { pvt.sec--; satt--; @@ -446,7 +445,7 @@ int main(int argc, char** argv) time_t ourt = timestamp.tv_sec; gmtime_r(&ourt, &ourtime); - double ourutc = ourt + timestamp.tv_usec/1000000.0; + //double ourutc = ourt + timestamp.tv_usec/1000000.0; seconds = ourtime.tm_sec + timestamp.tv_usec/1000000.0; // fmt::fprintf(stderr, "Our UTC : %02d:%02d:%06.4f -> %.4f or %d:%f -> delta = %.4fs\n", tm.tm_hour, tm.tm_min, seconds, ourutc, timestamp.tv_sec, 1.0*timestamp.tv_usec, ourutc - satutc); @@ -473,7 +472,7 @@ int main(int argc, char** argv) uint8_t prStddev = payload[43+23*n] & 0xf; uint8_t cpStddev = payload[44+23*n] & 0xf; uint8_t doStddev = payload[45+23*n] & 0xf; - uint8_t trkStat = payload[46+23*n] & 0xf; + //uint8_t trkStat = payload[46+23*n] & 0xf; NavMonMessage nmm; nmm.set_type(NavMonMessage::RFDataType); From a35df6545bfa04b3b2d867a21ab3f1b2d274c5be Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 16 Aug 2019 11:25:28 +0200 Subject: [PATCH 2/4] Allow for address:port spec of listening address --- navparse.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/navparse.cc b/navparse.cc index 2a29640..1277d97 100644 --- a/navparse.cc +++ b/navparse.cc @@ -628,11 +628,11 @@ try }); h2s.addDirectory("/", argc > 2 ? argv[2] : "./html/"); - int port = argc > 1 ? atoi(argv[1]) : 29599; - std::thread ws([&h2s, port]() { + const char *address = argc > 1 ? argv[1] : "127.0.0.1:29599"; + std::thread ws([&h2s, address]() { auto actx = h2s.addContext(); - h2s.addListener(ComboAddress("::", port), actx); - cout<<"Listening on port "<< port < Date: Sun, 18 Aug 2019 11:08:54 +0200 Subject: [PATCH 3/4] -L /usr/local/lib --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6ad9e92..f72591a 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ navparse: navparse.o ext/fmt-5.2.1/src/format.o $(H2OPP) $(SIMPLESOCKETS) minicu $(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lh2o-evloop -lssl -lcrypto -lz -lcurl -lprotobuf # -lwslay navdump: navdump.o ext/fmt-5.2.1/src/format.o bits.o navmon.pb.o gps.o ephemeris.o - $(CXX) -std=gnu++17 $^ -o $@ -pthread -lprotobuf + $(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lprotobuf navnexus: navnexus.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) ubx.o bits.o navmon.pb.o storage.o $(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lprotobuf From 4c020b093ab80dfdc9bd2da5a0b8c0d73dd18357 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 30 Aug 2019 17:18:15 +0200 Subject: [PATCH 4/4] No CRTSCTS --- ubxtool.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubxtool.cc b/ubxtool.cc index cc89306..2ba1d81 100644 --- a/ubxtool.cc +++ b/ubxtool.cc @@ -322,7 +322,7 @@ int initFD(const char* fname) } bzero(&newtio, sizeof(newtio)); - newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD; + newtio.c_cflag = BAUDRATE | /*CRTSCTS */ CS8 | CLOCAL | CREAD; newtio.c_iflag = IGNPAR; newtio.c_oflag = 0;