Skip to content

Commit

Permalink
Stop sweep after reset, fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jankae committed Apr 22, 2024
1 parent c5d0453 commit 0fc6c91
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/HIL_Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Documentation/UserManual/SCPI_Examples/libreVNA.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ def cmd(self, cmd, check=None, timeout=None):
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:
Expand Down
1 change: 1 addition & 0 deletions Software/Integrationtests/Integrationtest.py
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 1 addition & 1 deletion Software/Integrationtests/tests/TestCalibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_SOLT_calibration(self):
# 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()
Expand Down
5 changes: 4 additions & 1 deletion Software/Integrationtests/tests/TestRST.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def test_rst_hard(self):
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}")
Expand All @@ -236,6 +236,9 @@ def test_rst_hard(self):
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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class SpectrumAnalyzer : public Mode

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);
Expand Down Expand Up @@ -70,8 +74,6 @@ private slots:
void ClearNormalization();
void SetNormalizationLevel(double level);

void Run();
void Stop();
void ConfigureDevice();
void ResetLiveTraces();

Expand Down
4 changes: 2 additions & 2 deletions Software/PC_Application/LibreVNA-GUI/VNA/vna.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class VNA : public Mode
};

public slots:
void Run();
void Stop();
bool LoadCalibration(QString filename = "");
bool SaveCalibration(QString filename = "");

Expand Down Expand Up @@ -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<void(bool)> cb = nullptr);
void ResetLiveTraces();
private:
Expand Down
21 changes: 18 additions & 3 deletions Software/PC_Application/LibreVNA-GUI/appwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -490,6 +488,15 @@ void AppWindow::SetupSCPI()
}));
scpi.add(new SCPICommand("*RST", [=](QStringList){
SetInitialState();
auto vna = dynamic_cast<VNA*>(modeHandler->getActiveMode());
if(vna) {
vna->Stop();
}
auto sa = dynamic_cast<SpectrumAnalyzer*>(modeHandler->getActiveMode());
if(sa) {
sa->Stop();
}
ResetReference();
return SCPI::getResultName(SCPI::Result::Empty);
}, nullptr));
auto scpi_dev = new SCPINode("DEVice");
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Software/PC_Application/LibreVNA-GUI/scpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class SCPINode {

bool changeName(QString newname);

protected:
void setOperationPending(bool pending);

protected:
bool isOperationPending();

private:
Expand Down
4 changes: 2 additions & 2 deletions Software/VNA_embedded/Application/Hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down

0 comments on commit 0fc6c91

Please sign in to comment.