From: Urban Wallasch Date: Sun, 21 Jul 2019 21:40:38 +0000 (+0200) Subject: * Added simple console logger application. X-Git-Tag: v0.1.0~86 X-Git-Url: https://git.packet-gain.de/?a=commitdiff_plain;h=efecdd7ad182bbb0a7f40e8f0f9aebaaf4a9bd8b;p=ets2_tele.git * Added simple console logger application. --- diff --git a/.gitignore b/.gitignore index c6d1916..65014a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.o *.so telehttpd +telelogger diff --git a/Makefile b/Makefile index e4156d4..00c0074 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ endif .PHONY: all clean -all: telehttpd telemetry.so +all: telehttpd telelogger telemetry.so telemetry.so: telemetry.cpp $(SDK_HEADERS) g++ -o $@ -fPIC -Wall --shared -Wl,$(LIB_NAME_OPTION),$@ $(SDK_INCLUDES) telemetry.cpp @@ -33,6 +33,9 @@ telemetry.so: telemetry.cpp $(SDK_HEADERS) telehttpd: telehttpd.o shmget.o net.o fserv.o ntime.o $(CC) $(LDFLAGS) -o $@ -pthread $^ +telelogger: telelogger.o shmget.o net.o fserv.o ntime.o + $(CC) $(LDFLAGS) -o $@ $^ + %.o: %.c $(SELF) $(CC) -c $(CFLAGS) -o $*.o $*.c diff --git a/telelogger.c b/telelogger.c new file mode 100644 index 0000000..b79b145 --- /dev/null +++ b/telelogger.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fserv.h" +#include "net.h" +#include "log.h" +#include "shmget.h" + +static int log_console(void) { + uint64_t last_timestamp = telemetry->timestamp; + while ( 1 ) { + printf("timestamp: %"PRIu64"\n", telemetry->timestamp); + // uint64_t raw_rendering_timestamp; + // uint64_t raw_simulation_timestamp; + // uint64_t raw_paused_simulation_timestamp; + if ( telemetry->placement_available ) { + printf( "position: %.3f, %.3f, %.3f\n", + telemetry->x, telemetry->y, telemetry->z ); + printf( "orientation: h:%.1f p:%.1f r:%.1f\n", + telemetry->heading * 360.0, telemetry->pitch * 360.0, telemetry->roll * 360.0 ); + } + else { + printf( "position: n.a.\n" ); + printf( "orientation: n.a.\n" ); + } + printf( "speed: %.1fkm/h (%.1fm/s)\n", telemetry->speed * 3.6, telemetry->speed ); + printf( "cctrl: %.1fkm/h (%.1fm/s)\n", telemetry->cc * 3.6, telemetry->cc ); + printf( "rpm: %.0f\n", telemetry->rpm ); + printf( "gear: %d\n", telemetry->gear ); + printf( "fc_avg: %.1f\n", telemetry->fc_avg ); + puts(""); + sleep( 1 ); + while ( last_timestamp == telemetry->timestamp ) + sleep( 1 ); + last_timestamp = telemetry->timestamp; + } + return 0; +} + +int main(int argc, char *argv[]) { + if ( 0 != init_shm() ) + exit( EXIT_FAILURE); + if ( 0 != log_console() ) + exit( EXIT_FAILURE); + exit( EXIT_SUCCESS ); + (void)argc; (void)argv; +}