32 struct iio_scan_context *scan_ctx;
33 struct iio_context_info **info;
35 scan_ctx = iio_create_scan_context(0, 0);
39 qCritical(
"PlutoSDRScan::scan: could not create scan context");
43 num_contexts = iio_scan_context_get_info_list(scan_ctx, &info);
47 qCritical(
"PlutoSDRScan::scan: could not get contexts");
53 if (num_contexts == 0)
55 struct iio_context *ctx = iio_create_network_context(
"pluto.local");
59 m_scans.push_back({std::string(
"PlutoSDR"), std::string(
"networked"), std::string(
"ip:pluto.local")});
62 iio_context_destroy(ctx);
65 for (i = 0; i < num_contexts; i++)
67 const char *description = iio_context_info_get_description(info[i]);
68 const char *uri = iio_context_info_get_uri(info[i]);
74 qDebug(
"PlutoSDRScan::scan: %d: %s [%s]", i, description, uri);
75 char *pch = strstr(const_cast<char*>(description),
"PlutoSDR");
79 m_scans.push_back({std::string(description), std::string(
"TBD"), std::string(uri)});
82 std::regex desc_regex(
".*serial=(.+)");
83 std::smatch desc_match;
84 std::regex_search(
m_scans.back().m_name, desc_match, desc_regex);
86 if (desc_match.size() == 2)
88 m_scans.back().m_serial = desc_match[1];
94 iio_context_info_list_free(info);
95 iio_scan_context_destroy(scan_ctx);
101 return &(
m_scans[index].m_uri);
110 return &(
m_scans[index].m_serial);
117 const std::string& serial)
const 119 std::map<std::string, DeviceScan*>::const_iterator it =
m_serialMap.find(serial);
123 return &((it->second)->m_uri);
129 std::vector<DeviceScan>::const_iterator it =
m_scans.begin();
132 for (; it !=
m_scans.end(); ++it) {
133 serials.push_back(it->m_serial);
std::vector< DeviceScan > m_scans
std::map< std::string, DeviceScan * > m_urilMap
std::map< std::string, DeviceScan * > m_serialMap
const std::string * getSerialAt(unsigned int index) const
void getSerials(std::vector< std::string > &serials) const
const std::string * getURIFromSerial(const std::string &serial) const
static bool probeURI(const std::string &uri)
const std::string * getURIAt(unsigned int index) const