mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-03 06:24:48 -04:00
Support for Airspy: first working version
This commit is contained in:
@@ -53,8 +53,11 @@ PluginInterface::SampleSourceDevices AirspyPlugin::enumSampleSources()
|
||||
{
|
||||
SampleSourceDevices result;
|
||||
airspy_read_partid_serialno_t read_partid_serialno;
|
||||
struct airspy_device *devinfo = 0;
|
||||
struct airspy_device *devinfo;
|
||||
uint32_t serial_msb = 0;
|
||||
uint32_t serial_lsb = 0;
|
||||
airspy_error rc;
|
||||
int i;
|
||||
|
||||
rc = (airspy_error) airspy_init();
|
||||
|
||||
@@ -63,29 +66,40 @@ PluginInterface::SampleSourceDevices AirspyPlugin::enumSampleSources()
|
||||
qCritical("AirspyPlugin::enumSampleSources: failed to initiate Airspy library: %s", airspy_error_name(rc));
|
||||
}
|
||||
|
||||
for (int i=0; i < AIRSPY_MAX_DEVICE; i++)
|
||||
for (i=0; i < AIRSPY_MAX_DEVICE; i++)
|
||||
{
|
||||
rc = (airspy_error) airspy_open(&devinfo);
|
||||
|
||||
if (rc == AIRSPY_SUCCESS)
|
||||
{
|
||||
qDebug("AirspyPlugin::enumSampleSources: 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));
|
||||
airspy_close(devinfo);
|
||||
continue; // next
|
||||
}
|
||||
|
||||
QString serial_str = QString::number(read_partid_serialno.serial_no[2], 16) + QString::number(read_partid_serialno.serial_no[3], 16);
|
||||
uint64_t serial_num = (((uint64_t) read_partid_serialno.serial_no[2])<<32) + read_partid_serialno.serial_no[3];
|
||||
QString displayedName(QString("Airspy #%1 0x%2").arg(i+1).arg(serial_str));
|
||||
SimpleSerializer s(1);
|
||||
s.writeS32(1, i);
|
||||
s.writeString(2, serial_str);
|
||||
s.writeU64(3, serial_num);
|
||||
if ((read_partid_serialno.serial_no[2] != serial_msb) && (read_partid_serialno.serial_no[3] != serial_lsb))
|
||||
{
|
||||
serial_msb = read_partid_serialno.serial_no[2];
|
||||
serial_lsb = read_partid_serialno.serial_no[3];
|
||||
|
||||
result.append(SampleSourceDevice(displayedName, "org.osmocom.sdr.samplesource.airspy", s.final()));
|
||||
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 0x%2").arg(i).arg(serial_str));
|
||||
SimpleSerializer s(1);
|
||||
s.writeS32(1, i);
|
||||
s.writeString(2, serial_str);
|
||||
s.writeU64(3, serial_num);
|
||||
result.append(SampleSourceDevice(displayedName, "org.osmocom.sdr.samplesource.airspy", s.final()));
|
||||
qDebug("AirspyPlugin::enumSampleSources: enumerated Airspy device #%d", i);
|
||||
}
|
||||
|
||||
airspy_close(devinfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -94,7 +108,8 @@ PluginInterface::SampleSourceDevices AirspyPlugin::enumSampleSources()
|
||||
}
|
||||
}
|
||||
|
||||
airspy_exit();
|
||||
rc = (airspy_error) airspy_exit();
|
||||
qDebug("AirspyPlugin::enumSampleSources: airspy_exit: %s", airspy_error_name(rc));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user