summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp27
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
8using namespace std; 15using namespace std;
9 16
10// constexpr auto PORT = "/dev/cuaU0"; 17constexpr auto PORT = "/dev/cuaU0";
11constexpr auto PORT = "/dev/ugen0.14"; 18constexpr auto BAUDRATE = 9600;
12constexpr auto BAUDRATE = 9600; 19constexpr auto KNOTS_TO_KMH = 1.852F;
13 20
14namespace { 21namespace {
15 22
@@ -32,7 +39,7 @@ read_line(asio::serial_port& com)
32} 39}
33 40
34string 41string
35get_gps_timestamp(const minmea_time& time, const minmea_date& date) 42get_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 ) {