2 #include <marnav/nmea/io.hpp>
8 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(sfi
)
10 constexpr const char * sfi::TAG
;
13 : sentence(ID
, TAG
, talker_id::global_positioning_system
)
17 sfi::sfi(talker talk
, fields::const_iterator first
, fields::const_iterator last
)
18 : sentence(ID
, TAG
, talk
)
20 const auto size
= std::distance(first
, last
);
21 if ((size
< 2) || (size
> 2 + max_number_of_frequencies
* 2))
22 throw std::invalid_argument
{"invalid number of fields in sfi"};
24 throw std::invalid_argument
{"invalid number of fields in sfi"};
26 read(*(first
+ 0), number_of_messages
);
27 read(*(first
+ 1), message_number
);
30 frequencies
.reserve(size
- 2);
31 for (auto i
= 2; i
< size
; i
+= 2) {
34 read(*(first
+ i
+ 0), frequency
);
35 read(*(first
+ i
+ 1), mode
);
36 frequencies
.push_back({frequency
, mode
});
40 void sfi::set_frequencies(const std::vector
<scanning_frequency
> & v
)
42 if (v
.size() > max_number_of_frequencies
)
43 throw std::invalid_argument
{
44 "number of frequencies exceeds max entries in sfi::set_frequencies"};
49 std::vector
<std::string
> sfi::get_data() const
51 std::vector
<std::string
> result
{to_string(number_of_messages
), to_string(message_number
)};
53 for (auto const & entry
: frequencies
) {
54 result
.push_back(to_string(entry
.frequency
));
55 result
.push_back(to_string(entry
.mode
));