diff --git a/Makefile b/Makefile index 8251ffd..2371a3f 100644 --- a/Makefile +++ b/Makefile @@ -36,34 +36,34 @@ clean: decrypt: decrypt.o bits.o ext/fmt-5.2.1/src/format.o $(CXX) -std=gnu++17 $^ -o $@ -navparse: navparse.o ext/fmt-5.2.1/src/format.o $(H2OPP) $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o trkmeas.o influxpush.o ${EXTRADEP} +navparse: navparse.o ext/fmt-5.2.1/src/format.o $(H2OPP) $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o trkmeas.o influxpush.o ${EXTRADEP} githash.o $(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -L/usr/local/opt/openssl/lib/ -lh2o-evloop -lssl -lcrypto -lz -lcurl -lprotobuf $(WSLAY) -reporter: reporter.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o +reporter: reporter.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o githash.o $(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lprotobuf -lcurl galmonmon: galmonmon.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) minicurl.o ubx.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o navmon.o coverage.o osen.o githash.o $(CXX) -std=gnu++17 $^ -o $@ -pthread -L/usr/local/lib -lprotobuf -lcurl -navdump: navdump.o ext/fmt-5.2.1/src/format.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o navmon.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o sp3.o osen.o trkmeas.o ${EXTRADEP} +navdump: navdump.o ext/fmt-5.2.1/src/format.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o navmon.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) tle.o sp3.o osen.o trkmeas.o githash.o ${EXTRADEP} $(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -pthread -lprotobuf -navdisplay: navdisplay.o ext/fmt-5.2.1/src/format.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o ephemeris.o navmon.o osen.o +navdisplay: navdisplay.o ext/fmt-5.2.1/src/format.o bits.o navmon.pb.o gps.o ephemeris.o beidou.o glonass.o ephemeris.o navmon.o osen.o githash.o $(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -pthread -lprotobuf -lncurses -navnexus: navnexus.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) ubx.o bits.o navmon.pb.o storage.o +navnexus: navnexus.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) ubx.o bits.o navmon.pb.o storage.o githash.o $(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -pthread -lprotobuf -navcat: navcat.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) ubx.o bits.o navmon.pb.o storage.o navmon.o +navcat: navcat.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) ubx.o bits.o navmon.pb.o storage.o navmon.o githash.o $(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -pthread -lprotobuf -navrecv: navrecv.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) navmon.pb.o storage.o +navrecv: navrecv.o ext/fmt-5.2.1/src/format.o $(SIMPLESOCKETS) navmon.pb.o storage.o githash.o $(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -pthread -lprotobuf -tlecatch: tlecatch.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) +tlecatch: tlecatch.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) githash.o $(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -pthread -lprotobuf navmon.pb.cc: navmon.proto diff --git a/galmonmon.cc b/galmonmon.cc index 6646f73..738bdb2 100644 --- a/galmonmon.cc +++ b/galmonmon.cc @@ -7,8 +7,20 @@ #include "ext/powerblog/h2o-pp.hh" #include #include "githash.h" +#include "CLI/CLI.hpp" +#include "version.hh" + +static char program[]="galmonmon"; + using namespace std; +extern const char* g_gitHash; + +void showVersion() +{ + _showVersion(program,g_gitHash) +} + /* Monitoring the satellites for sensible alerts. @@ -164,15 +176,29 @@ int main(int argc, char **argv) MiniCurl::MiniCurlHeaders mch; // string url="https://galmon.eu/svs.json"; string url="http://[::1]:10000/"; - + bool doVERSION{false}; + + CLI::App app(program); + + app.add_flag("--version", doVERSION, "show program version and copyright"); + + try { + app.parse(argc, argv); + } catch(const CLI::Error &e) { + return app.exit(e); + } + + if(doVERSION) { + showVersion(); + exit(0); + } + g_sk.setBoolNames("health", "healthy", "unhealthy"); g_sk.setBoolNames("eph-too-old", "ephemeris fresh", "ephemeris too old"); g_sk.setBoolNames("silent", "observed", "not observed"); std::variant tst; - extern const char* g_gitHash; - auto observers = nlohmann::json::parse(mc.getURL(url+"observers.json")); cout<<("Galmonmon " +string(g_gitHash)+ " started, " + std::to_string(observers.size()) +" observers seen")< #include #include "navmon.hh" +#include "githash.h" +#include "CLI/CLI.hpp" +#include "version.hh" + +static char program[]="navcat"; using namespace std; +extern const char* g_gitHash; + +void showVersion() +{ + _showVersion(program,g_gitHash) +} + void unixDie(const std::string& str) { throw std::runtime_error(str+string(": ")+string(strerror(errno))); @@ -163,6 +175,23 @@ void sendProtobuf(string_view dir, time_t startTime, time_t stopTime=0) int main(int argc, char** argv) { + bool doVERSION{false}; + + CLI::App app(program); + + app.add_flag("--version", doVERSION, "show program version and copyright"); + + try { + app.parse(argc, argv); + } catch(const CLI::Error &e) { + return app.exit(e); + } + + if(doVERSION) { + showVersion(); + exit(0); + } + signal(SIGPIPE, SIG_IGN); if(argc < 3) { cout<<"Syntax: navcat storage start stop"< #include "navmon.hh" +#include "githash.h" +#include "CLI/CLI.hpp" +#include "version.hh" + +static char program[]="navdisplay"; + using namespace std; +extern const char* g_gitHash; + +void showVersion() +{ + _showVersion(program,g_gitHash) +} struct WinKeeper { diff --git a/navdump.cc b/navdump.cc index 3bb89ab..f64de6e 100644 --- a/navdump.cc +++ b/navdump.cc @@ -26,8 +26,20 @@ #include "sp3.hh" #include "ubx.hh" #include +#include "githash.h" +#include "version.hh" + +static char program[]="navdump"; + using namespace std; +extern const char* g_gitHash; + +void showVersion() +{ + _showVersion(program,g_gitHash) +} + Point g_ourpos; @@ -226,7 +238,7 @@ try { GOOGLE_PROTOBUF_VERIFY_VERSION; - CLI::App app("navdump"); + CLI::App app(program); TLERepo tles; @@ -247,16 +259,22 @@ try bool doReceptionData{false}; bool doRFData{true}; bool doObserverPosition{false}; + bool doVERSION{false}; app.add_option("--svs", svpairs, "Listen to specified svs. '0' = gps, '2' = Galileo, '2,1' is E01"); app.add_option("--stations", stations, "Listen to specified stations."); app.add_option("--positions,-p", doObserverPosition, "Print out observer positions (or not)"); app.add_option("--rfdata,-r", doRFData, "Print out RF data (or not)"); + app.add_flag("--version", doVERSION, "show program version and copyright"); try { app.parse(argc, argv); } catch(const CLI::Error &e) { return app.exit(e); } + if(doVERSION) { + showVersion(); + exit(0); + } SVFilter svfilter; for(const auto& svp : svpairs) { svfilter.addFilter(svp); diff --git a/navnexus.cc b/navnexus.cc index f8ef6ee..e69e85b 100644 --- a/navnexus.cc +++ b/navnexus.cc @@ -15,9 +15,22 @@ #include "storage.hh" #include #include +#include "githash.h" +#include "CLI/CLI.hpp" +#include "version.hh" + +static char program[]="navnexus"; using namespace std; +extern const char* g_gitHash; + +void showVersion() +{ + _showVersion(program,g_gitHash) +} + + std::mutex g_clientmut; set g_clients; @@ -143,6 +156,23 @@ void sendListener(Socket&& s, ComboAddress local, int hours) int main(int argc, char** argv) { + bool doVERSION{false}; + + CLI::App app(program); + + app.add_flag("--version", doVERSION, "show program version and copyright"); + + try { + app.parse(argc, argv); + } catch(const CLI::Error &e) { + return app.exit(e); + } + + if(doVERSION) { + showVersion(); + exit(0); + } + signal(SIGPIPE, SIG_IGN); if(argc < 3) { cout<<"Syntax: navnexus storage listen-address [backlog-hours]"< #include "influxpush.hh" +#include "githash.h" +#include "CLI/CLI.hpp" +#include "version.hh" + +static char program[]="navparse"; using namespace std; +extern const char* g_gitHash; + +void showVersion() +{ + _showVersion(program,g_gitHash) +} + struct ObserverPosition { Point pos; @@ -415,6 +427,23 @@ void addHeaders(h2o_req_t* req) int main(int argc, char** argv) try { + bool doVERSION{false}; + + CLI::App app(program); + + app.add_flag("--version", doVERSION, "show program version and copyright"); + + try { + app.parse(argc, argv); + } catch(const CLI::Error &e) { + return app.exit(e); + } + + if(doVERSION) { + showVersion(); + exit(0); + } + // feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); diff --git a/navrecv.cc b/navrecv.cc index a91d436..7335daf 100644 --- a/navrecv.cc +++ b/navrecv.cc @@ -11,8 +11,21 @@ #include #include #include +#include "githash.h" +#include "CLI/CLI.hpp" +#include "version.hh" + +static char program[]="navrecv"; + using namespace std; +extern const char* g_gitHash; + +void showVersion() +{ + _showVersion(program,g_gitHash) +} + /* Goals in life: 1) NEVER EVER GO DOWN @@ -181,6 +194,23 @@ void recvListener(Socket&& s, ComboAddress local) int main(int argc, char** argv) { + bool doVERSION{false}; + + CLI::App app(program); + + app.add_flag("--version", doVERSION, "show program version and copyright"); + + try { + app.parse(argc, argv); + } catch(const CLI::Error &e) { + return app.exit(e); + } + + if(doVERSION) { + showVersion(); + exit(0); + } + signal(SIGPIPE, SIG_IGN); if(argc != 3) { cout<<"Syntax: navrecv listen-address storage"< #include +#include "githash.h" +#include "CLI/CLI.hpp" +#include "version.hh" + +static char program[]="tlecatch"; + using namespace std; + +extern const char* g_gitHash; + +void showVersion() +{ + _showVersion(program,g_gitHash) +} + int main(int argc, char **argv) { string line; @@ -9,7 +23,23 @@ int main(int argc, char **argv) time_t now = time(0); struct tm tm; gmtime_r(&now, &tm); - + bool doVERSION{false}; + + CLI::App app(program); + + app.add_flag("--version", doVERSION, "show program version and copyright"); + + try { + app.parse(argc, argv); + } catch(const CLI::Error &e) { + return app.exit(e); + } + + if(doVERSION) { + showVersion(); + exit(0); + } + for(;;) { DateTime d(1900 + tm.tm_year, tm.tm_mon+1, tm.tm_mday, 04, 43, 51); string name, line1, line2; diff --git a/ubxtool.cc b/ubxtool.cc index 1413785..c76f383 100644 --- a/ubxtool.cc +++ b/ubxtool.cc @@ -32,9 +32,13 @@ #include "swrappers.hh" #include "sclasses.hh" #include "githash.h" +#include "version.hh" + +static char program[]="ubxtool"; bool doDEBUG{false}; bool doLOGFILE{false}; +bool doVERSION{false}; struct timespec g_gnssutc; uint16_t g_galwn; @@ -44,6 +48,12 @@ using namespace std; uint16_t g_srcid{0}; int g_fixtype{-1}; double g_speed{-1}; +extern const char* g_gitHash; + +void showVersion() +{ + _showVersion(program,g_gitHash) +} static int getBaudrate(int baud) { @@ -534,7 +544,7 @@ int main(int argc, char** argv) time_t starttime=time(0); GOOGLE_PROTOBUF_VERIFY_VERSION; - CLI::App app("ubxtool"); + CLI::App app(program); bool doGPS{true}, doGalileo{true}, doGlonass{false}, doBeidou{true}, doReset{false}, doWait{true}, doRTSCTS{true}, doSBAS{false}; @@ -563,7 +573,7 @@ int main(int argc, char** argv) app.add_flag("--sbas,-s", doSBAS, "Enable SBAS (EGNOS/WAAS/etc) reception"); app.add_option("--rtscts", doRTSCTS, "Set hardware handshaking"); app.add_flag("--stdout", doSTDOUT, "Emit output to stdout"); - app.add_option("--port,-p", portName, "Device or file to read serial from")->required(); + auto pn = app.add_option("--port,-p", portName, "Device or file to read serial from"); app.add_option("--station", g_srcid, "Station id"); app.add_option("--ubxport,-u", ubxport, "UBX port to enable messages on (usb=3)"); app.add_option("--baud,-b", baudrate, "Baudrate for serial connection"); @@ -581,12 +591,22 @@ int main(int argc, char** argv) app.add_flag("--survey-reset", doSurveyReset, "Reset the Surveyed-in state"); app.add_flag("--debug", doDEBUG, "Display debug information"); app.add_flag("--logfile", doLOGFILE, "Create logfile"); + app.add_flag("--version", doVERSION, "show program version and copyright"); try { app.parse(argc, argv); } catch(const CLI::Error &e) { return app.exit(e); } + if(doVERSION) { + showVersion(); + exit(0); + } + + if(! *pn) { + cerr<<"you must provide the --port"<set_owner(owner); nmm.mutable_od()->set_remark(remark); - extern const char* g_gitHash; nmm.mutable_od()->set_recvgithash(g_gitHash); nmm.mutable_od()->set_uptime(time(0) - starttime); diff --git a/version.hh b/version.hh new file mode 100644 index 0000000..9cb81e2 --- /dev/null +++ b/version.hh @@ -0,0 +1,8 @@ +#pragma once + +#define _showVersion(program,g_gitHash) { \ + cout <<"galmon tools (" <