From 5046f77cd909e952bdce99b56f792aec18dd093e Mon Sep 17 00:00:00 2001 From: bsongis Date: Wed, 17 Dec 2014 18:32:15 +0100 Subject: [PATCH] Refactoring fixes --- companion/src/modeledit/setup.cpp | 6 +- companion/src/mountlist.h | 4 +- companion/src/process_flash.cpp | 8 +-- companion/src/process_flash.h | 5 ++ companion/src/radiointerface.cpp | 98 +++++++++++++++---------------- 5 files changed, 61 insertions(+), 60 deletions(-) diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 4353cda3d..c9296de3f 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -715,6 +715,8 @@ void SetupPanel::updateStartupSwitches() unsigned int switchStates = model->switchWarningStates; for (int i=0; igetCapability(Switches); i++) { + if (!IS_TARANIS(firmware->getBoard()) && i==firmware->getCapability(Switches)-1) + continue; QSlider * slider = startupSwitchesSliders[i]; QCheckBox * cb = startupSwitchesCheckboxes[i]; bool enabled = !(model->switchWarningEnable & (1 << i)); @@ -725,10 +727,6 @@ void SetupPanel::updateStartupSwitches() switchStates >>= 2; } else { - if (i == firmware->getCapability(Switches)-1) { - // Trainer switch, no switch warning - continue; - } slider->setValue(i==0 ? switchStates & 0x3 : switchStates & 0x1); switchStates >>= (i==0 ? 2 : 1); } diff --git a/companion/src/mountlist.h b/companion/src/mountlist.h index f480c3ed7..8d8c3cbf4 100644 --- a/companion/src/mountlist.h +++ b/companion/src/mountlist.h @@ -28,9 +28,7 @@ #ifndef MOUNTLIST_H_ # define MOUNTLIST_H_ -#if defined WIN32 || !defined __GNUC__ - #define bool char -#else +#if defined __GNUC__ # include #endif diff --git a/companion/src/process_flash.cpp b/companion/src/process_flash.cpp index efa3f5eb6..44671ee82 100755 --- a/companion/src/process_flash.cpp +++ b/companion/src/process_flash.cpp @@ -74,7 +74,7 @@ void FlashProcess::onStarted() } # if !__GNUC__ -bool KillProcessByName(const char *szProcessToKill) +bool killProcessByName(const char *szProcessToKill) { HANDLE hProcessSnap; HANDLE hProcess; @@ -107,13 +107,13 @@ bool KillProcessByName(const char *szProcessToKill) } #endif -# if !__GNUC__ void FlashProcess::onKillTimerElapsed() { +# if !__GNUC__ // trick to accelerate SAM-BA startup - KillProcessByName("tasklist.exe"); -} + killProcessByName("tasklist.exe"); #endif +} void FlashProcess::analyseStandardOutput(const QString &text) { diff --git a/companion/src/process_flash.h b/companion/src/process_flash.h index 0ff7bd988..39f12f86e 100755 --- a/companion/src/process_flash.h +++ b/companion/src/process_flash.h @@ -7,6 +7,7 @@ class ProgressWidget; class QProcess; +class QTimer; class FlashProcess : public QObject { @@ -25,6 +26,7 @@ protected slots: void onReadyReadStandardOutput(); void onReadyReadStandardError(); void onFinished(int); + void onKillTimerElapsed(); protected: void analyseStandardOutput(const QString &text); @@ -43,6 +45,9 @@ protected: unsigned int efuse; enum FlashPhase { READING, WRITING, VERIFYING }; FlashPhase flashPhase; +#if !__GNUC__ + QTimer *killTimer; +#endif }; #endif // FLASHPROCESS_H_ diff --git a/companion/src/radiointerface.cpp b/companion/src/radiointerface.cpp index 3276105a7..ddc3840a2 100755 --- a/companion/src/radiointerface.cpp +++ b/companion/src/radiointerface.cpp @@ -30,55 +30,6 @@ QString getRadioInterfaceCmd() } } -QString findMassstoragePath(const QString &filename) -{ - QString temppath; - QStringList drives; - QString eepromfile; - QString fsname; -#if defined WIN32 || !defined __GNUC__ - foreach( QFileInfo drive, QDir::drives() ) { - WCHAR szVolumeName[256] ; - WCHAR szFileSystemName[256]; - DWORD dwSerialNumber = 0; - DWORD dwMaxFileNameLength=256; - DWORD dwFileSystemFlags=0; - bool ret = GetVolumeInformationW( (WCHAR *) drive.absolutePath().utf16(),szVolumeName,256,&dwSerialNumber,&dwMaxFileNameLength,&dwFileSystemFlags,szFileSystemName,256); - if (ret) { - QString vName = QString::fromUtf16 ( (const ushort *) szVolumeName) ; - temppath = drive.absolutePath(); - eepromfile = temppath; - eepromfile.append("/" + filename); - if (QFile::exists(eepromfile)) { - return eepromfile; - } - } - } -#else - struct mount_entry *entry; - entry = read_file_system_list(true); - while (entry != NULL) { - if (!drives.contains(entry->me_devname)) { - drives.append(entry->me_devname); - temppath = entry->me_mountdir; - eepromfile = temppath; - eepromfile.append("/" + filename); -#if !defined __APPLE__ - QString fstype = entry->me_type; - if (QFile::exists(eepromfile) && fstype.contains("fat") ) { -#else - if (QFile::exists(eepromfile)) { -#endif - return eepromfile; - } - } - entry = entry->me_next; - } -#endif - - return QString(); -} - QStringList getAvrdudeArgs(const QString &cmd, const QString &filename) { QStringList args; @@ -407,3 +358,52 @@ bool writeEeprom(const QString &filename, ProgressWidget *progress) return false; } + +QString findMassstoragePath(const QString &filename) +{ + QString temppath; + QStringList drives; + QString eepromfile; + QString fsname; +#if defined WIN32 || !defined __GNUC__ + foreach(QFileInfo drive, QDir::drives()) { + WCHAR szVolumeName[256] ; + WCHAR szFileSystemName[256]; + DWORD dwSerialNumber = 0; + DWORD dwMaxFileNameLength=256; + DWORD dwFileSystemFlags=0; + bool ret = GetVolumeInformationW( (WCHAR *) drive.absolutePath().utf16(),szVolumeName,256,&dwSerialNumber,&dwMaxFileNameLength,&dwFileSystemFlags,szFileSystemName,256); + if (ret) { + QString vName = QString::fromUtf16 ( (const ushort *) szVolumeName) ; + temppath = drive.absolutePath(); + eepromfile = temppath; + eepromfile.append("/" + filename); + if (QFile::exists(eepromfile)) { + return eepromfile; + } + } + } +#else + struct mount_entry *entry; + entry = read_file_system_list(true); + while (entry != NULL) { + if (!drives.contains(entry->me_devname)) { + drives.append(entry->me_devname); + temppath = entry->me_mountdir; + eepromfile = temppath; + eepromfile.append("/" + filename); +#if !defined __APPLE__ + QString fstype = entry->me_type; + if (QFile::exists(eepromfile) && fstype.contains("fat") ) { +#else + if (QFile::exists(eepromfile)) { +#endif + return eepromfile; + } + } + entry = entry->me_next; + } +#endif + + return QString(); +}