1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 06:04:39 -04:00

Plugins device enumeration optimization

This commit is contained in:
f4exb
2019-09-17 00:34:11 +02:00
parent b7e5e2bbc5
commit e9bbf0b266
64 changed files with 1377 additions and 480 deletions
+47 -19
View File
@@ -33,7 +33,7 @@ const int AirspyPlugin::m_maxDevices = 32;
const PluginDescriptor AirspyPlugin::m_pluginDescriptor = {
QString("Airspy Input"),
QString("4.11.6"),
QString("4.11.10"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
@@ -58,9 +58,12 @@ void AirspyPlugin::initPlugin(PluginAPI* pluginAPI)
pluginAPI->registerSampleSource(m_deviceTypeID, this);
}
PluginInterface::SamplingDevices AirspyPlugin::enumSampleSources()
void AirspyPlugin::enumOriginDevices(QStringList& listedHwIds, OriginDevices& originDevices)
{
SamplingDevices result;
if (listedHwIds.contains(m_hardwareID)) { // check if it was done
return;
}
airspy_read_partid_serialno_t read_partid_serialno;
struct airspy_device *devinfo;
uint32_t serial_msb = 0;
@@ -72,7 +75,7 @@ PluginInterface::SamplingDevices AirspyPlugin::enumSampleSources()
if (rc != AIRSPY_SUCCESS)
{
qCritical("AirspyPlugin::enumSampleSources: failed to initiate Airspy library: %s", airspy_error_name(rc));
qCritical("AirspyPlugin::enumOriginDevices: failed to initiate Airspy library: %s", airspy_error_name(rc));
}
for (i=0; i < m_maxDevices; i++)
@@ -81,13 +84,13 @@ PluginInterface::SamplingDevices AirspyPlugin::enumSampleSources()
if (rc == AIRSPY_SUCCESS)
{
qDebug("AirspyPlugin::enumSampleSources: try to enumerate Airspy device #%d", i);
qDebug("AirspyPlugin::enumOriginDevices: try to enumerate Airspy device #%d", i);
rc = (airspy_error) airspy_board_partid_serialno_read(devinfo, &read_partid_serialno);
if (rc != AIRSPY_SUCCESS)
{
qDebug("AirspyPlugin::enumSampleSources: failed to read serial no: %s", airspy_error_name(rc));
qDebug("AirspyPlugin::enumOriginDevices: failed to read serial no: %s", airspy_error_name(rc));
airspy_close(devinfo);
continue; // next
}
@@ -99,32 +102,57 @@ PluginInterface::SamplingDevices AirspyPlugin::enumSampleSources()
QString serial_str = QString::number(serial_msb, 16) + QString::number(serial_lsb, 16);
//uint64_t serial_num = (((uint64_t) serial_msb)<<32) + serial_lsb;
QString displayedName(QString("Airspy[%1] %2").arg(i).arg(serial_str));
QString displayableName(QString("Airspy[%1] %2").arg(i).arg(serial_str));
result.append(SamplingDevice(displayedName,
m_hardwareID,
m_deviceTypeID,
serial_str,
i,
PluginInterface::SamplingDevice::PhysicalDevice,
PluginInterface::SamplingDevice::StreamSingleRx,
1,
0));
originDevices.append(OriginDevice(
displayableName,
m_hardwareID,
serial_str,
i,
1,
0
));
qDebug("AirspyPlugin::enumSampleSources: enumerated Airspy device #%d", i);
qDebug("AirspyPlugin::enumOriginDevices: enumerated Airspy device #%d", i);
}
airspy_close(devinfo);
}
else
{
qDebug("AirspyPlugin::enumSampleSources: enumerated %d Airspy devices %s", i, airspy_error_name(rc));
qDebug("AirspyPlugin::enumOriginDevices: enumerated %d Airspy devices %s", i, airspy_error_name(rc));
break; // finished
}
}
rc = (airspy_error) airspy_exit();
qDebug("AirspyPlugin::enumSampleSources: airspy_exit: %s", airspy_error_name(rc));
qDebug("AirspyPlugin::enumOriginDevices: airspy_exit: %s", airspy_error_name(rc));
listedHwIds.append(m_hardwareID);
}
PluginInterface::SamplingDevices AirspyPlugin::enumSampleSources(const OriginDevices& originDevices)
{
SamplingDevices result;
for (OriginDevices::const_iterator it = originDevices.begin(); it != originDevices.end(); ++it)
{
if (it->hardwareId == m_hardwareID)
{
result.append(SamplingDevice(
it->displayableName,
m_hardwareID,
m_deviceTypeID,
it->serial,
it->sequence,
PluginInterface::SamplingDevice::PhysicalDevice,
PluginInterface::SamplingDevice::StreamSingleRx,
1,
0
));
qDebug("AirspyPlugin::enumSampleSources: enumerated Airspy device #%d", it->sequence);
}
}
return result;
}