QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
AndroidSerialAccess.cc
Go to the documentation of this file.
2
3#include <atomic>
4
5#include "AndroidSerialJni.h"
8
9// The category of the port list, by the name that it has always had.
10QGC_LOGGING_CATEGORY(AndroidSerialPortInfoLog, "Android.AndroidSerialPortInfo")
11
12namespace {
13std::atomic<bool> s_usePosixSerial{false};
14} // namespace
15
17{
18 s_usePosixSerial.store(use);
19 qCDebug(AndroidSerialPortInfoLog) << "Serial ports:" << (use ? "USB and POSIX" : "USB");
20}
21
23{
24 return s_usePosixSerial.load();
25}
26
28{
29 return !QSerialPortInfo::posixPorts(QStringLiteral("/dev"), QStringLiteral("/sys/class/tty")).isEmpty();
30}
31
32bool AndroidSerialAccess::hasUsbPermission(const QString& portName)
33{
34 const QString location = QSerialPortInfo::portNameToSystemLocation(portName);
36}
37
38bool AndroidSerialAccess::requestUsbPermission(const QString& portName)
39{
40 const QString location = QSerialPortInfo::portNameToSystemLocation(portName);
41 return QSerialPortInfo::isUsbLocation(location) && !AndroidSerial::hasPermission(location) &&
43}
44
45bool AndroidSerialAccess::isUsbPermissionDenied(const QString& portName)
46{
47 const QString location = QSerialPortInfo::portNameToSystemLocation(portName);
49}
#define QGC_LOGGING_CATEGORY(name, categoryStr)
static bool isUsbLocation(const QString &systemLocation)
static QList< QSerialPortInfo > posixPorts(const QString &devDir, const QString &sysTtyDir, const QList< QSerialPortInfo > &usbPorts={})
static QString portNameToSystemLocation(const QString &portName)
bool isUsbPermissionDenied(const QString &portName)
Whether the port is a USB one whose device the user has denied QGC, and has not been asked for again ...
bool hasPosixSerialPorts()
Whether the device has a serial port node that QGC may read and write.
void setUsePosixSerial(bool use)
bool requestUsbPermission(const QString &portName)
bool hasUsbPermission(const QString &portName)
Whether the port is a USB one whose device QGC may open.
bool hasPermission(const QString &portName)
Whether QGC may open the device of this port.
bool isPermissionDenied(const QString &portName)
bool requestPermission(const QString &portName)