diff --git a/Software/PC_Application/51-vna.rules b/Software/PC_Application/51-vna.rules index 6da541f..a35c97c 100644 --- a/Software/PC_Application/51-vna.rules +++ b/Software/PC_Application/51-vna.rules @@ -1 +1,2 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="564e", MODE:="0666" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="4121", MODE:="0666" diff --git a/Software/PC_Application/Application b/Software/PC_Application/Application index 1303b71..4dab255 100755 Binary files a/Software/PC_Application/Application and b/Software/PC_Application/Application differ diff --git a/Software/PC_Application/Device/device.cpp b/Software/PC_Application/Device/device.cpp index 0667365..abe079f 100644 --- a/Software/PC_Application/Device/device.cpp +++ b/Software/PC_Application/Device/device.cpp @@ -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 lck(mtx); cv.wait(lck); - qDebug() << "Cancellation complete"; } delete buffer; } diff --git a/Software/PC_Application/Device/device.h b/Software/PC_Application/Device/device.h index f21ed35..b13c28d 100644 --- a/Software/PC_Application/Device/device.h +++ b/Software/PC_Application/Device/device.h @@ -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; diff --git a/Software/PC_Application/Device/devicelog.cpp b/Software/PC_Application/Device/devicelog.cpp index e952756..297e2e2 100644 --- a/Software/PC_Application/Device/devicelog.cpp +++ b/Software/PC_Application/Device/devicelog.cpp @@ -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; } diff --git a/Software/PC_Application/Device/firmwareupdatedialog.cpp b/Software/PC_Application/Device/firmwareupdatedialog.cpp index dbc8b10..65e20f7 100644 --- a/Software/PC_Application/Device/firmwareupdatedialog.cpp +++ b/Software/PC_Application/Device/firmwareupdatedialog.cpp @@ -2,7 +2,7 @@ #include "ui_firmwareupdatedialog.h" #include -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; diff --git a/Software/PC_Application/Device/firmwareupdatedialog.h b/Software/PC_Application/Device/firmwareupdatedialog.h index 8404a62..2a59e01 100644 --- a/Software/PC_Application/Device/firmwareupdatedialog.h +++ b/Software/PC_Application/Device/firmwareupdatedialog.h @@ -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; diff --git a/Software/PC_Application/Device/manualcontroldialog.ui b/Software/PC_Application/Device/manualcontroldialog.ui index c3b0a27..e826b0e 100644 --- a/Software/PC_Application/Device/manualcontroldialog.ui +++ b/Software/PC_Application/Device/manualcontroldialog.ui @@ -523,13 +523,13 @@ 128 - 131072 + 130944 128 - 131072 + 130944 diff --git a/Software/PC_Application/appwindow.cpp b/Software/PC_Application/appwindow.cpp index 45f6bb2..f3c2a06 100644 --- a/Software/PC_Application/appwindow.cpp +++ b/Software/PC_Application/appwindow.cpp @@ -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); diff --git a/Software/VNA_embedded/.settings/language.settings.xml b/Software/VNA_embedded/.settings/language.settings.xml index 2892ea2..aadbc97 100644 --- a/Software/VNA_embedded/.settings/language.settings.xml +++ b/Software/VNA_embedded/.settings/language.settings.xml @@ -1,25 +1,48 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/VNA_embedded/Application/App.cpp b/Software/VNA_embedded/Application/App.cpp index 7556c24..4106d91 100644 --- a/Software/VNA_embedded/Application/App.cpp +++ b/Software/VNA_embedded/Application/App.cpp @@ -229,11 +229,9 @@ void App_Start() { LOG_INFO("Firmware update process triggered"); auto fw_info = Firmware::GetFlashContentInfo(&flash); if(fw_info.valid) { - Protocol::PacketInfo p; - p.type = Protocol::PacketType::Ack; - Communication::Send(p); + Communication::SendWithoutPayload(Protocol::PacketType::Ack); // Some delay to allow communication to finish - vTaskDelay(1000); + vTaskDelay(100); Firmware::PerformUpdate(&flash, fw_info); // should never get here Communication::SendWithoutPayload(Protocol::PacketType::Nack); diff --git a/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.cpp b/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.cpp index 15885c9..df43c8d 100644 --- a/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.cpp +++ b/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.cpp @@ -117,7 +117,9 @@ void FPGA::SetSamplesPerPoint(uint32_t nsamples) { // register is in multiples of 128 nsamples /= 128; // constrain to maximum value - nsamples &= 0x03FF; + if(nsamples >= 1024) { + nsamples = 1023; + } WriteRegister(Reg::SamplesPerPoint, nsamples); } diff --git a/Software/VNA_embedded/Application/Firmware.cpp b/Software/VNA_embedded/Application/Firmware.cpp index cba54bc..cfc79c1 100644 --- a/Software/VNA_embedded/Application/Firmware.cpp +++ b/Software/VNA_embedded/Application/Firmware.cpp @@ -57,7 +57,7 @@ Firmware::Info Firmware::GetFlashContentInfo(Flash *f) { } f->read(h.CPU_start + checked_size, read_size, buf); if(memcmp(buf, (void*)(0x8000000+checked_size), read_size)) { - LOG_WARN("Difference to CPU firmware in external FLASH detected, update required"); + LOG_INFO("Difference to CPU firmware in external FLASH detected, update required"); ret.CPU_need_update = true; break; } diff --git a/Software/VNA_embedded/Application/VNA.cpp b/Software/VNA_embedded/Application/VNA.cpp index 5add2b3..3f3d4e7 100644 --- a/Software/VNA_embedded/Application/VNA.cpp +++ b/Software/VNA_embedded/Application/VNA.cpp @@ -493,6 +493,11 @@ bool VNA::Ref::applySettings(Protocol::ReferenceSettings s) { } bool VNA::ConfigureGenerator(Protocol::GeneratorSettings g) { + if(g.activePort == 0) { + // both ports disabled, no need to configure PLLs + SetIdle(); + return true; + } Protocol::ManualControl m; // LOs not required m.LO1CE = 0; @@ -533,13 +538,6 @@ bool VNA::ConfigureGenerator(Protocol::GeneratorSettings g) { m.SourceHighband = true; } switch(g.activePort) { - case 0: - // no output signal, disable - m.AmplifierEN = 0; - m.SourceHighCE = 0; - m.SourceHighRFEN = 0; - m.SourceLowEN = 0; - break; case 1: m.AmplifierEN = 1; m.PortSwitch = 0;