From d8b82ddecd5dce6d664d0b2f98af2bb26383e0da Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 30 Oct 2018 00:19:51 +0100 Subject: [PATCH] SoapySDR support: set enumeration serial to driver and sequence so buddies are paired appropriately --- devices/soapysdr/devicesoapysdrscan.cpp | 50 ++++++++++--------- devices/soapysdr/devicesoapysdrscan.h | 9 ++-- .../soapysdroutput/soapysdroutputplugin.cpp | 8 +-- .../soapysdrinput/soapysdrinputplugin.cpp | 8 +-- 4 files changed, 41 insertions(+), 34 deletions(-) diff --git a/devices/soapysdr/devicesoapysdrscan.cpp b/devices/soapysdr/devicesoapysdrscan.cpp index 2be76ab72..61b44d0c2 100644 --- a/devices/soapysdr/devicesoapysdrscan.cpp +++ b/devices/soapysdr/devicesoapysdrscan.cpp @@ -60,33 +60,35 @@ void DeviceSoapySDRScan::scan() { m_deviceEnums.push_back(SoapySDRDeviceEnum()); m_deviceEnums.back().m_driverName = QString(it.first.c_str()); + m_deviceEnums.back().m_sequence = deviceSeq; // collect identification information - for (SoapySDR::Kwargs::const_iterator kargIt = kit->begin(); kargIt != kit->end(); ++kargIt) + + SoapySDR::Kwargs::const_iterator kargIt; + + if ((kargIt = kit->find("label")) != kit->end()) { - if (kargIt->first == "label") - { - m_deviceEnums.back().m_label = QString(kargIt->second.c_str()); - qDebug("DeviceSoapySDRScan::scan: %s #%u %s", - m_deviceEnums.back().m_driverName.toStdString().c_str(), - deviceSeq, - kargIt->second.c_str()); - } - else if ((m_deviceEnums.back().m_idKey.size() == 0) && (kargIt->first == "serial")) - { - m_deviceEnums.back().m_idKey = QString(kargIt->first.c_str()); - m_deviceEnums.back().m_idValue = QString(kargIt->second.c_str()); - } - else if ((m_deviceEnums.back().m_idKey.size() == 0) && (kargIt->first == "device_id")) - { - m_deviceEnums.back().m_idKey = QString(kargIt->first.c_str()); - m_deviceEnums.back().m_idValue = QString(kargIt->second.c_str()); - } - else if ((m_deviceEnums.back().m_idKey.size() == 0) && (kargIt->first == "addr")) - { - m_deviceEnums.back().m_idKey = QString(kargIt->first.c_str()); - m_deviceEnums.back().m_idValue = QString(kargIt->second.c_str()); - } + m_deviceEnums.back().m_label = QString(kargIt->second.c_str()); + qDebug("DeviceSoapySDRScan::scan: %s #%u %s", + m_deviceEnums.back().m_driverName.toStdString().c_str(), + deviceSeq, + kargIt->second.c_str()); + } + + if ((kargIt = kit->find("serial")) != kit->end()) + { + m_deviceEnums.back().m_idKey = QString(kargIt->first.c_str()); + m_deviceEnums.back().m_idValue = QString(kargIt->second.c_str()); + } + else if ((kargIt = kit->find("device_id")) != kit->end()) + { + m_deviceEnums.back().m_idKey = QString(kargIt->first.c_str()); + m_deviceEnums.back().m_idValue = QString(kargIt->second.c_str()); + } + else if ((kargIt = kit->find("addr")) != kit->end()) + { + m_deviceEnums.back().m_idKey = QString(kargIt->first.c_str()); + m_deviceEnums.back().m_idValue = QString(kargIt->second.c_str()); } // access the device to get the number of Rx and Tx channels and at the same time probe diff --git a/devices/soapysdr/devicesoapysdrscan.h b/devices/soapysdr/devicesoapysdrscan.h index bfc7f80dc..b4cc59a0d 100644 --- a/devices/soapysdr/devicesoapysdrscan.h +++ b/devices/soapysdr/devicesoapysdrscan.h @@ -29,13 +29,14 @@ public: struct SoapySDRDeviceEnum { QString m_driverName; - QString m_label; //!< the label key for display should always be present - QString m_idKey; //!< key to uniquely identify device - QString m_idValue; //!< value for the above key + uint32_t m_sequence; //!< device sequence for this driver + QString m_label; //!< the label key for display should always be present + QString m_idKey; //!< key to uniquely identify device + QString m_idValue; //!< value for the above key uint32_t m_nbRx; uint32_t m_nbTx; - SoapySDRDeviceEnum() : m_nbRx(0), m_nbTx(0) + SoapySDRDeviceEnum() : m_sequence(0), m_nbRx(0), m_nbTx(0) {} }; diff --git a/plugins/samplesink/soapysdroutput/soapysdroutputplugin.cpp b/plugins/samplesink/soapysdroutput/soapysdroutputplugin.cpp index f8691ed50..cdb6def6d 100644 --- a/plugins/samplesink/soapysdroutput/soapysdroutputplugin.cpp +++ b/plugins/samplesink/soapysdroutput/soapysdroutputplugin.cpp @@ -61,7 +61,7 @@ PluginInterface::SamplingDevices SoapySDROutputPlugin::enumSampleSinks() SamplingDevices result; DeviceSoapySDR& deviceSoapySDR = DeviceSoapySDR::instance(); const std::vector& devicesEnumeration = deviceSoapySDR.getDevicesEnumeration(); - qDebug("SoapySDRInputPlugin::enumSampleSources: found %lu devices", devicesEnumeration.size()); + qDebug("SoapySDROutputPlugin::enumSampleSinks: %lu SoapySDR devices. Enumerate these with Tx channel(s):", devicesEnumeration.size()); std::vector::const_iterator it = devicesEnumeration.begin(); for (int idev = 0; it != devicesEnumeration.end(); ++it, idev++) @@ -70,12 +70,14 @@ PluginInterface::SamplingDevices SoapySDROutputPlugin::enumSampleSinks() for (unsigned int ichan = 0; ichan < nbTxChannels; ichan++) { - qDebug("SoapySDROutputPlugin::enumSampleSinks: device #%d (%s) channel %u", idev, it->m_label, ichan); QString displayedName(QString("SoapySDR[%1:%2] %3").arg(idev).arg(ichan).arg(it->m_label)); + QString serial(QString("%1-%2").arg(it->m_driverName).arg(it->m_sequence)); + qDebug("SoapySDROutputPlugin::enumSampleSinks: device #%d (%s) serial %s channel %u", + idev, it->m_label.toStdString().c_str(), serial.toStdString().c_str(), ichan); result.append(SamplingDevice(displayedName, m_hardwareID, m_deviceTypeID, - it->m_idValue, + serial, idev, PluginInterface::SamplingDevice::PhysicalDevice, false, diff --git a/plugins/samplesource/soapysdrinput/soapysdrinputplugin.cpp b/plugins/samplesource/soapysdrinput/soapysdrinputplugin.cpp index 495fa7bd4..f0e6ed867 100644 --- a/plugins/samplesource/soapysdrinput/soapysdrinputplugin.cpp +++ b/plugins/samplesource/soapysdrinput/soapysdrinputplugin.cpp @@ -60,7 +60,7 @@ PluginInterface::SamplingDevices SoapySDRInputPlugin::enumSampleSources() SamplingDevices result; DeviceSoapySDR& deviceSoapySDR = DeviceSoapySDR::instance(); const std::vector& devicesEnumeration = deviceSoapySDR.getDevicesEnumeration(); - qDebug("SoapySDRInputPlugin::enumSampleSources: found %lu devices", devicesEnumeration.size()); + qDebug("SoapySDRInputPlugin::enumSampleSources: %lu SoapySDR devices. Enumerate these with Rx channel(s):", devicesEnumeration.size()); std::vector::const_iterator it = devicesEnumeration.begin(); for (int idev = 0; it != devicesEnumeration.end(); ++it, idev++) @@ -69,12 +69,14 @@ PluginInterface::SamplingDevices SoapySDRInputPlugin::enumSampleSources() for (unsigned int ichan = 0; ichan < nbRxChannels; ichan++) { - qDebug("SoapySDRInputPlugin::enumSampleSources: device #%d (%s) channel %u", idev, it->m_label, ichan); QString displayedName(QString("SoapySDR[%1:%2] %3").arg(idev).arg(ichan).arg(it->m_label)); + QString serial(QString("%1-%2").arg(it->m_driverName).arg(it->m_sequence)); + qDebug("SoapySDRInputPlugin::enumSampleSources: device #%d (%s) serial %s channel %u", + idev, it->m_label.toStdString().c_str(), serial.toStdString().c_str(), ichan); result.append(SamplingDevice(displayedName, m_hardwareID, m_deviceTypeID, - it->m_idValue, + serial, idev, PluginInterface::SamplingDevice::PhysicalDevice, true,