diff --git a/Makefile b/Makefile index 6bfceb4..edc4131 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ CXXFLAGS:= -std=gnu++17 -Wall -O3 -MMD -MP -ggdb -fno-omit-frame-pointer -Iext/C # CXXFLAGS += -Wno-delete-non-virtual-dtor + +CHEAT_ARG := $(shell ./update-git-hash-if-necessary) + PROGRAMS = navparse ubxtool navnexus navcat navrecv navdump testrunner navdisplay tlecatch reporter all: navmon.pb.cc $(PROGRAMS) @@ -52,7 +55,7 @@ tlecatch: tlecatch.o $(patsubst %.cc,%.o,$(wildcard ext/sgp4/libsgp4/*.cc)) 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 beidou.o navmon.o ephemeris.o $(SIMPLESOCKETS) osen.o +ubxtool: navmon.pb.o ubxtool.o ubx.o bits.o ext/fmt-5.2.1/src/format.o galileo.o gps.o beidou.o navmon.o ephemeris.o $(SIMPLESOCKETS) osen.o githash.o $(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -lprotobuf -pthread testrunner: navmon.pb.o testrunner.o ubx.o bits.o ext/fmt-5.2.1/src/format.o galileo.o gps.o beidou.o ephemeris.o sp3.o osen.o diff --git a/githash.h b/githash.h new file mode 100644 index 0000000..1c2fba4 --- /dev/null +++ b/githash.h @@ -0,0 +1 @@ +#define GIT_HASH "e795f29+" diff --git a/navmon.proto b/navmon.proto index c3f8c7c..914af82 100644 --- a/navmon.proto +++ b/navmon.proto @@ -139,6 +139,8 @@ message NavMonMessage { optional double freqAccuracyPS = 9; optional string owner = 10; optional string remark = 11; + optional string recvgithash = 12; + optional uint32 uptime = 13; } diff --git a/ubxtool.cc b/ubxtool.cc index 9f793d4..f9f43ca 100644 --- a/ubxtool.cc +++ b/ubxtool.cc @@ -31,6 +31,7 @@ #include "comboaddress.hh" #include "swrappers.hh" #include "sclasses.hh" +#include "githash.h" bool doDEBUG{false}; bool doLOGFILE{false}; @@ -521,6 +522,7 @@ int initFD(const char* fname, bool doRTSCTS) // ubxtool device srcid int main(int argc, char** argv) { + time_t starttime=time(0); GOOGLE_PROTOBUF_VERIFY_VERSION; CLI::App app("ubxtool"); @@ -1395,6 +1397,11 @@ int main(int argc, char** argv) nmm.mutable_od()->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); + + ns.emitNMM( nmm); } else if(msg.getClass() == 0x02 && msg.getType() == 0x14) { // UBX-RXM-MEASX diff --git a/update-git-hash-if-necessary b/update-git-hash-if-necessary new file mode 100755 index 0000000..a746c16 --- /dev/null +++ b/update-git-hash-if-necessary @@ -0,0 +1,17 @@ +#!/bin/sh +HASH=$(git describe --always --dirty=+ | tr -d '\n') + +echo \#define GIT_HASH \"$HASH\" > githash.h.tmp +echo $HASH > githash + +cmp -s githash.h githash.h.tmp > /dev/null + +if [ "$?" -ne "0" ] +then + mv githash.h.tmp githash.h + echo updated githash.h +else + rm githash.h.tmp +fi + +