aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/transport/libusb1_base.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-10-04 10:09:31 -0700
committerJosh Blum <josh@joshknows.com>2010-10-04 10:09:31 -0700
commit1da774f8abffefb9ed239699551fb116a5effba3 (patch)
tree77385c5a521e5a2e99dbf969d7770ff4b6bf229f /host/lib/transport/libusb1_base.cpp
parent46d2fc423d2fdcf32454621c6f41e555d2496702 (diff)
parent9cea1342941e74b911ca26cc41c64e340f04c270 (diff)
downloaduhd-1da774f8abffefb9ed239699551fb116a5effba3.tar.gz
uhd-1da774f8abffefb9ed239699551fb116a5effba3.tar.bz2
uhd-1da774f8abffefb9ed239699551fb116a5effba3.zip
Merge branch 'timeout' into usrp_e_mmap
Diffstat (limited to 'host/lib/transport/libusb1_base.cpp')
-rw-r--r--host/lib/transport/libusb1_base.cpp16
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());
+ }
}
/***********************************************************************