QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
SerialGPSTransport.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <cstdint>
5#include <memory>
6
7#include <QtCore/QString>
8
10
11class QSerialPort;
12
16{
17public:
19 static constexpr std::chrono::milliseconds OPEN_TIMEOUT{30000};
20
22 std::chrono::milliseconds openTimeout = OPEN_TIMEOUT);
24
27 GPSOpenResult open() override;
28
30 bool fatalError() const override;
31
32 bool setBaudrate(unsigned baudrate) override;
33
34protected:
35 QIODevice* device() const override;
36 bool readUnavailable() const override;
37 bool waitReadable(QDeadlineTimer deadline) override;
38 GPSReadResult readFailure() const override;
39 void waitWritten(QDeadlineTimer& deadline) override;
40 qint64 confirmedWritten(int accepted, qint64 drained) override;
41
42private:
47 static constexpr std::chrono::milliseconds CANCELLATION_POLL{50};
48 static constexpr std::chrono::milliseconds OPEN_RETRY{500};
49
50 QString _errorDetail() const;
51 bool _inputBudgetExhausted() const;
52
53 QString _device;
54 std::chrono::milliseconds _openTimeout;
55 std::unique_ptr<QSerialPort> _serial;
56 bool _inputOverflow = false;
57 qint64 _acceptedTotal = 0;
58 qint64 _writtenTotal = 0;
59};
const GPSCancelToken & cancelToken() const
Provides functions to access serial ports.
Definition qserialport.h:17
bool setBaudrate(unsigned baudrate) override
void waitWritten(QDeadlineTimer &deadline) override
Waits for queued bytes to drain. May expire deadline to end the write.
bool fatalError() const override
True once the port hits an error the receive loop should stop retrying past.
GPSOpenResult open() override
GPSReadResult readFailure() const override
Describes a failed link; by default, a closed connection with the device's error.
qint64 confirmedWritten(int accepted, qint64 drained) override
~SerialGPSTransport() override
bool waitReadable(QDeadlineTimer deadline) override
Waits until input is buffered. Input reported buffered is delivered even after the link fails.
bool readUnavailable() const override
Whether read() fails without waiting; by default, when there is no device.
static constexpr std::chrono::milliseconds OPEN_TIMEOUT
How long open() keeps retrying a device it is not permitted to open yet.
QIODevice * device() const override
The open device, or null before open().