Re #4224: Enable reading and writing Models and Settings from/to Horu… (#4254)

* Re #4224: Enable reading and writing Models and Settings from/to Horus radio (SD card)

* Fix for findMassstoragePath() on Windows (which got there in previous commit)
This commit is contained in:
Damjan Adamic
2017-01-19 21:26:18 +01:00
committed by Bertrand Songis
parent 3c62cbf200
commit e59a51e25f
5 changed files with 46 additions and 15 deletions
+14 -4
View File
@@ -740,13 +740,23 @@ void MainWindow::loadBackup()
void MainWindow::readEeprom() void MainWindow::readEeprom()
{ {
if (getCurrentBoard()== BOARD_HORUS) { BoardEnum board = getCurrentBoard();
qDebug() << "TODO readEEPROM HORUS"; if (board == BOARD_HORUS) {
QString radioPath = findMassstoragePath("RADIO", true);
qDebug() << "Searching for SD card, found" << radioPath;
if (radioPath.isEmpty()) {
qDebug() << "MainWindow::readEeprom(): Horus radio not found";
QMessageBox::critical(this, tr("Error"), tr("Unable to find Horus radio SD card!"));
return;
}
MdiChild *child = createMdiChild();
if (child->loadFile(radioPath)) {
statusBar()->showMessage(tr("Models and Settings read"), 2000);
child->show();
}
} }
else { else {
QString tempFile; QString tempFile;
BoardEnum board = getCurrentBoard();
if (IS_ARM(board)) if (IS_ARM(board))
tempFile = generateProcessUniqueTempFileName("temp.bin"); tempFile = generateProcessUniqueTempFileName("temp.bin");
else else
+27 -7
View File
@@ -31,6 +31,7 @@
#include "wizarddialog.h" #include "wizarddialog.h"
#include "flashfirmwaredialog.h" #include "flashfirmwaredialog.h"
#include "storage.h" #include "storage.h"
#include "radiointerface.h"
#if defined _MSC_VER || !defined __GNUC__ #if defined _MSC_VER || !defined __GNUC__
#include <windows.h> #include <windows.h>
@@ -41,6 +42,7 @@
MdiChild::MdiChild(MainWindow * parent): MdiChild::MdiChild(MainWindow * parent):
QWidget(), QWidget(),
parent(parent),
ui(new Ui::MdiChild), ui(new Ui::MdiChild),
modelsListModel(NULL), modelsListModel(NULL),
firmware(getCurrentFirmware()), firmware(getCurrentFirmware()),
@@ -599,14 +601,32 @@ void MdiChild::setCurrentFile(const QString &fileName)
void MdiChild::writeEeprom() // write to Tx void MdiChild::writeEeprom() // write to Tx
{ {
QString tempFile = generateProcessUniqueTempFileName("temp.bin"); BoardEnum board = getCurrentBoard();
saveFile(tempFile, false); if (board == BOARD_HORUS) {
if (!QFileInfo(tempFile).exists()) { QString radioPath = findMassstoragePath("RADIO", true);
QMessageBox::critical(this, tr("Error"), tr("Cannot write temporary file!")); qDebug() << "Searching for SD card, found" << radioPath;
return; if (radioPath.isEmpty()) {
qDebug() << "MdiChild::writeEeprom(): Horus radio not found";
QMessageBox::critical(this, tr("Error"), tr("Unable to find Horus radio SD card!"));
return;
}
if (saveFile(radioPath, false)) {
parent->statusBar()->showMessage(tr("Models and Settings written"), 2000);
}
else {
qDebug() << "MdiChild::writeEeprom(): saveFile error";
}
}
else {
QString tempFile = generateProcessUniqueTempFileName("temp.bin");
saveFile(tempFile, false);
if (!QFileInfo(tempFile).exists()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot write temporary file!"));
return;
}
FlashEEpromDialog * cd = new FlashEEpromDialog(this, tempFile);
cd->exec();
} }
FlashEEpromDialog * cd = new FlashEEpromDialog(this, tempFile);
cd->exec();
} }
void MdiChild::on_radioSettings_clicked() void MdiChild::on_radioSettings_clicked()
+1
View File
@@ -100,6 +100,7 @@ class MdiChild : public QWidget
void doPaste(QByteArray * gmData, int index); void doPaste(QByteArray * gmData, int index);
void initModelsList(); void initModelsList();
MainWindow * parent;
Ui::MdiChild * ui; Ui::MdiChild * ui;
TreeModel * modelsListModel; TreeModel * modelsListModel;
+3 -3
View File
@@ -400,7 +400,7 @@ bool isRemovableMedia(const QString & vol)
} }
#endif #endif
QString findMassstoragePath(const QString &filename) QString findMassstoragePath(const QString &filename, bool onlyPath)
{ {
QString temppath; QString temppath;
QStringList drives; QStringList drives;
@@ -426,7 +426,7 @@ QString findMassstoragePath(const QString &filename)
eepromfile = temppath; eepromfile = temppath;
eepromfile.append("/" + filename); eepromfile.append("/" + filename);
if (QFile::exists(eepromfile)) { if (QFile::exists(eepromfile)) {
return eepromfile; return onlyPath ? temppath : eepromfile;
} }
} }
} }
@@ -452,7 +452,7 @@ QString findMassstoragePath(const QString &filename)
if (QFile::exists(eepromfile)) { if (QFile::exists(eepromfile)) {
#endif #endif
free_file_system_list(firstEntry); free_file_system_list(firstEntry);
return eepromfile; return onlyPath ? temppath : eepromfile;
} }
} }
entry = entry->me_next; entry = entry->me_next;
+1 -1
View File
@@ -28,7 +28,7 @@ class ProgressWidget;
QString getRadioInterfaceCmd(); QString getRadioInterfaceCmd();
QString findMassstoragePath(const QString &filename); QString findMassstoragePath(const QString &filename, bool onlyPath = false);
QStringList getAvrdudeArgs(const QString &cmd, const QString &filename); QStringList getAvrdudeArgs(const QString &cmd, const QString &filename);
QStringList getSambaArgs(const QString &tcl); QStringList getSambaArgs(const QString &tcl);