NMEA: detectio of the optional tag block in front of a sentence, ignoring it for...
[marnav.git] / src / marnav / nmea / fsi.cpp
blob5fc568ba3166b8a915daec51f2348f4c1ea74f04
1 #include "fsi.hpp"
2 #include <marnav/nmea/checks.hpp>
3 #include <marnav/nmea/io.hpp>
5 namespace marnav
7 namespace nmea
9 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(fsi)
11 constexpr const char * fsi::TAG;
13 fsi::fsi()
14 : sentence(ID, TAG, talker_id::global_positioning_system)
18 fsi::fsi(talker talk, fields::const_iterator first, fields::const_iterator last)
19 : sentence(ID, TAG, talk)
21 if (std::distance(first, last) != 5)
22 throw std::invalid_argument{"invalid number of fields in fsi"};
24 read(*(first + 0), tx_frequency);
25 read(*(first + 1), rx_frequency);
26 read(*(first + 2), communications_mode);
27 read(*(first + 3), power_level);
28 read(*(first + 4), sentence_status);
31 void fsi::set_power_level(uint32_t t)
33 if (t > 9)
34 throw std::invalid_argument{"invalid value for power_level (0..9)"};
35 power_level = t;
38 void fsi::set_sentence_status(char t)
40 check_value(t, {'R', 'C'}, "sentence_status");
41 sentence_status = t;
44 std::vector<std::string> fsi::get_data() const
46 return {to_string(tx_frequency), to_string(rx_frequency), to_string(communications_mode),
47 to_string(power_level), to_string(sentence_status)};