SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Public Member Functions | Private Attributes | List of all members
DeviceSoapySDRScan Class Reference

#include <devicesoapysdrscan.h>

Classes

struct  SoapySDRDeviceEnum
 

Public Member Functions

void scan ()
 
uint32_t getNbDevices () const
 
const std::vector< SoapySDRDeviceEnum > & getDevicesEnumeration () const
 

Private Attributes

std::vector< SoapySDRDeviceEnumm_deviceEnums
 

Detailed Description

Definition at line 27 of file devicesoapysdrscan.h.

Member Function Documentation

◆ getDevicesEnumeration()

const std::vector<SoapySDRDeviceEnum>& DeviceSoapySDRScan::getDevicesEnumeration ( ) const
inline

Definition at line 46 of file devicesoapysdrscan.h.

Referenced by DeviceSoapySDR::openopenSoapySDRFromSequence().

46 { return m_deviceEnums; }
std::vector< SoapySDRDeviceEnum > m_deviceEnums
+ Here is the caller graph for this function:

◆ getNbDevices()

uint32_t DeviceSoapySDRScan::getNbDevices ( ) const
inline

Definition at line 45 of file devicesoapysdrscan.h.

Referenced by DeviceSoapySDR::openopenSoapySDRFromSequence().

45 { return m_deviceEnums.size(); }
std::vector< SoapySDRDeviceEnum > m_deviceEnums
+ Here is the caller graph for this function:

◆ scan()

void DeviceSoapySDRScan::scan ( )

Definition at line 28 of file devicesoapysdrscan.cpp.

References arg(), and m_deviceEnums.

Referenced by DeviceSoapySDR::DeviceSoapySDR().

29 {
30  qDebug("DeviceSoapySDRScan::scan: Lib Version: v%s", SoapySDR::getLibVersion().c_str());
31  qDebug("DeviceSoapySDRScan::scan: API Version: v%s", SoapySDR::getAPIVersion().c_str());
32  qDebug("DeviceSoapySDRScan::scan: ABI Version: v%s", SoapySDR::getABIVersion().c_str());
33  qDebug("DeviceSoapySDRScan::scan: Install root: %s", SoapySDR::getRootPath().c_str());
34 
35  const std::vector<std::string>& modules = SoapySDR::listModules();
36 
37  for (const auto &it : modules)
38  {
39  const auto &errMsg = SoapySDR::loadModule(it);
40 
41  if (not errMsg.empty()) {
42  qWarning("DeviceSoapySDRScan::scan: cannot load module %s: %s", it.c_str(), errMsg.c_str());
43  } else {
44  qDebug("DeviceSoapySDRScan::scan: loaded module: %s", it.c_str());
45  }
46  }
47 
48  SoapySDR::FindFunctions findFunctions = SoapySDR::Registry::listFindFunctions();
49  SoapySDR::Kwargs kwargs;
50  m_deviceEnums.clear();
51 
52  for (const auto &it : findFunctions) // for each driver
53  {
54  qDebug("DeviceSoapySDRScan::scan: driver: %s", it.first.c_str());
55  kwargs["driver"] = it.first;
56 
57  SoapySDR::KwargsList kwargsList = SoapySDR::Device::enumerate(kwargs);
58  SoapySDR::KwargsList::const_iterator kit = kwargsList.begin();
59 
60  for (int deviceSeq = 0; kit != kwargsList.end(); ++kit, deviceSeq++) // for each device
61  {
62  m_deviceEnums.push_back(SoapySDRDeviceEnum());
63  m_deviceEnums.back().m_driverName = QString(it.first.c_str());
64  m_deviceEnums.back().m_sequence = deviceSeq;
65 
66  // collect identification information
67 
68  SoapySDR::Kwargs::const_iterator kargIt;
69 
70  if ((kargIt = kit->find("label")) != kit->end()) {
71  m_deviceEnums.back().m_label = QString(kargIt->second.c_str());
72  } else { // if no label is registered for this device then create a label with the driver name and sequence
73  m_deviceEnums.back().m_label = QString("%1-%2").arg(m_deviceEnums.back().m_driverName).arg(deviceSeq);
74  }
75 
76  if ((kargIt = kit->find("serial")) != kit->end())
77  {
78  m_deviceEnums.back().m_idKey = QString(kargIt->first.c_str());
79  m_deviceEnums.back().m_idValue = QString(kargIt->second.c_str());
80  }
81  else if ((kargIt = kit->find("device_id")) != kit->end())
82  {
83  m_deviceEnums.back().m_idKey = QString(kargIt->first.c_str());
84  m_deviceEnums.back().m_idValue = QString(kargIt->second.c_str());
85  }
86  else if ((kargIt = kit->find("addr")) != kit->end())
87  {
88  m_deviceEnums.back().m_idKey = QString(kargIt->first.c_str());
89  m_deviceEnums.back().m_idValue = QString(kargIt->second.c_str());
90  }
91 
92  qDebug("DeviceSoapySDRScan::scan: %s #%u %s id: %s=%s",
93  m_deviceEnums.back().m_driverName.toStdString().c_str(),
94  deviceSeq,
95  m_deviceEnums.back().m_label.toStdString().c_str(),
96  m_deviceEnums.back().m_idKey.toStdString().c_str(),
97  m_deviceEnums.back().m_idValue.toStdString().c_str());
98 
99  // access the device to get the number of Rx and Tx channels and at the same time probe
100  // whether it is available for Soapy
101 
102  try
103  {
104  SoapySDR::Device *device;
105  SoapySDR::Kwargs kwargs;
106  kwargs["driver"] = m_deviceEnums.back().m_driverName.toStdString();
107 
108  if (m_deviceEnums.back().m_idKey.size() > 0) {
109  kwargs[m_deviceEnums.back().m_idKey.toStdString()] = m_deviceEnums.back().m_idValue.toStdString();
110  }
111 
112  device = SoapySDR::Device::make(kwargs);
113  m_deviceEnums.back().m_nbRx = device->getNumChannels(SOAPY_SDR_RX);
114  m_deviceEnums.back().m_nbTx = device->getNumChannels(SOAPY_SDR_TX);
115  qDebug("DeviceSoapySDRScan::scan: %s #%u driver=%s hardware=%s #Rx=%u #Tx=%u",
116  m_deviceEnums.back().m_driverName.toStdString().c_str(),
117  deviceSeq,
118  device->getDriverKey().c_str(),
119  device->getHardwareKey().c_str(),
120  m_deviceEnums.back().m_nbRx,
121  m_deviceEnums.back().m_nbTx);
122 
123  SoapySDR::Device::unmake(device);
124  }
125  catch (const std::exception &ex)
126  {
127  qWarning("DeviceSoapySDRScan::scan: %s #%u cannot be opened: %s",
128  m_deviceEnums.back().m_driverName.toStdString().c_str(),
129  deviceSeq,
130  ex.what());
131  m_deviceEnums.pop_back();
132  }
133  } // for each device
134  }
135 }
std::vector< SoapySDRDeviceEnum > m_deviceEnums
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_deviceEnums

std::vector<SoapySDRDeviceEnum> DeviceSoapySDRScan::m_deviceEnums
private

Definition at line 49 of file devicesoapysdrscan.h.

Referenced by scan().


The documentation for this class was generated from the following files: