diff options
Diffstat (limited to 'host/lib/transport')
-rw-r--r-- | host/lib/transport/libusb1_zero_copy.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
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){ |