summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Corgan <nick.corgan@ettus.com>2013-11-18 13:01:32 -0800
committerNicholas Corgan <nick.corgan@ettus.com>2013-11-18 13:01:32 -0800
commit9a45063077f27140367ccb749c8d794f60729526 (patch)
tree71fa01735f4c4701c6e6d504eb14874c6b99a58d
parent91c10b31f94f95f1588571e0580b09a8b354a2a3 (diff)
downloaduhd-9a45063077f27140367ccb749c8d794f60729526.tar.gz
uhd-9a45063077f27140367ccb749c8d794f60729526.tar.bz2
uhd-9a45063077f27140367ccb749c8d794f60729526.zip
b2xx_fx3_utils: catch error when WinUSB drivers aren't installed
-rw-r--r--host/utils/b2xx_fx3_utils.cpp55
1 files changed, 46 insertions, 9 deletions
diff --git a/host/utils/b2xx_fx3_utils.cpp b/host/utils/b2xx_fx3_utils.cpp
index d4e3b0f9a..391b45ab9 100644
--- a/host/utils/b2xx_fx3_utils.cpp
+++ b/host/utils/b2xx_fx3_utils.cpp
@@ -35,6 +35,7 @@
#include <boost/functional/hash.hpp>
#include <b200_iface.hpp>
+#include <uhd/config.hpp>
#include <uhd/transport/usb_control.hpp>
#include <uhd/transport/usb_device_handle.hpp>
#include <uhd/exception.hpp>
@@ -178,8 +179,17 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) {
<< boost::format("0x%X") % pid << std::endl;
return -1;
}
- usb_ctrl = uhd::transport::usb_control::make(handles[0], 0);
- b200 = b200_iface::make(usb_ctrl);
+ try {
+ usb_ctrl = uhd::transport::usb_control::make(handles[0], 0);
+ b200 = b200_iface::make(usb_ctrl);
+ }
+ catch(const std::exception &e) {
+ std::cerr << "Failed to communicate with device!" << std::endl;
+ #ifdef UHD_PLATFORM_WIN32
+ std::cerr << "The necessary drivers are not installed. Read the UHD Transport Application Notes for details." << std::endl;
+ #endif /* UHD_PLATFORM_WIN32 */
+ return -1;
+ }
if (!(handles[0]->firmware_loaded()))
{
@@ -226,8 +236,17 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) {
std::cerr << "Cannot find device" << std::endl;
return -1;
}
- usb_ctrl = uhd::transport::usb_control::make(handles[0], 0);
- b200 = b200_iface::make(usb_ctrl);
+ try {
+ usb_ctrl = uhd::transport::usb_control::make(handles[0], 0);
+ b200 = b200_iface::make(usb_ctrl);
+ }
+ catch(const std::exception &e) {
+ std::cerr << "Failed to communicate with device!" << std::endl;
+ #ifdef UHD_PLATFORM_WIN32
+ std::cerr << "The necessary drivers are not installed. Read the UHD Transport Application Notes for details." << std::endl;
+ #endif /* UHD_PLATFORM_WIN32 */
+ return -1;
+ }
if (!(handles[0]->firmware_loaded()))
{
@@ -307,8 +326,17 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) {
std::cout << "Initialized B2xx detected..." << std::flush;
- usb_ctrl = uhd::transport::usb_control::make(handles[0], 0);
- b200 = b200_iface::make(usb_ctrl);
+ try {
+ usb_ctrl = uhd::transport::usb_control::make(handles[0], 0);
+ b200 = b200_iface::make(usb_ctrl);
+ }
+ catch(const std::exception &e) {
+ std::cerr << "Failed to communicate with device!" << std::endl;
+ #ifdef UHD_PLATFORM_WIN32
+ std::cerr << "The necessary drivers are not installed. Read the UHD Transport Application Notes for details." << std::endl;
+ #endif /* UHD_PLATFORM_WIN32 */
+ return -1;
+ }
std::cout << " Control of B2xx granted..." << std::endl << std::endl;
@@ -383,9 +411,18 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) {
std::cout << "Uninitialized B2xx detected..." << std::flush;
- usb_ctrl = uhd::transport::usb_control::make(handles[0], 0);
- b200 = b200_iface::make(usb_ctrl);
-
+ try {
+ usb_ctrl = uhd::transport::usb_control::make(handles[0], 0);
+ b200 = b200_iface::make(usb_ctrl);
+ }
+ catch(const std::exception &e) {
+ std::cerr << "Failed to communicate with device!" << std::endl;
+ #ifdef UHD_PLATFORM_WIN32
+ std::cerr << "The necessary drivers are not installed. Read the UHD Transport Application Notes for details." << std::endl;
+ #endif /* UHD_PLATFORM_WIN32 */
+ return -1;
+ }
+
std::cout << " Control of B2xx granted..." << std::endl << std::endl;
if (!(handles[0]->firmware_loaded()))