NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / xtr.cpp
blobaf99c83ee1270728895002be2a93bd3b4d0254a4
1 #include "xtr.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(xtr)
10 constexpr const char * xtr::TAG;
12 xtr::xtr()
13 : sentence(ID, TAG, talker_id::global_positioning_system)
17 xtr::xtr(talker talk, fields::const_iterator first, fields::const_iterator last)
18 : sentence(ID, TAG, talk)
20 if (std::distance(first, last) != 3)
21 throw std::invalid_argument{"invalid number of fields in xtr"};
23 read(*(first + 0), cross_track_error_magnitude);
24 read(*(first + 1), direction_to_steer);
25 read(*(first + 2), cross_track_unit);
28 std::vector<std::string> xtr::get_data() const
30 return {to_string(cross_track_error_magnitude), to_string(direction_to_steer),
31 to_string(cross_track_unit)};