fix(cpn): ensure hardware definitions are loaded when reading binary files (#5037)
This commit is contained in:
@@ -141,6 +141,16 @@ const char * OpenTxEepromInterface::getName()
|
|||||||
|
|
||||||
bool OpenTxEepromInterface::loadRadioSettingsFromRLE(GeneralSettings & settings, RleFile * rleFile, uint8_t version)
|
bool OpenTxEepromInterface::loadRadioSettingsFromRLE(GeneralSettings & settings, RleFile * rleFile, uint8_t version)
|
||||||
{
|
{
|
||||||
|
// Companion loads the current profile firmware and associated board hardware definition ONLY!!!!
|
||||||
|
// For each OpenTxEepromInterface create a firmware variant to force the associated base firmware board hardware definition to be loaded.
|
||||||
|
// Note: The base firmware instance does not do load its hardware definition to save unnecessary processing.
|
||||||
|
// To create the variant take the base id and append the language from the current radio profile.
|
||||||
|
Firmware *fw = Firmware::getFirmwareForId(firmware->getId().append("-%1").arg(g.currentProfile().fwType().split('-').last()));
|
||||||
|
if (!fw) {
|
||||||
|
qWarning() << " error unable to create firmware variant";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray data(sizeof(settings), 0); // GeneralSettings should be always bigger than the EEPROM struct
|
QByteArray data(sizeof(settings), 0); // GeneralSettings should be always bigger than the EEPROM struct
|
||||||
OpenTxGeneralData open9xSettings(settings, board, version);
|
OpenTxGeneralData open9xSettings(settings, board, version);
|
||||||
efile->openRd(FILE_GENERAL);
|
efile->openRd(FILE_GENERAL);
|
||||||
@@ -194,6 +204,16 @@ bool OpenTxEepromInterface::saveToByteArray(const T & src, QByteArray & data, ui
|
|||||||
template <class T, class M>
|
template <class T, class M>
|
||||||
bool OpenTxEepromInterface::loadFromByteArray(T & dest, const QByteArray & data, uint8_t version, uint32_t variant)
|
bool OpenTxEepromInterface::loadFromByteArray(T & dest, const QByteArray & data, uint8_t version, uint32_t variant)
|
||||||
{
|
{
|
||||||
|
// Companion loads the current profile firmware and associated board hardware definition ONLY!!!!
|
||||||
|
// For each OpenTxEepromInterface create a firmware variant to force the associated base firmware board hardware definition to be loaded.
|
||||||
|
// Note: The base firmware instance does not do load its hardware definition to save unnecessary processing.
|
||||||
|
// To create the variant take the base id and append the language from the current radio profile.
|
||||||
|
Firmware *fw = Firmware::getFirmwareForId(firmware->getId().append("-%1").arg(g.currentProfile().fwType().split('-').last()));
|
||||||
|
if (!fw) {
|
||||||
|
qWarning() << " error unable to create firmware variant";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
M manager(dest, board, version, variant);
|
M manager(dest, board, version, variant);
|
||||||
if (manager.Import(data) != 0) {
|
if (manager.Import(data) != 0) {
|
||||||
return false;
|
return false;
|
||||||
@@ -216,8 +236,9 @@ bool OpenTxEepromInterface::loadFromByteArray(T & dest, const QByteArray & data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (board != getCurrentBoard()) {
|
if (Boards::getFourCC(board) == Boards::getFourCC(getCurrentBoard()) &&
|
||||||
qDebug() << QString("%1: not a match to profile %2").arg(getName()).arg(Boards::getBoardName(getCurrentBoard()));
|
board != getCurrentFirmware()->getBoard()) {
|
||||||
|
qDebug() << QString("%1: Fourcc not unique and does not match profile board: %2").arg(getName()).arg(Boards::getBoardName(getCurrentBoard()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user