diff options
author | Josh Blum <josh@joshknows.com> | 2010-10-01 11:54:22 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-10-01 11:54:22 -0700 |
commit | 348b5b12ad9ec916c92d642bfb28e47264473535 (patch) | |
tree | bdc1affa3208ca9c262073cfaa9acf4e0df319b0 /host/lib/transport | |
parent | b079d9d1751415139518f34d792200b041aff10b (diff) | |
download | uhd-348b5b12ad9ec916c92d642bfb28e47264473535.tar.gz uhd-348b5b12ad9ec916c92d642bfb28e47264473535.tar.bz2 uhd-348b5b12ad9ec916c92d642bfb28e47264473535.zip |
usb: catch open errors and print message, device: catch exceptions at discovery time
Diffstat (limited to 'host/lib/transport')
-rw-r--r-- | host/lib/transport/libusb1_base.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/host/lib/transport/libusb1_base.cpp b/host/lib/transport/libusb1_base.cpp index 49f524a32..910b04fc8 100644 --- a/host/lib/transport/libusb1_base.cpp +++ b/host/lib/transport/libusb1_base.cpp @@ -213,15 +213,21 @@ private: libusb::device_handle::sptr libusb::device_handle::get_cached_handle(device::sptr dev){ static uhd::dict<libusb_device *, boost::weak_ptr<device_handle> > handles; - //not expired -> get existing session + //not expired -> get existing handle if (handles.has_key(dev->get()) and not handles[dev->get()].expired()){ return handles[dev->get()].lock(); } - //create a new global session - sptr new_handle(new libusb_device_handle_impl(dev)); - handles[dev->get()] = new_handle; - return new_handle; + //create a new cached handle + try{ + sptr new_handle(new libusb_device_handle_impl(dev)); + handles[dev->get()] = new_handle; + return new_handle; + } + catch(const std::exception &e){ + std::cerr << "USB open failed: see the application notes for your device." << std::endl; + throw std::runtime_error(e.what()); + } } /*********************************************************************** |