mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 04:15:26 +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->BurnFlashButton->setDisabled(true);
|
||||||
ui->FWFileName->clear();
|
ui->FWFileName->clear();
|
||||||
ui->DateField->clear();
|
ui->DateField->clear();
|
||||||
ui->SVNField->clear();
|
ui->versionField->clear();
|
||||||
ui->ModField->clear();
|
ui->ModField->clear();
|
||||||
ui->FramFWInfo->hide();
|
ui->FramFWInfo->hide();
|
||||||
ui->SplashFrame->hide();
|
ui->SplashFrame->hide();
|
||||||
|
@ -132,7 +132,7 @@ void burnDialog::on_FlashLoadButton_clicked()
|
||||||
ui->BurnFlashButton->setDisabled(true);
|
ui->BurnFlashButton->setDisabled(true);
|
||||||
ui->FWFileName->clear();
|
ui->FWFileName->clear();
|
||||||
ui->DateField->clear();
|
ui->DateField->clear();
|
||||||
ui->SVNField->clear();
|
ui->versionField->clear();
|
||||||
ui->ModField->clear();
|
ui->ModField->clear();
|
||||||
ui->FramFWInfo->hide();
|
ui->FramFWInfo->hide();
|
||||||
ui->SplashFrame->hide();
|
ui->SplashFrame->hide();
|
||||||
|
@ -192,8 +192,8 @@ void burnDialog::checkFw(QString fileName)
|
||||||
if (flash.isValid()) {
|
if (flash.isValid()) {
|
||||||
ui->FramFWInfo->show();
|
ui->FramFWInfo->show();
|
||||||
ui->DateField->setText(flash.getDate() + " " + flash.getTime());
|
ui->DateField->setText(flash.getDate() + " " + flash.getTime());
|
||||||
ui->SVNField->setText(flash.getSvn());
|
ui->versionField->setText(flash.getVersion().isEmpty() ? flash.getSvn() : flash.getVersion());
|
||||||
ui->ModField->setText(flash.getBuild());
|
ui->ModField->setText(flash.getEEprom());
|
||||||
|
|
||||||
ui->SplashFrame->hide();
|
ui->SplashFrame->hide();
|
||||||
if (flash.hasSplash()) {
|
if (flash.hasSplash()) {
|
||||||
|
|
|
@ -113,8 +113,15 @@
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_5">
|
<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">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="SVNField">
|
<widget class="QLineEdit" name="versionField">
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -135,20 +142,13 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="svnLabel">
|
<widget class="QLabel" name="versionLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>SVN</string>
|
<string>Version</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="3" column="1">
|
||||||
<widget class="QLabel" name="dateLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Date & Time</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLineEdit" name="DateField">
|
<widget class="QLineEdit" name="DateField">
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -360,8 +360,7 @@
|
||||||
<tabstop>BurnFlashButton</tabstop>
|
<tabstop>BurnFlashButton</tabstop>
|
||||||
<tabstop>FWFileName</tabstop>
|
<tabstop>FWFileName</tabstop>
|
||||||
<tabstop>FlashLoadButton</tabstop>
|
<tabstop>FlashLoadButton</tabstop>
|
||||||
<tabstop>DateField</tabstop>
|
<tabstop>versionField</tabstop>
|
||||||
<tabstop>SVNField</tabstop>
|
|
||||||
<tabstop>ModField</tabstop>
|
<tabstop>ModField</tabstop>
|
||||||
<tabstop>useProfileImageCB</tabstop>
|
<tabstop>useProfileImageCB</tabstop>
|
||||||
<tabstop>useFwImageCB</tabstop>
|
<tabstop>useFwImageCB</tabstop>
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "hexinterface.h"
|
#include "hexinterface.h"
|
||||||
#include "splash.h"
|
#include "splash.h"
|
||||||
|
@ -20,192 +21,77 @@
|
||||||
|
|
||||||
int getFileType(const QString &fullFileName)
|
int getFileType(const QString &fullFileName)
|
||||||
{
|
{
|
||||||
if(QFileInfo(fullFileName).suffix().toUpper()=="HEX") return FILE_TYPE_HEX;
|
QString suffix = QFileInfo(fullFileName).suffix().toUpper();
|
||||||
if(QFileInfo(fullFileName).suffix().toUpper()=="BIN") return FILE_TYPE_BIN;
|
if (suffix == "HEX")
|
||||||
if(QFileInfo(fullFileName).suffix().toUpper()=="EEPM") return FILE_TYPE_EEPM;
|
return FILE_TYPE_HEX;
|
||||||
if(QFileInfo(fullFileName).suffix().toUpper()=="EEPE") return FILE_TYPE_EEPE;
|
else if (suffix == "BIN")
|
||||||
if(QFileInfo(fullFileName).suffix().toUpper()=="XML") return FILE_TYPE_XML;
|
return FILE_TYPE_BIN;
|
||||||
return 0;
|
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);
|
QFile file(fileName);
|
||||||
flash_size=0;
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { //reading HEX TEXT file
|
|
||||||
isValidFlag = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QTextStream inputStream(&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();
|
file.close();
|
||||||
inputStream.reset();
|
|
||||||
if (flash_size == 0) {
|
if (flash_size == 0) {
|
||||||
QFile file(fileName);
|
|
||||||
file.open(QIODevice::ReadOnly);
|
file.open(QIODevice::ReadOnly);
|
||||||
char * bin_flash = (char *)malloc(MAX_FSIZE);
|
flash_size = file.read((char *)flash.data(), 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);
|
|
||||||
}
|
}
|
||||||
if (flash_size > 0) {
|
if (flash_size > 0) {
|
||||||
SeekSvn();
|
svn = seekLabel(SVN_MARK);
|
||||||
SeekDate();
|
version = seekLabel(VERS_MARK);
|
||||||
SeekTime();
|
date = seekLabel(DATE_MARK);
|
||||||
SeekBuild();
|
time = seekLabel(TIME_MARK);
|
||||||
|
eeprom = seekLabel(EEPR_MARK);
|
||||||
SeekSplash();
|
SeekSplash();
|
||||||
}
|
isValidFlag = true;
|
||||||
else {
|
|
||||||
isValidFlag = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FlashInterface::getDate(void)
|
QString FlashInterface::seekString(const QString & string)
|
||||||
{
|
{
|
||||||
return date;
|
QString result = "";
|
||||||
}
|
|
||||||
|
|
||||||
QString FlashInterface::getTime(void)
|
int start = flash.indexOf(string);
|
||||||
{
|
|
||||||
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));
|
|
||||||
if (start > 0) {
|
if (start > 0) {
|
||||||
start += QString(SVN_MARK).length();
|
start += string.length();
|
||||||
for (i = start; i < (start + 20); i++) {
|
int end = -1;
|
||||||
if (flash.at(i) == 0) {
|
for (int i=start; i<start+20; i++) {
|
||||||
|
char c = flash.at(i);
|
||||||
|
if (c == '\0' || c == '\036') {
|
||||||
end = i;
|
end = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (end > 0) {
|
if (end > 0) {
|
||||||
svn = QString(flash.mid(start, (end - start))).trimmed();
|
result = flash.mid(start, (end - start)).trimmed();
|
||||||
}
|
|
||||||
else {
|
|
||||||
svn = QString("");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlashInterface::SeekDate(void)
|
QString FlashInterface::seekLabel(const QString & label)
|
||||||
{
|
{
|
||||||
int i, start = -1, end = -1, startsvn=0;
|
QString result = seekString(label + "\037\033:");
|
||||||
startsvn = flash.indexOf(QString(SVN_MARK));
|
if (!result.isEmpty())
|
||||||
if (startsvn>0) {
|
return result;
|
||||||
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("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FlashInterface::SeekTime(void)
|
return seekString(label + ":");
|
||||||
{
|
|
||||||
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("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlashInterface::SeekSplash(void)
|
void FlashInterface::SeekSplash(void)
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#ifndef FLASHINTERFACE_H
|
#ifndef FLASHINTERFACE_H
|
||||||
#define FLASHINTERFACE_H
|
#define FLASHINTERFACE_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
@ -32,12 +33,12 @@
|
||||||
#define ERSKY9X_SPS "SPS"
|
#define ERSKY9X_SPS "SPS"
|
||||||
#define ERSKY9X_SPE "SPE"
|
#define ERSKY9X_SPE "SPE"
|
||||||
#define ERSKY9X_OFFSET (7)
|
#define ERSKY9X_OFFSET (7)
|
||||||
#define VERS_MARK "VERS:"
|
#define VERS_MARK "VERS"
|
||||||
#define SVN_MARK "SVN:"
|
#define SVN_MARK "SVN"
|
||||||
#define DATE_MARK "DATE:"
|
#define DATE_MARK "DATE"
|
||||||
#define TIME_MARK "TIME:"
|
#define TIME_MARK "TIME"
|
||||||
#define BLD_MARK "BLD:"
|
#define BLD_MARK "BLD"
|
||||||
#define VAR_MARK "EEPR:"
|
#define EEPR_MARK "EEPR"
|
||||||
|
|
||||||
#define FILE_TYPE_BIN 1
|
#define FILE_TYPE_BIN 1
|
||||||
#define FILE_TYPE_HEX 2
|
#define FILE_TYPE_HEX 2
|
||||||
|
@ -49,48 +50,46 @@ int getFileType(const QString &fullFileName);
|
||||||
|
|
||||||
class FlashInterface
|
class FlashInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FlashInterface(QString filename);
|
FlashInterface(QString filename);
|
||||||
QString getDate();
|
inline QString getDate() { return date; }
|
||||||
QString getTime();
|
inline QString getTime() { return time; }
|
||||||
QString getSvn();
|
inline QString getSvn() { return svn; }
|
||||||
int getSize();
|
int getSize() { return flash_size; }
|
||||||
QString getBuild();
|
inline QString getVersion() { return version; }
|
||||||
QImage getSplash();
|
inline QString getEEprom() { return eeprom; }
|
||||||
bool setSplash(const QImage & newsplash);
|
QImage getSplash();
|
||||||
bool hasSplash();
|
bool setSplash(const QImage & newsplash);
|
||||||
int getSplashWidth();
|
bool hasSplash();
|
||||||
uint getSplashHeight();
|
int getSplashWidth();
|
||||||
uint getSplashColors();
|
uint getSplashHeight();
|
||||||
QImage::Format getSplashFormat();
|
uint getSplashColors();
|
||||||
uint saveFlash(QString fileName);
|
QImage::Format getSplashFormat();
|
||||||
bool isValid();
|
uint saveFlash(QString fileName);
|
||||||
|
bool isValid();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QByteArray flash;
|
QByteArray flash;
|
||||||
void SeekVer();
|
QString seekString(const QString & string);
|
||||||
void SeekSvn();
|
QString seekLabel(const QString & label);
|
||||||
void SeekDate();
|
void SeekSplash();
|
||||||
void SeekTime();
|
QString filename;
|
||||||
void SeekBuild();
|
QString date;
|
||||||
void SeekSplash();
|
QString time;
|
||||||
QString filename;
|
QString svn;
|
||||||
QString date;
|
QString version;
|
||||||
QString time;
|
QString eeprom;
|
||||||
QString svn;
|
QByteArray splash;
|
||||||
QString build;
|
uint splash_offset;
|
||||||
QByteArray splash;
|
uint splash_type;
|
||||||
uint splash_offset;
|
uint splash_size;
|
||||||
uint splash_type;
|
uint splash_width;
|
||||||
uint splash_size;
|
uint splash_height;
|
||||||
uint splash_width;
|
uint splash_colors;
|
||||||
uint splash_height;
|
QImage::Format splash_format;
|
||||||
uint splash_colors;
|
uint flash_size;
|
||||||
QImage::Format splash_format;
|
bool isValidFlag;
|
||||||
uint flash_size;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool isValidFlag;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FLASHINTERFACE_H */
|
#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 ((svnTags.at(0) == "open9x")||(svnTags.at(0) == "opentx")) {
|
||||||
if (revision > 1464) {
|
if (revision > 1464) {
|
||||||
QString fwBuild = flash.getBuild();
|
QString fwEEprom = flash.getEEprom();
|
||||||
if (fwBuild.contains("-")) {
|
if (fwEEprom.contains("-")) {
|
||||||
QStringList buildTags = fwBuild.split("-", QString::SkipEmptyParts);
|
QStringList buildTags = fwEEprom.split("-", QString::SkipEmptyParts);
|
||||||
if (buildTags.size() >= 1)
|
if (buildTags.size() >= 1)
|
||||||
version = buildTags.at(0).toInt();
|
version = buildTags.at(0).toInt();
|
||||||
if (buildTags.size() >= 2)
|
if (buildTags.size() >= 2)
|
||||||
variant = buildTags.at(1).toInt();
|
variant = buildTags.at(1).toInt();
|
||||||
} else {
|
}
|
||||||
version = fwBuild.toInt(); // TODO changer le nom de la variable
|
else {
|
||||||
|
version = fwEEprom.toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -41,7 +41,9 @@
|
||||||
#define DEFNUMSTR(s) STR2(s)
|
#define DEFNUMSTR(s) STR2(s)
|
||||||
|
|
||||||
#if defined(PCBSTD)
|
#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
|
#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
|
#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