mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-01-26 10:24:14 +01:00
only use fast coefficient protocol for newer LibreCAL firmware
This commit is contained in:
parent
2c639d8080
commit
74858c1098
|
|
@ -1,7 +1,10 @@
|
|||
#include "caldevice.h"
|
||||
|
||||
#include "Util/util.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
|
||||
using namespace std;
|
||||
|
||||
static QString getLocalDateTimeWithUtcOffset()
|
||||
|
|
@ -173,7 +176,7 @@ void CalDevice::loadCoefficientSets(QStringList names, bool fast)
|
|||
{
|
||||
coeffSets.clear();
|
||||
abortLoading = false;
|
||||
if(fast) {
|
||||
if(fast && Util::firmwareEqualOrHigher(firmware, "0.2.1")) {
|
||||
loadThread = new std::thread(&CalDevice::loadCoefficientSetsThreadFast, this, names);
|
||||
} else {
|
||||
loadThread = new std::thread(&CalDevice::loadCoefficientSetsThreadSlow, this, names);
|
||||
|
|
|
|||
|
|
@ -212,7 +212,6 @@ void USBDevice::SearchDevices(std::function<bool (libusb_device_handle *, QStrin
|
|||
|
||||
bool USBDevice::send(const QString &s)
|
||||
{
|
||||
// qDebug() << "Send:"<<s;
|
||||
unsigned char data[s.size()+2];
|
||||
memcpy(data, s.toLatin1().data(), s.size());
|
||||
memcpy(&data[s.size()], "\r\n", 2);
|
||||
|
|
@ -244,7 +243,6 @@ bool USBDevice::receive(QString *s, unsigned int timeout)
|
|||
void USBDevice::ReceivedData()
|
||||
{
|
||||
uint16_t handled_len;
|
||||
// qDebug() << "received new data";
|
||||
unique_lock<mutex> lck(mtx);
|
||||
do {
|
||||
handled_len = 0;
|
||||
|
|
@ -255,7 +253,6 @@ void USBDevice::ReceivedData()
|
|||
|
||||
// add received line to buffer
|
||||
lineBuffer.append(line);
|
||||
// qDebug() << "append" << line << "size" << lineBuffer.size();
|
||||
|
||||
usbBuffer->removeBytes(handled_len + 1);
|
||||
}
|
||||
|
|
@ -263,7 +260,6 @@ void USBDevice::ReceivedData()
|
|||
if(lineBuffer.size() > 0) {
|
||||
cv.notify_one();
|
||||
}
|
||||
// qDebug() << "notify done";
|
||||
}
|
||||
|
||||
void USBDevice::flushReceived()
|
||||
|
|
|
|||
|
|
@ -201,3 +201,27 @@ QColor Util::getIntensityGradeColor(double intensity)
|
|||
return Qt::black;
|
||||
}
|
||||
}
|
||||
|
||||
bool Util::firmwareEqualOrHigher(QString firmware, QString compare)
|
||||
{
|
||||
QStringList f = firmware.split(".");
|
||||
QStringList c = compare.split(".");
|
||||
if(f.size() != 3 || c.size() != 3) {
|
||||
return false;
|
||||
}
|
||||
if(f[0].toInt() < c[0].toInt()) {
|
||||
return false;
|
||||
} else if(f[0].toInt() > c[0].toInt()) {
|
||||
return true;
|
||||
}
|
||||
if(f[1].toInt() < c[1].toInt()) {
|
||||
return false;
|
||||
} else if(f[1].toInt() > c[1].toInt()) {
|
||||
return true;
|
||||
}
|
||||
if(f[2].toInt() < c[2].toInt()) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,6 +166,8 @@ namespace Util {
|
|||
|
||||
// intensity color scale, input value from 0.0 to 1.0
|
||||
QColor getIntensityGradeColor(double intensity);
|
||||
|
||||
bool firmwareEqualOrHigher(QString firmware, QString compare);
|
||||
}
|
||||
|
||||
#endif // UTILH_H
|
||||
|
|
|
|||
|
|
@ -63,3 +63,18 @@ void UtilTests::NoisyCircleApproximation()
|
|||
QVERIFY(abs(center.real() - circCenter.real()) <= maxDelta);
|
||||
QVERIFY(abs(center.imag() - circCenter.imag()) <= maxDelta);
|
||||
}
|
||||
|
||||
void UtilTests::FirmwareComparison()
|
||||
{
|
||||
QVERIFY(Util::firmwareEqualOrHigher("3.1.2", "2.1.2") == true);
|
||||
QVERIFY(Util::firmwareEqualOrHigher("2.1.2", "2.0.2") == true);
|
||||
QVERIFY(Util::firmwareEqualOrHigher("2.1.2", "2.1.1") == true);
|
||||
QVERIFY(Util::firmwareEqualOrHigher("2.1.2", "2.1.2") == true);
|
||||
QVERIFY(Util::firmwareEqualOrHigher("2.1.1", "2.1.2") == false);
|
||||
|
||||
QVERIFY(Util::firmwareEqualOrHigher("2.2.2", "2.3.1") == false);
|
||||
QVERIFY(Util::firmwareEqualOrHigher("2.2.2", "2.1.3") == true);
|
||||
|
||||
QVERIFY(Util::firmwareEqualOrHigher("2.2.2", "2.3") == false);
|
||||
QVERIFY(Util::firmwareEqualOrHigher("2.2", "2.3.1") == false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ private slots:
|
|||
void IdealCircleApproximation();
|
||||
void IdealArcApproximation();
|
||||
void NoisyCircleApproximation();
|
||||
void FirmwareComparison();
|
||||
};
|
||||
|
||||
#endif // UTILTESTS_H
|
||||
|
|
|
|||
Loading…
Reference in a new issue