From fdffbcd7ff5f19db0ebfb574a9e012a35b3cd633 Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 31 May 2024 22:31:00 -0400 Subject: [PATCH] SerialLink: Use QSerialPortInfo for BaudRate Map --- .../qserialport_android.cpp | 1 + src/Comms/SerialLink.cc | 60 ++----------------- src/Comms/SerialLink.h | 2 - 3 files changed, 6 insertions(+), 57 deletions(-) diff --git a/libs/qtandroidserialport/qserialport_android.cpp b/libs/qtandroidserialport/qserialport_android.cpp index 8ef21c8a501..e136f304aae 100644 --- a/libs/qtandroidserialport/qserialport_android.cpp +++ b/libs/qtandroidserialport/qserialport_android.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include diff --git a/src/Comms/SerialLink.cc b/src/Comms/SerialLink.cc index a9fc903fad3..db0cf434499 100644 --- a/src/Comms/SerialLink.cc +++ b/src/Comms/SerialLink.cc @@ -21,8 +21,6 @@ QGC_LOGGING_CATEGORY(SerialLinkLog, "SerialLinkLog") -static QStringList kSupportedBaudRates; - SerialLink::SerialLink(SharedLinkConfigurationPtr& config, bool isPX4Flow) : LinkInterface(config, isPX4Flow) , _serialConfig(qobject_cast(config.get())) @@ -395,60 +393,12 @@ void SerialConfiguration::loadSettings(QSettings& settings, const QString& root) QStringList SerialConfiguration::supportedBaudRates() { - if(!kSupportedBaudRates.size()) - _initBaudRates(); - return kSupportedBaudRates; -} + QStringList supportBaudRateStrings; + for (int rate : QSerialPortInfo::standardBaudRates()) { + (void) supportBaudRateStrings.append(QString::number(rate)); + } -void SerialConfiguration::_initBaudRates() -{ - kSupportedBaudRates.clear(); - kSupportedBaudRates = QStringList({ -#if USE_ANCIENT_RATES -#if defined(Q_OS_UNIX) || defined(Q_OS_LINUX) || defined(Q_OS_DARWIN) - "50", - "75", -#endif - "110", -#if defined(Q_OS_UNIX) || defined(Q_OS_LINUX) || defined(Q_OS_DARWIN) - "150", - "200" , - "134" , -#endif - "300", - "600", - "1200", -#if defined(Q_OS_UNIX) || defined(Q_OS_LINUX) || defined(Q_OS_DARWIN) - "1800", -#endif -#endif - "2400", - "4800", - "9600", -#if defined(Q_OS_WIN) - "14400", -#endif - "19200", - "38400", -#if defined(Q_OS_WIN) - "56000", -#endif - "57600", - "115200", -#if defined(Q_OS_WIN) - "128000", -#endif - "230400", -#if defined(Q_OS_WIN) - "256000", -#endif - "460800", - "500000", -#if defined(Q_OS_LINUX) - "576000", -#endif - "921600", - }); + return supportBaudRateStrings; } void SerialConfiguration::setUsbDirect(bool usbDirect) diff --git a/src/Comms/SerialLink.h b/src/Comms/SerialLink.h index 5c8ba91cf0b..9b4bea0d608 100644 --- a/src/Comms/SerialLink.h +++ b/src/Comms/SerialLink.h @@ -89,8 +89,6 @@ class SerialConfiguration : public LinkConfiguration void usbDirectChanged (bool usbDirect); private: - static void _initBaudRates(); - int _baud; int _dataBits; int _flowControl;