Skip to content

Commit

Permalink
add githash and receiver uptime to stream
Browse files Browse the repository at this point in the history
  • Loading branch information
ahupowerdns committed Dec 28, 2019
1 parent e795f29 commit 869aaeb
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions githash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define GIT_HASH "e795f29+"
2 changes: 2 additions & 0 deletions navmon.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down
7 changes: 7 additions & 0 deletions ubxtool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "comboaddress.hh"
#include "swrappers.hh"
#include "sclasses.hh"
#include "githash.h"

bool doDEBUG{false};
bool doLOGFILE{false};
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions update-git-hash-if-necessary
Original file line number Diff line number Diff line change
@@ -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


0 comments on commit 869aaeb

Please sign in to comment.