Skip to content

Commit

Permalink
Comms: Convert Serial to Signals/Slots
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Sep 7, 2024
1 parent a703ff2 commit 2c8fedb
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 417 deletions.
2 changes: 1 addition & 1 deletion src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void APMAutoPilotPlugin::_checkForBadCubeBlack(void)
// FIXME: Put back
for (const QVariant& varLink: _vehicle->links()) {
SerialLink* serialLink = varLink.value<SerialLink*>();
if (serialLink && QSerialPortInfo(*serialLink->_hackAccessToPort()).description().contains(QStringLiteral("CubeBlack"))) {
if (serialLink && QSerialPortInfo(*serialLink->port()).description().contains(QStringLiteral("CubeBlack"))) {
cubeBlackFound = true;
}

Expand Down
16 changes: 7 additions & 9 deletions src/Comms/LinkManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ LinkManager::LinkManager(QGCApplication* app, QGCToolbox* toolbox)

qRegisterMetaType<QAbstractSocket::SocketError>();
qRegisterMetaType<LinkInterface*>("LinkInterface*");
#ifndef NO_SERIAL_LINK
qRegisterMetaType<QGCSerialPortInfo>("QGCSerialPortInfo");
#endif
}

LinkManager::~LinkManager()
Expand Down Expand Up @@ -257,11 +259,6 @@ void LinkManager::setConnectionsSuspended(QString reason)
_connectionsSuspendedReason = reason;
}

void LinkManager::suspendConfigurationUpdates(bool suspend)
{
_configUpdateSuspended = suspend;
}

void LinkManager::saveLinkConfigurationList()
{
QSettings settings;
Expand Down Expand Up @@ -915,7 +912,8 @@ bool LinkManager::_allowAutoConnectToBoard(QGCSerialPortInfo::BoardType_t boardT
bool LinkManager::_portAlreadyConnected(const QString &portName)
{
const QString searchPort = portName.trimmed();
for (const SharedLinkInterfacePtr &linkConfig : _rgLinks) {
for (const SharedLinkInterfacePtr &linkInterface : _rgLinks) {
const SharedLinkConfigurationPtr linkConfig = linkInterface->linkConfiguration();
const SerialConfiguration* const serialConfig = qobject_cast<const SerialConfiguration*>(linkConfig.get());
if (serialConfig && (serialConfig->portName() == searchPort)) {
return true;
Expand All @@ -933,13 +931,13 @@ void LinkManager::_updateSerialPorts()
for (const QGCSerialPortInfo &info: portList) {
const QString port = info.systemLocation().trimmed(); // + " " + info.description();
_commPortList += port;
_commPortDisplayList += SerialConfiguration::cleanPortDisplayname(port);
_commPortDisplayList += SerialConfiguration::cleanPortDisplayName(port);
}
}

QStringList LinkManager::serialPortStrings()
{
if (!_commPortDisplayList.size()) {
if (_commPortDisplayList.isEmpty()) {
_updateSerialPorts();
}

Expand All @@ -948,7 +946,7 @@ QStringList LinkManager::serialPortStrings()

QStringList LinkManager::serialPorts()
{
if (!_commPortList.size()) {
if (_commPortList.isEmpty()) {
_updateSerialPorts();
}

Expand Down
3 changes: 0 additions & 3 deletions src/Comms/LinkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ class LinkManager : public QGCTool
void loadLinkConfigurationList();
void saveLinkConfigurationList();

/// Suspend automatic confguration updates (during link maintenance for instance)
void suspendConfigurationUpdates(bool suspend);

/// Sets the flag to suspend the all new connections
/// @param reason User visible reason to suspend connections
void setConnectionsSuspended(QString reason);
Expand Down
Loading

0 comments on commit 2c8fedb

Please sign in to comment.