QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GPSStreamDemux.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstdint>
5#include <memory>
6#include <span>
7#include <string_view>
8
9#include <QtCore/QFlags>
10#include <QtCore/QtGlobal>
11
13enum class GPSFrameKind : uint8_t
14{
15 RTCM3 = 0x01,
16 UBX = 0x02,
17 SBF = 0x04,
18 NMEASentence = 0x08,
19 ASCIILine = 0x10,
20};
21Q_DECLARE_FLAGS(GPSFrameKinds, GPSFrameKind)
22Q_DECLARE_OPERATORS_FOR_FLAGS(GPSFrameKinds)
23
24
27{
30 std::span<const uint8_t> bytes{};
32 std::span<const uint8_t> payload{};
34 uint32_t messageId = 0;
35
36 [[nodiscard]] std::string_view text() const { return {reinterpret_cast<const char*>(bytes.data()), bytes.size()}; }
37};
38
41{
43 GPSFrameKinds framers{};
45 GPSFrameKinds enabled{};
47 bool shareSBFSync = false;
48};
49
62{
63public:
64 class Handler
65 {
66 public:
68 virtual void frame(const GPSFrame& frame) = 0;
69
70 protected:
71 ~Handler() = default;
72 };
73
74 explicit GPSStreamDemux(const GPSStreamConfig& config);
76
77 Q_DISABLE_COPY(GPSStreamDemux)
78
79 void push(uint8_t byte, Handler& handler);
80
81 void reset();
82 void reset(GPSFrameKind kind);
83
85 void setEnabled(GPSFrameKind kind, bool enabled);
86
87 class Framer;
88
89private:
90 static constexpr size_t FRAMER_COUNT = 5;
91
92 std::array<std::unique_ptr<Framer>, FRAMER_COUNT> _framers;
93};
GPSFrameKind
Wire framings the stream demultiplexer recognises; also the set of framers a receiver family enables.
@ 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.
Config config
virtual void frame(const GPSFrame &frame)=0
Receives each completed frame; the handler may reset or enable framers.
void push(uint8_t byte, Handler &handler)
void setEnabled(GPSFrameKind kind, bool enabled)
Enables or disables an available framer; either way it restarts from an empty state.
Septentrio receivers configured as RTK bases with SBF commands; they stream PVTGeodetic blocks and RT...
u-blox receivers over UBX: CFG-VALSET configuration from protocol 27, CFG-MSG and CFG-TMODE3 before i...
std::string_view text() const
The framers of one receiver stream and how they share it.
bool shareSBFSync
SBF watches its "$@" sync instead of claiming '$', so '$' text in the same stream still reaches a tex...
GPSFrameKinds enabled
Framers enabled when the stream is created.
GPSFrameKinds framers
Framers the family can use; only these can be enabled later.