1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-01 21:54:55 -04:00

Plugins device enumeration optimization: factorization of common code for Rx/Tx devices

This commit is contained in:
f4exb
2019-09-17 19:54:13 +02:00
parent e9bbf0b266
commit ee3313dc82
34 changed files with 341 additions and 550 deletions
@@ -62,55 +62,7 @@ void HackRFOutputPlugin::enumOriginDevices(QStringList& listedHwIds, OriginDevic
return;
}
hackrf_device_list_t *hackrf_devices = hackrf_device_list();
hackrf_device *hackrf_ptr;
read_partid_serialno_t read_partid_serialno;
int i;
for (i=0; i < hackrf_devices->devicecount; i++)
{
hackrf_error rc = (hackrf_error) hackrf_device_list_open(hackrf_devices, i, &hackrf_ptr);
if (rc == HACKRF_SUCCESS)
{
qDebug("HackRFOutputPlugin::enumOriginDevices: try to enumerate HackRF device #%d", i);
rc = (hackrf_error) hackrf_board_partid_serialno_read(hackrf_ptr, &read_partid_serialno);
if (rc != HACKRF_SUCCESS)
{
qDebug("HackRFOutputPlugin::enumOriginDevices: failed to read serial no: %s", hackrf_error_name(rc));
hackrf_close(hackrf_ptr);
continue; // next
}
uint32_t serial_msb = read_partid_serialno.serial_no[2];
uint32_t serial_lsb = read_partid_serialno.serial_no[3];
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("HackRF[%1] %2").arg(i).arg(serial_str));
originDevices.append(OriginDevice(
displayedName,
m_hardwareID,
serial_str,
i,
1,
1
));
qDebug("HackRFOutputPlugin::enumOriginDevices: enumerated HackRF device #%d", i);
hackrf_close(hackrf_ptr);
}
else
{
qDebug("HackRFOutputPlugin::enumOriginDevices: failed to enumerate HackRF device #%d: %s", i, hackrf_error_name(rc));
}
}
hackrf_device_list_free(hackrf_devices);
DeviceHackRF::enumOriginDevices(m_hardwareID, originDevices);
listedHwIds.append(m_hardwareID);
}