usb display message when device is in use/another cgminer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
diff --git a/usbutils.c b/usbutils.c
index fe8931a..ad3ff27 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -714,6 +714,10 @@ bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find
cgusb = calloc(1, sizeof(*cgusb));
cgusb->found = found;
+
+ cgusb->bus_number = libusb_get_bus_number(dev);
+ cgusb->device_address = libusb_get_device_address(dev);
+
cgusb->descriptor = calloc(1, sizeof(*(cgusb->descriptor)));
err = libusb_get_device_descriptor(dev, cgusb->descriptor);
@@ -737,7 +741,6 @@ bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find
default:
applog(LOG_ERR, "USB init, open device failed, err %d", err);
}
-
goto dame;
}
@@ -751,8 +754,15 @@ bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find
err = libusb_set_configuration(cgusb->handle, found->config);
if (err) {
- applog(LOG_DEBUG, "USB init, failed to set config to %d, err %d",
- found->config, err);
+ switch(err) {
+ case LIBUSB_ERROR_BUSY:
+ applog(LOG_WARNING, "USB init, %s device %d:%d in use",
+ found->name, cgusb->bus_number, cgusb->device_address);
+ break;
+ default:
+ applog(LOG_DEBUG, "USB init, failed to set config to %d, err %d",
+ found->config, err);
+ }
goto cldame;
}
@@ -797,8 +807,6 @@ bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find
goto cldame;
}
- cgusb->bus_number = libusb_get_bus_number(dev);
- cgusb->device_address = libusb_get_device_address(dev);
cgusb->usbver = cgusb->descriptor->bcdUSB;
// TODO: allow this with the right version of the libusb include and running library