From 4f78ef5b3ab7d4ff864b7ad6d31e0184d1aa0872 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Fri, 14 Aug 2026 14:05:35 +0200 Subject: automatischer Download von minmea --- .gitignore | 5 +++++ compile_flags.txt | 5 +---- config.mk | 5 +++-- makefile | 20 ++++++++++++++++---- src/main.cpp | 27 ++++++++++++++++++--------- 5 files changed, 43 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index cd42ee3..ca1f238 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ +minmea.tgz +src/minmea.c +src/minmea.h +src/.minmea.stamp bin/ obj/ + diff --git a/compile_flags.txt b/compile_flags.txt index 3ea2c1a..cccab63 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -4,7 +4,4 @@ -Wconversion -Wdouble-promotion -pedantic --std=c++17 --Iinclude --I../minmea/include --I/usr/local/include +-std=c++23 diff --git a/config.mk b/config.mk index 29f8ca1..aa17664 100644 --- a/config.mk +++ b/config.mk @@ -1,2 +1,3 @@ -CPPFLAGS=-Wall -Werror -pedantic -std=c++17 -O2 -Iinclude -I../minmea/include -I/usr/local/include -DNDEBUG -LDFLAGS=-L../minmea/lib -lminmea -L/usr/local/lib -lpthread +CPPFLAGS=-Wall -Wno-gnu-anonymous-struct -pedantic -std=c++23 -O2 -DNDEBUG +CFLAGS=-Wall -pedantic -std=c11 -O2 -DNDEBUG +LDFLAGS=-lpthread diff --git a/makefile b/makefile index 3f481bc..a8742bf 100644 --- a/makefile +++ b/makefile @@ -1,15 +1,27 @@ include config.mk -bin/app: obj/main.o | bin +bin/app: obj/main.o obj/minmea.o | bin c++ $(LDFLAGS) $^ -o $@ -obj/%.o: src/%.cpp | obj +obj/%.o: src/%.cpp src/minmea.h | obj c++ $(CPPFLAGS) -c $< -o $@ +obj/%.o: src/%.c src/minmea.h | obj + cc $(CFLAGS) -c $< -o $@ + +minmea.tgz: + curl -s -o $@ https://codeload.github.com/kosma/minmea/tar.gz/refs/tags/v1.0.0 + +src/.minmea.stamp: minmea.tgz | src + tar -xzvf $< --strip-components=1 -C src/ minmea-1.0.0/minmea.h minmea-1.0.0/minmea.c + touch $@ + +src/minmea.h src/minmea.c: src/.minmea.stamp + clean: - rm -rf bin obj + rm -rf bin obj minmea.tgz bin obj: - mkdir $@ + mkdir -p $@ .PHONY: all clean diff --git a/src/main.cpp b/src/main.cpp index e699c6a..ed98cb4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,15 +1,22 @@ -#include +// Standard C++ +#include #include +#include +#include #include #include +// Asio +#include + +// minmea #include "minmea.h" using namespace std; -// constexpr auto PORT = "/dev/cuaU0"; -constexpr auto PORT = "/dev/ugen0.14"; -constexpr auto BAUDRATE = 9600; +constexpr auto PORT = "/dev/cuaU0"; +constexpr auto BAUDRATE = 9600; +constexpr auto KNOTS_TO_KMH = 1.852F; namespace { @@ -32,7 +39,7 @@ read_line(asio::serial_port& com) } string -get_gps_timestamp(const minmea_time& time, const minmea_date& date) +get_gps_datetime(const minmea_time& time, const minmea_date& date) { tm tm_utc{}; ::minmea_getdatetime(&tm_utc, &date, &time); @@ -73,11 +80,13 @@ main() continue; } - auto timestamp = get_gps_timestamp(frame.time, frame.date); + auto timestamp = get_gps_datetime(frame.time, frame.date); - cout << timestamp << ": $RMC floating point degree coordinates and speed: (" - << ::minmea_tocoord(&frame.latitude) << "," << ::minmea_tocoord(&frame.longitude) << ") " - << ::minmea_tofloat(&frame.speed) << '\n'; + cout << format("{}: $RMC floating point degree coordinates and speed: ({},{}) {} km/h\n", + timestamp, + ::minmea_tocoord(&frame.latitude), + ::minmea_tocoord(&frame.longitude), + ::minmea_tofloat(&frame.speed) * KNOTS_TO_KMH); } } catch ( exception& e ) { -- cgit v1.3