|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <SerialGPSTransport.h>
Inheritance diagram for SerialGPSTransport:
Collaboration diagram for SerialGPSTransport:Public Member Functions | |
| SerialGPSTransport (QString device, GPSCancelToken cancelToken, std::chrono::milliseconds openTimeout=OPEN_TIMEOUT) | |
| ~SerialGPSTransport () override | |
| GPSOpenResult | open () override |
| bool | fatalError () const override |
| True once the port hits an error the receive loop should stop retrying past. | |
| bool | setBaudrate (unsigned baudrate) override |
Public Member Functions inherited from GPSDeviceTransport | |
| GPSReadResult | read (std::span< uint8_t > buffer, std::chrono::milliseconds timeout) override |
| GPSTransport (GPSCancelToken cancelToken) | |
Public Member Functions inherited from GPSTransport | |
| GPSTransport (GPSCancelToken cancelToken) | |
| virtual | ~GPSTransport () |
| 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 std::chrono::milliseconds | configurationWriteTimeout () const |
| GPSWriteResult | write (QByteArrayView bytes, QDeadlineTimer deadline) |
Static Public Attributes | |
| static constexpr std::chrono::milliseconds | OPEN_TIMEOUT {30000} |
| How long open() keeps retrying a device it is not permitted to open yet. | |
Static Public Attributes inherited from GPSTransport | |
| 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 | |
| QIODevice * | device () const override |
| The open device, or null before open(). | |
| bool | readUnavailable () const override |
| Whether read() fails without waiting; by default, when there is no device. | |
| bool | waitReadable (QDeadlineTimer deadline) override |
| Waits until input is buffered. Input reported buffered is delivered even after the link fails. | |
| GPSReadResult | readFailure () const override |
| Describes a failed link; by default, a closed connection with the device's error. | |
| void | waitWritten (QDeadlineTimer &deadline) override |
| Waits for queued bytes to drain. May expire deadline to end the write. | |
| qint64 | confirmedWritten (int accepted, qint64 drained) override |
Protected Member Functions inherited from GPSDeviceTransport | |
| virtual qint64 | take (std::span< uint8_t > buffer) |
| Takes buffered input. | |
| GPSWriteResult | writeData (QByteArrayView bytes, QDeadlineTimer deadline) override |
| Receives non-empty bytes and an unexpired, capped deadline that implementations must honor. | |
| virtual void | retire () |
| Retires the connection after a failed write that accepted bytes; by default closes the device. | |
| bool | waitUntil (const std::function< bool()> &done, QDeadlineTimer deadline) |
| bool | waitForDevice (const std::function< bool()> &ready, QDeadlineTimer deadline) |
GPSTransport backed by a QSerialPort. Owns the port and must be constructed on the thread that pumps the driver — QSerialPort has thread affinity.
Definition at line 15 of file SerialGPSTransport.h.
| SerialGPSTransport::SerialGPSTransport | ( | QString | device, |
| GPSCancelToken | cancelToken, | ||
| std::chrono::milliseconds | openTimeout = OPEN_TIMEOUT |
||
| ) |
Definition at line 45 of file SerialGPSTransport.cc.
|
overridedefault |
|
overrideprotectedvirtual |
Bytes of this write the link confirmed, given accepted bytes accepted and drained bytes reported by the device's bytesWritten() during the write; by default drained.
Reimplemented from GPSDeviceTransport.
Definition at line 158 of file SerialGPSTransport.cc.
References fatalError().
|
overrideprotectedvirtual |
The open device, or null before open().
Implements GPSDeviceTransport.
Definition at line 116 of file SerialGPSTransport.cc.
|
overridevirtual |
True once the port hits an error the receive loop should stop retrying past.
Implements GPSTransport.
Definition at line 110 of file SerialGPSTransport.cc.
References QSerialPort::NoError, and QSerialPort::TimeoutError.
Referenced by confirmedWritten(), readUnavailable(), setBaudrate(), and waitReadable().
|
overridevirtual |
Open the device, retrying briefly while it settles after startup. Aborts the retry promptly once a stop is requested, so a disconnect can't be stalled by it.
Implements GPSTransport.
Definition at line 54 of file SerialGPSTransport.cc.
References QSerialPort::Baud9600, Cancelled, QSerialPort::Data8, Error, GPSTransport::isCancelled(), QSerialPort::NoFlowControl, QSerialPort::NoParity, QSerialPort::OneStop, Opened, QSerialPort::PermissionError, GPSTransport::READ_BUFFER_BYTES, TimedOut, and GPSDeviceTransport::waitUntil().
|
overrideprotectedvirtual |
Describes a failed link; by default, a closed connection with the device's error.
Reimplemented from GPSDeviceTransport.
Definition at line 132 of file SerialGPSTransport.cc.
|
overrideprotectedvirtual |
Whether read() fails without waiting; by default, when there is no device.
Reimplemented from GPSDeviceTransport.
Definition at line 121 of file SerialGPSTransport.cc.
References fatalError().
|
overridevirtual |
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 from GPSTransport.
Definition at line 169 of file SerialGPSTransport.cc.
References fatalError(), GPSTransport::isCancelled(), and QSerialPort::ResourceError.
|
overrideprotectedvirtual |
Waits until input is buffered. Input reported buffered is delivered even after the link fails.
Reimplemented from GPSDeviceTransport.
Definition at line 126 of file SerialGPSTransport.cc.
References fatalError(), GPSTransport::isCancelled(), and GPSDeviceTransport::waitReadable().
|
overrideprotectedvirtual |
Waits for queued bytes to drain. May expire deadline to end the write.
Reimplemented from GPSDeviceTransport.
Definition at line 150 of file SerialGPSTransport.cc.
|
staticconstexpr |
How long open() keeps retrying a device it is not permitted to open yet.
Definition at line 19 of file SerialGPSTransport.h.