diff --git a/Software/PC_Application/LibreVNA-GUI/Device/Harogic/harogicb60.cpp b/Software/PC_Application/LibreVNA-GUI/Device/Harogic/harogicb60.cpp new file mode 100644 index 0000000..04d5c70 --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/Harogic/harogicb60.cpp @@ -0,0 +1,16 @@ +#include "harogicb60.h" + +HarogicB60::HarogicB60() +{ + validUSBIDs.clear(); + validUSBIDs.append({0x367F, 0x0200, "B60"}); + + for(auto &s : specificSettings) { + s.name.replace("LibreVNAUSBDriver", "HarogicB60Driver"); + } +} + +QString HarogicB60::getDriverName() +{ + return "Harogic B60"; +} diff --git a/Software/PC_Application/LibreVNA-GUI/Device/Harogic/harogicb60.h b/Software/PC_Application/LibreVNA-GUI/Device/Harogic/harogicb60.h new file mode 100644 index 0000000..b727f59 --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/Harogic/harogicb60.h @@ -0,0 +1,19 @@ +#ifndef HAROGICB60_H +#define HAROGICB60_H + +#include "../LibreVNA/librevnausbdriver.h" + +class HarogicB60 : public LibreVNAUSBDriver +{ + Q_OBJECT +public: + HarogicB60(); + + /** + * @brief Returns the driver name. It must be unique across all implemented drivers and is used to identify the driver + * @return driver name + */ + virtual QString getDriverName() override; +}; + +#endif // HAROGICB60_H diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp index c9d03df..a35d4ca 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp @@ -8,16 +8,6 @@ using namespace std; -using USBID = struct { - int VID; - int PID; -}; -static constexpr USBID IDs[] = { - {0x0483, 0x564e}, - {0x0483, 0x4121}, - {0x1209, 0x4121}, -}; - LibreVNAUSBDriver::LibreVNAUSBDriver() : LibreVNADriver() { @@ -30,6 +20,10 @@ LibreVNAUSBDriver::LibreVNAUSBDriver() lastTimestamp = QDateTime::currentDateTime(); byteCnt = 0; + validUSBIDs.append({0x0483, 0x564e, "VNA"}); + validUSBIDs.append({0x0483, 0x4121, "VNA"}); + validUSBIDs.append({0x1209, 0x4121, "VNA"}); + specificSettings.push_back(Savable::SettingDescription(&captureRawReceiverValues, "LibreVNAUSBDriver.captureRawReceiverValues", false)); specificSettings.push_back(Savable::SettingDescription(&harmonicMixing, "LibreVNAUSBDriver.harmonicMixing", false)); specificSettings.push_back(Savable::SettingDescription(&SASignalID, "LibreVNAUSBDriver.signalID", true)); @@ -309,15 +303,15 @@ void LibreVNAUSBDriver::SearchDevices(std::function 0) { /* managed to read the product string */ QString product(c_product); - if (product == "VNA") { + if (product == validUSBIDs[IDindex].deviceName) { // this is a match if(!foundCallback(handle, QString(c_serial))) { // abort search diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.h index 1f44b96..77c3362 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.h +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.h @@ -54,7 +54,7 @@ private: void USBHandleThread(); // foundCallback is called for every device that is found. If it returns true the search continues, otherwise it is aborted. // When the search is aborted the last found device is still opened - static void SearchDevices(std::function foundCallback, libusb_context *context, bool ignoreOpenError); + void SearchDevices(std::function foundCallback, libusb_context *context, bool ignoreOpenError); libusb_device_handle *m_handle; libusb_context *m_context; @@ -82,6 +82,13 @@ private: QDateTime lastTimestamp; unsigned long byteCnt; + using USBID = struct { + int VID; + int PID; + QString deviceName; + }; +protected: + QList validUSBIDs; }; #endif // LIBREVNAUSBDRIVER_H diff --git a/Software/PC_Application/LibreVNA-GUI/Device/devicedriver.cpp b/Software/PC_Application/LibreVNA-GUI/Device/devicedriver.cpp index f1f389a..49627c5 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/devicedriver.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/devicedriver.cpp @@ -5,6 +5,7 @@ #include "LibreVNA/Compound/compounddriver.h" #include "SSA3000X/ssa3000xdriver.h" #include "SNA5000A/sna5000adriver.h" +#include "Harogic/harogicb60.h" DeviceDriver *DeviceDriver::activeDriver = nullptr; @@ -25,6 +26,7 @@ std::vector DeviceDriver::getDrivers() ret.push_back(new CompoundDriver); ret.push_back(new SSA3000XDriver); ret.push_back(new SNA5000ADriver); + ret.push_back(new HarogicB60); } return ret; } diff --git a/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro b/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro index e8f086f..34c4af3 100644 --- a/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro +++ b/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro @@ -20,6 +20,7 @@ HEADERS += \ CustomWidgets/toggleswitch.h \ CustomWidgets/touchstoneimport.h \ CustomWidgets/tracesetselector.h \ + Device/Harogic/harogicb60.h \ Device/LibreVNA/Compound/compounddevice.h \ Device/LibreVNA/Compound/compounddeviceeditdialog.h \ Device/LibreVNA/Compound/compounddriver.h \ @@ -191,6 +192,7 @@ SOURCES += \ CustomWidgets/toggleswitch.cpp \ CustomWidgets/touchstoneimport.cpp \ CustomWidgets/tracesetselector.cpp \ + Device/Harogic/harogicb60.cpp \ Device/LibreVNA/Compound/compounddevice.cpp \ Device/LibreVNA/Compound/compounddeviceeditdialog.cpp \ Device/LibreVNA/Compound/compounddriver.cpp \ diff --git a/Software/PC_Application/LibreVNA-GUI/preferences.cpp b/Software/PC_Application/LibreVNA-GUI/preferences.cpp index e248e73..403e0ef 100644 --- a/Software/PC_Application/LibreVNA-GUI/preferences.cpp +++ b/Software/PC_Application/LibreVNA-GUI/preferences.cpp @@ -162,7 +162,7 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : if(!w) { continue; } - w->setObjectName(driver->getDriverName()); + w->setObjectName(driver->getDriverName().replace(" ", "")); ui->pageWidget->addWidget(w); auto driverItem = new QTreeWidgetItem(); driverItem->setText(0, driver->getDriverName()); diff --git a/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro b/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro index f156b6b..8b69927 100644 --- a/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro +++ b/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro @@ -26,6 +26,7 @@ SOURCES += \ ../LibreVNA-GUI/CustomWidgets/toggleswitch.cpp \ ../LibreVNA-GUI/CustomWidgets/touchstoneimport.cpp \ ../LibreVNA-GUI/CustomWidgets/tracesetselector.cpp \ + ../LibreVNA-GUI/Device/Harogic/harogicb60.cpp \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.cpp \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.cpp \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.cpp \ @@ -219,6 +220,7 @@ HEADERS += \ ../LibreVNA-GUI/CustomWidgets/toggleswitch.h \ ../LibreVNA-GUI/CustomWidgets/touchstoneimport.h \ ../LibreVNA-GUI/CustomWidgets/tracesetselector.h \ + ../LibreVNA-GUI/Device/Harogic/harogicb60.h \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.h \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.h \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvd0.h \