aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/cmake/Modules/FindUSB1.cmake7
-rw-r--r--host/lib/transport/libusb1_zero_copy.cpp15
2 files changed, 19 insertions, 3 deletions
diff --git a/host/cmake/Modules/FindUSB1.cmake b/host/cmake/Modules/FindUSB1.cmake
index a1ab4ca90..a494e1350 100644
--- a/host/cmake/Modules/FindUSB1.cmake
+++ b/host/cmake/Modules/FindUSB1.cmake
@@ -40,12 +40,17 @@ endif()
if(LIBUSB_LIBRARIES)
set(CMAKE_REQUIRED_LIBRARIES ${LIBUSB_LIBRARIES})
endif()
-CHECK_FUNCTION_EXISTS("libusb_handle_events_timeout_completed" HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED)
+CHECK_FUNCTION_EXISTS("libusb_handle_events_timeout_completed" HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED)
if(HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED)
list(APPEND LIBUSB_DEFINITIONS "HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED=1")
endif(HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED)
+CHECK_FUNCTION_EXISTS("libusb_error_name" HAVE_LIBUSB_ERROR_NAME)
+if(HAVE_LIBUSB_ERROR_NAME)
+ list(APPEND LIBUSB_DEFINITIONS "HAVE_LIBUSB_ERROR_NAME=1")
+endif(HAVE_LIBUSB_ERROR_NAME)
+
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIRS)
MARK_AS_ADVANCED(LIBUSB_INCLUDE_DIRS LIBUSB_LIBRARIES)
diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp
index 3532dc4aa..09ead2adf 100644
--- a/host/lib/transport/libusb1_zero_copy.cpp
+++ b/host/lib/transport/libusb1_zero_copy.cpp
@@ -21,6 +21,7 @@
#include <uhd/utils/msg.hpp>
#include <uhd/exception.hpp>
#include <boost/foreach.hpp>
+#include <boost/format.hpp>
#include <boost/make_shared.hpp>
#include <boost/thread/thread.hpp>
#include <list>
@@ -42,6 +43,12 @@ static const size_t DEFAULT_XFER_SIZE = 32*512; //bytes
libusb_handle_events_timeout(ctx, tx)
#endif
+//! libusb_error_name is only in newer API
+#ifndef HAVE_LIBUSB_ERROR_NAME
+ #define libusb_error_name(code) \
+ str(boost::format("LIBUSB_ERROR_CODE %d") % code)
+#endif
+
/*!
* All libusb callback functions should be marked with the LIBUSB_CALL macro
* to ensure that they are compiled with the same calling convention as libusb.
@@ -105,7 +112,9 @@ public:
void release(void){
completed = 0;
_lut->length = _frame_size; //always reset length
- UHD_ASSERT_THROW(libusb_submit_transfer(_lut) == 0);
+ const int ret = libusb_submit_transfer(_lut);
+ if (ret != 0) throw uhd::runtime_error(
+ "usb rx submit failed: " + std::string(libusb_error_name(ret)));
}
sptr get_new(const double timeout, size_t &index){
@@ -138,7 +147,9 @@ public:
void release(void){
completed = 0;
_lut->length = size();
- UHD_ASSERT_THROW(libusb_submit_transfer(_lut) == 0);
+ const int ret = libusb_submit_transfer(_lut);
+ if (ret != 0) throw uhd::runtime_error(
+ "usb tx submit failed: " + std::string(libusb_error_name(ret)));
}
sptr get_new(const double timeout, size_t &index){