* Scan for devices. No specific options apply here, this is
* best effort auto detection.
*/
- for (auto entry : context->drivers()) {
+ for (auto& entry : context->drivers()) {
if (!do_scan)
break;
+
+ // Skip drivers we won't scan anyway
+ if (!driver_supported(entry.second))
+ continue;
+
progress->setLabelText(QObject::tr("Scanning for %1...")
.arg(QString::fromStdString(entry.first)));
{
map<const ConfigKey *, Glib::VariantBase> result;
- for (auto entry : user_spec) {
+ for (auto& entry : user_spec) {
/*
* Split key=value specs. Accept entries without separator
* (for simplified boolean specifications).
return result;
}
-list< shared_ptr<devices::HardwareDevice> >
-DeviceManager::driver_scan(
- shared_ptr<Driver> driver, map<const ConfigKey *, VariantBase> drvopts)
+bool DeviceManager::driver_supported(shared_ptr<Driver> driver) const
{
- list< shared_ptr<devices::HardwareDevice> > driver_devices;
-
- assert(driver);
-
/*
* We currently only support devices that can deliver samples at
* a fixed samplerate (i.e. oscilloscopes and logic analysers).
* @todo Add support for non-monotonic devices (DMMs, sensors, etc).
*/
const auto keys = driver->config_keys();
- bool supported_device = keys.count(ConfigKey::LOGIC_ANALYZER) |
- keys.count(ConfigKey::OSCILLOSCOPE);
- if (!supported_device)
+
+ return keys.count(ConfigKey::LOGIC_ANALYZER) | keys.count(ConfigKey::OSCILLOSCOPE);
+}
+
+list< shared_ptr<devices::HardwareDevice> >
+DeviceManager::driver_scan(
+ shared_ptr<Driver> driver, map<const ConfigKey *, VariantBase> drvopts)
+{
+ list< shared_ptr<devices::HardwareDevice> > driver_devices;
+
+ assert(driver);
+
+ if (!driver_supported(driver))
return driver_devices;
// Remove any device instances from this driver from the device
auto devices = driver->scan(drvopts);
// Add the scanned devices to the main list, set display names and sort.
- for (shared_ptr<sigrok::HardwareDevice> device : devices) {
+ for (shared_ptr<sigrok::HardwareDevice>& device : devices) {
const shared_ptr<devices::HardwareDevice> d(
new devices::HardwareDevice(context_, device));
driver_devices.push_back(d);