Use ETX instead of OTX (also as a file extension).
This commit is contained in:
committed by
Raphael Coeffic
parent
20961e460b
commit
89517d8bd8
@@ -60,8 +60,9 @@
|
||||
#define DFU_FILES_FILTER "DFU " % CPN_STR_FILES % " (*.dfu);;"
|
||||
#define EEPE_FILES_FILTER "EEPE " % CPN_STR_FILES % " (*.eepe);;"
|
||||
#define OTX_FILES_FILTER "OpenTX " % CPN_STR_FILES % " (*.otx);;"
|
||||
#define ETX_FILES_FILTER "EdgeTX " % CPN_STR_FILES % " (*.etx);;"
|
||||
#define YML_FILES_FILTER "YAML " % CPN_STR_FILES % " (*.yml);;"
|
||||
#define EEPROM_FILES_FILTER CPN_STR_RAD_MOD_SETTINGS % " " % CPN_STR_FILES % " (*.otx *.yml *.eepe *.bin *.hex);;" % OTX_FILES_FILTER % YML_FILES_FILTER % EEPE_FILES_FILTER % BIN_FILES_FILTER % HEX_FILES_FILTER
|
||||
#define EEPROM_FILES_FILTER CPN_STR_RAD_MOD_SETTINGS % " " % CPN_STR_FILES % " (*.etx *.otx *.yml *.eepe *.bin *.hex);;" % ETX_FILES_FILTER % OTX_FILES_FILTER % YML_FILES_FILTER % EEPE_FILES_FILTER % BIN_FILES_FILTER % HEX_FILES_FILTER
|
||||
#define FLASH_FILES_FILTER "FLASH " % CPN_STR_FILES % " (*.bin *.hex *.dfu);;" % BIN_FILES_FILTER % HEX_FILES_FILTER % DFU_FILES_FILTER
|
||||
#define EXTERNAL_EEPROM_FILES_FILTER "EEPROM " % CPN_STR_FILES % " (*.bin *.hex);;" % BIN_FILES_FILTER % HEX_FILES_FILTER
|
||||
#define ER9X_EEPROM_FILE_TYPE "ER9X_EEPROM_FILE"
|
||||
|
||||
@@ -157,7 +157,7 @@ MainWindow::MainWindow():
|
||||
if (!str.isEmpty()) {
|
||||
int fileType = getStorageType(str);
|
||||
|
||||
if (fileType==STORAGE_TYPE_EEPE || fileType==STORAGE_TYPE_EEPM || fileType==STORAGE_TYPE_BIN || fileType==STORAGE_TYPE_OTX) {
|
||||
if (fileType==STORAGE_TYPE_EEPE || fileType==STORAGE_TYPE_EEPM || fileType==STORAGE_TYPE_BIN || fileType==STORAGE_TYPE_ETX) {
|
||||
MdiChild * child = createMdiChild();
|
||||
if (child->loadFile(str)) {
|
||||
if (!(printing && model >= 0 && (getCurrentFirmware()->getCapability(Models) == 0 || model<getCurrentFirmware()->getCapability(Models)) && !printfilename.isEmpty())) {
|
||||
@@ -908,7 +908,7 @@ void MainWindow::readEeprom()
|
||||
Board::Type board = getCurrentBoard();
|
||||
QString tempFile;
|
||||
if (IS_FAMILY_HORUS_OR_T16(board))
|
||||
tempFile = generateProcessUniqueTempFileName("temp.otx");
|
||||
tempFile = generateProcessUniqueTempFileName("temp.etx");
|
||||
else
|
||||
tempFile = generateProcessUniqueTempFileName("temp.bin");
|
||||
|
||||
|
||||
@@ -1320,7 +1320,7 @@ void MdiChild::newFile(bool createDefaults)
|
||||
{
|
||||
static int sequenceNumber = 1;
|
||||
isUntitled = true;
|
||||
curFile = QString("document%1.otx").arg(sequenceNumber++);
|
||||
curFile = QString("document%1.etx").arg(sequenceNumber++);
|
||||
updateTitle();
|
||||
|
||||
if (createDefaults && firmware->getCapability(Capability::HasModelCategories)) {
|
||||
@@ -1375,7 +1375,7 @@ bool MdiChild::saveAs(bool isNew)
|
||||
#ifdef __APPLE__
|
||||
QString filter;
|
||||
#else
|
||||
QString filter(OTX_FILES_FILTER % YML_FILES_FILTER);
|
||||
QString filter(ETX_FILES_FILTER % YML_FILES_FILTER);
|
||||
#endif
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.eepromDir() + "/" + fi.fileName(), filter);
|
||||
@@ -1455,7 +1455,7 @@ void MdiChild::setCurrentFile(const QString & fileName)
|
||||
|
||||
void MdiChild::forceNewFilename(const QString & suffix, const QString & ext)
|
||||
{
|
||||
curFile.replace(QRegExp("\\.(eepe|bin|hex|otx)$"), suffix + "." + ext);
|
||||
curFile.replace(QRegExp("\\.(eepe|bin|hex|etx)$"), suffix + "." + ext);
|
||||
}
|
||||
|
||||
bool MdiChild::convertStorage(Board::Type from, Board::Type to, bool newFile)
|
||||
|
||||
@@ -179,7 +179,7 @@ class MdiChild : public QWidget
|
||||
|
||||
bool maybeSave();
|
||||
void setCurrentFile(const QString & fileName);
|
||||
void forceNewFilename(const QString & suffix = "", const QString & ext = "otx");
|
||||
void forceNewFilename(const QString & suffix = "", const QString & ext = "etx");
|
||||
bool convertStorage(Board::Type from, Board::Type to, bool newFile = false);
|
||||
void showWarning(const QString & msg);
|
||||
int askQuestion(const QString & msg, QMessageBox::StandardButtons buttons = (QMessageBox::Yes | QMessageBox::No), QMessageBox::StandardButton defaultButton = QMessageBox::No);
|
||||
|
||||
@@ -120,7 +120,7 @@ QString SimulatorStartupDialog::radioEepromFileName(const QString & firmwareId,
|
||||
if (pos > 0)
|
||||
radioId = radioId.mid(pos+1);
|
||||
if (usesCategorizedStorage(radioId))
|
||||
ext = "otx";
|
||||
ext = "etx";
|
||||
|
||||
eepromFileName = QString("eeprom-%1.%2").arg(radioId, ext);
|
||||
eepromFileName = QDir(folder).filePath(eepromFileName.toLatin1());
|
||||
|
||||
@@ -249,9 +249,9 @@ bool SimulatorWidget::setStartupData(const QByteArray & dataSource, bool fromFil
|
||||
error = store.error();
|
||||
}
|
||||
else {
|
||||
if (fileName.endsWith(".otx", Qt::CaseInsensitive)) {
|
||||
// no radios can work with .otx files directly, so we load contents into either
|
||||
// a temporary folder (Horus) or local data array (other radios) which we'll save back to .otx upon exit
|
||||
if (fileName.endsWith(".etx", Qt::CaseInsensitive)) {
|
||||
// no radios can work with .etx files directly, so we load contents into either
|
||||
// a temporary folder (Horus) or local data array (other radios) which we'll save back to .etx upon exit
|
||||
if ((ret = setRadioData(&simuData))) {
|
||||
startupFromFile = false;
|
||||
return true;
|
||||
@@ -365,7 +365,7 @@ bool SimulatorWidget::useTempDataPath(bool deleteOnClose)
|
||||
if (deleteTempRadioData)
|
||||
deleteTempData();
|
||||
|
||||
QTemporaryDir tmpDir(QDir::tempPath() + "/otx-XXXXXX");
|
||||
QTemporaryDir tmpDir(QDir::tempPath() + "/etx-XXXXXX");
|
||||
if (tmpDir.isValid()) {
|
||||
setDataPath(tmpDir.path());
|
||||
tmpDir.setAutoRemove(false);
|
||||
@@ -379,7 +379,7 @@ bool SimulatorWidget::useTempDataPath(bool deleteOnClose)
|
||||
}
|
||||
}
|
||||
|
||||
// This will save radio data from temporary folder structure back into an .otx file, eg. for Horus.
|
||||
// This will save radio data from temporary folder structure back into an .etx file, eg. for Horus.
|
||||
bool SimulatorWidget::saveTempData()
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
@@ -127,7 +127,7 @@ CommandLineParseResult cliOptions(SimulatorOptions * simOptions, int * profileId
|
||||
QApplication::translate("SimulatorMain", "type"));
|
||||
|
||||
cliOptions.addPositionalArgument(QApplication::translate("SimulatorMain", "data-source"),
|
||||
QApplication::translate("SimulatorMain", "Radio data (.bin/.eeprom/.otx) image file to use OR data folder path (for Horus-style radios).\n"
|
||||
QApplication::translate("SimulatorMain", "Radio data (.bin/.eeprom/.etx) image file to use OR data folder path (for Horus-style radios).\n"
|
||||
"NOTE: any existing EEPROM data incompatible with the selected radio type may be overwritten!"),
|
||||
QApplication::translate("SimulatorMain", "[data-source]"));
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ set(storage_NAMES
|
||||
hexeeprom
|
||||
categorized
|
||||
sdcard
|
||||
otx
|
||||
etx
|
||||
yaml
|
||||
)
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "otx.h"
|
||||
#include "etx.h"
|
||||
#include "miniz.c"
|
||||
#include <QFile>
|
||||
|
||||
#define MZ_ALLOCATION_SIZE (32*1024)
|
||||
|
||||
bool OtxFormat::load(RadioData & radioData)
|
||||
bool EtxFormat::load(RadioData & radioData)
|
||||
{
|
||||
QFile file(filename);
|
||||
|
||||
@@ -40,7 +40,7 @@ bool OtxFormat::load(RadioData & radioData)
|
||||
// open zip file
|
||||
memset(&zip_archive, 0, sizeof(zip_archive));
|
||||
if (!mz_zip_reader_init_mem(&zip_archive, archiveContents.data(), archiveContents.size(), 0)) {
|
||||
qDebug() << tr("Error opening OTX archive %1").arg(filename);
|
||||
qDebug() << tr("Error opening ETX archive %1").arg(filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ bool OtxFormat::load(RadioData & radioData)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool OtxFormat::write(const RadioData & radioData)
|
||||
bool EtxFormat::write(const RadioData & radioData)
|
||||
{
|
||||
qDebug() << "Saving to archive" << filename;
|
||||
|
||||
memset(&zip_archive, 0, sizeof(zip_archive));
|
||||
if (!mz_zip_writer_init_heap(&zip_archive, 0, MZ_ALLOCATION_SIZE)) {
|
||||
setError(tr("Error initializing OTX archive writer"));
|
||||
setError(tr("Error initializing ETX archive writer"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -76,12 +76,12 @@ bool OtxFormat::write(const RadioData & radioData)
|
||||
}
|
||||
}
|
||||
else {
|
||||
setError(tr("Error creating OTX file %1:\n%2.").arg(filename).arg(file.errorString()));
|
||||
setError(tr("Error creating ETX file %1:\n%2.").arg(filename).arg(file.errorString()));
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
setError(tr("Error creating OTX archive"));
|
||||
setError(tr("Error creating ETX archive"));
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ bool OtxFormat::write(const RadioData & radioData)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool OtxFormat::loadFile(QByteArray & filedata, const QString & filename)
|
||||
bool EtxFormat::loadFile(QByteArray & filedata, const QString & filename)
|
||||
{
|
||||
size_t size;
|
||||
void * data = mz_zip_reader_extract_file_to_heap(&zip_archive, qPrintable(filename), &size, 0);
|
||||
@@ -105,10 +105,10 @@ bool OtxFormat::loadFile(QByteArray & filedata, const QString & filename)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OtxFormat::writeFile(const QByteArray & filedata, const QString & filename)
|
||||
bool EtxFormat::writeFile(const QByteArray & filedata, const QString & filename)
|
||||
{
|
||||
if (!mz_zip_writer_add_mem(&zip_archive, filename.toStdString().c_str(), filedata.data(), filedata.size(), MZ_DEFAULT_LEVEL)) {
|
||||
setError(tr("Error adding %1 to OTX archive").arg(filename));
|
||||
setError(tr("Error adding %1 to ETX archive").arg(filename));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _OTX_H_
|
||||
#define _OTX_H_
|
||||
#ifndef _ETX_H_
|
||||
#define _ETX_H_
|
||||
|
||||
#include "categorized.h"
|
||||
|
||||
@@ -29,17 +29,17 @@
|
||||
#include "miniz.c"
|
||||
#undef MINIZ_HEADER_FILE_ONLY
|
||||
|
||||
class OtxFormat : public CategorizedStorageFormat
|
||||
class EtxFormat : public CategorizedStorageFormat
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(OtxFormat)
|
||||
Q_DECLARE_TR_FUNCTIONS(EtxFormat)
|
||||
|
||||
public:
|
||||
OtxFormat(const QString & filename):
|
||||
EtxFormat(const QString & filename):
|
||||
CategorizedStorageFormat(filename)
|
||||
{
|
||||
}
|
||||
|
||||
virtual QString name() { return "otx"; }
|
||||
virtual QString name() { return "etx"; }
|
||||
virtual bool load(RadioData & radioData);
|
||||
virtual bool write(const RadioData & radioData);
|
||||
|
||||
@@ -50,4 +50,4 @@ class OtxFormat : public CategorizedStorageFormat
|
||||
mz_zip_archive zip_archive;
|
||||
};
|
||||
|
||||
#endif // _OTX_H_
|
||||
#endif // _ETX_H_
|
||||
@@ -305,11 +305,11 @@ bool FirmwareInterface::seekSplash(QByteArray sps, QByteArray spe, int size)
|
||||
return false;
|
||||
}
|
||||
|
||||
#define OTX_SPS_9X "SPS\0\200\100"
|
||||
#define OTX_SPS_TARANIS "SPS\0\324\100"
|
||||
#define OTX_SPS_SIZE 6
|
||||
#define OTX_SPE "SPE"
|
||||
#define OTX_SPE_SIZE 4
|
||||
#define ETX_SPS_9X "SPS\0\200\100"
|
||||
#define ETX_SPS_TARANIS "SPS\0\324\100"
|
||||
#define ETX_SPS_SIZE 6
|
||||
#define ETX_SPE "SPE"
|
||||
#define ETX_SPE_SIZE 4
|
||||
|
||||
void FirmwareInterface::seekSplash()
|
||||
{
|
||||
@@ -342,11 +342,11 @@ void FirmwareInterface::seekSplash()
|
||||
return;
|
||||
}
|
||||
|
||||
if (seekSplash(QByteArray(OTX_SPS_9X, OTX_SPS_SIZE), QByteArray(OTX_SPE, OTX_SPE_SIZE), 1024)) {
|
||||
if (seekSplash(QByteArray(ETX_SPS_9X, ETX_SPS_SIZE), QByteArray(ETX_SPE, ETX_SPE_SIZE), 1024)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (seekSplash(QByteArray(OTX_SPS_TARANIS, OTX_SPS_SIZE), QByteArray(OTX_SPE, OTX_SPE_SIZE), RLE_SPLASH_MAX_SIZE)) {
|
||||
if (seekSplash(QByteArray(ETX_SPS_TARANIS, ETX_SPS_SIZE), QByteArray(ETX_SPE, ETX_SPE_SIZE), RLE_SPLASH_MAX_SIZE)) {
|
||||
splashWidth = SPLASHX9D_WIDTH;
|
||||
splashHeight = SPLASHX9D_HEIGHT;
|
||||
splash_format = QImage::Format_Indexed8;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "bineeprom.h"
|
||||
#include "eepe.h"
|
||||
#include "otx.h"
|
||||
#include "etx.h"
|
||||
#include "sdcard.h"
|
||||
#include "yaml.h"
|
||||
#include "firmwareinterface.h"
|
||||
@@ -42,6 +42,8 @@ StorageType getStorageType(const QString & filename)
|
||||
return STORAGE_TYPE_XML;
|
||||
else if (suffix == "OTX")
|
||||
return STORAGE_TYPE_OTX;
|
||||
else if (suffix == "ETX")
|
||||
return STORAGE_TYPE_ETX;
|
||||
else if (suffix == "YML")
|
||||
return STORAGE_TYPE_YML;
|
||||
else
|
||||
@@ -63,7 +65,7 @@ void registerStorageFactories()
|
||||
registerStorageFactory(new DefaultStorageFactory<BinEepromFormat>("bin"));
|
||||
registerStorageFactory(new DefaultStorageFactory<EepeFormat>("eepe"));
|
||||
registerStorageFactory(new DefaultStorageFactory<HexEepromFormat>("hex"));
|
||||
registerStorageFactory(new DefaultStorageFactory<OtxFormat>("otx"));
|
||||
registerStorageFactory(new DefaultStorageFactory<EtxFormat>("etx"));
|
||||
registerStorageFactory(new DefaultStorageFactory<YamlFormat>("yml"));
|
||||
registerStorageFactory(new SdcardStorageFactory());
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ enum StorageType
|
||||
STORAGE_TYPE_XML,
|
||||
STORAGE_TYPE_SDCARD,
|
||||
STORAGE_TYPE_OTX,
|
||||
STORAGE_TYPE_YML
|
||||
STORAGE_TYPE_YML,
|
||||
STORAGE_TYPE_ETX
|
||||
};
|
||||
|
||||
StorageType getStorageType(const QString & filename);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "gtests.h"
|
||||
#include "location.h"
|
||||
#include "storage/otx.h"
|
||||
#include "storage/etx.h"
|
||||
#include "storage/storage.h"
|
||||
#include "firmwares/opentx/opentxinterface.h"
|
||||
#include "firmwares/customfunctiondata.h"
|
||||
@@ -210,12 +210,12 @@ TEST(Conversions, ConversionX10From22)
|
||||
{
|
||||
QByteArray byteBuffer;
|
||||
|
||||
#define USE_OTX
|
||||
#define USE_ETX
|
||||
|
||||
#if defined(USE_OTX)
|
||||
OtxFormat otx(RADIO_TESTS_PATH "/model_22_x10.otx");
|
||||
#if defined(USE_ETX)
|
||||
EtxFormat etx(RADIO_TESTS_PATH "/model_22_x10.etx");
|
||||
RadioData radio;
|
||||
EXPECT_EQ(true, otx.load(radio));
|
||||
EXPECT_EQ(true, etx.load(radio));
|
||||
|
||||
const GeneralSettings& settings = radio.generalSettings;
|
||||
const ModelData& model = radio.models[0];
|
||||
@@ -253,7 +253,7 @@ TEST(Conversions, ConversionX10From22)
|
||||
EXPECT_STREQ("BT_X10", settings.bluetoothName);
|
||||
EXPECT_STREQ("EdgeTX", settings.themeData.themeName);
|
||||
|
||||
#if !defined(USE_OTX)
|
||||
#if !defined(USE_ETX)
|
||||
byteBuffer.clear();
|
||||
ASSERT_EQ(true, loadFile(byteBuffer, RADIO_TESTS_PATH "/model_22_x10/MODELS/model1.bin"));
|
||||
|
||||
@@ -295,12 +295,12 @@ TEST(Conversions, ConversionX12SFrom22)
|
||||
{
|
||||
QByteArray byteBuffer;
|
||||
|
||||
#define USE_OTX
|
||||
#define USE_ETX
|
||||
|
||||
#if defined(USE_OTX)
|
||||
OtxFormat otx(RADIO_TESTS_PATH "/model_22_x12s.otx");
|
||||
#if defined(USE_ETX)
|
||||
EtxFormat etx(RADIO_TESTS_PATH "/model_22_x12s.etx");
|
||||
RadioData radio;
|
||||
EXPECT_EQ(true, otx.load(radio));
|
||||
EXPECT_EQ(true, etx.load(radio));
|
||||
|
||||
const GeneralSettings& settings = radio.generalSettings;
|
||||
const ModelData& model = radio.models[0];
|
||||
@@ -330,7 +330,7 @@ TEST(Conversions, ConversionX12SFrom22)
|
||||
EXPECT_STREQ("BT", settings.bluetoothName);
|
||||
EXPECT_STREQ("EdgeTX", settings.themeData.themeName);
|
||||
|
||||
#if !defined(USE_OTX)
|
||||
#if !defined(USE_ETX)
|
||||
byteBuffer.clear();
|
||||
ASSERT_EQ(true, loadFile(byteBuffer, RADIO_TESTS_PATH "/model_22_x10/MODELS/model1.bin"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user