diff --git a/companion/src/constants.h b/companion/src/constants.h index 1ce4617ff..eeff0ae0c 100644 --- a/companion/src/constants.h +++ b/companion/src/constants.h @@ -77,7 +77,6 @@ #define EEPROM_FILES_FILTER CPN_STR_RAD_MOD_SETTINGS % " " % CPN_STR_FILES % " (*.etx *.yml);;" % ETX_FILES_FILTER % YML_FILES_FILTER #define FIRMWARE_FILES_FILTER "Firmware " % CPN_STR_FILES % " (*.bin *.uf2);;" % BIN_FILES_FILTER % UF2_FILES_FILTER #define EXTERNAL_EEPROM_FILES_FILTER "EEPROM " % CPN_STR_FILES % " (*.bin);;" % BIN_FILES_FILTER -#define EEPE_EEPROM_FILE_HEADER "EEPE EEPROM FILE" #define SIMU_FILES_FILTER ETX_FILES_FILTER #define CPN_STR_APP_SETTINGS QCoreApplication::translate("Companion", "Application Settings") diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index 5d9ce0345..1aa79b559 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -29,7 +29,6 @@ #include "version.h" #include "customizesplashdialog.h" #include "flashfirmwaredialog.h" -#include "hexinterface.h" #include "warnings.h" #include "helpers.h" #include "appdata.h" diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index 3cfb0e50e..239154d6f 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -1538,7 +1538,7 @@ void MdiChild::setCurrentFile(const QString & fileName) void MdiChild::forceNewFilename(const QString & suffix, const QString & ext) { - curFile.replace(QRegularExpression("\\.(eepe|bin|hex|otx|etx)$"), suffix + "." + ext); + curFile.replace(QRegularExpression("\\.etx$"), suffix + "." + ext); } bool MdiChild::convertStorage(Board::Type from, Board::Type to, bool newFile) diff --git a/companion/src/storage/CMakeLists.txt b/companion/src/storage/CMakeLists.txt index 28d9466ab..b72e7e5e3 100644 --- a/companion/src/storage/CMakeLists.txt +++ b/companion/src/storage/CMakeLists.txt @@ -2,13 +2,10 @@ project(storage) set(${PROJECT_NAME}_NAMES - hexinterface mountlist appdata firmwareinterface storage - eepe - hexeeprom labeled sdcard etx diff --git a/companion/src/storage/eepe.cpp b/companion/src/storage/eepe.cpp deleted file mode 100644 index 6386fc1a6..000000000 --- a/companion/src/storage/eepe.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "eepe.h" -#include -#include "eeprominterface.h" -#include "hexinterface.h" - -bool EepeFormat::load(RadioData & radioData) -{ - QFile file(filename); - - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - setError(tr("Unable to open %1: %2").arg(filename).arg(file.errorString())); - return false; - } - - QTextStream inputStream(&file); - QString hline = inputStream.readLine(); - if (hline != EEPE_EEPROM_FILE_HEADER) { - qDebug() << qPrintable("[eepe] No EEPE header"); - return false; - } - - qDebug() << qPrintable("[eepe] EEPE header found"); - - QByteArray eeprom(Boards::getEEpromSize(Board::BOARD_UNKNOWN), 0); - int eeprom_size = HexInterface(inputStream).load((uint8_t *)eeprom.data(), Boards::getEEpromSize(Board::BOARD_UNKNOWN)); - if (!eeprom_size) { - setError(tr("Invalid EEPROM file %1").arg(filename)); - return false; - } - eeprom.resize(eeprom_size); - - return extract(radioData, eeprom); -} diff --git a/companion/src/storage/eepe.h b/companion/src/storage/eepe.h deleted file mode 100644 index dee2f34b8..000000000 --- a/companion/src/storage/eepe.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _EEPE_H_ -#define _EEPE_H_ - -#include "hexeeprom.h" - -#include - -class EepeFormat : public HexEepromFormat -{ - Q_DECLARE_TR_FUNCTIONS(EepeFormat) - - public: - EepeFormat(const QString & filename): - HexEepromFormat(filename) - { - } - - virtual QString name() { return "eepe"; } - virtual bool load(RadioData & radioData); -}; - -#endif // _EEPE_H_ diff --git a/companion/src/storage/eepexml.cpp b/companion/src/storage/eepexml.cpp deleted file mode 100644 index 6d63466d5..000000000 --- a/companion/src/storage/eepexml.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -// TODO not enabled for now - -bool EepeXmlFormat::load(RadioData & radioData) -{ - QFile file(filename); - - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug() << "Unable to open" << filename << file.errorString(); - return false; - } - - QDomDocument doc(ER9X_EEPROM_FILE_TYPE); - bool xmlOK = doc.setContent(&file); - if (xmlOK) { - std::bitset errors((unsigned long long) LoadEepromXml(radioData, doc)); - if (errors.test(ALL_OK)) { - return true; - } - else { - qDebug() << "XML parsing error"; - } - } - else { - qDebug() << "No XML content"; - } - - return false; -} \ No newline at end of file diff --git a/companion/src/storage/firmwareinterface.cpp b/companion/src/storage/firmwareinterface.cpp index 3466e233b..a15dd96e0 100644 --- a/companion/src/storage/firmwareinterface.cpp +++ b/companion/src/storage/firmwareinterface.cpp @@ -19,7 +19,6 @@ * GNU General Public License for more details. */ -#include "hexinterface.h" #include "firmwareinterface.h" #include "helpers.h" diff --git a/companion/src/storage/hexeeprom.cpp b/companion/src/storage/hexeeprom.cpp deleted file mode 100644 index 2d04b1755..000000000 --- a/companion/src/storage/hexeeprom.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "hexeeprom.h" -#include "eeprominterface.h" -#include "hexinterface.h" -#include - -bool HexEepromFormat::load(RadioData & radioData) -{ - QFile file(filename); - - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qDebug() << "Unable to open" << filename << file.errorString(); - return false; - } - - QTextStream inputStream(&file); - QByteArray eeprom(Boards::getEEpromSize(Board::BOARD_UNKNOWN), 0); - int eeprom_size = HexInterface(inputStream).load((uint8_t *)eeprom.data(), Boards::getEEpromSize(Board::BOARD_UNKNOWN)); - if (!eeprom_size) { - setError(tr("Invalid EEPROM File %1").arg(filename)); - return false; - } - eeprom.resize(eeprom_size); - - return extract(radioData, eeprom); -} - -bool HexEepromFormat::writeToFile(const uint8_t * eeprom, uint32_t size) -{ - QFile file(filename); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - setError(tr("Cannot open file %1:\n%2.").arg(filename).arg(file.errorString())); - return false; - } - - QTextStream outputStream(&file); - if (!HexInterface(outputStream).save(eeprom, size)) { - setError(tr("Error writing file %1:\n%2.").arg(filename).arg(file.errorString())); - return false; - } - - return true; -} diff --git a/companion/src/storage/hexeeprom.h b/companion/src/storage/hexeeprom.h deleted file mode 100644 index 6c43612b2..000000000 --- a/companion/src/storage/hexeeprom.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _HEXEEPROM_H_ -#define _HEXEEPROM_H_ - -#include "bineeprom.h" - -#include - -class HexEepromFormat : public BinEepromFormat -{ - Q_DECLARE_TR_FUNCTIONS(HexEepromFormat) - - public: - HexEepromFormat(const QString & filename): - BinEepromFormat(filename) - { - } - - virtual QString name() { return "hex"; } - virtual bool load(RadioData & radioData); - - protected: - virtual bool writeToFile(const uint8_t * eeprom, uint32_t size); -}; - -#endif // _HEXEEPROM_H_ diff --git a/companion/src/storage/hexinterface.cpp b/companion/src/storage/hexinterface.cpp deleted file mode 100644 index ce0c11eda..000000000 --- a/companion/src/storage/hexinterface.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "hexinterface.h" - -HexInterface::HexInterface(QTextStream &stream): - stream(stream) -{ -} - -int HexInterface::getValueFromLine(const QString &line, int pos, int len) -{ - bool ok; - int hex = line.mid(pos,len).toInt(&ok, 16); - return ok ? hex : -1; -} - -int HexInterface::load(uint8_t *data, int maxsize) -{ - int result = 0; - int offset = 0; - while (!stream.atEnd()) { - QString line = stream.readLine(); - - if(line.left(1)!=":") continue; - - int byteCount = getValueFromLine(line,1); - int address = getValueFromLine(line,3,4); - int recType = getValueFromLine(line,7); - - if (recType==0x02) - offset+=0x010000; - - if(byteCount<0 || address<0 || recType<0) - return 0; - - QByteArray ba; - ba.clear(); - - quint8 chkSum = 0; - chkSum -= byteCount; - chkSum -= recType; - chkSum -= address & 0xFF; - chkSum -= address >> 8; - for(int i=0; i(nextbank*0x010000)-1) { - stream << iHEXExtRec(nextbank) << "\n"; - nextbank++; - } - int llen = 32; - if ((size - addr) < llen) - llen = size - addr; - stream << iHEXLine(data, addr, llen) << "\n"; - addr += llen; - } - stream << ":00000001FF\n"; // write EOF - return true; -} - -QString HexInterface::iHEXLine(const quint8 * data, quint32 addr, quint8 len) -{ - unsigned int bankaddr; - bankaddr=addr&0xffff; - QString str = QString(":%1%2000").arg(len, 2, 16, QChar('0')).arg(bankaddr, 4, 16, QChar('0')); //write start, bytecount (32), address and record type - quint8 chkSum = 0; - chkSum = -len; //-bytecount; recordtype is zero - chkSum -= bankaddr & 0xFF; - chkSum -= bankaddr >> 8; - for (int j = 0; j < len; j++) { - str += QString("%1").arg(data[addr + j], 2, 16, QChar('0')); - chkSum -= data[addr + j]; - } - - str += QString("%1").arg(chkSum, 2, 16, QChar('0')); - return str.toUpper(); // output to file and lf; -} - -QString HexInterface::iHEXExtRec(quint8 bank) -{ - QString str = QString(":02000002"); //write record type 2 record - quint8 chkSum = 0; - chkSum = -2; //-bytecount; recordtype is zero - chkSum -= 2; // type 2 record type - str += QString("%1000").arg((bank&0x0f)<<4,1,16,QChar('0')); - chkSum -= ((bank&0x0f)<<4); // type 2 record type - str += QString("%1").arg(chkSum, 2, 16, QChar('0')); - return str.toUpper(); // output to file and lf; -} diff --git a/companion/src/storage/hexinterface.h b/companion/src/storage/hexinterface.h deleted file mode 100644 index a8ec93332..000000000 --- a/companion/src/storage/hexinterface.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) EdgeTX - * - * Based on code named - * opentx - https://github.com/opentx/opentx - * th9x - http://code.google.com/p/th9x - * er9x - http://code.google.com/p/er9x - * gruvin9x - http://code.google.com/p/gruvin9x - * - * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#pragma once - -#include -#include - -class HexInterface { - public: - HexInterface(QTextStream &stream); - - int load(uint8_t * output, int maxsize); - bool save(const uint8_t * data, const int size); - - protected: - - int getValueFromLine(const QString &line, int pos, int len=2); - QString iHEXLine(const quint8 * data, quint32 addr, quint8 len); - QString iHEXExtRec(quint8 bank); - - QTextStream & stream; -};