diff --git a/.github/workflows/HIL_Tests.yml b/.github/workflows/HIL_Tests.yml index 221bc9f..ba3f096 100644 --- a/.github/workflows/HIL_Tests.yml +++ b/.github/workflows/HIL_Tests.yml @@ -56,7 +56,7 @@ jobs: needs: [PC_Application_RPi5, Embedded_Firmware] steps: - name: Run HIL tests - run: | + run: | cd Software/Integrationtests export DISPLAY=:0 python3 Integrationtest.py diff --git a/Documentation/UserManual/SCPI_Examples/libreVNA.py b/Documentation/UserManual/SCPI_Examples/libreVNA.py index c4213e1..d14a086 100755 --- a/Documentation/UserManual/SCPI_Examples/libreVNA.py +++ b/Documentation/UserManual/SCPI_Examples/libreVNA.py @@ -91,13 +91,13 @@ class libreVNA: self.sock.send(b"\n") if check or (check is None and self.default_check_cmds): status = self.get_status(timeout=timeout) - if self.get_status() & 0x20: + if status & 0x20: raise Exception("Command Error") - if self.get_status() & 0x10: + if status & 0x10: raise Exception("Execution Error") - if self.get_status() & 0x08: + if status & 0x08: raise Exception("Device Error") - if self.get_status() & 0x04: + if status & 0x04: raise Exception("Query Error") return status else: diff --git a/Software/Integrationtests/Integrationtest.py b/Software/Integrationtests/Integrationtest.py index e358ed5..e3a5100 100644 --- a/Software/Integrationtests/Integrationtest.py +++ b/Software/Integrationtests/Integrationtest.py @@ -1,6 +1,7 @@ import unittest testmodules = [ + 'tests.TestUpdate', # Must go first because it updates the connected VNA to the firwmare which should be tested 'tests.TestConnect', 'tests.TestStatusRegisters', 'tests.TestMode', diff --git a/Software/Integrationtests/tests/TestCalibration.py b/Software/Integrationtests/tests/TestCalibration.py index 65f82d4..6e93b4b 100644 --- a/Software/Integrationtests/tests/TestCalibration.py +++ b/Software/Integrationtests/tests/TestCalibration.py @@ -153,7 +153,7 @@ class TestCalibration(TestBase): # Start measurement and grab data self.vna.cmd(":VNA:ACQ:SINGLE TRUE") self.assertEqual(self.vna.query(":VNA:ACQ:FIN?"), "FALSE") - self.vna.cmd("*WAI") + self.vna.cmd("*WAI", timeout=3) self.assertEqual(self.vna.query(":VNA:ACQ:FIN?"), "TRUE") cal.reset() diff --git a/Software/Integrationtests/tests/TestRST.py b/Software/Integrationtests/tests/TestRST.py index c86021c..221b7fd 100644 --- a/Software/Integrationtests/tests/TestRST.py +++ b/Software/Integrationtests/tests/TestRST.py @@ -225,7 +225,7 @@ class TestRST(TestBase): self.vna.cmd("SA:TRACK:EN TRUE") self.vna.cmd(f"SA:TRACK:LVL {pwr_1_2}") self.vna.cmd("SA:TRACK:NORM:EN TRUE") - self.vna.cmd("SA:TRACK:NORM:LVL {pwr_1_3}") + self.vna.cmd(f"SA:TRACK:NORM:LVL {pwr_1_3}") self.vna.cmd("SA:TRACK:OFF 1.0e+6;PORT 2") self.vna.cmd("VNA:ACQ:AVG 10") self.vna.cmd(f"VNA:ACQ:IFBW {ifbw_1_2}") @@ -236,6 +236,9 @@ class TestRST(TestBase): self.vna.cmd(f"VNA:STIM:FREQ {f_1_3}") self.vna.cmd(f"VNA:STIM:LVL {pwr_min}") self.vna.cmd("VNA:SWEEP POWER") + + # We just configured a lot of settings, give some time to empty the output queue from the GUI to the device + time.sleep(2) # Reset and verify all settings revert. self.vna.cmd("*RST") diff --git a/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.h b/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.h index dde0b1f..ee52ab8 100644 --- a/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.h +++ b/Software/PC_Application/LibreVNA-GUI/SpectrumAnalyzer/spectrumanalyzer.h @@ -36,6 +36,10 @@ public: virtual void deviceInfoUpdated() override; +public slots: + void Run(); + void Stop(); + private: static QString WindowToString(DeviceDriver::SASettings::Window w); static DeviceDriver::SASettings::Window WindowFromString(QString s); @@ -70,8 +74,6 @@ private slots: void ClearNormalization(); void SetNormalizationLevel(double level); - void Run(); - void Stop(); void ConfigureDevice(); void ResetLiveTraces(); diff --git a/Software/PC_Application/LibreVNA-GUI/VNA/vna.h b/Software/PC_Application/LibreVNA-GUI/VNA/vna.h index aa2f2aa..653b553 100644 --- a/Software/PC_Application/LibreVNA-GUI/VNA/vna.h +++ b/Software/PC_Application/LibreVNA-GUI/VNA/vna.h @@ -76,6 +76,8 @@ public: }; public slots: + void Run(); + void Stop(); bool LoadCalibration(QString filename = ""); bool SaveCalibration(QString filename = ""); @@ -130,8 +132,6 @@ private slots: void EnableDeembedding(bool enable); void UpdateStatusbar(); void SetSingleSweep(bool single); - void Run(); - void Stop(); void ConfigureDevice(bool resetTraces = true, std::function cb = nullptr); void ResetLiveTraces(); private: diff --git a/Software/PC_Application/LibreVNA-GUI/appwindow.cpp b/Software/PC_Application/LibreVNA-GUI/appwindow.cpp index 5b0b367..4235b9f 100644 --- a/Software/PC_Application/LibreVNA-GUI/appwindow.cpp +++ b/Software/PC_Application/LibreVNA-GUI/appwindow.cpp @@ -322,8 +322,6 @@ void AppWindow::SetInitialState() modeHandler->createMode("Spectrum Analyzer", Mode::Type::SA); modeHandler->setCurrentIndex(vnaIndex); } - - ResetReference(); } bool AppWindow::ConnectToDevice(QString serial, DeviceDriver *driver) @@ -490,6 +488,15 @@ void AppWindow::SetupSCPI() })); scpi.add(new SCPICommand("*RST", [=](QStringList){ SetInitialState(); + auto vna = dynamic_cast(modeHandler->getActiveMode()); + if(vna) { + vna->Stop(); + } + auto sa = dynamic_cast(modeHandler->getActiveMode()); + if(sa) { + sa->Stop(); + } + ResetReference(); return SCPI::getResultName(SCPI::Result::Empty); }, nullptr)); auto scpi_dev = new SCPINode("DEVice"); @@ -529,7 +536,10 @@ void AppWindow::SetupSCPI() // not connected to any device return SCPI::getResultName(SCPI::Result::Error); } - if(!device->updateFirmware(params[0])) { + scpi.setOperationPending(true); + auto ret = device->updateFirmware(params[0]); + scpi.setOperationPending(false); + if(!ret) { // update failed return SCPI::getResultName(SCPI::Result::Error); } else { @@ -1064,8 +1074,13 @@ int AppWindow::UpdateDeviceList() void AppWindow::ResetReference() { + toolbars.reference.type->blockSignals(true); + toolbars.reference.outFreq->blockSignals(true); toolbars.reference.type->setCurrentIndex(0); toolbars.reference.outFreq->setCurrentIndex(0); + toolbars.reference.type->blockSignals(false); + toolbars.reference.outFreq->blockSignals(false); + UpdateReference(); } //void AppWindow::StartManualControl() diff --git a/Software/PC_Application/LibreVNA-GUI/scpi.h b/Software/PC_Application/LibreVNA-GUI/scpi.h index 85fa7df..c0e3b15 100644 --- a/Software/PC_Application/LibreVNA-GUI/scpi.h +++ b/Software/PC_Application/LibreVNA-GUI/scpi.h @@ -44,9 +44,9 @@ public: bool changeName(QString newname); -protected: void setOperationPending(bool pending); +protected: bool isOperationPending(); private: diff --git a/Software/VNA_embedded/Application/Hardware.cpp b/Software/VNA_embedded/Application/Hardware.cpp index 00cde2f..6bc4a24 100644 --- a/Software/VNA_embedded/Application/Hardware.cpp +++ b/Software/VNA_embedded/Application/Hardware.cpp @@ -347,7 +347,7 @@ void HW::getDeviceStatus(Protocol::DeviceStatus *status, bool updateEvenWhenBusy status->V1.LO1_locked = (FPGA_status & (int) FPGA::Interrupt::LO1Unlock) ? 0 : 1; status->V1.source_locked = (FPGA_status & (int) FPGA::Interrupt::SourceUnlock) ? 0 : 1; status->V1.extRefAvailable = Ref::available(); - status->V1.extRefInUse = extRefInUse; + status->V1.extRefInUse = Ref::usingExternal(); status->V1.unlevel = unlevel; status->V1.temp_LO1 = tempLO; status->V1.temp_source = tempSource; @@ -365,7 +365,7 @@ void HW::Ref::set(Protocol::ReferenceSettings s) { } bool HW::Ref::usingExternal() { - return extRefInUse; + return extRefInUse && (ref.UseExternalRef || ref.AutomaticSwitch); } void HW::Ref::update() {