NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / msk.cpp
blobd9ed5e51ea63367399079600fbcb947dba6c0b2c
1 #include "msk.hpp"
2 #include <marnav/nmea/io.hpp>
4 namespace marnav
6 namespace nmea
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(msk)
10 constexpr const char * msk::TAG;
12 msk::msk()
13 : sentence(ID, TAG, talker_id::global_positioning_system)
17 msk::msk(talker talk, fields::const_iterator first, fields::const_iterator last)
18 : sentence(ID, TAG, talk)
20 if (std::distance(first, last) != 5)
21 throw std::invalid_argument{"invalid number of fields in msk"};
23 read(*(first + 0), frequency);
24 read(*(first + 1), frequency_mode);
25 read(*(first + 2), bitrate);
26 read(*(first + 3), bitrate_mode);
27 read(*(first + 4), frequency_mss_status);
30 void msk::set_frequency(uint32_t f, selection_mode mode) noexcept
32 frequency = f;
33 frequency_mode = mode;
36 void msk::set_bitrate(uint32_t rate, selection_mode mode) noexcept
38 bitrate = rate;
39 bitrate_mode = mode;
42 std::vector<std::string> msk::get_data() const
44 return {format(frequency, 3), to_string(frequency_mode), format(bitrate, 3),
45 to_string(bitrate_mode), format(frequency_mss_status, 3)};