diff options
| author | Thomas Schmucker <ts@its1.de> | 2026-08-14 14:05:35 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2026-08-14 14:05:35 +0200 |
| commit | 4f78ef5b3ab7d4ff864b7ad6d31e0184d1aa0872 (patch) | |
| tree | 8eed1929e1d86a6c8be90aad4a39108c01597979 /src | |
| parent | 46c9893607ecd32f8d9e2e6b7c3afa38bfc7e324 (diff) | |
| download | use-minmea-4f78ef5b3ab7d4ff864b7ad6d31e0184d1aa0872.tar.gz use-minmea-4f78ef5b3ab7d4ff864b7ad6d31e0184d1aa0872.tar.bz2 use-minmea-4f78ef5b3ab7d4ff864b7ad6d31e0184d1aa0872.zip | |
automatischer Download von minmea
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
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 @@ | |||
| 1 | #include <asio.hpp> | 1 | // Standard C++ |
| 2 | #include <array> | ||
| 2 | #include <ctime> | 3 | #include <ctime> |
| 4 | #include <exception> | ||
| 5 | #include <format> | ||
| 3 | #include <iostream> | 6 | #include <iostream> |
| 4 | #include <string> | 7 | #include <string> |
| 5 | 8 | ||
| 9 | // Asio | ||
| 10 | #include <asio.hpp> | ||
| 11 | |||
| 12 | // minmea | ||
| 6 | #include "minmea.h" | 13 | #include "minmea.h" |
| 7 | 14 | ||
| 8 | using namespace std; | 15 | using namespace std; |
| 9 | 16 | ||
| 10 | // constexpr auto PORT = "/dev/cuaU0"; | 17 | constexpr auto PORT = "/dev/cuaU0"; |
| 11 | constexpr auto PORT = "/dev/ugen0.14"; | 18 | constexpr auto BAUDRATE = 9600; |
| 12 | constexpr auto BAUDRATE = 9600; | 19 | constexpr auto KNOTS_TO_KMH = 1.852F; |
| 13 | 20 | ||
| 14 | namespace { | 21 | namespace { |
| 15 | 22 | ||
| @@ -32,7 +39,7 @@ read_line(asio::serial_port& com) | |||
| 32 | } | 39 | } |
| 33 | 40 | ||
| 34 | string | 41 | string |
| 35 | get_gps_timestamp(const minmea_time& time, const minmea_date& date) | 42 | get_gps_datetime(const minmea_time& time, const minmea_date& date) |
| 36 | { | 43 | { |
| 37 | tm tm_utc{}; | 44 | tm tm_utc{}; |
| 38 | ::minmea_getdatetime(&tm_utc, &date, &time); | 45 | ::minmea_getdatetime(&tm_utc, &date, &time); |
| @@ -73,11 +80,13 @@ main() | |||
| 73 | continue; | 80 | continue; |
| 74 | } | 81 | } |
| 75 | 82 | ||
| 76 | auto timestamp = get_gps_timestamp(frame.time, frame.date); | 83 | auto timestamp = get_gps_datetime(frame.time, frame.date); |
| 77 | 84 | ||
| 78 | cout << timestamp << ": $RMC floating point degree coordinates and speed: (" | 85 | cout << format("{}: $RMC floating point degree coordinates and speed: ({},{}) {} km/h\n", |
| 79 | << ::minmea_tocoord(&frame.latitude) << "," << ::minmea_tocoord(&frame.longitude) << ") " | 86 | timestamp, |
| 80 | << ::minmea_tofloat(&frame.speed) << '\n'; | 87 | ::minmea_tocoord(&frame.latitude), |
| 88 | ::minmea_tocoord(&frame.longitude), | ||
| 89 | ::minmea_tofloat(&frame.speed) * KNOTS_TO_KMH); | ||
| 81 | } | 90 | } |
| 82 | } | 91 | } |
| 83 | catch ( exception& e ) { | 92 | catch ( exception& e ) { |
