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 --- src/main.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/main.cpp') 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