From a91849bb2fa18c197cba496dd03f8ebc3222e700 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 24 Oct 2011 14:42:46 -0700 Subject: usb: improve messages/logging for when the usb open fails --- host/lib/transport/libusb1_base.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'host/lib') 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 +#include +#include #include #include +#include #include #include @@ -195,6 +198,10 @@ private: libusb::device_handle::sptr libusb::device_handle::get_cached_handle(device::sptr dev){ static uhd::dict > 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; } } -- cgit v1.2.3