mirror of
https://github.com/opentx/opentx.git
synced 2025-07-14 20:10:08 +03:00
Issue #782 fixed
This commit is contained in:
parent
dd7298a35b
commit
b973c5db1d
6 changed files with 115 additions and 228 deletions
|
@ -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()) {
|
||||
|
|
|
@ -113,8 +113,15 @@
|
|||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="dateLabel">
|
||||
<property name="text">
|
||||
<string>Date & Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="SVNField">
|
||||
<widget class="QLineEdit" name="versionField">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
@ -135,20 +142,13 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="svnLabel">
|
||||
<widget class="QLabel" name="versionLabel">
|
||||
<property name="text">
|
||||
<string>SVN</string>
|
||||
<string>Version</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="dateLabel">
|
||||
<property name="text">
|
||||
<string>Date & Time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="DateField">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
|
@ -360,8 +360,7 @@
|
|||
<tabstop>BurnFlashButton</tabstop>
|
||||
<tabstop>FWFileName</tabstop>
|
||||
<tabstop>FlashLoadButton</tabstop>
|
||||
<tabstop>DateField</tabstop>
|
||||
<tabstop>SVNField</tabstop>
|
||||
<tabstop>versionField</tabstop>
|
||||
<tabstop>ModField</tabstop>
|
||||
<tabstop>useProfileImageCB</tabstop>
|
||||
<tabstop>useFwImageCB</tabstop>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QtGui>
|
||||
#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<start+20; i++) {
|
||||
char c = flash.at(i);
|
||||
if (c == '\0' || c == '\036') {
|
||||
end = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (end > 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)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#ifndef FLASHINTERFACE_H
|
||||
#define FLASHINTERFACE_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QtGui>
|
||||
#include <inttypes.h>
|
||||
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue