mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-06 23:13:43 +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
|
|
@ -1 +1,2 @@
|
|||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="564e", MODE:="0666"
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="4121", MODE:="0666"
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -99,6 +99,8 @@ AppWindow::AppWindow(QWidget *parent)
|
|||
connect(ui->actionFirmware_Update, &QAction::triggered, [=](){
|
||||
if(device) {
|
||||
auto fw_update = new FirmwareUpdateDialog(device);
|
||||
connect(fw_update, &FirmwareUpdateDialog::DeviceRebooting, this, &AppWindow::DisconnectDevice);
|
||||
connect(fw_update, &FirmwareUpdateDialog::DeviceRebooted, this, &AppWindow::ConnectToDevice);
|
||||
fw_update->exec();
|
||||
}
|
||||
});
|
||||
|
|
@ -196,12 +198,16 @@ void AppWindow::DisconnectDevice()
|
|||
ui->actionDisconnect->setEnabled(false);
|
||||
ui->actionManual_Control->setEnabled(false);
|
||||
ui->actionFirmware_Update->setEnabled(false);
|
||||
for(auto a : deviceActionGroup->actions()) {
|
||||
a->setChecked(false);
|
||||
}
|
||||
if(deviceActionGroup->checkedAction()) {
|
||||
deviceActionGroup->checkedAction()->setChecked(false);
|
||||
}
|
||||
lConnectionStatus.setText("No device connected");
|
||||
lDeviceInfo.setText("No device information available yet");
|
||||
Mode::getActiveMode()->deviceDisconnected();
|
||||
qDebug() << "Disconnected device";
|
||||
}
|
||||
|
||||
void AppWindow::DeviceConnectionLost()
|
||||
|
|
@ -244,22 +250,19 @@ void AppWindow::CreateToolbars()
|
|||
|
||||
int AppWindow::UpdateDeviceList()
|
||||
{
|
||||
deviceActionGroup->setExclusive(true);
|
||||
ui->menuConnect_to->clear();
|
||||
auto devices = Device::GetDevices();
|
||||
if(devices.size()) {
|
||||
for(auto d : devices) {
|
||||
auto connectAction = ui->menuConnect_to->addAction(d);
|
||||
deviceActionGroup->addAction(connectAction);
|
||||
connectAction->setCheckable(true);
|
||||
connectAction->setActionGroup(deviceActionGroup);
|
||||
if(device && d == device->serial()) {
|
||||
connectAction->setChecked(true);
|
||||
}
|
||||
connect(connectAction, &QAction::triggered, [this, connectAction, d]() {
|
||||
connect(connectAction, &QAction::triggered, [this, d]() {
|
||||
ConnectToDevice(d);
|
||||
if(device) {
|
||||
// connectAction might have been unchecked if it was a reconnect to the already connected device
|
||||
connectAction->setChecked(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
ui->menuConnect_to->setEnabled(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue