QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GPSProtocolRuntime Class Referencefinal

#include <GPSProtocolRuntime.h>

+ Inheritance diagram for GPSProtocolRuntime:
+ Collaboration diagram for GPSProtocolRuntime:

Public Member Functions

 GPSProtocolRuntime (const GPSReceiverFamily &family, GPSRuntimeIO io, GPSRuntimeObserver observer={})
 Creates the family's protocol with its factory.
 
 GPSProtocolRuntime (const GPSReceiverFamily &family, std::unique_ptr< GPSFamilyProtocol > protocol, GPSRuntimeIO io, GPSRuntimeObserver observer={})
 Hosts protocol, for families configured by the caller such as test doubles.
 
 ~GPSProtocolRuntime ()
 
bool configure (const GPSConfig &config, unsigned &baud)
 
bool probe (std::chrono::milliseconds budget)
 
GPSReceiveUpdates receive (std::chrono::milliseconds timeout)
 
bool armDecodeOnly (const GPSConfig &config)
 
bool armNavigationDecode (GPSNavigationDecode decode={})
 
GPSEventBatch decode (std::span< const uint8_t > bytes)
 Decodes bytes without I/O or observer callbacks.
 
GPSReceiveUpdates consume (std::span< const uint8_t > bytes)
 Decodes bytes and delivers their batch to the observer. An empty span flushes.
 
GPSReceiveUpdates consumeFrame (const GPSFrame &frame)
 Decodes one frame another stream framed and delivers its batch to the observer, without flushing.
 
bool receiverReady () const
 
QString identity () const
 Model and firmware reported during configuration, trimmed; empty when unknown.
 
GPSProtocolError error () const
 
const QString & errorDetail () const
 
const GPSReceiverFamily & family () const
 
GPSFamilyProtocol & protocol ()
 
GPSStreamDemux & stream ()
 
GPSLogCategory logCategory () const
 The family's logging category, or the runtime's when the family has none.
 

Friends

class GPSCommandChannel
 

Detailed Description

Hosts one receiver family on a blocking transport. It owns the family protocol, the stream demultiplexer, the decode context that collects events, and the command channel with its deadlines, evidence and sticky failure. configure(), probe() and receive() run the family's code to completion on the caller thread; its channel operations block on GPSRuntimeIO.

Definition at line 47 of file GPSProtocolRuntime.h.

Constructor & Destructor Documentation

◆ GPSProtocolRuntime() [1/2]

GPSProtocolRuntime::GPSProtocolRuntime ( const GPSReceiverFamily &  family,
GPSRuntimeIO  io,
GPSRuntimeObserver  observer = {} 
)

Creates the family's protocol with its factory.

Definition at line 13 of file GPSProtocolRuntime.cc.

◆ GPSProtocolRuntime() [2/2]

GPSProtocolRuntime::GPSProtocolRuntime ( const GPSReceiverFamily &  family,
std::unique_ptr< GPSFamilyProtocol >  protocol,
GPSRuntimeIO  io,
GPSRuntimeObserver  observer = {} 
)

Hosts protocol, for families configured by the caller such as test doubles.

Definition at line 17 of file GPSProtocolRuntime.cc.

References GPSRuntimeIO::cancelToken, GPSRuntimeIO::clock, Error, logCategory(), GPSRuntimeIO::read, GPSRuntimeIO::setBaudrate, GPSReceiverFamily::type, Unsupported, GPSClock::wait, and GPSRuntimeIO::write.

◆ ~GPSProtocolRuntime()

GPSProtocolRuntime::~GPSProtocolRuntime ( )
default

Member Function Documentation

◆ armDecodeOnly()

bool GPSProtocolRuntime::armDecodeOnly ( const GPSConfig &  config)

Prepares decode() and consume() for traffic from a receiver configured with config, without I/O (GPSFamilyProtocol::armDecodeOnly()). config is valid for the family, as GPSDriver::configure() requires.

Returns
false when the family needs a live configuration to report base status for its base mode.

Definition at line 101 of file GPSProtocolRuntime.cc.

References config.

◆ armNavigationDecode()

bool GPSProtocolRuntime::armNavigationDecode ( GPSNavigationDecode  decode = {})

Prepares decode() and consume() for the navigation output of a receiver configured elsewhere, without I/O (GPSFamilyProtocol::armNavigationDecode()).

Returns
false when the family decodes it without being armed.

Definition at line 109 of file GPSProtocolRuntime.cc.

References decode().

◆ configure()

bool GPSProtocolRuntime::configure ( const GPSConfig &  config,
unsigned &  baud 
)

Configures the receiver after clearing any sticky failure. A zero baud requests detection and returns the detected rate. A command still pending at the end is retired as Written, and a successful configuration flushes once more so a fixed-base or survey-start event is delivered without another read.

Returns
true when the receiver is ready; otherwise error() reports the failure, Protocol unless the link, a stop or a needed consent ended it, and errorDetail() describes it.

Definition at line 59 of file GPSProtocolRuntime.cc.

References config, consume(), GPSCommandChannel::errorDetail(), GPSCommandChannel::failControl(), GPSCommandChannel::finishCommand(), and Written.

◆ consume()

GPSReceiveUpdates GPSProtocolRuntime::consume ( std::span< const uint8_t >  bytes)

Decodes bytes and delivers their batch to the observer. An empty span flushes.

Definition at line 127 of file GPSProtocolRuntime.cc.

References decode().

Referenced by configure(), GPSCommandChannel::flush(), and GPSCommandChannel::receiveCycle().

◆ consumeFrame()

GPSReceiveUpdates GPSProtocolRuntime::consumeFrame ( const GPSFrame &  frame)

Decodes one frame another stream framed and delivers its batch to the observer, without flushing.

Definition at line 132 of file GPSProtocolRuntime.cc.

◆ decode()

GPSEventBatch GPSProtocolRuntime::decode ( std::span< const uint8_t >  bytes)

Decodes bytes without I/O or observer callbacks.

Returns
their events; an empty span flushes.

Definition at line 114 of file GPSProtocolRuntime.cc.

References GPSStreamDemux::push().

Referenced by armNavigationDecode(), and consume().

◆ error()

GPSProtocolError GPSProtocolRuntime::error ( ) const
inline

Definition at line 98 of file GPSProtocolRuntime.h.

References GPSCommandChannel::error().

◆ errorDetail()

const QString & GPSProtocolRuntime::errorDetail ( ) const
inline

Definition at line 100 of file GPSProtocolRuntime.h.

References GPSCommandChannel::errorDetail().

◆ family()

const GPSReceiverFamily & GPSProtocolRuntime::family ( ) const
inline

◆ identity()

QString GPSProtocolRuntime::identity ( ) const

Model and firmware reported during configuration, trimmed; empty when unknown.

Definition at line 156 of file GPSProtocolRuntime.cc.

◆ logCategory()

GPSLogCategory GPSProtocolRuntime::logCategory ( ) const

The family's logging category, or the runtime's when the family has none.

Definition at line 54 of file GPSProtocolRuntime.cc.

References GPSReceiverFamily::logCategory.

Referenced by GPSProtocolRuntime(), and GPSCommandChannel::logCategory().

◆ probe()

bool GPSProtocolRuntime::probe ( std::chrono::milliseconds  budget)

Runs the family's identity probe (GPSFamilyProtocol::probe()) within budget at the link's current rate, after clearing any sticky failure.

Returns
whether a receiver of this family answered; false for a family receiver detection never probes.

Definition at line 78 of file GPSProtocolRuntime.cc.

References GPSCommandChannel::deadlineScope(), GPSCommandChannel::finishCommand(), and Written.

Referenced by GPSReceiverDetector::detect().

◆ protocol()

GPSFamilyProtocol & GPSProtocolRuntime::protocol ( )
inline

◆ receive()

GPSReceiveUpdates GPSProtocolRuntime::receive ( std::chrono::milliseconds  timeout)

One streaming receive of up to timeout, including the family's streaming services. Failures are reported through error().

Returns
the updates decoded.

Definition at line 93 of file GPSProtocolRuntime.cc.

◆ receiverReady()

bool GPSProtocolRuntime::receiverReady ( ) const

Definition at line 151 of file GPSProtocolRuntime.cc.

References GPSDecodeContext::failed().

◆ stream()

GPSStreamDemux & GPSProtocolRuntime::stream ( )
inline

Definition at line 106 of file GPSProtocolRuntime.h.

Referenced by GPSCommandChannel::stream().

Friends And Related Symbol Documentation

◆ GPSCommandChannel

friend class GPSCommandChannel
friend

Definition at line 112 of file GPSProtocolRuntime.h.


The documentation for this class was generated from the following files: