diff options
author | Marcus Müller <marcus.mueller@ettus.com> | 2015-02-27 19:44:26 +0100 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2015-03-03 14:12:43 -0800 |
commit | 499bcc0238315a2e1f01625d725a67b168acb99f (patch) | |
tree | f059e1e126f7a6817a2e9675f66417ce563439a0 | |
parent | 963dcaa6a75862aec9ee4924dd88fa0901b39934 (diff) | |
download | uhd-499bcc0238315a2e1f01625d725a67b168acb99f.tar.gz uhd-499bcc0238315a2e1f01625d725a67b168acb99f.tar.bz2 uhd-499bcc0238315a2e1f01625d725a67b168acb99f.zip |
uhd: Fixed: Exception during detection kills device::make
On systems with libusb but not USB, device detection for USB
devices fails (lsusb itself dies with "error -99").
This crashes the device detection process itself.
Also made the documentation for ::make match what it actually does.
-rw-r--r-- | host/include/uhd/device.hpp | 4 | ||||
-rw-r--r-- | host/lib/device.cpp | 23 |
2 files changed, 17 insertions, 10 deletions
diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp index 1e88a4138..5ca48f8e9 100644 --- a/host/include/uhd/device.hpp +++ b/host/include/uhd/device.hpp @@ -77,7 +77,9 @@ public: /*! * \brief Create a new device from the device address hint. * - * The make routine will call find and pick one of the results. + * The method will go through the registered device types and pick one of + * the discovered devices. + * * By default, the first result will be used to create a new device. * Use the which parameter as an index into the list of results. * diff --git a/host/lib/device.cpp b/host/lib/device.cpp index 006ea6ec8..3e84d5bea 100644 --- a/host/lib/device.cpp +++ b/host/lib/device.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010-2011,2014 Ettus Research LLC +// Copyright 2010-2011,2014-2015 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -90,9 +90,9 @@ device_addrs_t device::find(const device_addr_t &hint, device_filter_t filter){ device_addrs_t device_addrs; - BOOST_FOREACH(const dev_fcn_reg_t &fcn, get_dev_fcn_regs()){ - try{ - if(filter == ANY or fcn.get<2>() == filter){ + BOOST_FOREACH(const dev_fcn_reg_t &fcn, get_dev_fcn_regs()) { + try { + if (filter == ANY or fcn.get<2>() == filter) { device_addrs_t discovered_addrs = fcn.get<0>()(hint); device_addrs.insert( device_addrs.begin(), @@ -101,7 +101,7 @@ device_addrs_t device::find(const device_addr_t &hint, device_filter_t filter){ ); } } - catch(const std::exception &e){ + catch (const std::exception &e) { UHD_MSG(error) << "Device discovery error: " << e.what() << std::endl; } } @@ -119,12 +119,17 @@ device::sptr device::make(const device_addr_t &hint, device_filter_t filter, siz std::vector<dev_addr_make_t> dev_addr_makers; BOOST_FOREACH(const dev_fcn_reg_t &fcn, get_dev_fcn_regs()){ - if(filter == ANY or fcn.get<2>() == filter){ - BOOST_FOREACH(device_addr_t dev_addr, fcn.get<0>()(hint)){ - //append the discovered address and its factory function - dev_addr_makers.push_back(dev_addr_make_t(dev_addr, fcn.get<1>())); + try{ + if(filter == ANY or fcn.get<2>() == filter){ + BOOST_FOREACH(device_addr_t dev_addr, fcn.get<0>()(hint)){ + //append the discovered address and its factory function + dev_addr_makers.push_back(dev_addr_make_t(dev_addr, fcn.get<1>())); + } } } + catch(const std::exception &e){ + UHD_MSG(error) << "Device discovery error: " << e.what() << std::endl; + } } //check that we found any devices |