QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PosixSerialBackend.cc
Go to the documentation of this file.
1// The POSIX backend of QSerialPort: a serial device node, such as the built-in UART that a rooted device
2// exposes as /dev/ttyS1.
3
4#include <cerrno>
5#include <cstring>
6#include <fcntl.h>
7#include <poll.h>
8#include <sys/ioctl.h>
9#include <termios.h>
10#include <unistd.h>
11
12#include <QtCore/QDeadlineTimer>
13#include <QtCore/QPointer>
14#include <QtCore/QSocketNotifier>
15
17
18namespace {
19
20speed_t baudRateToSpeed(qint32 baudRate)
21{
22 switch (baudRate) {
23 case 50:
24 return B50;
25 case 75:
26 return B75;
27 case 110:
28 return B110;
29 case 134:
30 return B134;
31 case 150:
32 return B150;
33 case 200:
34 return B200;
35 case 300:
36 return B300;
37 case 600:
38 return B600;
39 case 1200:
40 return B1200;
41 case 1800:
42 return B1800;
43 case 2400:
44 return B2400;
45 case 4800:
46 return B4800;
47 case 9600:
48 return B9600;
49 case 19200:
50 return B19200;
51 case 38400:
52 return B38400;
53 case 57600:
54 return B57600;
55 case 115200:
56 return B115200;
57 case 230400:
58 return B230400;
59 case 460800:
60 return B460800;
61 case 500000:
62 return B500000;
63 case 576000:
64 return B576000;
65 case 921600:
66 return B921600;
67 case 1000000:
68 return B1000000;
69 case 1152000:
70 return B1152000;
71 case 1500000:
72 return B1500000;
73 case 2000000:
74 return B2000000;
75 case 2500000:
76 return B2500000;
77 case 3000000:
78 return B3000000;
79 case 3500000:
80 return B3500000;
81 case 4000000:
82 return B4000000;
83 default:
84 return B0;
85 }
86}
87
88// The kernel's interface for the baud rates that termios has no constant for. It is declared here, as in Qt's
89// own serial port, because the header that declares it, <asm/termbits.h>, also defines struct termios again.
90struct KernelTermios2
91{
92 tcflag_t c_iflag;
93 tcflag_t c_oflag;
94 tcflag_t c_cflag;
95 tcflag_t c_lflag;
96 cc_t c_line;
97 cc_t c_cc[19];
98 speed_t c_ispeed;
99 speed_t c_ospeed;
100};
101
102constexpr unsigned long kGetTermios2 = _IOR('T', 0x2A, KernelTermios2);
103constexpr unsigned long kSetTermios2 = _IOW('T', 0x2B, KernelTermios2);
104// BOTHER: the rate is the number in c_ispeed and c_ospeed.
105constexpr tcflag_t kOtherBaudRate = 0010000;
106
107int pollTimeoutMs(const QDeadlineTimer& deadline)
108{
109 return deadline.isForever() ? -1 : static_cast<int>(qMax<qint64>(0, deadline.remainingTime()));
110}
111
112class PosixSerialBackend final : public AndroidSerialBackend
113{
114public:
115 explicit PosixSerialBackend(AndroidSerialBackendHost port)
116 : _port(port)
117 {}
118
119 ~PosixSerialBackend() override { close(); }
120
121 bool open(QIODevice::OpenMode mode) override;
122 void close() override;
123
124 int descriptor() const override { return _descriptor; }
125
126 bool startReading() override;
127 bool waitForInput(const QDeadlineTimer& deadline) override;
128 qint64 startWrite(const char* data, qint64 maxSize) override;
129 bool waitForWritable(const QDeadlineTimer& deadline) override;
130 bool setParameters(qint32 baudRate, QSerialPort::DataBits dataBits, QSerialPort::StopBits stopBits,
131 QSerialPort::Parity parity, const QString& failureText) override;
132 bool setFlowControl(QSerialPort::FlowControl flowControl) override;
133 bool setBreakEnabled(bool set) override;
134 bool clear(QSerialPort::Directions directions) override;
135 QSerialPort::PinoutSignals pinoutSignals() override;
136 bool setDataTerminalReady(bool set) override;
137 bool setRequestToSend(bool set) override;
138
139private:
141 bool _setCustomBaudRate(qint32 baudRate);
143 bool _applySettings(qint32 baudRate, QSerialPort::DataBits dataBits, QSerialPort::StopBits stopBits,
145 bool _setControlLine(int line, bool set, const char* lineName, const QString& failureText);
147 bool _readActivated();
149 void _writeActivated();
150 void _readFailed(int readError);
151
152 AndroidSerialBackendHost _port;
153 int _descriptor = -1;
154 QPointer<QSocketNotifier> _readNotifier;
155 // Whether the port has answered that it has no room for more input. The device is not read until the port
156 // starts reading again, so the kernel holds its input meanwhile, as it does for desktop QSerialPort.
157 bool _readPaused = false;
158 // Enabled while the device takes no more output, to tell the port when it does again.
159 QPointer<QSocketNotifier> _writeNotifier;
160};
161
162bool PosixSerialBackend::open(QIODevice::OpenMode mode)
163{
164 int flags = O_NOCTTY | O_NONBLOCK;
165 if ((mode & QIODevice::ReadWrite) == QIODevice::ReadWrite) {
166 flags |= O_RDWR;
167 } else if (mode & QIODevice::WriteOnly) {
168 flags |= O_WRONLY;
169 } else {
170 flags |= O_RDONLY;
171 }
172
173 // TODO: once QGC compiles against Android API 37, take this descriptor from android.hardware.serial where the
174 // device has it: SerialPort.requestOpen() asks the user and opens the node for the app, so a device that is
175 // not rooted can use this backend, and SerialManager.getPorts() lists the nodes for
176 // QSerialPortInfo::posixPorts(). This open() succeeds only where the system lets the app open /dev/tty*.
177 const int descriptor = ::open(_port.systemLocation().toLocal8Bit().constData(), flags);
178 if (descriptor == -1) {
179 const int openErrno = errno;
180 qCWarning(AndroidSerialPortLog) << "Error opening" << _port.systemLocation() << ":" << strerror(openErrno);
181 const QSerialPort::SerialPortError openError = (openErrno == ENOENT) ? QSerialPort::DeviceNotFoundError
182 : (openErrno == EACCES) ? QSerialPort::PermissionError
183 : QSerialPort::OpenError;
184 _port.setError(openError, QString::fromLocal8Bit(strerror(openErrno)));
185 return false;
186 }
187
188 if (::isatty(descriptor) == 0) {
189 qCWarning(AndroidSerialPortLog) << _port.systemLocation() << "is not a tty device";
190 (void) ::close(descriptor);
191 _port.setError(QSerialPort::OpenError, QSerialPort::tr("Not a tty device"));
192 return false;
193 }
194
195 // Request exclusive access. Failure is not fatal.
196 if (::ioctl(descriptor, TIOCEXCL) == -1) {
197 qCDebug(AndroidSerialPortLog) << "Failed to set exclusive access on" << _port.systemLocation() << ":"
198 << strerror(errno);
199 }
200
201 _descriptor = descriptor;
202
203 QSerialPort* const q = &_port.serialPort();
204 if (mode & QIODevice::ReadOnly) {
205 _readNotifier = new QSocketNotifier(descriptor, QSocketNotifier::Read, q);
206 // The port starts reading once it has applied its settings.
207 _readNotifier->setEnabled(false);
208 QObject::connect(_readNotifier, &QSocketNotifier::activated, q, [this]() { (void) _readActivated(); });
209 }
210 if (mode & QIODevice::WriteOnly) {
211 _writeNotifier = new QSocketNotifier(descriptor, QSocketNotifier::Write, q);
212 _writeNotifier->setEnabled(false);
213 QObject::connect(_writeNotifier, &QSocketNotifier::activated, q, [this]() { _writeActivated(); });
214 }
215
216 return true;
217}
218
219void PosixSerialBackend::close()
220{
221 delete _readNotifier.data();
222 delete _writeNotifier.data();
223 _readPaused = false;
224
225 if (_descriptor != -1) {
226 // The exclusive access that open() took outlives this descriptor while anyone else holds the device
227 // open, and would refuse the next open.
228 (void) ::ioctl(_descriptor, TIOCNXCL);
229 if (::close(_descriptor) == -1) {
230 qCWarning(AndroidSerialPortLog) << "Failed to close" << _port.systemLocation() << ":" << strerror(errno);
231 }
232 _descriptor = -1;
233 }
234}
235
236bool PosixSerialBackend::startReading()
237{
238 _readPaused = false;
239 if (_readNotifier) {
240 _readNotifier->setEnabled(true);
241 }
242
243 return true;
244}
245
246bool PosixSerialBackend::waitForInput(const QDeadlineTimer& deadline)
247{
248 // While the device takes no more output, also wake when it does, so that the port can go on writing.
249 const bool writeBlocked = _writeNotifier && _writeNotifier->isEnabled();
250 // Input that the port has no room for stays with the device, and does not end the wait.
251 const short events = static_cast<short>((_readPaused ? 0 : POLLIN) | (writeBlocked ? POLLOUT : 0));
252 struct pollfd pfd = {_descriptor, events, 0};
253 const int ready = ::poll(&pfd, 1, pollTimeoutMs(deadline));
254 if (ready < 0) {
255 if (errno == EINTR) {
256 return true;
257 }
258 const int pollErrno = errno;
259 qCWarning(AndroidSerialPortLog) << "Poll error on" << _port.systemLocation() << ":" << strerror(pollErrno);
260 _port.setError(QSerialPort::ReadError, QString::fromLocal8Bit(strerror(pollErrno)));
261 return false;
262 }
263 if (ready == 0) {
264 return true;
265 }
266 if (pfd.revents & POLLOUT) {
267 _writeActivated();
268 }
269 if (!(pfd.revents & ~POLLOUT)) {
270 return true;
271 }
272
273 // Read on any other wakeup, an error or hangup too: a read that fails reports the real error.
274 const bool hungUp = pfd.revents & (POLLERR | POLLHUP | POLLNVAL);
275 const bool readSucceeded = _readActivated();
276 if (_port.inputArrived()) {
277 return true;
278 }
279 if (!readSucceeded) {
280 return false;
281 }
282 if (hungUp) {
283 // Nothing to read from a descriptor that hung up: report it rather than poll it until the deadline.
284 _port.setError(QSerialPort::ResourceError, QSerialPort::tr("Device disconnected"));
285 return false;
286 }
287
288 return true;
289}
290
291bool PosixSerialBackend::_readActivated()
292{
293 char readBuf[4096];
294 bool gotData = false;
295
296 for (;;) {
297 const ssize_t bytesRead = ::read(_descriptor, readBuf, sizeof(readBuf));
298 if (bytesRead > 0) {
299 gotData = true;
300 if (!_port.newDataArrived(readBuf, static_cast<int>(bytesRead))) {
301 _readPaused = true;
302 if (_readNotifier) {
303 _readNotifier->setEnabled(false);
304 }
305 return true;
306 }
307 if (bytesRead < static_cast<ssize_t>(sizeof(readBuf))) {
308 return true;
309 }
310 continue;
311 }
312
313 if ((bytesRead < 0) && (errno == EINTR)) {
314 continue;
315 }
316
317 if (bytesRead < 0) {
318 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {
319 return true;
320 }
321 _readFailed(errno);
322 return false;
323 }
324
325 if (gotData) {
326 return true;
327 }
328 // The descriptor was reported readable, so having nothing to read means the device hung up.
329 _readFailed(0);
330 return false;
331 }
332}
333
334void PosixSerialBackend::_readFailed(int readError)
335{
336 const bool deviceGone =
337 (readError == 0) || (readError == EIO) || (readError == ENODEV) || (readError == ENXIO) || (readError == EBADF);
338 if (!deviceGone) {
339 qCWarning(AndroidSerialPortLog) << "Read error on" << _port.systemLocation() << ":" << strerror(readError);
340 _port.setError(QSerialPort::ReadError, QString::fromLocal8Bit(strerror(readError)));
341 return;
342 }
343
344 // Like desktop QSerialPort: a vanished device is a ResourceError, which tells the owner to close the port.
345 // Its descriptor stays readable for good, so it must not keep waking the event loop.
346 if (_readNotifier) {
347 _readNotifier->setEnabled(false);
348 }
349 qCWarning(AndroidSerialPortLog) << "Device lost on" << _port.systemLocation() << ":"
350 << (readError == 0 ? "hung up" : strerror(readError));
351 _port.setError(QSerialPort::ResourceError, QSerialPort::tr("Device disconnected"));
352}
353
354qint64 PosixSerialBackend::startWrite(const char* data, qint64 maxSize)
355{
356 ssize_t written;
357 do {
358 written = ::write(_descriptor, data, static_cast<size_t>(maxSize));
359 } while ((written < 0) && (errno == EINTR));
360
361 if ((written < 0) && (errno != EAGAIN) && (errno != EWOULDBLOCK)) {
362 const int writeErrno = errno;
363 qCWarning(AndroidSerialPortLog) << "Write error on" << _port.systemLocation() << ":" << strerror(writeErrno);
364 // Like the USB backend and desktop QSerialPort: a vanished device is a ResourceError.
365 const bool deviceGone = (writeErrno == EIO) || (writeErrno == ENODEV) || (writeErrno == ENXIO);
366 if (deviceGone) {
367 _port.setError(QSerialPort::ResourceError, QSerialPort::tr("Device disconnected"));
368 } else {
369 _port.setError(QSerialPort::WriteError, QSerialPort::tr("Failed to write to port"));
370 }
371 return -1;
372 }
373
374 const qint64 taken = (written > 0) ? written : 0;
375 if ((taken < maxSize) && _writeNotifier) {
376 // The device takes no more for now.
377 _writeNotifier->setEnabled(true);
378 }
379 if (taken > 0) {
380 _port.writeCompleted(taken);
381 }
382
383 return taken;
384}
385
386void PosixSerialBackend::_writeActivated()
387{
388 if (_writeNotifier) {
389 _writeNotifier->setEnabled(false);
390 }
391 _port.writeCompleted(0);
392}
393
394bool PosixSerialBackend::waitForWritable(const QDeadlineTimer& deadline)
395{
396 struct pollfd pfd = {_descriptor, POLLOUT, 0};
397 if (::poll(&pfd, 1, pollTimeoutMs(deadline)) > 0) {
398 _writeActivated();
399 }
400
401 return true;
402}
403
404bool PosixSerialBackend::setParameters(qint32 baudRate, QSerialPort::DataBits dataBits, QSerialPort::StopBits stopBits,
405 QSerialPort::Parity parity, const QString&)
406{
407 return _applySettings(baudRate, dataBits, stopBits, parity, _port.serialPort().flowControl());
408}
409
410bool PosixSerialBackend::setFlowControl(QSerialPort::FlowControl flowControl)
411{
412 const QSerialPort& port = _port.serialPort();
413 return _applySettings(port.baudRate(), port.dataBits(), port.stopBits(), port.parity(), flowControl);
414}
415
416bool PosixSerialBackend::_applySettings(qint32 baudRate, QSerialPort::DataBits dataBits, QSerialPort::StopBits stopBits,
418{
419 struct termios tio;
420 if (::tcgetattr(_descriptor, &tio) == -1) {
421 const int getErrno = errno;
422 qCWarning(AndroidSerialPortLog) << "tcgetattr failed on" << _port.systemLocation() << ":" << strerror(getErrno);
423 _port.setError(QSerialPort::UnknownError, QString::fromLocal8Bit(strerror(getErrno)));
424 return false;
425 }
426
427 ::cfmakeraw(&tio);
428 // As desktop QSerialPort. cfmakeraw() leaves both flags as the last user of the device set them, and they
429 // decide what a byte that arrives damaged reads as.
430 tio.c_iflag &= ~INPCK;
431 tio.c_iflag |= IGNPAR;
432 tio.c_cflag |= (CLOCAL | CREAD);
433 tio.c_cc[VMIN] = 0;
434 tio.c_cc[VTIME] = 0;
435
436 // A closed port keeps any rate it is given. One without a constant goes to the kernel as a number, which
437 // takes 0 for a hang-up and a negative one for a huge rate.
438 if (baudRate <= 0) {
439 qCWarning(AndroidSerialPortLog) << "Unsupported baud rate" << baudRate << "on" << _port.systemLocation();
440 _port.setError(QSerialPort::UnsupportedOperationError, QSerialPort::tr("Unsupported baud rate"));
441 return false;
442 }
443
444 // A rate without a constant is set afterwards, on its own.
445 const speed_t speed = baudRateToSpeed(baudRate);
446 if (speed != B0) {
447 (void) ::cfsetispeed(&tio, speed);
448 (void) ::cfsetospeed(&tio, speed);
449 }
450
451 tio.c_cflag &= ~CSIZE;
452 switch (dataBits) {
454 tio.c_cflag |= CS5;
455 break;
457 tio.c_cflag |= CS6;
458 break;
460 tio.c_cflag |= CS7;
461 break;
463 tio.c_cflag |= CS8;
464 break;
465 default:
466 qCWarning(AndroidSerialPortLog) << "Unsupported data bits:" << dataBits;
467 _port.setError(QSerialPort::UnsupportedOperationError, QSerialPort::tr("Unsupported data bits"));
468 return false;
469 }
470
471 // CMSPAR makes the parity bit constant: a mark with PARODD, otherwise a space.
472 tio.c_cflag &= ~(PARENB | PARODD | CMSPAR);
473 switch (parity) {
475 break;
477 tio.c_cflag |= PARENB;
478 break;
480 tio.c_cflag |= (PARENB | PARODD);
481 break;
483 tio.c_cflag |= (PARENB | CMSPAR);
484 break;
486 tio.c_cflag |= (PARENB | CMSPAR | PARODD);
487 break;
488 default:
489 qCWarning(AndroidSerialPortLog) << "Unsupported parity:" << parity;
490 _port.setError(QSerialPort::UnsupportedOperationError, QSerialPort::tr("Unsupported parity"));
491 return false;
492 }
493
494 switch (stopBits) {
496 tio.c_cflag &= ~CSTOPB;
497 break;
499 tio.c_cflag |= CSTOPB;
500 break;
501 default:
502 qCWarning(AndroidSerialPortLog) << "Unsupported stop bits:" << stopBits;
503 _port.setError(QSerialPort::UnsupportedOperationError, QSerialPort::tr("Unsupported stop bits"));
504 return false;
505 }
506
507 switch (flowControl) {
509 tio.c_cflag &= ~CRTSCTS;
510 tio.c_iflag &= ~(IXON | IXOFF);
511 break;
513 tio.c_cflag |= CRTSCTS;
514 tio.c_iflag &= ~(IXON | IXOFF);
515 break;
517 tio.c_cflag &= ~CRTSCTS;
518 tio.c_iflag |= (IXON | IXOFF);
519 break;
520 default:
521 qCWarning(AndroidSerialPortLog) << "Unsupported flow control:" << flowControl;
522 _port.setError(QSerialPort::UnsupportedOperationError, QSerialPort::tr("Unsupported flow control"));
523 return false;
524 }
525
526 if (::tcsetattr(_descriptor, TCSANOW, &tio) == -1) {
527 const int setErrno = errno;
528 qCWarning(AndroidSerialPortLog) << "tcsetattr failed on" << _port.systemLocation() << ":" << strerror(setErrno);
529 _port.setError(QSerialPort::UnknownError, QString::fromLocal8Bit(strerror(setErrno)));
530 return false;
531 }
532
533 return (speed != B0) || _setCustomBaudRate(baudRate);
534}
535
536bool PosixSerialBackend::_setCustomBaudRate(qint32 baudRate)
537{
538 KernelTermios2 tio;
539 if (::ioctl(_descriptor, kGetTermios2, &tio) != -1) {
540 tio.c_cflag &= ~CBAUD;
541 tio.c_cflag |= kOtherBaudRate;
542 tio.c_ispeed = static_cast<speed_t>(baudRate);
543 tio.c_ospeed = static_cast<speed_t>(baudRate);
544 if (::ioctl(_descriptor, kSetTermios2, &tio) != -1) {
545 return true;
546 }
547 }
548
549 const int setErrno = errno;
550 qCWarning(AndroidSerialPortLog) << "Unsupported baud rate" << baudRate << "on" << _port.systemLocation() << ":"
551 << strerror(setErrno);
552 _port.setError(QSerialPort::UnsupportedOperationError, QSerialPort::tr("Unsupported baud rate"));
553 return false;
554}
555
556bool PosixSerialBackend::clear(QSerialPort::Directions directions)
557{
558 int queues = 0;
559 if (directions == QSerialPort::AllDirections) {
560 queues = TCIOFLUSH;
561 } else if (directions & QSerialPort::Input) {
562 queues = TCIFLUSH;
563 } else if (directions & QSerialPort::Output) {
564 queues = TCOFLUSH;
565 } else {
566 return true;
567 }
568
569 if (::tcflush(_descriptor, queues) == -1) {
570 const int flushErrno = errno;
571 qCWarning(AndroidSerialPortLog) << "tcflush failed on" << _port.systemLocation() << ":" << strerror(flushErrno);
572 _port.setError(QSerialPort::UnknownError, QString::fromLocal8Bit(strerror(flushErrno)));
573 return false;
574 }
575
576 return true;
577}
578
579QSerialPort::PinoutSignals PosixSerialBackend::pinoutSignals()
580{
581 int arg = 0;
582 if (::ioctl(_descriptor, TIOCMGET, &arg) == -1) {
583 const int getErrno = errno;
584 qCWarning(AndroidSerialPortLog) << "TIOCMGET failed on" << _port.systemLocation() << ":" << strerror(getErrno);
585 _port.setError(QSerialPort::UnknownError, QString::fromLocal8Bit(strerror(getErrno)));
587 }
588
589 QSerialPort::PinoutSignals signals_ = QSerialPort::NoSignal;
590 if (arg & TIOCM_DTR) {
592 }
593 if (arg & TIOCM_RTS) {
595 }
596 if (arg & TIOCM_CTS) {
598 }
599 if (arg & TIOCM_DSR) {
601 }
602 if (arg & TIOCM_CAR) {
604 }
605 if (arg & TIOCM_RNG) {
607 }
608 if (arg & TIOCM_ST) {
610 }
611 if (arg & TIOCM_SR) {
613 }
614
615 return signals_;
616}
617
618bool PosixSerialBackend::_setControlLine(int line, bool set, const char* lineName, const QString& failureText)
619{
620 if (::ioctl(_descriptor, set ? TIOCMBIS : TIOCMBIC, &line) != -1) {
621 return true;
622 }
623
624 const int lineErrno = errno;
625 const auto code = (lineErrno == ENOTTY) || (lineErrno == EOPNOTSUPP) ? QSerialPort::UnsupportedOperationError
627 qCDebug(AndroidSerialPortLog) << "Failed to set" << lineName << "on" << _port.systemLocation() << ":"
628 << strerror(lineErrno);
629 _port.setError(code, failureText);
630 return false;
631}
632
633bool PosixSerialBackend::setDataTerminalReady(bool set)
634{
635 return _setControlLine(TIOCM_DTR, set, "DTR", QSerialPort::tr("Failed to set DTR"));
636}
637
638bool PosixSerialBackend::setRequestToSend(bool set)
639{
640 return _setControlLine(TIOCM_RTS, set, "RTS", QSerialPort::tr("Failed to set RTS"));
641}
642
643bool PosixSerialBackend::setBreakEnabled(bool set)
644{
645 if (::ioctl(_descriptor, set ? TIOCSBRK : TIOCCBRK) == -1) {
646 qCWarning(AndroidSerialPortLog) << "Failed to set break on" << _port.systemLocation() << ":" << strerror(errno);
647 _port.setError(QSerialPort::UnknownError, QSerialPort::tr("Failed to set break"));
648 return false;
649 }
650
651 return true;
652}
653
654} // namespace
655
656std::unique_ptr<AndroidSerialBackend> createPosixSerialBackend(AndroidSerialBackendHost port)
657{
658 return std::make_unique<PosixSerialBackend>(port);
659}
std::unique_ptr< AndroidSerialBackend > createPosixSerialBackend(AndroidSerialBackendHost port)
A serial device node, such as /dev/ttyS1.
A QSerialPort as its backend sees it: what the backend asks of the port and reports to it.
void setError(QSerialPort::SerialPortError error, const QString &text=QString())
bool newDataArrived(const char *bytes, int length)
void writeCompleted(qint64 bytes)
bool inputArrived()
Returns whether input has arrived that the port's owner has not been told of and can be told of now.
QSerialPort & serialPort() const
The port itself, for its settings, its error and its thread.
FlowControl flowControl() const
Result setDataTerminalReady(PortHandle handle, bool set)
Result setRequestToSend(PortHandle handle, bool set)
Result startReading(PortHandle handle)
Result setFlowControl(PortHandle handle, QSerialPort::FlowControl flowControl)
Result close(PortHandle handle)
int open(const QString &portName, PortHandle handle)
Result setParameters(PortHandle handle, qint32 baudRate, QSerialPort::DataBits dataBits, QSerialPort::StopBits stopBits, QSerialPort::Parity parity)
GPSCommandSequence port(QByteArrayView port, unsigned baud)
Clears the SBF output of port, keeps a serial port at the link's baud, and selects SBF and the WGS84 ...
Definition SBFPlan.cc:34