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()
{
if (getCurrentBoard()== BOARD_HORUS) {
qDebug() << "TODO readEEPROM HORUS";
BoardEnum board = getCurrentBoard();
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 {
QString tempFile;
BoardEnum board = getCurrentBoard();
if (IS_ARM(board))
tempFile = generateProcessUniqueTempFileName("temp.bin");
else
+27 -7
View File
@@ -31,6 +31,7 @@
#include "wizarddialog.h"
#include "flashfirmwaredialog.h"
#include "storage.h"
#include "radiointerface.h"
#if defined _MSC_VER || !defined __GNUC__
#include <windows.h>
@@ -41,6 +42,7 @@
MdiChild::MdiChild(MainWindow * parent):
QWidget(),
parent(parent),
ui(new Ui::MdiChild),
modelsListModel(NULL),
firmware(getCurrentFirmware()),
@@ -599,14 +601,32 @@ void MdiChild::setCurrentFile(const QString &fileName)
void MdiChild::writeEeprom() // write to Tx
{
QString tempFile = generateProcessUniqueTempFileName("temp.bin");
saveFile(tempFile, false);
if (!QFileInfo(tempFile).exists()) {
QMessageBox::critical(this, tr("Error"), tr("Cannot write temporary file!"));
return;
BoardEnum board = getCurrentBoard();
if (board == BOARD_HORUS) {
QString radioPath = findMassstoragePath("RADIO", true);
qDebug() << "Searching for SD card, found" << radioPath;
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()
+1
View File
@@ -100,6 +100,7 @@ class MdiChild : public QWidget
void doPaste(QByteArray * gmData, int index);
void initModelsList();
MainWindow * parent;
Ui::MdiChild * ui;
TreeModel * modelsListModel;
+3 -3
View File
@@ -400,7 +400,7 @@ bool isRemovableMedia(const QString & vol)
}
#endif
QString findMassstoragePath(const QString &filename)
QString findMassstoragePath(const QString &filename, bool onlyPath)
{
QString temppath;
QStringList drives;
@@ -426,7 +426,7 @@ QString findMassstoragePath(const QString &filename)
eepromfile = temppath;
eepromfile.append("/" + filename);
if (QFile::exists(eepromfile)) {
return eepromfile;
return onlyPath ? temppath : eepromfile;
}
}
}
@@ -452,7 +452,7 @@ QString findMassstoragePath(const QString &filename)
if (QFile::exists(eepromfile)) {
#endif
free_file_system_list(firstEntry);
return eepromfile;
return onlyPath ? temppath : eepromfile;
}
}
entry = entry->me_next;
+1 -1
View File
@@ -28,7 +28,7 @@ class ProgressWidget;
QString getRadioInterfaceCmd();
QString findMassstoragePath(const QString &filename);
QString findMassstoragePath(const QString &filename, bool onlyPath = false);
QStringList getAvrdudeArgs(const QString &cmd, const QString &filename);
QStringList getSambaArgs(const QString &tcl);