7#include <QtCore/QString>
31 bool configure(GPSCommandChannel& channel, GPSConfig config,
unsigned& baud)
override;
33 bool probe(GPSCommandChannel& channel)
override;
36 void serviceStreaming(GPSCommandChannel& channel)
override;
40 GPSReceiveUpdates _decodeLine(std::string_view line, GPSDecodeContext& context)
override;
41 void _setUpBase(GPSCommandChannel& channel);
42 void _activateRTCMOutput(GPSCommandChannel& channel);
44 GPSBaseStationConfig _base{};
45 bool _rtcmOutputActive =
false;
47 bool _rtcmActivationPending =
false;
48 GPSSurveyClock _surveyClock;
54 _rtcmOutputActive =
false;
55 _rtcmActivationPending =
false;
58 GPSStreamDemux& stream = channel.
stream();
60 _nmea.setRTCMEnabled(
false);
70 if (!identity.succeeded()) {
81 _nmea.setRTCMEnabled(
true);
83 _ready = !channel.
failed();
87void Protocol::serviceStreaming(GPSCommandChannel& channel)
89 if (_rtcmActivationPending) {
90 _rtcmActivationPending =
false;
91 _activateRTCMOutput(channel);
95void Protocol::_setUpBase(GPSCommandChannel& channel)
97 GPSDecodeContext& context = channel.
context();
98 const auto* fixed = std::get_if<GPSBaseStationConfig::Fixed>(&_base.
mode);
103 _surveyClock.
start(context);
109 _activateRTCMOutput(channel);
110 if (_rtcmOutputActive) {
115void Protocol::_activateRTCMOutput(GPSCommandChannel& channel)
118 _rtcmOutputActive =
true;
122GPSReceiveUpdates Protocol::_decodeLine(std::string_view line, GPSDecodeContext& context)
124 if (
line.size() >= 6 &&
line.substr(3, 3) ==
"GGA") {
132 _surveyClock.
finish(context,
true,
133 {.latitudeDegrees = fix->latitude,
134 .longitudeDegrees = fix->longitude,
135 .altitudeMeters = fix->altitude + fix->geoidSeparation});
136 _rtcmActivationPending =
true;
143bool portName(std::string_view field)
145 const size_t digits = field.find_first_of(
"0123456789");
146 if (digits == 0 || digits == std::string_view::npos) {
155QLatin1StringView signature(
const GPSFrame& frame)
157 const std::string_view text =
frame.text();
162 return QLatin1StringView(
"abbreviated ASCII replies");
165 return log && portName(log->source) ? QLatin1StringView(
"NovAtel-format ASCII logs") : QLatin1StringView();
169bool Protocol::probe(GPSCommandChannel& channel)
171 bool identified =
false;
183 .type = GPSType::femto,
184 .logCategory = &FemtoProtocolLog,
189 .signature = &signature,
std::optional< GPSASCIILog > gpsASCIILog(std::string_view line)
std::unique_ptr< GPSFamilyProtocol > gpsCreateProtocol()
The create of a family whose protocol is default-constructed: .create = &gpsCreateProtocol<Protocol>.
@ 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.
#define QGC_LOGGING_CATEGORY(name, categoryStr)
GPSDecodeContext & context()
bool setBaudrate(unsigned baudrate)
void failSequence(const GPSCommandSequence::Result &result)
GPSStreamDemux & stream()
bool runRequired(const GPSCommandSequence &sequence)
Runs sequence and fails control over a failed step as failSequence() does.
GPSCommandSequence::Result runSequence(const GPSCommandSequence &sequence)
Runs sequence in order until a required step fails or I/O fails; failed attempts retry up to their co...
void failNoAnswer(std::span< const unsigned > rates)
void publishSurvey(GPSSurveyReport &status)
Stamps status with the receipt time and publishes a copy. Survey progress is not an update flag.
void setEnabled(GPSFrameKind kind, bool enabled)
Enables or disables an available framer; either way it restarts from an empty state.
void start(uint64_t nowUs)
void finish(GPSDecodeContext &context, bool valid, const GPSEllipsoidPosition &position={})
Stops timing and publishes the finished survey, valid at position or failed.
void publishProgress(GPSDecodeContext &context)
Publishes the active survey when its whole-second duration advanced.
QByteArray line(std::string_view command)
command as one CR/LF-terminated line.
constexpr std::string_view REJECTED
constexpr unsigned AVERAGED_POSITION_QUALITY
GGA fix quality of a position the receiver holds fixed: position averaging finished.
GPSCommandSequence sequence(std::span< const Command > commands)
constexpr std::array IDENTIFY
Stops every log on this port and identifies the receiver, in up to IDENTIFY_ROUNDS rounds.
GPSCommandSequence fixedBase(const GPSEllipsoidPosition &position)
ELLIPSOID_HEIGHTS, FIX_POSITION for position, then GGA_OUTPUT.
constexpr std::array RTCM_OUTPUT
RTCM3 output once the base position is known.
constexpr std::array SURVEY_IN
Survey-in base: receiver position averaging. A GGA fix of quality 7 completes it, and RTCM_OUTPUT fol...
constexpr unsigned IDENTIFY_ROUNDS
constexpr Command VERSION
Identifies the receiver without changing it, so receiver detection probes with it alone.
constexpr unsigned BAUD
The link rate unless one is selected or detected, and the only rate receiver detection probes.
const GPSReceiverFamily FAMILY
std::optional< Sentence > sentence(std::string_view text)
constexpr bool isAsciiUpper(char ch)
std::optional< GGA > gga(const Sentence &input)
Quality zero is a valid fix-loss observation with empty coordinates and optional hemisphere fields.
constexpr bool isAsciiDigit(char ch)
Locale-independent ASCII character classes for receiver text.
std::optional< Frame > frame(std::string_view text)
constexpr std::array BAUD_RATES
Probing order of the automatic baud detection.
The receiver configuration requested for one configure() attempt.
GPSBaseStationConfig base
unsigned linkBaud(unsigned requested, unsigned fallback) const
The rate a family without a baud search runs the link at: requested, else detectedBaud,...