diff options
author | Josh Blum <josh@joshknows.com> | 2013-07-16 12:30:04 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2013-07-16 12:30:04 -0700 |
commit | f6dd15477d7267da281d4305386daf3e984ac437 (patch) | |
tree | af2419349835fbda7826cdc6fbfe5e204b9eb61e /host/lib | |
parent | 4677db78f1d555e604ff8a12fc7e36ecdb1e3c2d (diff) | |
download | uhd-f6dd15477d7267da281d4305386daf3e984ac437.tar.gz uhd-f6dd15477d7267da281d4305386daf3e984ac437.tar.bz2 uhd-f6dd15477d7267da281d4305386daf3e984ac437.zip |
usb: useful error messages on failed submit
Diffstat (limited to 'host/lib')
-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){ |