3 #include <marnav/nmea/io.hpp>
9 MARNAV_NMEA_DEFINE_SENTENCE_PARSE_FUNC(gsa
)
11 constexpr const char * gsa::TAG
;
14 : sentence(ID
, TAG
, talker_id::global_positioning_system
)
18 gsa::gsa(talker talk
, fields::const_iterator first
, fields::const_iterator last
)
19 : sentence(ID
, TAG
, talk
)
21 if (std::distance(first
, last
) != 17)
22 throw std::invalid_argument
{"invalid number of fields in gsa"};
24 read(*(first
+ 0), sel_mode
);
25 read(*(first
+ 1), mode
);
27 constexpr uint32_t init_val
= std::numeric_limits
<uint32_t>::max();
30 for (auto i
= 0; i
< max_satellite_ids
; ++i
, ++index
) {
31 uint32_t id
= init_val
;
32 read(*(first
+ index
), id
);
34 set_satellite_id(i
, id
);
36 read(*(first
+ 14), pdop
);
37 read(*(first
+ 15), hdop
);
38 read(*(first
+ 16), vdop
);
41 void gsa::check_index(int index
) const
43 if ((index
< 0) || (index
>= max_satellite_ids
)) {
44 throw std::out_of_range
{"satellite id out of range"};
48 void gsa::set_satellite_id(int index
, uint32_t t
)
51 satellite_id
[index
] = t
;
54 utils::optional
<uint32_t> gsa::get_satellite_id(int index
) const
57 return satellite_id
[index
];
60 std::vector
<std::string
> gsa::get_data() const
62 return {to_string(sel_mode
), to_string(mode
), format(satellite_id
[0], 2),
63 format(satellite_id
[1], 2), format(satellite_id
[2], 2), format(satellite_id
[3], 2),
64 format(satellite_id
[4], 2), format(satellite_id
[5], 2), format(satellite_id
[6], 2),
65 format(satellite_id
[7], 2), format(satellite_id
[8], 2), format(satellite_id
[9], 2),
66 format(satellite_id
[10], 2), format(satellite_id
[11], 2), to_string(pdop
),
67 to_string(hdop
), to_string(vdop
)};