QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
SerialPortManager Class Reference

Shared serial inventory and exclusive claims. Called on the application thread. More...

#include <SerialPortManager.h>

+ Inheritance diagram for SerialPortManager:
+ Collaboration diagram for SerialPortManager:

Classes

struct  Port
 
struct  Reservation
 

Public Types

using ReservationPtr = std::shared_ptr< const Reservation >
 
using Enumerator = std::function< QList< Port >()>
 

Signals

void serialPortsChanged ()
 
void portsEnumerated (const QStringList &availablePorts)
 Emitted only after a fresh scan, never for a retained Android snapshot. Includes native names and paths.
 

Public Member Functions

 SerialPortManager (QObject *parent=nullptr, Enumerator enumerator={})
 
QList< Port > availablePorts ()
 
void rescan ()
 As availablePorts(), without reusing a scan made less than a second ago.
 
QString displayName (const QString &systemLocation)
 
QStringList serialPorts () const
 
ReservationPtr reservePort (const QString &systemLocation)
 
bool canReservePort (const QString &systemLocation) const
 
bool isPortReserved (const QString &systemLocation) const
 
bool anyPortReserved () const
 
ReservationPtr excludeFromAutoConnect (const QString &systemLocation)
 Routing exclusions survive reconnects without marking the hardware occupied.
 
bool canAutoConnectPort (const QString &systemLocation) const
 
bool isAutoConnectExcluded (const QString &systemLocation) const
 
void setSinglePortOnly (bool enabled)
 

Static Public Member Functions

static SerialPortManager * instance ()
 
static bool isPrimaryInterface (const Port &port, QSet< QString > &seenDevices)
 
static QStringList supportedBaudRates ()
 

Static Public Attributes

static constexpr std::chrono::milliseconds NEW_PORT_SETTLE_DELAY {1000}
 How long a newly listed port settles before automatic connection opens it.
 

Detailed Description

Shared serial inventory and exclusive claims. Called on the application thread.

Definition at line 18 of file SerialPortManager.h.

Member Typedef Documentation

◆ Enumerator

using SerialPortManager::Enumerator = std::function<QList<Port>()>

Definition at line 47 of file SerialPortManager.h.

◆ ReservationPtr

using SerialPortManager::ReservationPtr = std::shared_ptr<const Reservation>

Definition at line 46 of file SerialPortManager.h.

Constructor & Destructor Documentation

◆ SerialPortManager()

SerialPortManager::SerialPortManager ( QObject *  parent = nullptr,
Enumerator  enumerator = {} 
)
explicit

Definition at line 15 of file SerialPortManager.cc.

Member Function Documentation

◆ anyPortReserved()

bool SerialPortManager::anyPortReserved ( ) const

Definition at line 125 of file SerialPortManager.cc.

Referenced by availablePorts(), and canReservePort().

◆ availablePorts()

QList< SerialPortManager::Port > SerialPortManager::availablePorts ( )

◆ canAutoConnectPort()

bool SerialPortManager::canAutoConnectPort ( const QString &  systemLocation) const

Definition at line 158 of file SerialPortManager.cc.

References canReservePort(), and isAutoConnectExcluded().

Referenced by SerialAutoConnect::update().

◆ canReservePort()

bool SerialPortManager::canReservePort ( const QString &  systemLocation) const

Definition at line 135 of file SerialPortManager.cc.

References anyPortReserved(), and isPortReserved().

Referenced by canAutoConnectPort(), and reservePort().

◆ displayName()

QString SerialPortManager::displayName ( const QString &  systemLocation)

Definition at line 94 of file SerialPortManager.cc.

References availablePorts().

Referenced by SerialConfiguration::cleanPortDisplayName().

◆ excludeFromAutoConnect()

SerialPortManager::ReservationPtr SerialPortManager::excludeFromAutoConnect ( const QString &  systemLocation)

Routing exclusions survive reconnects without marking the hardware occupied.

Definition at line 141 of file SerialPortManager.cc.

◆ instance()

◆ isAutoConnectExcluded()

bool SerialPortManager::isAutoConnectExcluded ( const QString &  systemLocation) const

Definition at line 218 of file SerialPortManager.cc.

Referenced by canAutoConnectPort(), and SerialAutoConnect::update().

◆ isPortReserved()

bool SerialPortManager::isPortReserved ( const QString &  systemLocation) const

Definition at line 120 of file SerialPortManager.cc.

Referenced by canReservePort().

◆ isPrimaryInterface()

bool SerialPortManager::isPrimaryInterface ( const Port &  port,
QSet< QString > &  seenDevices 
)
static

Whether port is the first interface listed of its physical device, which this records in seenDevices. A port without a device identity is always primary.

Definition at line 24 of file SerialPortManager.cc.

Referenced by SerialAutoConnect::update().

◆ portsEnumerated

void SerialPortManager::portsEnumerated ( const QStringList &  availablePorts)
signal

Emitted only after a fresh scan, never for a retained Android snapshot. Includes native names and paths.

Referenced by availablePorts(), GPSReceiver::GPSReceiver(), LinkManager::LinkManager(), and SerialLink::SerialLink().

◆ rescan()

void SerialPortManager::rescan ( )

As availablePorts(), without reusing a scan made less than a second ago.

Definition at line 88 of file SerialPortManager.cc.

References availablePorts().

◆ reservePort()

SerialPortManager::ReservationPtr SerialPortManager::reservePort ( const QString &  systemLocation)

Definition at line 106 of file SerialPortManager.cc.

References canReservePort().

Referenced by LinkManager::createConnectedLink().

◆ serialPorts()

QStringList SerialPortManager::serialPorts ( ) const
inline

Definition at line 69 of file SerialPortManager.h.

Referenced by availablePorts().

◆ serialPortsChanged

void SerialPortManager::serialPortsChanged ( )
signal

Referenced by availablePorts().

◆ setSinglePortOnly()

void SerialPortManager::setSinglePortOnly ( bool  enabled)
inline

Definition at line 82 of file SerialPortManager.h.

Referenced by LinkManager::init().

◆ supportedBaudRates()

QStringList SerialPortManager::supportedBaudRates ( )
static

Member Data Documentation

◆ NEW_PORT_SETTLE_DELAY

constexpr std::chrono::milliseconds SerialPortManager::NEW_PORT_SETTLE_DELAY {1000}
staticconstexpr

How long a newly listed port settles before automatic connection opens it.

Definition at line 54 of file SerialPortManager.h.

Referenced by SerialPortSettleTracker::settled().


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