Improve error message for not able to open
authortexane <texane@gmail.com>
Mon, 24 Nov 2014 22:29:09 +0000 (16:29 -0600)
committertexane <texane@gmail.com>
Mon, 24 Nov 2014 22:29:09 +0000 (16:29 -0600)
src/stlink-usb.c

index d0baa0deb965b23f31d5d6f9588460287c3a8bd2..d8b6c4673318a889147e6c8d76fcdac5de701f98 100644 (file)
@@ -5,6 +5,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <libusb.h>
+#include <errno.h>
 
 #include "stlink-common.h"
 #include "stlink-usb.h"
@@ -788,7 +789,8 @@ stlink_t* stlink_open_usb(const int verbose, int reset) {
     } else {
         int error = libusb_open(list[cnt], &slu->usb_handle);
         if( error !=0 ) {
-            WLOG("Error %d opening ST-Link/V2 device %03d:%03d\n", error, libusb_get_bus_number(list[cnt]), libusb_get_device_address(list[cnt]));
+            WLOG("Error %d (%s) opening ST-Link/V2 device %03d:%03d\n", 
+               error, strerror (errno), libusb_get_bus_number(list[cnt]), libusb_get_device_address(list[cnt]));
             goto on_error;
         }
     }