diff --git a/flight/PiOS/STM32F10x/pios_sys.c b/flight/PiOS/STM32F10x/pios_sys.c index 26e748171..cc35194e7 100644 --- a/flight/PiOS/STM32F10x/pios_sys.c +++ b/flight/PiOS/STM32F10x/pios_sys.c @@ -186,7 +186,7 @@ int32_t PIOS_SYS_SerialNumberGet(char *str) void NVIC_Configuration(void) { /* Set the Vector Table base address as specified in .ld file */ - extern void pios_isr_vector_table_base; + extern void *pios_isr_vector_table_base; NVIC_SetVectorTable((uint32_t)&pios_isr_vector_table_base, 0x0); /* 4 bits for Interrupt priorities so no sub priorities */ diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp index 2fb7778e7..07f0ef0c9 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp @@ -36,15 +36,13 @@ #include "fancytabwidget.h" #include "fancyactionbar.h" -#include "mainwindow.h" #include "qextserialport/src/qextserialenumerator.h" #include "qextserialport/src/qextserialport.h" - #include #include #include #include - +#include namespace Core { @@ -52,9 +50,9 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, Internal: QWidget(mainWindow), // Pip m_availableDevList(0), m_connectBtn(0), - m_ioDev(NULL) + m_ioDev(NULL),m_mainWindow(mainWindow) { - Q_UNUSED(mainWindow); + // Q_UNUSED(mainWindow); QVBoxLayout *top = new QVBoxLayout; top->setSpacing(0); @@ -344,7 +342,7 @@ void ConnectionManager::devChanged(IConnection *connection) //and add them back in the list QList availableDev = connection->availableDevices(); - foreach (IConnection::device dev, availableDev) + foreach (IConnection::device dev, availableDev) { QString cbName = connection->shortName() + ": " + dev.name; QString disp = connection->shortName() + " : " + dev.displayName; @@ -352,11 +350,27 @@ void ConnectionManager::devChanged(IConnection *connection) } //add all the list again to the combobox - foreach (devListItem d, m_devList) + foreach (devListItem d, m_devList) { m_availableDevList->addItem(d.displayName); m_availableDevList->setItemData(m_availableDevList->count()-1,(const QString)d.devName,Qt::ToolTipRole); + if(!m_ioDev && d.displayName.startsWith("USB")) + { + if(m_mainWindow->generalSettings()->autoConnect() || m_mainWindow->generalSettings()->autoSelect()) + m_availableDevList->setCurrentIndex(m_availableDevList->count()-1); + if(m_mainWindow->generalSettings()->autoConnect()) + connectDevice(); + } } + if(m_ioDev)//if a device is connected make it the one selected on the dropbox + { + for(int x=0;xcount();++x) + { + if(m_connectionDevice.devName==m_availableDevList->itemData(x,Qt::ToolTipRole).toString()) + m_availableDevList->setCurrentIndex(x); + } + } + //disable connection button if the liNameif (m_availableDevList->count() > 0) if (m_availableDevList->count() > 0) diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h index 20da52ed4..085111700 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h @@ -30,7 +30,8 @@ #define CONNECTIONMANAGER_H #include - +#include "mainwindow.h" +#include "generalsettings.h" #include #include #include @@ -108,6 +109,7 @@ protected: private: bool connectDevice(); + Internal::MainWindow *m_mainWindow; }; diff --git a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp index d1f047c15..e3e2602e8 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.cpp @@ -45,7 +45,8 @@ using namespace Core::Internal; GeneralSettings::GeneralSettings(): m_dialog(0), - m_saveSettingsOnExit(true) + m_saveSettingsOnExit(true), + m_autoConnect(true),m_autoSelect(true) { } @@ -113,8 +114,10 @@ QWidget *GeneralSettings::createPage(QWidget *parent) m_page->setupUi(w); fillLanguageBox(); + connect(m_page->checkAutoConnect,SIGNAL(stateChanged(int)),this,SLOT(slotAutoConnect(int))); m_page->checkBoxSaveOnExit->setChecked(m_saveSettingsOnExit); - + m_page->checkAutoConnect->setChecked(m_autoConnect); + m_page->checkAutoSelect->setChecked(m_autoSelect); m_page->colorButton->setColor(StyleHelper::baseColor()); #ifdef Q_OS_UNIX m_page->terminalEdit->setText(ConsoleProcess::terminalEmulator(Core::ICore::instance()->settings())); @@ -146,6 +149,8 @@ void GeneralSettings::apply() StyleHelper::setBaseColor(m_page->colorButton->color()); m_saveSettingsOnExit = m_page->checkBoxSaveOnExit->isChecked(); + m_autoConnect = m_page->checkAutoConnect->isChecked(); + m_autoSelect = m_page->checkAutoSelect->isChecked(); #ifdef Q_OS_UNIX ConsoleProcess::setTerminalEmulator(Core::ICore::instance()->settings(), m_page->terminalEdit->text()); @@ -163,6 +168,8 @@ void GeneralSettings::readSettings(QSettings* qs) qs->beginGroup(QLatin1String("General")); m_language = qs->value(QLatin1String("OverrideLanguage"),QLocale::system().name()).toString(); m_saveSettingsOnExit = qs->value(QLatin1String("SaveSettingsOnExit"),m_saveSettingsOnExit).toBool(); + m_autoConnect = qs->value(QLatin1String("AutoConnect"),m_autoConnect).toBool(); + m_autoSelect = qs->value(QLatin1String("AutoSelect"),m_autoSelect).toBool(); qs->endGroup(); } @@ -177,6 +184,8 @@ void GeneralSettings::saveSettings(QSettings* qs) qs->setValue(QLatin1String("OverrideLanguage"), m_language); qs->setValue(QLatin1String("SaveSettingsOnExit"), m_saveSettingsOnExit); + qs->setValue(QLatin1String("AutoConnect"), m_autoConnect); + qs->setValue(QLatin1String("AutoSelect"), m_autoSelect); qs->endGroup(); } @@ -241,3 +250,21 @@ bool GeneralSettings::saveSettingsOnExit() const { return m_saveSettingsOnExit; } + +bool GeneralSettings::autoConnect() const +{ + return m_autoConnect; +} + +bool GeneralSettings::autoSelect() const +{ + return m_autoSelect; +} + +void GeneralSettings::slotAutoConnect(int value) +{ + if (value==Qt::Checked) + m_page->checkAutoSelect->setEnabled(false); + else + m_page->checkAutoSelect->setEnabled(true); +} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h index 816deb8db..ad4790578 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.h @@ -56,6 +56,8 @@ public: void apply(); void finish(); bool saveSettingsOnExit() const; + bool autoConnect() const; + bool autoSelect() const; void readSettings(QSettings* qs); void saveSettings(QSettings* qs); @@ -64,6 +66,7 @@ private slots: void resetLanguage(); void resetExternalEditor(); void showHelpForExternalEditor(); + void slotAutoConnect(int); #ifdef Q_OS_UNIX void resetTerminal(); #endif @@ -75,6 +78,8 @@ private: Ui::GeneralSettings *m_page; QString m_language; bool m_saveSettingsOnExit; + bool m_autoConnect; + bool m_autoSelect; QPointer m_dialog; QList m_codecs; diff --git a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui index 3f009f4aa..752ba2bfb 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui +++ b/ground/openpilotgcs/src/plugins/coreplugin/generalsettings.ui @@ -241,6 +241,49 @@ + + + + Automatically connect an OpenPilot USB device + + + true + + + + + + + + + + true + + + + + + + Automatically select an OpenPilot USB device + + + true + + + + + + + false + + + + + + true + + + diff --git a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp index 19df8dde2..5926e6c98 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp @@ -874,6 +874,11 @@ MimeDatabase *MainWindow::mimeDatabase() const return m_mimeDatabase; } +GeneralSettings * MainWindow::generalSettings() const +{ + return m_generalSettings; +} + IContext *MainWindow::contextObject(QWidget *widget) { return m_contextWidgets.value(widget); diff --git a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.h b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.h index a7ce53419..585d4604a 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.h @@ -111,7 +111,7 @@ public: Core::ThreadManager *threadManager() const; Core::ModeManager *modeManager() const; Core::MimeDatabase *mimeDatabase() const; - + Internal::GeneralSettings *generalSettings() const; QSettings *settings(QSettings::Scope scope) const; inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; } IContext * currentContextObject() const; diff --git a/ground/openpilotgcs/src/plugins/rawhid/usbmonitor_win.cpp b/ground/openpilotgcs/src/plugins/rawhid/usbmonitor_win.cpp index 6681b8363..4eded8e7c 100644 --- a/ground/openpilotgcs/src/plugins/rawhid/usbmonitor_win.cpp +++ b/ground/openpilotgcs/src/plugins/rawhid/usbmonitor_win.cpp @@ -177,6 +177,7 @@ bool USBMonitor::matchAndDispatchChangedDevice(const QString & deviceID, const G info.devicePath=deviceID; if( wParam == DBT_DEVICEARRIVAL ) { + qDebug()<<"INSERTION"; if(infoFromHandle(guid,info,devInfo,i)==0) break; knowndevices.append(info); @@ -186,19 +187,19 @@ bool USBMonitor::matchAndDispatchChangedDevice(const QString & deviceID, const G } else if( wParam == DBT_DEVICEREMOVECOMPLETE ) { + bool found=false; for(int x=0;x +#include /** * Constructor @@ -224,7 +225,7 @@ UAVObjectField* UAVObject::getField(const QString& name) } } // If this point is reached then the field was not found - Q_ASSERT_X(0,"UAVObject::getField",QString("Non existant field " + name + " requested. This indicates a bug. Make sure you also have null checking for non-debug code.").toAscii()); + qWarning()<<"UAVObject::getField Non existant field "<