Allow firmware update with invalid magic header after user confirmation
This commit is contained in:
parent
ee8188775a
commit
ee16dbc070
@ -2,6 +2,7 @@
|
||||
|
||||
#include "ui_firmwareupdatedialog.h"
|
||||
#include "../../VNA_embedded/Application/Communication/PacketConstants.h"
|
||||
#include "CustomWidgets/informationbox.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QStyle>
|
||||
@ -60,8 +61,25 @@ void FirmwareUpdateDialog::on_bStart_clicked()
|
||||
char header[24];
|
||||
file->read(header, sizeof(header));
|
||||
if(strncmp(header, dev->getFirmwareMagicString().toStdString().c_str(), 4)) {
|
||||
abortWithError("Invalid magic header constant");
|
||||
return;
|
||||
// might be a firmware file for a wrong LibreVNA
|
||||
if(dev->getProtocolVersion() == Protocol::Version) {
|
||||
// we are talking to a LibreVNA with the correct protocol, this is definitely the wrong firmware file
|
||||
abortWithError("Invalid magic header constant");
|
||||
return;
|
||||
} else {
|
||||
// we might be talking to the correct hardware but with the wrong protocol version (which might result
|
||||
// in the magic string check falsely failing. Process after user confirmation
|
||||
auto confirm = InformationBox::AskQuestion("Continue?", "The firmware magic header constant does not match the expected"
|
||||
" value for your LibreVNA. Either this is the wrong firmware file"
|
||||
" or the hardware ID of your LibreVNA was read incorrectly. This"
|
||||
" can happen if the LibreVNA uses a different protocol version than"
|
||||
" what it expected by the GUI. Do you want to continue with the firmware update?", true);
|
||||
if(!confirm) {
|
||||
abortWithError("Aborted by user");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
file->seek(0);
|
||||
state = State::ErasingFLASH;
|
||||
|
@ -114,6 +114,7 @@ LibreVNADriver::LibreVNADriver()
|
||||
skipOwnPacketHandling = false;
|
||||
SApoints = 0;
|
||||
hardwareVersion = 0;
|
||||
protocolVersion = 0;
|
||||
setSynchronization(Synchronization::Disabled, false);
|
||||
|
||||
auto manual = new QAction("Manual Control");
|
||||
@ -589,6 +590,7 @@ void LibreVNADriver::handleReceivedPacket(const Protocol::PacketInfo &packet)
|
||||
switch(packet.type) {
|
||||
case Protocol::PacketType::DeviceInfo: {
|
||||
// Check protocol version
|
||||
protocolVersion = packet.info.ProtocolVersion;
|
||||
if(packet.info.ProtocolVersion != Protocol::Version) {
|
||||
auto ret = InformationBox::AskQuestion("Warning",
|
||||
"The device reports a different protocol"
|
||||
@ -703,6 +705,11 @@ QString LibreVNADriver::hardwareVersionToString(uint8_t version)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int LibreVNADriver::getProtocolVersion() const
|
||||
{
|
||||
return protocolVersion;
|
||||
}
|
||||
|
||||
unsigned int LibreVNADriver::getMaxAmplitudePoints() const
|
||||
{
|
||||
return limits_maxAmplitudePoints;
|
||||
|
@ -184,6 +184,8 @@ public:
|
||||
|
||||
QString getFirmwareMagicString();
|
||||
|
||||
unsigned int getProtocolVersion() const;
|
||||
|
||||
signals:
|
||||
void receivedAnswer(const LibreVNADriver::TransmissionResult &result);
|
||||
void receivedPacket(const Protocol::PacketInfo& packet);
|
||||
@ -194,6 +196,7 @@ protected:
|
||||
QString hardwareVersionToString(uint8_t version);
|
||||
|
||||
bool connected;
|
||||
unsigned int protocolVersion;
|
||||
QString serial;
|
||||
Info info;
|
||||
uint8_t hardwareVersion;
|
||||
|
Loading…
Reference in New Issue
Block a user