mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-06 15:04:11 +00:00
Bugfixes
- Firmware update device reattachment - Disconnect/connect with multiple devices - udev rule extended
This commit is contained in:
parent
2d44201de7
commit
44124bc09e
14 changed files with 90 additions and 66 deletions
|
|
@ -8,6 +8,15 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
using USBID = struct {
|
||||
int VID;
|
||||
int PID;
|
||||
};
|
||||
static constexpr USBID IDs[] = {
|
||||
{0x0483, 0x564e},
|
||||
{0x0483, 0x4121},
|
||||
};
|
||||
|
||||
USBInBuffer::USBInBuffer(libusb_device_handle *handle, unsigned char endpoint, int buffer_size) :
|
||||
buffer_size(buffer_size),
|
||||
received_size(0),
|
||||
|
|
@ -22,13 +31,11 @@ USBInBuffer::USBInBuffer(libusb_device_handle *handle, unsigned char endpoint, i
|
|||
USBInBuffer::~USBInBuffer()
|
||||
{
|
||||
if(transfer) {
|
||||
qDebug() << "Start cancellation";
|
||||
libusb_cancel_transfer(transfer);
|
||||
// wait for cancellation to complete
|
||||
mutex mtx;
|
||||
unique_lock<mutex> lck(mtx);
|
||||
cv.wait(lck);
|
||||
qDebug() << "Cancellation complete";
|
||||
}
|
||||
delete buffer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,14 +82,6 @@ private slots:
|
|||
}
|
||||
|
||||
private:
|
||||
using USBID = struct {
|
||||
int VID;
|
||||
int PID;
|
||||
};
|
||||
static constexpr USBID IDs[] = {
|
||||
{0x0483, 0x5640},
|
||||
{0x0483, 0x4121},
|
||||
};
|
||||
static constexpr int EP_Data_Out_Addr = 0x01;
|
||||
static constexpr int EP_Data_In_Addr = 0x81;
|
||||
static constexpr int EP_Log_In_Addr = 0x82;
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ void DeviceLog::addLine(QString line)
|
|||
if(line.contains(",CRT]")) {
|
||||
color = Qt::red;
|
||||
} else if(line.contains(",ERR]")) {
|
||||
color = QColor("orange");
|
||||
color = QColor(255, 94, 0);
|
||||
} else if(line.contains(",WRN]")) {
|
||||
color = Qt::darkYellow;
|
||||
color = QColor(255, 174, 26);
|
||||
} else if(line.contains(",DBG")) {
|
||||
color = Qt::gray;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "ui_firmwareupdatedialog.h"
|
||||
#include <QFileDialog>
|
||||
|
||||
FirmwareUpdateDialog::FirmwareUpdateDialog(Device *&dev, QWidget *parent) :
|
||||
FirmwareUpdateDialog::FirmwareUpdateDialog(Device *dev, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::FirmwareUpdateDialog),
|
||||
dev(dev),
|
||||
|
|
@ -98,12 +98,9 @@ void FirmwareUpdateDialog::timerCallback()
|
|||
auto devices = Device::GetDevices();
|
||||
if(devices.find(serialnumber) != devices.end()) {
|
||||
// the device rebooted and is available again
|
||||
dev = new Device(serialnumber);
|
||||
addStatus("...device reattached, update complete");
|
||||
addStatus("...device enumerated, update complete");
|
||||
timer.stop();
|
||||
ui->bStart->setEnabled(true);
|
||||
disconnect(dev, &Device::AckReceived, this, &FirmwareUpdateDialog::receivedAck);
|
||||
disconnect(dev, &Device::NackReceived, this, &FirmwareUpdateDialog::receivedNack);
|
||||
emit DeviceRebooted(serialnumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -139,11 +136,10 @@ void FirmwareUpdateDialog::receivedAck()
|
|||
case State::TriggeringUpdate:
|
||||
addStatus("Rebooting device...");
|
||||
serialnumber = dev->serial();
|
||||
delete dev;
|
||||
dev = nullptr;
|
||||
emit DeviceRebooting();
|
||||
state = State::WaitingForReboot;
|
||||
timer.setSingleShot(false);
|
||||
timer.start(1000);
|
||||
timer.start(2000);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -22,9 +22,13 @@ public:
|
|||
* - If the update fails during device reboot, the device pointer is set to zero and the device deleted
|
||||
* - If the update succeeds, the device pointer will be set to the new device instance
|
||||
*/
|
||||
explicit FirmwareUpdateDialog(Device *&dev, QWidget *parent = nullptr);
|
||||
explicit FirmwareUpdateDialog(Device *dev, QWidget *parent = nullptr);
|
||||
~FirmwareUpdateDialog();
|
||||
|
||||
signals:
|
||||
void DeviceRebooting(); // emitted when the update process is triggered, the device should be disconnected
|
||||
void DeviceRebooted(QString serial); // emitted when an updated device is enumerated after the update
|
||||
|
||||
private slots:
|
||||
void on_bFile_clicked();
|
||||
void on_bStart_clicked();
|
||||
|
|
@ -37,7 +41,7 @@ private:
|
|||
void abortWithError(QString error);
|
||||
void sendNextFirmwareChunk();
|
||||
Ui::FirmwareUpdateDialog *ui;
|
||||
Device *&dev;
|
||||
Device *dev;
|
||||
QFile *file;
|
||||
QTimer timer;
|
||||
|
||||
|
|
|
|||
|
|
@ -523,13 +523,13 @@
|
|||
<number>128</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>131072</number>
|
||||
<number>130944</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>128</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>131072</number>
|
||||
<number>130944</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue