diff options
author | Josh Blum <josh@joshknows.com> | 2011-10-24 14:42:46 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-10-24 14:42:46 -0700 |
commit | a91849bb2fa18c197cba496dd03f8ebc3222e700 (patch) | |
tree | be96a798b75ab8712e14fd22445cd435ad08cd5e /host/lib/transport/libusb1_base.cpp | |
parent | 7d0fe9fd86c1726e89c7513fb8bbd8502a4d4554 (diff) | |
download | uhd-a91849bb2fa18c197cba496dd03f8ebc3222e700.tar.gz uhd-a91849bb2fa18c197cba496dd03f8ebc3222e700.tar.bz2 uhd-a91849bb2fa18c197cba496dd03f8ebc3222e700.zip |
usb: improve messages/logging for when the usb open fails
Diffstat (limited to 'host/lib/transport/libusb1_base.cpp')
-rw-r--r-- | host/lib/transport/libusb1_base.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/host/lib/transport/libusb1_base.cpp b/host/lib/transport/libusb1_base.cpp index 9b4290c08..d4ec874f1 100644 --- a/host/lib/transport/libusb1_base.cpp +++ b/host/lib/transport/libusb1_base.cpp @@ -17,8 +17,11 @@ #include "libusb1_base.hpp" #include <uhd/exception.hpp> +#include <uhd/utils/msg.hpp> +#include <uhd/utils/log.hpp> #include <uhd/types/dict.hpp> #include <boost/weak_ptr.hpp> +#include <boost/thread/mutex.hpp> #include <boost/foreach.hpp> #include <iostream> @@ -195,6 +198,10 @@ 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; + //lock for atomic access to static table above + static boost::mutex mutex; + boost::mutex::scoped_lock lock(mutex); + //not expired -> get existing handle if (handles.has_key(dev->get()) and not handles[dev->get()].expired()){ return handles[dev->get()].lock(); @@ -207,7 +214,14 @@ libusb::device_handle::sptr libusb::device_handle::get_cached_handle(device::spt return new_handle; } catch(const uhd::exception &){ - std::cerr << "USB open failed: see the application notes for your device." << std::endl; + #ifdef UHD_PLATFORM_LINUX + UHD_MSG(error) << + "USB open failed: insufficient permissions.\n" + "See the application notes for your device.\n" + << std::endl; + #else + UHD_LOG << "USB open failed: device already claimed." << std::endl; + #endif throw; } } |