Commit e26e1af3 authored by Gus Grubba's avatar Gus Grubba

Merge pull request #2318 from dogmaphobic/linkSettings

Link Settings (WIP)
parents 73b18544 1a419660
...@@ -135,6 +135,9 @@ LinkConfiguration* LinkConfiguration::duplicateSettings(LinkConfiguration* sourc ...@@ -135,6 +135,9 @@ LinkConfiguration* LinkConfiguration::duplicateSettings(LinkConfiguration* sourc
dupe = new MockConfiguration(dynamic_cast<MockConfiguration*>(source)); dupe = new MockConfiguration(dynamic_cast<MockConfiguration*>(source));
break; break;
#endif #endif
case TypeLast:
default:
break;
} }
return dupe; return dupe;
} }
......
...@@ -33,14 +33,16 @@ class LinkInterface; ...@@ -33,14 +33,16 @@ class LinkInterface;
class LinkConfiguration : public QObject class LinkConfiguration : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS(LinkType)
public: public:
LinkConfiguration(const QString& name); LinkConfiguration(const QString& name);
LinkConfiguration(LinkConfiguration* copy); LinkConfiguration(LinkConfiguration* copy);
virtual ~LinkConfiguration() {} virtual ~LinkConfiguration() {}
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(LinkInterface* link READ link WRITE setLink NOTIFY linkChanged) Q_PROPERTY(LinkInterface* link READ link WRITE setLink NOTIFY linkChanged)
Q_PROPERTY(LinkType linkType READ type CONSTANT)
// Property accessors // Property accessors
...@@ -51,7 +53,7 @@ public: ...@@ -51,7 +53,7 @@ public:
void setLink(LinkInterface* link); void setLink(LinkInterface* link);
/// The link types supported by QGC /// The link types supported by QGC
enum { enum LinkType {
#ifndef __ios__ #ifndef __ios__
TypeSerial, ///< Serial Link TypeSerial, ///< Serial Link
#endif #endif
...@@ -88,7 +90,7 @@ public: ...@@ -88,7 +90,7 @@ public:
* Pure virtual method returning one of the -TypeXxx types above. * Pure virtual method returning one of the -TypeXxx types above.
* @return The type of links these settings belong to. * @return The type of links these settings belong to.
*/ */
virtual int type() = 0; virtual LinkType type() = 0;
/*! /*!
* @brief Load settings * @brief Load settings
......
...@@ -97,7 +97,7 @@ void LinkManager::setToolbox(QGCToolbox *toolbox) ...@@ -97,7 +97,7 @@ void LinkManager::setToolbox(QGCToolbox *toolbox)
connect(&_portListTimer, &QTimer::timeout, this, &LinkManager::_updateAutoConnectLinks); connect(&_portListTimer, &QTimer::timeout, this, &LinkManager::_updateAutoConnectLinks);
_portListTimer.start(6000); // timeout must be long enough to get past bootloader on second pass _portListTimer.start(6000); // timeout must be long enough to get past bootloader on second pass
} }
LinkInterface* LinkManager::createConnectedLink(LinkConfiguration* config) LinkInterface* LinkManager::createConnectedLink(LinkConfiguration* config)
...@@ -124,6 +124,9 @@ LinkInterface* LinkManager::createConnectedLink(LinkConfiguration* config) ...@@ -124,6 +124,9 @@ LinkInterface* LinkManager::createConnectedLink(LinkConfiguration* config)
pLink = new MockLink(dynamic_cast<MockConfiguration*>(config)); pLink = new MockLink(dynamic_cast<MockConfiguration*>(config));
break; break;
#endif #endif
case LinkConfiguration::TypeLast:
default:
break;
} }
if(pLink) { if(pLink) {
_addLink(pLink); _addLink(pLink);
...@@ -164,7 +167,7 @@ void LinkManager::_addLink(LinkInterface* link) ...@@ -164,7 +167,7 @@ void LinkManager::_addLink(LinkInterface* link)
break; break;
} }
} }
_links.append(link); _links.append(link);
emit newLink(link); emit newLink(link);
} }
...@@ -367,7 +370,7 @@ void LinkManager::loadLinkConfigurationList() ...@@ -367,7 +370,7 @@ void LinkManager::loadLinkConfigurationList()
} }
} }
} }
// Debug buids always add MockLink automatically // Debug buids always add MockLink automatically
#ifdef QT_DEBUG #ifdef QT_DEBUG
MockConfiguration* pMock = new MockConfiguration("Mock Link PX4"); MockConfiguration* pMock = new MockConfiguration("Mock Link PX4");
...@@ -454,7 +457,7 @@ void LinkManager::_updateAutoConnectLinks(void) ...@@ -454,7 +457,7 @@ void LinkManager::_updateAutoConnectLinks(void)
qCDebug(LinkManagerLog) << "Waiting for bootloader to finish" << portInfo.systemLocation(); qCDebug(LinkManagerLog) << "Waiting for bootloader to finish" << portInfo.systemLocation();
continue; continue;
} }
if (_autoconnectConfigurationsContainsPort(portInfo.systemLocation())) { if (_autoconnectConfigurationsContainsPort(portInfo.systemLocation())) {
qCDebug(LinkManagerVerboseLog) << "Skipping existing autoconnect" << portInfo.systemLocation(); qCDebug(LinkManagerVerboseLog) << "Skipping existing autoconnect" << portInfo.systemLocation();
} else if (!_autoconnectWaitList.contains(portInfo.systemLocation())) { } else if (!_autoconnectWaitList.contains(portInfo.systemLocation())) {
...@@ -661,3 +664,46 @@ void LinkManager::setAutoconnectPX4Flow(bool autoconnect) ...@@ -661,3 +664,46 @@ void LinkManager::setAutoconnectPX4Flow(bool autoconnect)
} }
} }
QStringList LinkManager::linkTypeStrings(void) const
{
//-- Must follow same order as enum LinkType in LinkConfiguration.h
static QStringList list;
if(!list.size())
{
#ifndef __ios__
list += "Serial";
#endif
list += "UDP";
list += "TCP";
list += "Mock Link";
list += "Log Replay";
}
return list;
}
QStringList LinkManager::serialPortStrings(void)
{
#ifndef __ios__
if(!_commPortList.size())
{
QList<QSerialPortInfo> portList = QSerialPortInfo::availablePorts();
foreach (const QSerialPortInfo &info, portList)
{
QString name = info.portName();
_commPortList += name;
}
}
#endif
return _commPortList;
}
QStringList LinkManager::serialBaudRates(void)
{
#ifdef __ios__
QStringList foo;
return foo;
#else
return SerialConfiguration::supportedBaudRates();
#endif
}
...@@ -78,10 +78,17 @@ public: ...@@ -78,10 +78,17 @@ public:
Q_PROPERTY(bool autoconnectPixhawk READ autoconnectPixhawk WRITE setAutoconnectPixhawk NOTIFY autoconnectPixhawkChanged) Q_PROPERTY(bool autoconnectPixhawk READ autoconnectPixhawk WRITE setAutoconnectPixhawk NOTIFY autoconnectPixhawkChanged)
Q_PROPERTY(bool autoconnect3DRRadio READ autoconnect3DRRadio WRITE setAutoconnect3DRRadio NOTIFY autoconnect3DRRadioChanged) Q_PROPERTY(bool autoconnect3DRRadio READ autoconnect3DRRadio WRITE setAutoconnect3DRRadio NOTIFY autoconnect3DRRadioChanged)
Q_PROPERTY(bool autoconnectPX4Flow READ autoconnectPX4Flow WRITE setAutoconnectPX4Flow NOTIFY autoconnectPX4FlowChanged) Q_PROPERTY(bool autoconnectPX4Flow READ autoconnectPX4Flow WRITE setAutoconnectPX4Flow NOTIFY autoconnectPX4FlowChanged)
//-- LinkInterface
Q_PROPERTY(QmlObjectListModel* links READ links CONSTANT) /// LinkInterface Accessor
//-- LinkConfiguration Q_PROPERTY(QmlObjectListModel* links READ links CONSTANT)
Q_PROPERTY(QmlObjectListModel* linkConfigurations READ linkConfigurations CONSTANT) /// LinkConfiguration Accessor
Q_PROPERTY(QmlObjectListModel* linkConfigurations READ linkConfigurations CONSTANT)
/// List of comm type strings
Q_PROPERTY(QStringList linkTypeStrings READ linkTypeStrings CONSTANT)
/// List of supported baud rates for serial links
Q_PROPERTY(QStringList serialBaudRates READ serialBaudRates CONSTANT)
/// List of comm ports
Q_PROPERTY(QStringList serialPortStrings READ serialPortStrings NOTIFY commPortStringsChanged)
// Property accessors // Property accessors
...@@ -92,14 +99,16 @@ public: ...@@ -92,14 +99,16 @@ public:
bool autoconnect3DRRadio(void) { return _autoconnect3DRRadio; } bool autoconnect3DRRadio(void) { return _autoconnect3DRRadio; }
bool autoconnectPX4Flow(void) { return _autoconnectPX4Flow; } bool autoconnectPX4Flow(void) { return _autoconnectPX4Flow; }
QmlObjectListModel* links(void) { return &_links; } QmlObjectListModel* links (void) { return &_links; }
QmlObjectListModel* linkConfigurations(void) { return &_linkConfigurations; } QmlObjectListModel* linkConfigurations (void) { return &_linkConfigurations; }
QStringList linkTypeStrings (void) const;
void setAutoconnectUDP(bool autoconnect); QStringList serialBaudRates (void);
void setAutoconnectPixhawk(bool autoconnect); QStringList serialPortStrings (void);
void setAutoconnect3DRRadio(bool autoconnect);
void setAutoconnectPX4Flow(bool autoconnect);
void setAutoconnectUDP (bool autoconnect);
void setAutoconnectPixhawk (bool autoconnect);
void setAutoconnect3DRRadio (bool autoconnect);
void setAutoconnectPX4Flow (bool autoconnect);
/// Load list of link configurations from disk /// Load list of link configurations from disk
void loadLinkConfigurationList(); void loadLinkConfigurationList();
...@@ -178,6 +187,7 @@ signals: ...@@ -178,6 +187,7 @@ signals:
void linkInactive(LinkInterface* link); void linkInactive(LinkInterface* link);
void linkConfigurationChanged(); void linkConfigurationChanged();
void commPortStringsChanged();
private slots: private slots:
void _linkConnected(void); void _linkConnected(void);
...@@ -207,6 +217,7 @@ private: ...@@ -207,6 +217,7 @@ private:
QmlObjectListModel _autoconnectConfigurations; QmlObjectListModel _autoconnectConfigurations;
QStringList _autoconnectWaitList; QStringList _autoconnectWaitList;
QStringList _commPortList;
bool _autoconnectUDP; bool _autoconnectUDP;
bool _autoconnectPixhawk; bool _autoconnectPixhawk;
......
...@@ -38,14 +38,14 @@ class LogReplayLinkConfiguration : public LinkConfiguration ...@@ -38,14 +38,14 @@ class LogReplayLinkConfiguration : public LinkConfiguration
public: public:
LogReplayLinkConfiguration(const QString& name); LogReplayLinkConfiguration(const QString& name);
LogReplayLinkConfiguration(LogReplayLinkConfiguration* copy); LogReplayLinkConfiguration(LogReplayLinkConfiguration* copy);
QString logFilename(void) { return _logFilename; } QString logFilename(void) { return _logFilename; }
void setLogFilename(const QString& logFilename) { _logFilename = logFilename; } void setLogFilename(const QString& logFilename) { _logFilename = logFilename; }
QString logFilenameShort(void); QString logFilenameShort(void);
// Virtuals from LinkConfiguration // Virtuals from LinkConfiguration
virtual int type() { return LinkConfiguration::TypeLogReplay; } virtual LinkType type() { return LinkConfiguration::TypeLogReplay; }
virtual void copyFrom(LinkConfiguration* source); virtual void copyFrom(LinkConfiguration* source);
virtual void loadSettings(QSettings& settings, const QString& root); virtual void loadSettings(QSettings& settings, const QString& root);
virtual void saveSettings(QSettings& settings, const QString& root); virtual void saveSettings(QSettings& settings, const QString& root);
...@@ -61,23 +61,23 @@ class LogReplayLink : public LinkInterface ...@@ -61,23 +61,23 @@ class LogReplayLink : public LinkInterface
Q_OBJECT Q_OBJECT
friend class LinkManager; friend class LinkManager;
public: public:
/// @return true: log is currently playing, false: log playback is paused /// @return true: log is currently playing, false: log playback is paused
bool isPlaying(void) { return _readTickTimer.isActive(); } bool isPlaying(void) { return _readTickTimer.isActive(); }
/// Start replay at current position /// Start replay at current position
void play(void) { emit _playOnThread(); } void play(void) { emit _playOnThread(); }
/// Pause replay /// Pause replay
void pause(void) { emit _pauseOnThread(); } void pause(void) { emit _pauseOnThread(); }
/// Move the playhead to the specified percent complete /// Move the playhead to the specified percent complete
void movePlayhead(int percentComplete); void movePlayhead(int percentComplete);
/// Sets the acceleration factor: -100: 0.01X, 0: 1.0X, 100: 100.0X /// Sets the acceleration factor: -100: 0.01X, 0: 1.0X, 100: 100.0X
void setAccelerationFactor(int factor) { emit _setAccelerationFactorOnThread(factor); } void setAccelerationFactor(int factor) { emit _setAccelerationFactorOnThread(factor); }
// Virtuals from LinkInterface // Virtuals from LinkInterface
virtual QString getName(void) const { return _config->name(); } virtual QString getName(void) const { return _config->name(); }
virtual void requestReset(void){ } virtual void requestReset(void){ }
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
public slots: public slots:
virtual void writeBytes(const char *bytes, qint64 cBytes); virtual void writeBytes(const char *bytes, qint64 cBytes);
signals: signals:
void logFileStats(bool logTimestamped, int logDurationSecs, int binaryBaudRate); void logFileStats(bool logTimestamped, int logDurationSecs, int binaryBaudRate);
void playbackStarted(void); void playbackStarted(void);
...@@ -101,7 +101,7 @@ signals: ...@@ -101,7 +101,7 @@ signals:
void playbackAtEnd(void); void playbackAtEnd(void);
void playbackError(void); void playbackError(void);
void playbackPercentCompleteChanged(int percentComplete); void playbackPercentCompleteChanged(int percentComplete);
// Internal signals // Internal signals
void _playOnThread(void); void _playOnThread(void);
void _pauseOnThread(void); void _pauseOnThread(void);
...@@ -110,7 +110,7 @@ signals: ...@@ -110,7 +110,7 @@ signals:
protected slots: protected slots:
// FIXME: This should not be part of LinkInterface. It is an internal link implementation detail. // FIXME: This should not be part of LinkInterface. It is an internal link implementation detail.
virtual void readBytes(void); virtual void readBytes(void);
private slots: private slots:
void _readNextLogEntry(void); void _readNextLogEntry(void);
void _play(void); void _play(void);
...@@ -121,7 +121,7 @@ private: ...@@ -121,7 +121,7 @@ private:
// Links are only created/destroyed by LinkManager so constructor/destructor is not public // Links are only created/destroyed by LinkManager so constructor/destructor is not public
LogReplayLink(LogReplayLinkConfiguration* config); LogReplayLink(LogReplayLinkConfiguration* config);
~LogReplayLink(); ~LogReplayLink();
void _replayError(const QString& errorMsg); void _replayError(const QString& errorMsg);
quint64 _parseTimestamp(const QByteArray& bytes); quint64 _parseTimestamp(const QByteArray& bytes);
quint64 _seekToNextMavlinkMessage(mavlink_message_t* nextMsg); quint64 _seekToNextMavlinkMessage(mavlink_message_t* nextMsg);
...@@ -129,37 +129,37 @@ private: ...@@ -129,37 +129,37 @@ private:
void _finishPlayback(void); void _finishPlayback(void);
void _playbackError(void); void _playbackError(void);
void _resetPlaybackToBeginning(void); void _resetPlaybackToBeginning(void);
// Virtuals from LinkInterface // Virtuals from LinkInterface
virtual bool _connect(void); virtual bool _connect(void);
virtual void _disconnect(void); virtual void _disconnect(void);
// Virtuals from QThread // Virtuals from QThread
virtual void run(void); virtual void run(void);
LogReplayLinkConfiguration* _config; LogReplayLinkConfiguration* _config;
bool _connected; bool _connected;
QTimer _readTickTimer; ///< Timer which signals a read of next log record QTimer _readTickTimer; ///< Timer which signals a read of next log record
static const char* _errorTitle; ///< Title for communicatorError signals static const char* _errorTitle; ///< Title for communicatorError signals
quint64 _logCurrentTimeUSecs; ///< The timestamp of the next message in the log file. quint64 _logCurrentTimeUSecs; ///< The timestamp of the next message in the log file.
quint64 _logStartTimeUSecs; ///< The first timestamp in the current log file. quint64 _logStartTimeUSecs; ///< The first timestamp in the current log file.
quint64 _logEndTimeUSecs; ///< The last timestamp in the current log file. quint64 _logEndTimeUSecs; ///< The last timestamp in the current log file.
quint64 _logDurationUSecs; quint64 _logDurationUSecs;
static const int _defaultBinaryBaudRate = 57600; static const int _defaultBinaryBaudRate = 57600;
int _binaryBaudRate; ///< Playback rate for binary log format int _binaryBaudRate; ///< Playback rate for binary log format
float _replayAccelerationFactor; ///< Factor to apply to playback rate float _replayAccelerationFactor; ///< Factor to apply to playback rate
quint64 _playbackStartTimeMSecs; ///< The time when the logfile was first played back. This is used to pace out replaying the messages to fix long-term drift/skew. 0 indicates that the player hasn't initiated playback of this log file. quint64 _playbackStartTimeMSecs; ///< The time when the logfile was first played back. This is used to pace out replaying the messages to fix long-term drift/skew. 0 indicates that the player hasn't initiated playback of this log file.
MAVLinkProtocol* _mavlink; MAVLinkProtocol* _mavlink;
QFile _logFile; QFile _logFile;
quint64 _logFileSize; quint64 _logFileSize;
bool _logTimestamped; ///< true: Timestamped log format, false: no timestamps bool _logTimestamped; ///< true: Timestamped log format, false: no timestamps
static const int cbTimestamp = sizeof(quint64); static const int cbTimestamp = sizeof(quint64);
}; };
......
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
bool sendStatusText(void) { return _sendStatusText; } bool sendStatusText(void) { return _sendStatusText; }
// Overrides from LinkConfiguration // Overrides from LinkConfiguration
int type(void) { return LinkConfiguration::TypeMock; } LinkType type(void) { return LinkConfiguration::TypeMock; }
void copyFrom(LinkConfiguration* source); void copyFrom(LinkConfiguration* source);
void loadSettings(QSettings& settings, const QString& root); void loadSettings(QSettings& settings, const QString& root);
void saveSettings(QSettings& settings, const QString& root); void saveSettings(QSettings& settings, const QString& root);
...@@ -92,10 +92,10 @@ public: ...@@ -92,10 +92,10 @@ public:
void setAPMMissionResponseMode(bool sendHomePositionOnEmptyList) { _apmSendHomePositionOnEmptyList = sendHomePositionOnEmptyList; } void setAPMMissionResponseMode(bool sendHomePositionOnEmptyList) { _apmSendHomePositionOnEmptyList = sendHomePositionOnEmptyList; }
void emitRemoteControlChannelRawChanged(int channel, uint16_t raw); void emitRemoteControlChannelRawChanged(int channel, uint16_t raw);
/// Sends the specified mavlink message to QGC /// Sends the specified mavlink message to QGC
void respondWithMavlinkMessage(const mavlink_message_t& msg); void respondWithMavlinkMessage(const mavlink_message_t& msg);
MockLinkFileServer* getFileServer(void) { return _fileServer; } MockLinkFileServer* getFileServer(void) { return _fileServer; }
// Virtuals from LinkInterface // Virtuals from LinkInterface
...@@ -111,21 +111,21 @@ public: ...@@ -111,21 +111,21 @@ public:
bool disconnect(void); bool disconnect(void);
LinkConfiguration* getLinkConfiguration() { return _config; } LinkConfiguration* getLinkConfiguration() { return _config; }
/// Sets a failure mode for unit testing /// Sets a failure mode for unit testing
/// @param failureMode Type of failure to simulate /// @param failureMode Type of failure to simulate
/// @param firstTimeOnly true: fail first call, success subsequent calls, false: fail all calls /// @param firstTimeOnly true: fail first call, success subsequent calls, false: fail all calls
void setMissionItemFailureMode(MockLinkMissionItemHandler::FailureMode_t failureMode, bool firstTimeOnly); void setMissionItemFailureMode(MockLinkMissionItemHandler::FailureMode_t failureMode, bool firstTimeOnly);
/// Called to send a MISSION_ACK message while the MissionManager is in idle state /// Called to send a MISSION_ACK message while the MissionManager is in idle state
void sendUnexpectedMissionAck(MAV_MISSION_RESULT ackType) { _missionItemHandler.sendUnexpectedMissionAck(ackType); } void sendUnexpectedMissionAck(MAV_MISSION_RESULT ackType) { _missionItemHandler.sendUnexpectedMissionAck(ackType); }
/// Called to send a MISSION_ITEM message while the MissionManager is in idle state /// Called to send a MISSION_ITEM message while the MissionManager is in idle state
void sendUnexpectedMissionItem(void) { _missionItemHandler.sendUnexpectedMissionItem(); } void sendUnexpectedMissionItem(void) { _missionItemHandler.sendUnexpectedMissionItem(); }
/// Called to send a MISSION_REQUEST message while the MissionManager is in idle state /// Called to send a MISSION_REQUEST message while the MissionManager is in idle state
void sendUnexpectedMissionRequest(void) { _missionItemHandler.sendUnexpectedMissionRequest(); } void sendUnexpectedMissionRequest(void) { _missionItemHandler.sendUnexpectedMissionRequest(); }
/// Reset the state of the MissionItemHandler to no items, no transactions in progress. /// Reset the state of the MissionItemHandler to no items, no transactions in progress.
void resetMissionItemHandler(void) { _missionItemHandler.reset(); } void resetMissionItemHandler(void) { _missionItemHandler.reset(); }
...@@ -193,7 +193,7 @@ private: ...@@ -193,7 +193,7 @@ private:
MockConfiguration* _config; MockConfiguration* _config;
MAV_AUTOPILOT _firmwareType; MAV_AUTOPILOT _firmwareType;
MAV_TYPE _vehicleType; MAV_TYPE _vehicleType;
MockLinkFileServer* _fileServer; MockLinkFileServer* _fileServer;
bool _sendStatusText; bool _sendStatusText;
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
QGC_LOGGING_CATEGORY(SerialLinkLog, "SerialLinkLog") QGC_LOGGING_CATEGORY(SerialLinkLog, "SerialLinkLog")
static QStringList kSupportedBaudRates;
SerialLink::SerialLink(SerialConfiguration* config) SerialLink::SerialLink(SerialConfiguration* config)
{ {
_bytesRead = 0; _bytesRead = 0;
...@@ -110,7 +112,7 @@ void SerialLink::readBytes() ...@@ -110,7 +112,7 @@ void SerialLink::readBytes()
if(maxLength < numBytes) numBytes = maxLength; if(maxLength < numBytes) numBytes = maxLength;
_logInputDataRate(numBytes, QDateTime::currentMSecsSinceEpoch()); _logInputDataRate(numBytes, QDateTime::currentMSecsSinceEpoch());
_port->read(data, numBytes); _port->read(data, numBytes);
QByteArray b(data, numBytes); QByteArray b(data, numBytes);
emit bytesReceived(this, b); emit bytesReceived(this, b);
...@@ -131,7 +133,7 @@ void SerialLink::_disconnect(void) ...@@ -131,7 +133,7 @@ void SerialLink::_disconnect(void)
delete _port; delete _port;
_port = NULL; _port = NULL;
} }
#ifdef __android__ #ifdef __android__
qgcApp()->toolbox()->linkManager()->suspendConfigurationUpdates(false); qgcApp()->toolbox()->linkManager()->suspendConfigurationUpdates(false);
#endif #endif
...@@ -147,11 +149,11 @@ bool SerialLink::_connect(void) ...@@ -147,11 +149,11 @@ bool SerialLink::_connect(void)
qCDebug(SerialLinkLog) << "CONNECT CALLED"; qCDebug(SerialLinkLog) << "CONNECT CALLED";
_disconnect(); _disconnect();
#ifdef __android__ #ifdef __android__
qgcApp()->toolbox()->linkManager()->suspendConfigurationUpdates(true); qgcApp()->toolbox()->linkManager()->suspendConfigurationUpdates(true);
#endif #endif
// Initialize the connection // Initialize the connection
if (!_hardwareConnect(_type)) { if (!_hardwareConnect(_type)) {
// Need to error out here. // Need to error out here.
...@@ -291,7 +293,7 @@ bool SerialLink::isConnected() const ...@@ -291,7 +293,7 @@ bool SerialLink::isConnected() const
if (_port) { if (_port) {
isConnected = _port->isOpen(); isConnected = _port->isOpen();
} }
return isConnected; return isConnected;
} }
...@@ -481,3 +483,60 @@ void SerialConfiguration::loadSettings(QSettings& settings, const QString& root) ...@@ -481,3 +483,60 @@ void SerialConfiguration::loadSettings(QSettings& settings, const QString& root)
if(settings.contains("portName")) _portName = settings.value("portName").toString(); if(settings.contains("portName")) _portName = settings.value("portName").toString();
settings.endGroup(); settings.endGroup();
} }
QStringList SerialConfiguration::supportedBaudRates()
{
if(!kSupportedBaudRates.size())
_initBaudRates();
return kSupportedBaudRates;
}
void SerialConfiguration::_initBaudRates()
{
kSupportedBaudRates.clear();
#if USE_ANCIENT_RATES
#if defined(Q_OS_UNIX) || defined(Q_OS_LINUX) || defined(Q_OS_DARWIN)
kSupportedBaudRates << "50";
kSupportedBaudRates << "75";
#endif
kSupportedBaudRates << "110";
#if defined(Q_OS_UNIX) || defined(Q_OS_LINUX) || defined(Q_OS_DARWIN)
kSupportedBaudRates << "134";
kSupportedBaudRates << "150";
kSupportedBaudRates << "200";
#endif
kSupportedBaudRates << "300";
kSupportedBaudRates << "600";
kSupportedBaudRates << "1200";
#if defined(Q_OS_UNIX) || defined(Q_OS_LINUX) || defined(Q_OS_DARWIN)
kSupportedBaudRates << "1800";
#endif
#endif
kSupportedBaudRates << "2400";
kSupportedBaudRates << "4800";
kSupportedBaudRates << "9600";
#if defined(Q_OS_WIN)
kSupportedBaudRates << "14400";
#endif
kSupportedBaudRates << "19200";
kSupportedBaudRates << "38400";
#if defined(Q_OS_WIN)
kSupportedBaudRates << "56000";
#endif
kSupportedBaudRates << "57600";
kSupportedBaudRates << "115200";
#if defined(Q_OS_WIN)
kSupportedBaudRates << "128000";
#endif
kSupportedBaudRates << "230400";
#if defined(Q_OS_WIN)
kSupportedBaudRates << "256000";
#endif
kSupportedBaudRates << "460800";
#if defined(Q_OS_LINUX)
kSupportedBaudRates << "500000";
kSupportedBaudRates << "576000";
#endif
kSupportedBaudRates << "921600";
}
...@@ -81,13 +81,18 @@ public: ...@@ -81,13 +81,18 @@ public:
void setParity (int parity); ///< QSerialPort Enums void setParity (int parity); ///< QSerialPort Enums
void setPortName (const QString& portName); void setPortName (const QString& portName);
static QStringList supportedBaudRates();
/// From LinkConfiguration /// From LinkConfiguration
int type() { return LinkConfiguration::TypeSerial; } LinkType type() { return LinkConfiguration::TypeSerial; }
void copyFrom(LinkConfiguration* source); void copyFrom(LinkConfiguration* source);
void loadSettings(QSettings& settings, const QString& root); void loadSettings(QSettings& settings, const QString& root);
void saveSettings(QSettings& settings, const QString& root); void saveSettings(QSettings& settings, const QString& root);
void updateSettings(); void updateSettings();
private:
static void _initBaudRates();
private: private:
int _baud; int _baud;
int _dataBits; int _dataBits;
...@@ -109,10 +114,10 @@ private: ...@@ -109,10 +114,10 @@ private:
class SerialLink : public LinkInterface class SerialLink : public LinkInterface
{ {
Q_OBJECT Q_OBJECT
friend class SerialConfiguration; friend class SerialConfiguration;
friend class LinkManager; friend class LinkManager;
public: public:
// LinkInterface // LinkInterface
...@@ -156,7 +161,7 @@ private: ...@@ -156,7 +161,7 @@ private:
// Links are only created/destroyed by LinkManager so constructor/destructor is not public // Links are only created/destroyed by LinkManager so constructor/destructor is not public
SerialLink(SerialConfiguration* config); SerialLink(SerialConfiguration* config);
~SerialLink(); ~SerialLink();
// From LinkInterface // From LinkInterface
virtual bool _connect(void); virtual bool _connect(void);
virtual void _disconnect(void); virtual void _disconnect(void);
......
/*===================================================================== /*=====================================================================
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful, QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>. along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/ ======================================================================*/
/// @file /// @file
...@@ -103,7 +103,7 @@ public: ...@@ -103,7 +103,7 @@ public:
void setAddress (const QHostAddress& address); void setAddress (const QHostAddress& address);
/// From LinkConfiguration /// From LinkConfiguration
int type() { return LinkConfiguration::TypeTcp; } LinkType type() { return LinkConfiguration::TypeTcp; }
void copyFrom(LinkConfiguration* source); void copyFrom(LinkConfiguration* source);
void loadSettings(QSettings& settings, const QString& root); void loadSettings(QSettings& settings, const QString& root);
void saveSettings(QSettings& settings, const QString& root); void saveSettings(QSettings& settings, const QString& root);
...@@ -117,14 +117,14 @@ private: ...@@ -117,14 +117,14 @@ private:
class TCPLink : public LinkInterface class TCPLink : public LinkInterface
{ {
Q_OBJECT Q_OBJECT
friend class TCPLinkUnitTest; friend class TCPLinkUnitTest;
friend class TCPConfiguration; friend class TCPConfiguration;
friend class LinkManager; friend class LinkManager;
public: public:
QTcpSocket* getSocket(void) { return _socket; } QTcpSocket* getSocket(void) { return _socket; }
void signalBytesWritten(void); void signalBytesWritten(void);
// LinkInterface methods // LinkInterface methods
...@@ -136,14 +136,14 @@ public: ...@@ -136,14 +136,14 @@ public:
qint64 getConnectionSpeed() const; qint64 getConnectionSpeed() const;
qint64 getCurrentInDataRate() const; qint64 getCurrentInDataRate() const;
qint64 getCurrentOutDataRate() const; qint64 getCurrentOutDataRate() const;
// These are left unimplemented in order to cause linker errors which indicate incorrect usage of // These are left unimplemented in order to cause linker errors which indicate incorrect usage of
// connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager. // connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager.
bool connect(void); bool connect(void);
bool disconnect(void); bool disconnect(void);
public slots: public slots:
// From LinkInterface // From LinkInterface
void writeBytes(const char* data, qint64 length); void writeBytes(const char* data, qint64 length);
void waitForBytesWritten(int msecs); void waitForBytesWritten(int msecs);
...@@ -158,12 +158,12 @@ protected slots: ...@@ -158,12 +158,12 @@ protected slots:
protected: protected:
// From LinkInterface->QThread // From LinkInterface->QThread
virtual void run(void); virtual void run(void);
private: private:
// Links are only created/destroyed by LinkManager so constructor/destructor is not public // Links are only created/destroyed by LinkManager so constructor/destructor is not public
TCPLink(TCPConfiguration* config); TCPLink(TCPConfiguration* config);
~TCPLink(); ~TCPLink();
// From LinkInterface // From LinkInterface
virtual bool _connect(void); virtual bool _connect(void);
virtual void _disconnect(void); virtual void _disconnect(void);
...@@ -178,7 +178,7 @@ private: ...@@ -178,7 +178,7 @@ private:
TCPConfiguration* _config; TCPConfiguration* _config;
QTcpSocket* _socket; QTcpSocket* _socket;
bool _socketIsConnected; bool _socketIsConnected;
quint64 _bitsSentTotal; quint64 _bitsSentTotal;
quint64 _bitsSentCurrent; quint64 _bitsSentCurrent;
quint64 _bitsSentMax; quint64 _bitsSentMax;
......
...@@ -136,7 +136,7 @@ public: ...@@ -136,7 +136,7 @@ public:
void setLocalPort (quint16 port); void setLocalPort (quint16 port);
/// From LinkConfiguration /// From LinkConfiguration
int type() { return LinkConfiguration::TypeUdp; } LinkType type() { return LinkConfiguration::TypeUdp; }
void copyFrom(LinkConfiguration* source); void copyFrom(LinkConfiguration* source);
void loadSettings(QSettings& settings, const QString& root); void loadSettings(QSettings& settings, const QString& root);
void saveSettings(QSettings& settings, const QString& root); void saveSettings(QSettings& settings, const QString& root);
...@@ -152,10 +152,10 @@ private: ...@@ -152,10 +152,10 @@ private:
class UDPLink : public LinkInterface class UDPLink : public LinkInterface
{ {
Q_OBJECT Q_OBJECT
friend class UDPConfiguration; friend class UDPConfiguration;
friend class LinkManager; friend class LinkManager;
public: public:
void requestReset() { } void requestReset() { }
bool isConnected() const; bool isConnected() const;
...@@ -202,7 +202,7 @@ private: ...@@ -202,7 +202,7 @@ private:
// Links are only created/destroyed by LinkManager so constructor/destructor is not public // Links are only created/destroyed by LinkManager so constructor/destructor is not public
UDPLink(UDPConfiguration* config); UDPLink(UDPConfiguration* config);
~UDPLink(); ~UDPLink();
// From LinkInterface // From LinkInterface
virtual bool _connect(void); virtual bool _connect(void);
virtual void _disconnect(void); virtual void _disconnect(void);
......
...@@ -178,6 +178,9 @@ void QGCLinkConfiguration::_fixUnnamed(LinkConfiguration* config) ...@@ -178,6 +178,9 @@ void QGCLinkConfiguration::_fixUnnamed(LinkConfiguration* config)
QString("Mock Link")); QString("Mock Link"));
break; break;
#endif #endif
case LinkConfiguration::TypeLast:
default:
break;
} }
} }
} }
......
...@@ -63,57 +63,11 @@ SerialConfigurationWindow::SerialConfigurationWindow(SerialConfiguration *config ...@@ -63,57 +63,11 @@ SerialConfigurationWindow::SerialConfigurationWindow(SerialConfiguration *config
// Keep track of all desired baud rates by OS. These are iterated through // Keep track of all desired baud rates by OS. These are iterated through
// later and added to _ui.baudRate. // later and added to _ui.baudRate.
QList<int> supportedBaudRates; QStringList supportedBaudRates = SerialConfiguration::supportedBaudRates();
#if USE_ANCIENT_RATES
// Baud rates supported only by POSIX systems
#if defined(Q_OS_UNIX) || defined(Q_OS_LINUX) || defined(Q_OS_DARWIN)
supportedBaudRates << 50;
supportedBaudRates << 75;
supportedBaudRates << 134;
supportedBaudRates << 150;
supportedBaudRates << 200;
supportedBaudRates << 1800;
#endif
#endif //USE_ANCIENT_RATES
// Baud rates supported only by Windows
#if defined(Q_OS_WIN)
supportedBaudRates << 14400;
supportedBaudRates << 56000;
supportedBaudRates << 128000;
supportedBaudRates << 256000;
#endif
// Baud rates supported by everyone
#if USE_ANCIENT_RATES
supportedBaudRates << 110;
supportedBaudRates << 300;
supportedBaudRates << 600;
supportedBaudRates << 1200;
#endif //USE_ANCIENT_RATES
supportedBaudRates << 2400;
supportedBaudRates << 4800;
supportedBaudRates << 9600;
supportedBaudRates << 19200;
supportedBaudRates << 38400;
supportedBaudRates << 57600;
supportedBaudRates << 115200;
supportedBaudRates << 230400;
supportedBaudRates << 460800;
#if defined(Q_OS_LINUX)
// Baud rates supported only by Linux
supportedBaudRates << 500000;
supportedBaudRates << 576000;
#endif
supportedBaudRates << 921600;
// Now actually add all of our supported baud rates to the ui. // Now actually add all of our supported baud rates to the ui.
qSort(supportedBaudRates.begin(), supportedBaudRates.end());
for (int i = 0; i < supportedBaudRates.size(); ++i) { for (int i = 0; i < supportedBaudRates.size(); ++i) {
_ui.baudRate->addItem(QString::number(supportedBaudRates.at(i)), supportedBaudRates.at(i)); _ui.baudRate->addItem(supportedBaudRates.at(i), supportedBaudRates.at(i).toInt());
} }
// Connect the individual user interface inputs // Connect the individual user interface inputs
......
...@@ -34,8 +34,10 @@ import QGroundControl.MultiVehicleManager 1.0 ...@@ -34,8 +34,10 @@ import QGroundControl.MultiVehicleManager 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
Rectangle { Rectangle {
id: _generalRoot id: _generalRoot
color: __qgcPal.window color: __qgcPal.window
anchors.fill: parent
anchors.margins: ScreenTools.defaultFontPixelWidth
QGCPalette { QGCPalette {
id: qgcPal id: qgcPal
...@@ -45,7 +47,6 @@ Rectangle { ...@@ -45,7 +47,6 @@ Rectangle {
Flickable { Flickable {
clip: true clip: true
anchors.fill: parent anchors.fill: parent
anchors.margins: ScreenTools.defaultFontPixelWidth
contentHeight: settingsColumn.height contentHeight: settingsColumn.height
contentWidth: _generalRoot.width contentWidth: _generalRoot.width
flickableDirection: Flickable.VerticalFlick flickableDirection: Flickable.VerticalFlick
...@@ -56,12 +57,15 @@ Rectangle { ...@@ -56,12 +57,15 @@ Rectangle {
width: _generalRoot.width width: _generalRoot.width
anchors.margins: ScreenTools.defaultFontPixelWidth anchors.margins: ScreenTools.defaultFontPixelWidth
spacing: ScreenTools.defaultFontPixelHeight / 2 spacing: ScreenTools.defaultFontPixelHeight / 2
QGCLabel { QGCLabel {
text: "General Settings" text: "General Settings"
font.pixelSize: ScreenTools.mediumFontPixelSize font.pixelSize: ScreenTools.mediumFontPixelSize
} }
Rectangle {
height: 1
width: parent.width
color: qgcPal.button
}
Item { Item {
height: ScreenTools.defaultFontPixelHeight / 2 height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width width: parent.width
......
This diff is collapsed.
...@@ -34,8 +34,9 @@ import QGroundControl.MultiVehicleManager 1.0 ...@@ -34,8 +34,9 @@ import QGroundControl.MultiVehicleManager 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
Rectangle { Rectangle {
id: __mavlinkRoot id: __mavlinkRoot
color: __qgcPal.window color: __qgcPal.window
anchors.fill: parent
QGCPalette { QGCPalette {
id: qgcPal id: qgcPal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment