QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GPSTransport Class Referenceabstract

#include <GPSTransport.h>

+ Inheritance diagram for GPSTransport:

Public Member Functions

 GPSTransport (GPSCancelToken cancelToken)
 
virtual ~GPSTransport ()
 
virtual GPSOpenResult open ()=0
 
virtual bool fatalError () const =0
 
bool isCancelled () const
 
const GPSCancelToken & cancelToken () const
 
virtual unsigned fixedBaudrate () const
 Nonzero when the link cannot follow baud-rate changes (for example, a serial bridge).
 
virtual GPSReadResult read (std::span< uint8_t > buffer, std::chrono::milliseconds timeout)=0
 
virtual std::chrono::milliseconds configurationWriteTimeout () const
 
GPSWriteResult write (QByteArrayView bytes, QDeadlineTimer deadline)
 
virtual bool setBaudrate (unsigned baudrate)
 

Static Public Attributes

static constexpr unsigned BRIDGE_BAUDRATE = 115200
 
static constexpr qint64 READ_BUFFER_BYTES = 64 * 1024
 
static constexpr qint64 WRITE_BUFFER_BYTES = 4 * 1024
 Bytes a link queues for writing at once.
 

Protected Member Functions

virtual GPSWriteResult writeData (QByteArrayView bytes, QDeadlineTimer deadline)=0
 Receives non-empty bytes and an unexpired, capped deadline that implementations must honor.
 

Detailed Description

Byte link the GPS driver reads and writes through. Implemented by the owner of the physical connection and consumed by GPSDriver, keeping the native protocol drivers decoupled from the concrete transport. Construct, use, and destroy on one owner thread. Blocking waits dispatch events: callbacks must not reenter, reopen, or destroy the transport during a call. Other threads cancel through the GPSCancelSource that issued the construction token.

Definition at line 75 of file GPSTransport.h.

Constructor & Destructor Documentation

◆ GPSTransport()

GPSTransport::GPSTransport ( GPSCancelToken  cancelToken)
explicit

Definition at line 10 of file GPSTransport.cc.

◆ ~GPSTransport()

GPSTransport::~GPSTransport ( )
virtual

Definition at line 16 of file GPSTransport.cc.

Member Function Documentation

◆ cancelToken()

const GPSCancelToken & GPSTransport::cancelToken ( ) const
inline

Definition at line 86 of file GPSTransport.h.

Referenced by GPSDriver::configure(), and GPSDeviceTransport::waitUntil().

◆ configurationWriteTimeout()

std::chrono::milliseconds GPSTransport::configurationWriteTimeout ( ) const
virtual

Reimplemented in TCPGPSTransport.

Definition at line 36 of file GPSTransport.cc.

Referenced by write().

◆ fatalError()

◆ fixedBaudrate()

virtual unsigned GPSTransport::fixedBaudrate ( ) const
inlinevirtual

Nonzero when the link cannot follow baud-rate changes (for example, a serial bridge).

Reimplemented in TCPGPSTransport, and UDPGPSTransport.

Definition at line 89 of file GPSTransport.h.

Referenced by GPSDriver::configure(), and setBaudrate().

◆ isCancelled()

◆ open()

virtual GPSOpenResult GPSTransport::open ( )
pure virtual

◆ read()

virtual GPSReadResult GPSTransport::read ( std::span< uint8_t >  buffer,
std::chrono::milliseconds  timeout 
)
pure virtual

A nonpositive timeout polls immediately available input. Failures never carry usable stream bytes. An empty buffer reports the failure of a failed link without reading.

Implemented in GPSDeviceTransport.

Referenced by GPSDriver::configure(), and GPSDriver::receiveOutcome().

◆ setBaudrate()

bool GPSTransport::setBaudrate ( unsigned  baudrate)
virtual

Sets the link baud rate. Returns true on success. By default only a healthy link's fixed rate succeeds, as a network bridge cannot change it. A refused rate leaves the link usable unless fatalError() reports otherwise.

Reimplemented in SerialGPSTransport.

Definition at line 41 of file GPSTransport.cc.

References fatalError(), fixedBaudrate(), and isCancelled().

Referenced by GPSDriver::configure().

◆ write()

GPSWriteResult GPSTransport::write ( QByteArrayView  bytes,
QDeadlineTimer  deadline 
)

Receiver configuration write under the command deadline, capped by configurationWriteTimeout(). Counts describe transport progress, never receiver acknowledgement. A failed operation that accepted bytes retires the connection; open a new session before writing again.

Definition at line 21 of file GPSTransport.cc.

References Cancelled, Completed, configurationWriteTimeout(), isCancelled(), TimedOut, and writeData().

Referenced by GPSDriver::configure().

◆ writeData()

virtual GPSWriteResult GPSTransport::writeData ( QByteArrayView  bytes,
QDeadlineTimer  deadline 
)
protectedpure virtual

Receives non-empty bytes and an unexpired, capped deadline that implementations must honor.

Implemented in GPSDeviceTransport, and UDPGPSTransport.

Referenced by write().

Member Data Documentation

◆ BRIDGE_BAUDRATE

constexpr unsigned GPSTransport::BRIDGE_BAUDRATE = 115200
staticconstexpr

Line rate that TCP and UDP links report. Drivers still program the receiver's serial port with it (UBX CFG-PRT sets UART1 to it), so the serial side of a network bridge and its receiver must run at this rate.

Definition at line 93 of file GPSTransport.h.

Referenced by TCPGPSTransport::fixedBaudrate(), and UDPGPSTransport::fixedBaudrate().

◆ READ_BUFFER_BYTES

constexpr qint64 GPSTransport::READ_BUFFER_BYTES = 64 * 1024
staticconstexpr

Received bytes a link buffers before it stops taking more (TCP), retires the session (serial) or drops the oldest (UDP).

Definition at line 96 of file GPSTransport.h.

Referenced by SerialGPSTransport::open(), and TCPGPSTransport::open().

◆ WRITE_BUFFER_BYTES

constexpr qint64 GPSTransport::WRITE_BUFFER_BYTES = 4 * 1024
staticconstexpr

Bytes a link queues for writing at once.

Definition at line 98 of file GPSTransport.h.

Referenced by GPSDeviceTransport::writeData().


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