From f6dd15477d7267da281d4305386daf3e984ac437 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 16 Jul 2013 12:30:04 -0700 Subject: usb: useful error messages on failed submit --- host/lib/transport/libusb1_zero_copy.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'host/lib/transport') 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 #include #include +#include #include #include #include @@ -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){ -- cgit v1.2.3