Does this work? (#4269)
Read an Horus SD card produces a temporary .otx file now
This commit is contained in:
@@ -728,36 +728,22 @@ void MainWindow::loadBackup()
|
|||||||
void MainWindow::readEeprom()
|
void MainWindow::readEeprom()
|
||||||
{
|
{
|
||||||
BoardEnum board = getCurrentBoard();
|
BoardEnum board = getCurrentBoard();
|
||||||
if (board == BOARD_HORUS) {
|
QString tempFile;
|
||||||
QString radioPath = findMassstoragePath("RADIO", true);
|
if (IS_HORUS(board))
|
||||||
qDebug() << "Searching for SD card, found" << radioPath;
|
tempFile = generateProcessUniqueTempFileName("temp.otx");
|
||||||
if (radioPath.isEmpty()) {
|
else if (IS_ARM(board))
|
||||||
qDebug() << "MainWindow::readEeprom(): Horus radio not found";
|
tempFile = generateProcessUniqueTempFileName("temp.bin");
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Unable to find Horus radio SD card!"));
|
else
|
||||||
return;
|
tempFile = generateProcessUniqueTempFileName("temp.hex");
|
||||||
}
|
|
||||||
MdiChild *child = createMdiChild();
|
|
||||||
if (child->loadFile(radioPath)) {
|
|
||||||
statusBar()->showMessage(tr("Models and Settings read"), 2000);
|
|
||||||
child->show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QString tempFile;
|
|
||||||
if (IS_ARM(board))
|
|
||||||
tempFile = generateProcessUniqueTempFileName("temp.bin");
|
|
||||||
else
|
|
||||||
tempFile += generateProcessUniqueTempFileName("temp.hex");
|
|
||||||
|
|
||||||
qDebug() << "MainWindow::readEeprom(): using temp file: " << tempFile;
|
qDebug() << "MainWindow::readEeprom(): using temp file: " << tempFile;
|
||||||
|
|
||||||
if (readEepromFromRadio(tempFile)) {
|
if (readEepromFromRadio(tempFile)) {
|
||||||
MdiChild * child = createMdiChild();
|
MdiChild * child = createMdiChild();
|
||||||
child->newFile();
|
child->newFile();
|
||||||
child->loadFile(tempFile, false);
|
child->loadFile(tempFile, false);
|
||||||
child->show();
|
child->show();
|
||||||
qunlink(tempFile);
|
qunlink(tempFile);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -487,8 +487,9 @@ bool MdiChild::loadFile(const QString & filename, bool resetCurrentFile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
refresh(true);
|
refresh(true);
|
||||||
if (resetCurrentFile)
|
if (resetCurrentFile) {
|
||||||
setCurrentFile(filename);
|
setCurrentFile(filename);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -588,7 +589,7 @@ bool MdiChild::maybeSave()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MdiChild::setCurrentFile(const QString &fileName)
|
void MdiChild::setCurrentFile(const QString & fileName)
|
||||||
{
|
{
|
||||||
curFile = QFileInfo(fileName).canonicalFilePath();
|
curFile = QFileInfo(fileName).canonicalFilePath();
|
||||||
isUntitled = false;
|
isUntitled = false;
|
||||||
|
|||||||
@@ -24,12 +24,10 @@
|
|||||||
#include "process_flash.h"
|
#include "process_flash.h"
|
||||||
#include "radionotfound.h"
|
#include "radionotfound.h"
|
||||||
#include "burnconfigdialog.h"
|
#include "burnconfigdialog.h"
|
||||||
#include "firmwareinterface.h"
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "mountlist.h"
|
#include "mountlist.h"
|
||||||
#include "process_copy.h"
|
#include "process_copy.h"
|
||||||
#include <QFile>
|
#include "storage.h"
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
#if defined WIN32 || !defined __GNUC__
|
#if defined WIN32 || !defined __GNUC__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@@ -99,7 +97,7 @@ QStringList getDfuArgs(const QString & cmd, const QString & filename)
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList getSambaArgs(const QString &tcl)
|
QStringList getSambaArgs(const QString & tcl)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
|
|
||||||
@@ -121,7 +119,7 @@ QStringList getSambaArgs(const QString &tcl)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList getReadEEpromCmd(const QString &filename)
|
QStringList getReadEEpromCmd(const QString & filename)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
EEPROMInterface *eepromInterface = getCurrentEEpromInterface();
|
EEPROMInterface *eepromInterface = getCurrentEEpromInterface();
|
||||||
@@ -137,7 +135,7 @@ QStringList getReadEEpromCmd(const QString &filename)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList getWriteEEpromCmd(const QString &filename)
|
QStringList getWriteEEpromCmd(const QString & filename)
|
||||||
{
|
{
|
||||||
BoardEnum board = getCurrentBoard();
|
BoardEnum board = getCurrentBoard();
|
||||||
if (IS_STM32(board)) {
|
if (IS_STM32(board)) {
|
||||||
@@ -152,7 +150,7 @@ QStringList getWriteEEpromCmd(const QString &filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList getWriteFirmwareArgs(const QString &filename)
|
QStringList getWriteFirmwareArgs(const QString & filename)
|
||||||
{
|
{
|
||||||
BoardEnum board = getCurrentBoard();
|
BoardEnum board = getCurrentBoard();
|
||||||
if (IS_STM32(board)) {
|
if (IS_STM32(board)) {
|
||||||
@@ -169,7 +167,7 @@ QStringList getWriteFirmwareArgs(const QString &filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList getReadFirmwareArgs(const QString &filename)
|
QStringList getReadFirmwareArgs(const QString & filename)
|
||||||
{
|
{
|
||||||
BoardEnum board = getCurrentBoard();
|
BoardEnum board = getCurrentBoard();
|
||||||
if (IS_STM32(board)) {
|
if (IS_STM32(board)) {
|
||||||
@@ -186,7 +184,7 @@ QStringList getReadFirmwareArgs(const QString &filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void readAvrdudeFuses(ProgressWidget *progress)
|
void readAvrdudeFuses(ProgressWidget * progress)
|
||||||
{
|
{
|
||||||
burnConfigDialog bcd;
|
burnConfigDialog bcd;
|
||||||
QStringList args;
|
QStringList args;
|
||||||
@@ -195,7 +193,7 @@ void readAvrdudeFuses(ProgressWidget *progress)
|
|||||||
flashProcess.run();
|
flashProcess.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetAvrdudeFuses(bool eepromProtect, ProgressWidget *progress)
|
void resetAvrdudeFuses(bool eepromProtect, ProgressWidget * progress)
|
||||||
{
|
{
|
||||||
//fuses
|
//fuses
|
||||||
//avrdude -c usbasp -p m64 -U lfuse:w:<0x0E>:m
|
//avrdude -c usbasp -p m64 -U lfuse:w:<0x0E>:m
|
||||||
@@ -261,7 +259,7 @@ void resetAvrdudeFuses(bool eepromProtect, ProgressWidget *progress)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool readFirmware(const QString &filename, ProgressWidget *progress)
|
bool readFirmware(const QString & filename, ProgressWidget * progress)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
@@ -293,7 +291,7 @@ bool readFirmware(const QString &filename, ProgressWidget *progress)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool writeFirmware(const QString &filename, ProgressWidget *progress)
|
bool writeFirmware(const QString & filename, ProgressWidget * progress)
|
||||||
{
|
{
|
||||||
if (IS_ARM(getCurrentBoard())) {
|
if (IS_ARM(getCurrentBoard())) {
|
||||||
QString path = findMassstoragePath("FIRMWARE.BIN");
|
QString path = findMassstoragePath("FIRMWARE.BIN");
|
||||||
@@ -309,53 +307,75 @@ bool writeFirmware(const QString &filename, ProgressWidget *progress)
|
|||||||
return flashProcess.run();
|
return flashProcess.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool readEeprom(const QString & filename, ProgressWidget * progress)
|
||||||
bool readEeprom(const QString &filename, ProgressWidget *progress)
|
|
||||||
{
|
{
|
||||||
bool result = false;
|
BoardEnum board = getCurrentBoard();
|
||||||
|
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (file.exists() && !file.remove()) {
|
if (file.exists() && !file.remove()) {
|
||||||
QMessageBox::warning(NULL, QObject::tr("Error"), QObject::tr("Could not delete temporary file: %1").arg(filename));
|
QMessageBox::warning(NULL,
|
||||||
|
QObject::tr("Error"),
|
||||||
|
QObject::tr("Could not delete temporary file: %1").arg(filename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ARM(getCurrentBoard())) {
|
if (IS_HORUS(board)) {
|
||||||
QString path = findMassstoragePath("EEPROM.BIN");
|
QString radioPath = findMassstoragePath("RADIO", true);
|
||||||
if (path.isEmpty()) {
|
qDebug() << "Searching for SD card, found" << radioPath;
|
||||||
// On previous OpenTX we called the EEPROM file "TARANIS.BIN" :(
|
if (radioPath.isEmpty()) {
|
||||||
path = findMassstoragePath("TARANIS.BIN");
|
return false;
|
||||||
}
|
}
|
||||||
if (path.isEmpty()) {
|
RadioData radioData;
|
||||||
// Mike's bootloader calls the EEPROM file "ERSKY9X.BIN" :(
|
Storage inputStorage(radioPath);
|
||||||
path = findMassstoragePath("ERSKY9X.BIN");
|
if (!inputStorage.load(radioData)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (!path.isEmpty()) {
|
Storage outputStorage(filename);
|
||||||
|
if (!outputStorage.write(radioData)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (IS_ARM(board)) {
|
||||||
|
QString path = findMassstoragePath("EEPROM.BIN");
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
// On previous OpenTX we called the EEPROM file "TARANIS.BIN" :(
|
||||||
|
path = findMassstoragePath("TARANIS.BIN");
|
||||||
|
}
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
// Mike's bootloader calls the EEPROM file "ERSKY9X.BIN" :(
|
||||||
|
path = findMassstoragePath("ERSKY9X.BIN");
|
||||||
|
}
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
CopyProcess copyProcess(path, filename, progress);
|
CopyProcess copyProcess(path, filename, progress);
|
||||||
result = copyProcess.run();
|
if (!copyProcess.run()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IS_STM32(board)) {
|
||||||
|
FlashProcess flashProcess(getRadioInterfaceCmd(), getReadEEpromCmd(filename), progress);
|
||||||
|
if (!flashProcess.run()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_ARM(board)) {
|
||||||
|
RadioNotFoundDialog dialog;
|
||||||
|
dialog.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == false && !IS_STM32(getCurrentBoard())) {
|
return QFileInfo(filename).exists();
|
||||||
FlashProcess flashProcess(getRadioInterfaceCmd(), getReadEEpromCmd(filename), progress);
|
|
||||||
result = flashProcess.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == false && IS_ARM(getCurrentBoard())) {
|
|
||||||
RadioNotFoundDialog dialog;
|
|
||||||
dialog.exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!QFileInfo(filename).exists()) {
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool writeEeprom(const QString &filename, ProgressWidget *progress)
|
bool writeEeprom(const QString & filename, ProgressWidget * progress)
|
||||||
{
|
{
|
||||||
if (IS_ARM(getCurrentBoard())) {
|
BoardEnum board = getCurrentBoard();
|
||||||
|
|
||||||
|
if (IS_ARM(board)) {
|
||||||
QString path = findMassstoragePath("EEPROM.BIN");
|
QString path = findMassstoragePath("EEPROM.BIN");
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
// On previous OpenTX we called the EEPROM file "TARANIS.BIN" :(
|
// On previous OpenTX we called the EEPROM file "TARANIS.BIN" :(
|
||||||
@@ -371,12 +391,12 @@ bool writeEeprom(const QString &filename, ProgressWidget *progress)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_TARANIS(getCurrentBoard())) {
|
if (!IS_TARANIS(board)) {
|
||||||
FlashProcess flashProcess(getRadioInterfaceCmd(), getWriteEEpromCmd(filename), progress);
|
FlashProcess flashProcess(getRadioInterfaceCmd(), getWriteEEpromCmd(filename), progress);
|
||||||
return flashProcess.run();
|
return flashProcess.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ARM(getCurrentBoard())) {
|
if (IS_ARM(board)) {
|
||||||
RadioNotFoundDialog dialog;
|
RadioNotFoundDialog dialog;
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
@@ -400,7 +420,7 @@ bool isRemovableMedia(const QString & vol)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QString findMassstoragePath(const QString &filename, bool onlyPath)
|
QString findMassstoragePath(const QString & filename, bool onlyPath)
|
||||||
{
|
{
|
||||||
QString temppath;
|
QString temppath;
|
||||||
QStringList drives;
|
QStringList drives;
|
||||||
|
|||||||
Reference in New Issue
Block a user