[Companion] Fixes #4777 (#4860)

This commit is contained in:
Bertrand Songis
2017-04-26 21:43:35 +02:00
committed by GitHub
parent f10bad7abe
commit 3aceed62c9
5 changed files with 37 additions and 39 deletions
@@ -1595,7 +1595,7 @@ class CurvesField: public TransformedField {
for (int i=0; i<maxCurves; i++) {
CurveData * curve = &curves[i];
if (!IS_STM32(board) || version < 216) {
if (!IS_ARM(board) || (!IS_STM32(board) && version < 218) || version < 216) {
int * next = &_points[5*(i+1) + _curves[i]];
int size = next - cur;
if (size % 2 == 0) {
@@ -26,6 +26,7 @@
#include <QMessageBox>
#include <QTime>
#include <QUrl>
#include <companion/src/storage/storage.h>
using namespace Board;
@@ -95,30 +96,6 @@ const char * OpenTxEepromInterface::getName()
}
}
uint32_t OpenTxEepromInterface::getFourCC()
{
switch (board) {
case BOARD_X12S:
case BOARD_X10:
return 0x3478746F;
case BOARD_TARANIS_X7:
return 0x3678746F;
case BOARD_TARANIS_X9E:
return 0x3578746F;
case BOARD_TARANIS_X9D:
case BOARD_TARANIS_X9DP:
return 0x3378746F;
case BOARD_SKY9X:
case BOARD_AR9X:
return 0x3278746F;
case BOARD_MEGA2560:
case BOARD_GRUVIN9X:
return 0x3178746F;
default:
return 0;
}
}
bool OpenTxEepromInterface::loadRadioSettingsFromRLE(GeneralSettings & settings, RleFile * rleFile, uint8_t version)
{
QByteArray data(sizeof(settings), 0); // GeneralSettings should be always bigger than the EEPROM struct
@@ -163,7 +140,7 @@ bool OpenTxEepromInterface::saveToByteArray(const T & src, QByteArray & data, ui
// manager.Dump();
manager.Export(raw);
data.resize(8);
*((uint32_t*)&data.data()[0]) = getFourCC();
*((uint32_t*)&data.data()[0]) = StorageFormat::getFourCC(board);
data[4] = version;
data[5] = 'M';
*((uint16_t*)&data.data()[6]) = raw.size();
@@ -186,12 +163,12 @@ template <class T, class M>
bool OpenTxEepromInterface::loadFromByteArray(T & dest, const QByteArray & data)
{
uint32_t fourcc = *((uint32_t*)&data.data()[0]);
if (getFourCC() != fourcc) {
if (StorageFormat::getFourCC(board) != fourcc) {
if (IS_HORUS(board) && fourcc == 0x3178396F) {
qDebug() << QString().sprintf("%s: Deprecated fourcc used %x vs %x", getName(), fourcc, getFourCC());
qDebug() << QString().sprintf("%s: Deprecated fourcc used %x vs %x", getName(), fourcc, StorageFormat::getFourCC(board));
}
else {
qDebug() << QString().sprintf("%s: Wrong fourcc %x vs %x", getName(), fourcc, getFourCC());
qDebug() << QString().sprintf("%s: Wrong fourcc %x vs %x", getName(), fourcc, StorageFormat::getFourCC(board));
return false;
}
}
@@ -72,8 +72,6 @@ class OpenTxEepromInterface : public EEPROMInterface
uint8_t getLastDataVersion(Board::Type board);
uint32_t getFourCC();
RleFile * efile;
OpenTxFirmware * firmware;
+1 -1
View File
@@ -702,7 +702,7 @@ void MdiChild::onFirmwareChanged()
Firmware * previous = firmware;
firmware = getCurrentFirmware();
//qDebug() << "onFirmwareChanged" << previous->getName() << "=>" << firmware->getName();
if (previous->getBoard() != firmware->getBoard()) {
if (StorageFormat::getFourCC(previous->getBoard()) != StorageFormat::getFourCC(firmware->getBoard())) {
convertStorage(previous->getBoard(), firmware->getBoard());
setModified();
}
+30 -7
View File
@@ -67,15 +67,38 @@ class StorageFormat
return board;
}
static uint32_t getFourCC(Board::Type board)
{
switch (board) {
case Board::BOARD_X12S:
case Board::BOARD_X10:
return 0x3478746F;
case Board::BOARD_TARANIS_X7:
return 0x3678746F;
case Board::BOARD_TARANIS_X9E:
return 0x3578746F;
case Board::BOARD_TARANIS_X9D:
case Board::BOARD_TARANIS_X9DP:
return 0x3378746F;
case Board::BOARD_SKY9X:
case Board::BOARD_AR9X:
return 0x3278746F;
case Board::BOARD_MEGA2560:
case Board::BOARD_GRUVIN9X:
return 0x3178746F;
default:
return 0;
}
}
uint32_t getFourCC()
{
return getFourCC(board);
}
virtual bool isBoardCompatible(Board::Type board)
{
if (this->board == board)
return true;
if (IS_TARANIS_X9D(this->board) && IS_TARANIS_X9D(board))
return true;
return false;
return getFourCC() == getFourCC(board);
}
protected: