QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GPSNMEAStream.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <cstdint>
5#include <string_view>
6
7#include "GPSProtocolEvent.h"
8#include "GPSStreamDemux.h"
10#include "NMEASatellites.h"
11
14
19{
20public:
22 enum class Navigation
23 {
26 };
27
31
33
35 void reset(GPSStreamDemux& stream);
36
37 void setRTCMEnabled(bool enabled) { _rtcmEnabled = enabled; }
38
41 template <typename Vendor>
42 GPSReceiveUpdates onFrame(const GPSFrame& frame, GPSDecodeContext& context, Vendor&& vendor)
43 {
44 if (frame.kind == GPSFrameKind::RTCM3) {
45 return _decodeRTCM(frame, context);
46 }
47 if (frame.kind != GPSFrameKind::ASCIILine && frame.kind != GPSFrameKind::NMEASentence) {
48 return {};
49 }
50 GPSReceiveUpdates updates = _decodeStandard(frame.text(), context);
51 updates |= vendor(frame.text());
52 return _finishLine(updates, context);
53 }
54
56 GPSReceiveUpdates onFrame(const GPSFrame& frame, GPSDecodeContext& context)
57 {
58 return onFrame(frame, context, [](std::string_view) { return GPSReceiveUpdates{}; });
59 }
60
62 void flush(GPSDecodeContext& context);
63
65 [[nodiscard]] std::chrono::milliseconds limitReceiveTimeout(std::chrono::milliseconds timeout,
66 uint64_t nowUs) const;
67
70 GPSReceiveUpdates receive(GPSCommandChannel& channel, std::chrono::milliseconds timeout) const;
71
72 [[nodiscard]] GPSDecodedPosition& position() { return _position; }
73
74private:
76 GPSReceiveUpdates _decodeRTCM(const GPSFrame& frame, GPSDecodeContext& context);
77
79 GPSReceiveUpdates _decodeStandard(std::string_view line, GPSDecodeContext& context);
80
83 GPSReceiveUpdates _finishLine(GPSReceiveUpdates updates, GPSDecodeContext& context);
84
85 void _queueSatellites(const NMEA::SatelliteEpoch& epoch);
86 void _publishSatellites(GPSDecodeContext& context);
87
88 GPSDecodedPosition _position;
89 NMEA::SatelliteAssembler _satelliteAssembler;
91 NMEA::SatelliteEpoch _pendingSatellites;
92 NMEA::NavigationEpochAssembler _navigationAssembler;
94 bool _rtcmEnabled = true;
95};
@ ASCIILine
Printable lines up to CR/LF, without the terminator; the decoder checks checksums.
@ RTCM3
0xD3 frames with a valid CRC-24Q.
@ NMEASentence
'$' to a valid "*hh" checksum, without a line ending.
GPSDecodedPosition & position()
GPSReceiveUpdates receive(GPSCommandChannel &channel, std::chrono::milliseconds timeout) const
void flush(GPSDecodeContext &context)
Expires untimed metadata and publishes satellite epochs that became due.
void reset(GPSStreamDemux &stream)
Starts a new receiver session: clears every framer of stream, the epochs and the working reports.
GPSReceiveUpdates onFrame(const GPSFrame &frame, GPSDecodeContext &context, Vendor &&vendor)
GPSReceiveUpdates onFrame(const GPSFrame &frame, GPSDecodeContext &context)
The whole frame handling for a family without vendor sentences.
static constexpr GPSStreamConfig STREAM
Framers an ASCII family's descriptor declares.
Navigation
Who turns sentences into positions: this stream from standard NMEA, or the family's own sentences.
void setRTCMEnabled(bool enabled)
std::chrono::milliseconds limitReceiveTimeout(std::chrono::milliseconds timeout, uint64_t nowUs) const
Shortens a receive timeout so a pending satellite epoch is published when it becomes due.
Bounded multipart/multisignal assembly; scheduling and delivery remain with the caller.
std::vector< SatelliteSystem > SatelliteEpoch
Decoded navigation plus whether the producer accepted its velocity solution.
The framers of one receiver stream and how they share it.
GPSFrameKinds framers
Framers the family can use; only these can be enabled later.