diff --git a/companion/src/burndialog.cpp b/companion/src/burndialog.cpp
index d5e89805f..21b151051 100644
--- a/companion/src/burndialog.cpp
+++ b/companion/src/burndialog.cpp
@@ -52,7 +52,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
ui->BurnFlashButton->setDisabled(true);
ui->FWFileName->clear();
ui->DateField->clear();
- ui->SVNField->clear();
+ ui->versionField->clear();
ui->ModField->clear();
ui->FramFWInfo->hide();
ui->SplashFrame->hide();
@@ -132,7 +132,7 @@ void burnDialog::on_FlashLoadButton_clicked()
ui->BurnFlashButton->setDisabled(true);
ui->FWFileName->clear();
ui->DateField->clear();
- ui->SVNField->clear();
+ ui->versionField->clear();
ui->ModField->clear();
ui->FramFWInfo->hide();
ui->SplashFrame->hide();
@@ -192,8 +192,8 @@ void burnDialog::checkFw(QString fileName)
if (flash.isValid()) {
ui->FramFWInfo->show();
ui->DateField->setText(flash.getDate() + " " + flash.getTime());
- ui->SVNField->setText(flash.getSvn());
- ui->ModField->setText(flash.getBuild());
+ ui->versionField->setText(flash.getVersion().isEmpty() ? flash.getSvn() : flash.getVersion());
+ ui->ModField->setText(flash.getEEprom());
ui->SplashFrame->hide();
if (flash.hasSplash()) {
diff --git a/companion/src/burndialog.ui b/companion/src/burndialog.ui
index e766d31f9..208bc4527 100644
--- a/companion/src/burndialog.ui
+++ b/companion/src/burndialog.ui
@@ -113,8 +113,15 @@
QFrame::Raised
+ -
+
+
+ Date & Time
+
+
+
-
-
+
true
@@ -135,20 +142,13 @@
-
-
+
- SVN
+ Version
- -
-
-
- Date & Time
-
-
-
- -
+
-
true
@@ -360,8 +360,7 @@
BurnFlashButton
FWFileName
FlashLoadButton
- DateField
- SVNField
+ versionField
ModField
useProfileImageCB
useFwImageCB
diff --git a/companion/src/flashinterface.cpp b/companion/src/flashinterface.cpp
index 0b56cc795..3c2824d44 100644
--- a/companion/src/flashinterface.cpp
+++ b/companion/src/flashinterface.cpp
@@ -13,6 +13,7 @@
* GNU General Public License for more details.
*
*/
+
#include
#include "hexinterface.h"
#include "splash.h"
@@ -20,192 +21,77 @@
int getFileType(const QString &fullFileName)
{
- if(QFileInfo(fullFileName).suffix().toUpper()=="HEX") return FILE_TYPE_HEX;
- if(QFileInfo(fullFileName).suffix().toUpper()=="BIN") return FILE_TYPE_BIN;
- if(QFileInfo(fullFileName).suffix().toUpper()=="EEPM") return FILE_TYPE_EEPM;
- if(QFileInfo(fullFileName).suffix().toUpper()=="EEPE") return FILE_TYPE_EEPE;
- if(QFileInfo(fullFileName).suffix().toUpper()=="XML") return FILE_TYPE_XML;
- return 0;
+ QString suffix = QFileInfo(fullFileName).suffix().toUpper();
+ if (suffix == "HEX")
+ return FILE_TYPE_HEX;
+ else if (suffix == "BIN")
+ return FILE_TYPE_BIN;
+ else if (suffix == "EEPM")
+ return FILE_TYPE_EEPM;
+ else if (suffix == "EEPE")
+ return FILE_TYPE_EEPE;
+ else if (suffix == "XML")
+ return FILE_TYPE_XML;
+ else
+ return 0;
}
-FlashInterface::FlashInterface(QString fileName)
+FlashInterface::FlashInterface(QString fileName):
+ flash(MAX_FSIZE, 0),
+ flash_size(0),
+ isValidFlag(false)
{
- char * temp = (char *)malloc(MAX_FSIZE);
- date = "";
- time = "";
- svn = "";
- build = "";
- isValidFlag = true;
QFile file(fileName);
- flash_size=0;
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file
- isValidFlag = false;
- }
- else {
+ if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file
QTextStream inputStream(&file);
- flash_size = HexInterface(inputStream).load((uint8_t *)temp, MAX_FSIZE);
+ flash_size = HexInterface(inputStream).load((uint8_t *)flash.data(), MAX_FSIZE);
file.close();
- inputStream.reset();
if (flash_size == 0) {
- QFile file(fileName);
file.open(QIODevice::ReadOnly);
- char * bin_flash = (char *)malloc(MAX_FSIZE);
- flash_size = file.read(bin_flash, MAX_FSIZE);
- flash = QByteArray(bin_flash, flash_size);
- free(bin_flash);
- }
- else {
- flash = QByteArray(temp, flash_size);
+ flash_size = file.read((char *)flash.data(), MAX_FSIZE);
}
if (flash_size > 0) {
- SeekSvn();
- SeekDate();
- SeekTime();
- SeekBuild();
+ svn = seekLabel(SVN_MARK);
+ version = seekLabel(VERS_MARK);
+ date = seekLabel(DATE_MARK);
+ time = seekLabel(TIME_MARK);
+ eeprom = seekLabel(EEPR_MARK);
SeekSplash();
- }
- else {
- isValidFlag = false;
+ isValidFlag = true;
}
}
- free(temp);
}
-QString FlashInterface::getDate(void)
+QString FlashInterface::seekString(const QString & string)
{
- return date;
-}
+ QString result = "";
-QString FlashInterface::getTime(void)
-{
- return time;
-}
-
-QString FlashInterface::getSvn(void)
-{
- return svn;
-}
-
-QString FlashInterface::getBuild(void)
-{
- return build;
-}
-
-int FlashInterface::getSize()
-{
- return flash_size;
-}
-
-void FlashInterface::SeekSvn(void)
-{
- int i, start = -1, end = -1;
- start = flash.indexOf(QString(SVN_MARK));
+ int start = flash.indexOf(string);
if (start > 0) {
- start += QString(SVN_MARK).length();
- for (i = start; i < (start + 20); i++) {
- if (flash.at(i) == 0) {
+ start += string.length();
+ int end = -1;
+ for (int i=start; i 0) {
- svn = QString(flash.mid(start, (end - start))).trimmed();
- }
- else {
- svn = QString("");
+ result = flash.mid(start, (end - start)).trimmed();
}
}
+
+ return result;
}
-void FlashInterface::SeekDate(void)
+QString FlashInterface::seekLabel(const QString & label)
{
- int i, start = -1, end = -1, startsvn=0;
- startsvn = flash.indexOf(QString(SVN_MARK));
- if (startsvn>0) {
- start = flash.indexOf(QString(DATE_MARK),startsvn);
- } else {
- start = flash.indexOf(QString(DATE_MARK));
- }
- if (start > 0) {
- start += QString(DATE_MARK).length();
- for (i = start; i < (start + 20); i++) {
- if (flash.at(i) == 0) {
- end = i;
- break;
- }
- }
- if (end > 0) {
- date = QString(flash.mid(start, (end - start))).trimmed();
- }
- else {
- date = QString("");
- }
- }
-}
+ QString result = seekString(label + "\037\033:");
+ if (!result.isEmpty())
+ return result;
-void FlashInterface::SeekTime(void)
-{
- int i, start = -1, end = -1, startsvn=0;
- startsvn = flash.indexOf(QString(SVN_MARK));
- if (startsvn>0) {
- start = flash.indexOf(QString(TIME_MARK),startsvn);
- } else {
- start = flash.indexOf(QString(TIME_MARK));
- }
- if (start > 0) {
- start += QString(TIME_MARK).length();
- for (i = start; i < (start + 20); i++) {
- if (flash.at(i) == 0) {
- end = i;
- break;
- }
- }
- if (end > 0) {
- time = QString(flash.mid(start, (end - start))).trimmed();
- }
- else {
- time = QString("");
- }
- }
-}
-
-void FlashInterface::SeekBuild(void)
-{
- int i, start = -1, end = -1;
- start = flash.indexOf(QString(BLD_MARK));
- if (start > 0) {
- start += QString(BLD_MARK).length();
- for (i = start; i < (start + 20); i++) {
- if (flash.at(i) == 0) {
- end = i;
- break;
- }
- }
- if (end > 0) {
- build = QString(flash.mid(start, (end - start))).trimmed();
- }
- else {
- build = QString("");
- }
- }
- else {
- start = flash.indexOf(QString(VAR_MARK));
- if (start > 0) {
- start += QString(VAR_MARK).length();
- for (i = start; i < (start + 20); i++) {
- if (flash.at(i) == 0) {
- end = i;
- break;
- }
- }
- if (end > 0) {
- build = QString(flash.mid(start, (end - start))).trimmed();
- }
- else {
- build = QString("");
- }
- }
- }
+ return seekString(label + ":");
}
void FlashInterface::SeekSplash(void)
diff --git a/companion/src/flashinterface.h b/companion/src/flashinterface.h
index eb1459d85..d7f7719b7 100644
--- a/companion/src/flashinterface.h
+++ b/companion/src/flashinterface.h
@@ -14,6 +14,7 @@
#ifndef FLASHINTERFACE_H
#define FLASHINTERFACE_H
+
#include
#include
#include
@@ -32,12 +33,12 @@
#define ERSKY9X_SPS "SPS"
#define ERSKY9X_SPE "SPE"
#define ERSKY9X_OFFSET (7)
-#define VERS_MARK "VERS:"
-#define SVN_MARK "SVN:"
-#define DATE_MARK "DATE:"
-#define TIME_MARK "TIME:"
-#define BLD_MARK "BLD:"
-#define VAR_MARK "EEPR:"
+#define VERS_MARK "VERS"
+#define SVN_MARK "SVN"
+#define DATE_MARK "DATE"
+#define TIME_MARK "TIME"
+#define BLD_MARK "BLD"
+#define EEPR_MARK "EEPR"
#define FILE_TYPE_BIN 1
#define FILE_TYPE_HEX 2
@@ -49,48 +50,46 @@ int getFileType(const QString &fullFileName);
class FlashInterface
{
-public:
- FlashInterface(QString filename);
- QString getDate();
- QString getTime();
- QString getSvn();
- int getSize();
- QString getBuild();
- QImage getSplash();
- bool setSplash(const QImage & newsplash);
- bool hasSplash();
- int getSplashWidth();
- uint getSplashHeight();
- uint getSplashColors();
- QImage::Format getSplashFormat();
- uint saveFlash(QString fileName);
- bool isValid();
+ public:
+ FlashInterface(QString filename);
+ inline QString getDate() { return date; }
+ inline QString getTime() { return time; }
+ inline QString getSvn() { return svn; }
+ int getSize() { return flash_size; }
+ inline QString getVersion() { return version; }
+ inline QString getEEprom() { return eeprom; }
+ QImage getSplash();
+ bool setSplash(const QImage & newsplash);
+ bool hasSplash();
+ int getSplashWidth();
+ uint getSplashHeight();
+ uint getSplashColors();
+ QImage::Format getSplashFormat();
+ uint saveFlash(QString fileName);
+ bool isValid();
-private:
- QByteArray flash;
- void SeekVer();
- void SeekSvn();
- void SeekDate();
- void SeekTime();
- void SeekBuild();
- void SeekSplash();
- QString filename;
- QString date;
- QString time;
- QString svn;
- QString build;
- QByteArray splash;
- uint splash_offset;
- uint splash_type;
- uint splash_size;
- uint splash_width;
- uint splash_height;
- uint splash_colors;
- QImage::Format splash_format;
- uint flash_size;
-
-protected:
- bool isValidFlag;
+ private:
+ QByteArray flash;
+ QString seekString(const QString & string);
+ QString seekLabel(const QString & label);
+ void SeekSplash();
+ QString filename;
+ QString date;
+ QString time;
+ QString svn;
+ QString version;
+ QString eeprom;
+ QByteArray splash;
+ uint splash_offset;
+ uint splash_type;
+ uint splash_size;
+ uint splash_width;
+ uint splash_height;
+ uint splash_colors;
+ QImage::Format splash_format;
+ uint flash_size;
+ bool isValidFlag;
};
+
#endif /* FLASHINTERFACE_H */
diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp
index aff8ad8cc..bd13d50c3 100644
--- a/companion/src/mainwindow.cpp
+++ b/companion/src/mainwindow.cpp
@@ -1251,15 +1251,16 @@ bool MainWindow::convertEEPROM(QString backupFile, QString restoreFile, QString
if ((svnTags.at(0) == "open9x")||(svnTags.at(0) == "opentx")) {
if (revision > 1464) {
- QString fwBuild = flash.getBuild();
- if (fwBuild.contains("-")) {
- QStringList buildTags = fwBuild.split("-", QString::SkipEmptyParts);
+ QString fwEEprom = flash.getEEprom();
+ if (fwEEprom.contains("-")) {
+ QStringList buildTags = fwEEprom.split("-", QString::SkipEmptyParts);
if (buildTags.size() >= 1)
version = buildTags.at(0).toInt();
if (buildTags.size() >= 2)
variant = buildTags.at(1).toInt();
- } else {
- version = fwBuild.toInt(); // TODO changer le nom de la variable
+ }
+ else {
+ version = fwEEprom.toInt();
}
}
else {
diff --git a/radio/src/stamp.cpp b/radio/src/stamp.cpp
index cce6febc4..f4dec0b66 100644
--- a/radio/src/stamp.cpp
+++ b/radio/src/stamp.cpp
@@ -41,7 +41,9 @@
#define DEFNUMSTR(s) STR2(s)
#if defined(PCBSTD)
-const pm_char vers_stamp[] PROGMEM = "VERS\037\033: " VERS_STR "\036DATE\037\033: " DATE_STR"\036TIME\037\033: " TIME_STR "\036EEPR\037\033: " DEFNUMSTR(EEPROM_VER) "-" DEFNUMSTR(EEPROM_VARIANT);
+ #define EEPROM_STR DEFNUMSTR(EEPROM_VER) "-" DEFNUMSTR(EEPROM_VARIANT)
#else
-const pm_char vers_stamp[] PROGMEM = "VERS\037\033: " VERS_STR "\036DATE\037\033: " DATE_STR"\036TIME\037\033: " TIME_STR "\036EEPR\037\033: " DEFNUMSTR(EEPROM_VER);
+ #define EEPROM_STR DEFNUMSTR(EEPROM_VER);
#endif
+
+const pm_char vers_stamp[] PROGMEM = "VERS\037\033: " VERS_STR "\036DATE\037\033: " DATE_STR"\036TIME\037\033: " TIME_STR "\036EEPR\037\033: " EEPROM_STR;