1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

LibbladeRF2: BladeRF1 specific enumeration

This commit is contained in:
f4exb 2018-09-19 06:15:22 +02:00
parent bf726e16b1
commit 94837dbd51
2 changed files with 65 additions and 20 deletions

View File

@ -66,7 +66,26 @@ PluginInterface::SamplingDevices BladerfOutputPlugin::enumSampleSinks()
{
for(int i = 0; i < count; i++)
{
QString displayedName(QString("BladeRF[%1] %2").arg(devinfo[i].instance).arg(devinfo[i].serial));
struct bladerf *dev;
int status = bladerf_open_with_devinfo(&dev, &devinfo[i]);
if (status == BLADERF_ERR_NODEV)
{
qCritical("BladerfOutputPlugin::enumSampleSinks: No device at index %d", i);
continue;
}
else if (status != 0)
{
qCritical("BladerfOutputPlugin::enumSampleSinks: Failed to open device at index %d", i);
continue;
}
const char *boardName = bladerf_get_board_name(dev);
if (strcmp(boardName, "bladerf1") == 0)
{
QString displayedName(QString("BladeRF1[%1] %2").arg(devinfo[i].instance).arg(devinfo[i].serial));
result.append(SamplingDevice(displayedName,
m_hardwareID,
@ -77,6 +96,10 @@ PluginInterface::SamplingDevices BladerfOutputPlugin::enumSampleSinks()
false,
1,
0));
}
bladerf_close(dev);
}
bladerf_free_device_list(devinfo); // Valgrind memcheck

View File

@ -66,7 +66,26 @@ PluginInterface::SamplingDevices BlderfInputPlugin::enumSampleSources()
{
for(int i = 0; i < count; i++)
{
QString displayedName(QString("BladeRF[%1] %2").arg(devinfo[i].instance).arg(devinfo[i].serial));
struct bladerf *dev;
int status = bladerf_open_with_devinfo(&dev, &devinfo[i]);
if (status == BLADERF_ERR_NODEV)
{
qCritical("BlderfInputPlugin::enumSampleSources: No device at index %d", i);
continue;
}
else if (status != 0)
{
qCritical("BlderfInputPlugin::enumSampleSources: Failed to open device at index %d", i);
continue;
}
const char *boardName = bladerf_get_board_name(dev);
if (strcmp(boardName, "bladerf1") == 0)
{
QString displayedName(QString("BladeRF1[%1] %2").arg(devinfo[i].instance).arg(devinfo[i].serial));
result.append(SamplingDevice(displayedName,
m_hardwareID,
@ -79,6 +98,9 @@ PluginInterface::SamplingDevices BlderfInputPlugin::enumSampleSources()
0));
}
bladerf_close(dev);
}
bladerf_free_device_list(devinfo); // Valgrind memcheck
}