.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
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
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <stdbool.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#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;
+}