add githash and receiver uptime to stream

pull/59/head
bert hubert 2019-12-28 23:19:40 +01:00
parent e795f29d8a
commit 869aaebfe0
5 changed files with 31 additions and 1 deletions

View File

@ -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

1
githash.h 100644
View File

@ -0,0 +1 @@
#define GIT_HASH "e795f29+"

View File

@ -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;
}

View File

@ -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

View File

@ -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