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. Depending on the LibreVNA, different hardware interfaces may be used for the implementation of this protocol.
\subsection{USB device} \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} \begin{itemize}
\item \textbf{Endpoint 0x01:} Communication data from the USB host to the LibreVNA \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 \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 %\insertTableNotes % tell LaTeX where to insert the table-related notes
\endlastfoot \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 \\ 2 & 1 & UINT8 & FW\_major & Major firmware version \\
3 & 1 & UINT8 & FW\_minor & Minor firmware version \\ 3 & 1 & UINT8 & FW\_minor & Minor firmware version \\
4 & 1 & UINT8 & FW\_patch & Patch of the 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 * Download the latest [Release](https://github.com/jankae/LibreVNA/releases) and unpack the zip file
* Install the required libraries: * Install the required libraries:
```console ```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): * Install the udev rule (otherwise you don't have the permissions to access the USB device):
```console ```console

View File

@ -1,2 +1,3 @@
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="564e", MODE:="0666" SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="564e", MODE:="0666"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="4121", 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); 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 nlohmann::json toJSON() override;
virtual void fromJSON(nlohmann::json j) override; virtual void fromJSON(nlohmann::json j) override;
void setIdealDefault();
private: private:
void clearStandards(); void clearStandards();
QString manufacturer, serialnumber, description; QString manufacturer, serialnumber, description;

View File

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

View File

@ -150,7 +150,7 @@ private:
std::set<CalibrationMeasurement::Base*> calMeasurements; std::set<CalibrationMeasurement::Base*> calMeasurements;
bool calMeasuring; bool calMeasuring;
bool calWaitFirst; bool calWaitFirst;
QProgressDialog calDialog; QProgressDialog *calDialog;
Calibration::InterpolationType getCalInterpolation(); Calibration::InterpolationType getCalInterpolation();
QString getCalStyle(); QString getCalStyle();
QString getCalToolTip(); 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) { bool VNA::Setup(Protocol::SweepSettings s) {
VNA::Stop(); VNA::Stop();
vTaskDelay(5); vTaskDelay(5);
data.clear();
HW::SetMode(HW::Mode::VNA); HW::SetMode(HW::Mode::VNA);
// Abort possible active sweep first // Abort possible active sweep first
FPGA::SetMode(FPGA::Mode::FPGA); FPGA::SetMode(FPGA::Mode::FPGA);