mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 23:08:07 +00:00
usbutils allow device selection to specify expected Manufacturer/Product strings
This commit is contained in:
parent
2517a8a49e
commit
ebfa56db02
42
usbutils.c
42
usbutils.c
@ -109,6 +109,8 @@ static struct usb_find_devices find_dev[] = {
|
|||||||
.name = "BAS",
|
.name = "BAS",
|
||||||
.idVendor = 0x0403,
|
.idVendor = 0x0403,
|
||||||
.idProduct = 0x6014,
|
.idProduct = 0x6014,
|
||||||
|
.iManufacturer = "Butterfly Labs",
|
||||||
|
.iProduct = "BitFORCE SHA256 SC",
|
||||||
.kernel = 0,
|
.kernel = 0,
|
||||||
.config = 1,
|
.config = 1,
|
||||||
.interface = 0,
|
.interface = 0,
|
||||||
@ -122,6 +124,8 @@ static struct usb_find_devices find_dev[] = {
|
|||||||
.name = "BFL",
|
.name = "BFL",
|
||||||
.idVendor = 0x0403,
|
.idVendor = 0x0403,
|
||||||
.idProduct = 0x6014,
|
.idProduct = 0x6014,
|
||||||
|
.iManufacturer = "Butterfly Labs",
|
||||||
|
.iProduct = "BitFORCE SHA256",
|
||||||
.kernel = 0,
|
.kernel = 0,
|
||||||
.config = 1,
|
.config = 1,
|
||||||
.interface = 0,
|
.interface = 0,
|
||||||
@ -170,7 +174,7 @@ static struct usb_find_devices find_dev[] = {
|
|||||||
.epcount = 0,
|
.epcount = 0,
|
||||||
.eps = NULL },
|
.eps = NULL },
|
||||||
#endif
|
#endif
|
||||||
{ DRV_LAST, NULL, 0, 0, 0, 0, 0, 0, 0, NULL }
|
{ DRV_LAST, NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_BFLSC
|
#ifdef USE_BFLSC
|
||||||
@ -1176,6 +1180,42 @@ bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (found->iManufacturer) {
|
||||||
|
unsigned char man[STRBUFLEN+1];
|
||||||
|
applog(LOG_ERR, "USB init, looking for man='%s'", found->iManufacturer);
|
||||||
|
|
||||||
|
err = libusb_get_string_descriptor_ascii(cgusb->handle,
|
||||||
|
cgusb->descriptor->iManufacturer,
|
||||||
|
man, STRBUFLEN);
|
||||||
|
if (err < 0) {
|
||||||
|
applog(LOG_DEBUG,
|
||||||
|
"USB init, failed to get iManufacturer, err %d %s",
|
||||||
|
err, devstr);
|
||||||
|
goto cldame;
|
||||||
|
}
|
||||||
|
applog(LOG_ERR, "USB init, man='%s' to '%s'", found->iManufacturer, man);
|
||||||
|
if (strcmp((char *)man, found->iManufacturer))
|
||||||
|
goto cldame;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found->iProduct) {
|
||||||
|
unsigned char prod[STRBUFLEN+1];
|
||||||
|
applog(LOG_ERR, "USB init, looking for prod='%s'", found->iProduct);
|
||||||
|
|
||||||
|
err = libusb_get_string_descriptor_ascii(cgusb->handle,
|
||||||
|
cgusb->descriptor->iProduct,
|
||||||
|
prod, STRBUFLEN);
|
||||||
|
if (err < 0) {
|
||||||
|
applog(LOG_DEBUG,
|
||||||
|
"USB init, failed to get iProduct, err %d %s",
|
||||||
|
err, devstr);
|
||||||
|
goto cldame;
|
||||||
|
}
|
||||||
|
applog(LOG_ERR, "USB init, prod='%s' to '%s'", found->iProduct, prod);
|
||||||
|
if (strcmp((char *)prod, found->iProduct))
|
||||||
|
goto cldame;
|
||||||
|
}
|
||||||
|
|
||||||
err = libusb_set_configuration(cgusb->handle, found->config);
|
err = libusb_set_configuration(cgusb->handle, found->config);
|
||||||
if (err) {
|
if (err) {
|
||||||
switch(err) {
|
switch(err) {
|
||||||
|
@ -55,6 +55,8 @@ struct usb_find_devices {
|
|||||||
const char *name;
|
const char *name;
|
||||||
uint16_t idVendor;
|
uint16_t idVendor;
|
||||||
uint16_t idProduct;
|
uint16_t idProduct;
|
||||||
|
char *iManufacturer;
|
||||||
|
char *iProduct;
|
||||||
int kernel;
|
int kernel;
|
||||||
int config;
|
int config;
|
||||||
int interface;
|
int interface;
|
||||||
|
Loading…
Reference in New Issue
Block a user