Merge branch 'master' of github.com:jankae/LibreVNA

This commit is contained in:
Jan Käberich 2023-09-05 11:13:13 +02:00
commit 5a78091f2b
9 changed files with 38 additions and 17 deletions

View File

@ -174,7 +174,7 @@ This document describes the device protocol of the LibreVNA. This is the protoco
Depending on the LibreVNA, different hardware interfaces may be used for the implementation of this protocol.
\subsection{USB device}
The LibreVNA implements a ``custom class'' USB device. It uses a VID of 0x0483 and a PID of 0x4121. The custom class contains a single interface with three bulk endpoints:
The LibreVNA implements a ``custom class'' USB device. It uses a VID of 0x1209 and a PID of 0x4121. The custom class contains a single interface with three bulk endpoints:
\begin{itemize}
\item \textbf{Endpoint 0x01:} Communication data from the USB host to the LibreVNA
\item \textbf{Endpoint 0x81:} Communication data from the LibreVNA to the USB host
@ -766,7 +766,7 @@ The packet contains the following fields:
%\insertTableNotes % tell LaTeX where to insert the table-related notes
\endlastfoot
0 & 2 & UINT16 & ProtocolVersion & Set to 12. If another value is reported, refer to the corresponding protocol description.\\
0 & 2 & UINT16 & ProtocolVersion & Set to 13. If another value is reported, refer to the corresponding protocol description.\\
2 & 1 & UINT8 & FW\_major & Major firmware version \\
3 & 1 & UINT8 & FW\_minor & Minor firmware version \\
4 & 1 & UINT8 & FW\_patch & Patch of the firmware version \\

View File

@ -17,7 +17,7 @@ This is the improved version of my [first attempt](https://www.github.com/jankae
* Download the latest [Release](https://github.com/jankae/LibreVNA/releases) and unpack the zip file
* Install the required libraries:
```console
sudo apt install libqt6widgets6
sudo apt install libqt6widgets6 libqt6svg6
```
* Install the udev rule (otherwise you don't have the permissions to access the USB device):
```console

View File

@ -1,2 +1,3 @@
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="564e", MODE:="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="4121", MODE:="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="4121", MODE:="0666"

View File

@ -414,3 +414,14 @@ void Calkit::fromJSON(nlohmann::json j)
standards.push_back(s);
}
}
void Calkit::setIdealDefault()
{
manufacturer = "LibreVNA";
description = "Default calibration kit with ideal standards";
clearStandards();
addStandard(new CalStandard::Open("Ideal Open Standard", 50.0, 0, 0, 0, 0, 0, 0));
addStandard(new CalStandard::Short("Ideal Short Standard", 50.0, 0, 0, 0, 0, 0, 0));
addStandard(new CalStandard::Load("Ideal Load Standard", 50.0, 0, 0, 50.0, 0, 0));
addStandard(new CalStandard::Through("Ideal Through Standard", 50.0, 0, 0));
}

View File

@ -53,6 +53,8 @@ public:
virtual nlohmann::json toJSON() override;
virtual void fromJSON(nlohmann::json j) override;
void setIdealDefault();
private:
void clearStandards();
QString manufacturer, serialnumber, description;

View File

@ -66,10 +66,8 @@ VNA::VNA(AppWindow *window, QString name)
singleSweep = false;
calMeasuring = false;
calWaitFirst = false;
calDialog.reset();
// A modal QProgressDialog calls processEvents() in setValue(). Needs to use a queued connection to update the progress
// value from within the NewDatapoint slot to prevent possible re-entrancy.
connect(this, &VNA::calibrationMeasurementPercentage, &calDialog, &QProgressDialog::setValue, Qt::QueuedConnection);
calDialog = nullptr;
changingSettings = false;
settings.sweepType = SweepType::Frequency;
settings.zerospan = false;
@ -157,6 +155,8 @@ VNA::VNA(AppWindow *window, QString name)
}
});
cal.getKit().setIdealDefault();
// portExtension.setCalkit(&cal.getCalibrationKit());
// De-embedding menu
@ -889,7 +889,7 @@ void VNA::NewDatapoint(DeviceDriver::VNAMeasurement m)
if(m_avg.pointNum == settings.npoints - 1) {
calMeasuring = false;
cal.measurementsComplete();
calDialog.reset();
delete calDialog;
}
}
}
@ -1247,18 +1247,24 @@ void VNA::StartCalibrationMeasurements(std::set<CalibrationMeasurement::Base*> m
} else {
text.append("multiple calibration standards.");
}
calDialog.setLabelText(text);
calDialog.setCancelButtonText("Abort");
calDialog.setWindowTitle("Taking calibration measurement...");
calDialog.setValue(0);
calDialog.setWindowModality(Qt::ApplicationModal);
calDialog = new QProgressDialog();
calDialog->setLabelText(text);
calDialog->setCancelButtonText("Abort");
calDialog->setWindowTitle("Taking calibration measurement...");
calDialog->setValue(0);
calDialog->setWindowModality(Qt::ApplicationModal);
// always show the dialog
calDialog.setMinimumDuration(0);
connect(&calDialog, &QProgressDialog::canceled, [=]() {
calDialog->setMinimumDuration(0);
// A modal QProgressDialog calls processEvents() in setValue(). Needs to use a queued connection to update the progress
// value from within the NewDatapoint slot to prevent possible re-entrancy.
connect(this, &VNA::calibrationMeasurementPercentage, calDialog, &QProgressDialog::setValue, Qt::QueuedConnection);
connect(calDialog, &QProgressDialog::canceled, this, [=]() {
// the user aborted the calibration measurement
calMeasuring = false;
cal.clearMeasurements(calMeasurements);
});
delete calDialog;
}, Qt::UniqueConnection);
// Trigger sweep to start from beginning
running = true;
ConfigureDevice(true, [=](bool){

View File

@ -150,7 +150,7 @@ private:
std::set<CalibrationMeasurement::Base*> calMeasurements;
bool calMeasuring;
bool calWaitFirst;
QProgressDialog calDialog;
QProgressDialog *calDialog;
Calibration::InterpolationType getCalInterpolation();
QString getCalStyle();
QString getCalToolTip();

View File

@ -109,6 +109,7 @@ static bool needs2LOshift(uint64_t f, uint32_t current2LO, uint32_t IFBW, uint32
bool VNA::Setup(Protocol::SweepSettings s) {
VNA::Stop();
vTaskDelay(5);
data.clear();
HW::SetMode(HW::Mode::VNA);
// Abort possible active sweep first
FPGA::SetMode(FPGA::Mode::FPGA);