Browse Source

Merge pull request #406 from kanoi/bflsc

USB device list - convert some common error numbers to messages + nDevs required for -n with usb
nfactor-troky
Con Kolivas 12 years ago
parent
commit
e10a7041d8
  1. 4
      cgminer.c
  2. 52
      usbutils.c

4
cgminer.c

@ -92,9 +92,11 @@ int opt_bench_algo = -1;
static const bool opt_time = true; static const bool opt_time = true;
unsigned long long global_hashrate; unsigned long long global_hashrate;
#if defined(HAVE_OPENCL) || defined(USE_USBUTILS)
int nDevs;
#endif
#ifdef HAVE_OPENCL #ifdef HAVE_OPENCL
int opt_dynamic_interval = 7; int opt_dynamic_interval = 7;
int nDevs;
int opt_g_threads = 2; int opt_g_threads = 2;
int gpu_threads; int gpu_threads;
#ifdef USE_SCRYPT #ifdef USE_SCRYPT

52
usbutils.c

@ -33,8 +33,12 @@
#define DRV_MODMINER 3 #define DRV_MODMINER 3
#endif #endif
#ifdef USE_ZTEX
#define DRV_ZTEX 4
#endif
#ifdef USE_ICARUS #ifdef USE_ICARUS
#define DRV_ICARUS 4 #define DRV_ICARUS 5
#endif #endif
#define DRV_LAST -1 #define DRV_LAST -1
@ -124,6 +128,21 @@ static struct usb_find_devices find_dev[] = {
.timeout = MODMINER_TIMEOUT_MS, .timeout = MODMINER_TIMEOUT_MS,
.epcount = ARRAY_SIZE(mmq_eps), .epcount = ARRAY_SIZE(mmq_eps),
.eps = mmq_eps }, .eps = mmq_eps },
#endif
#ifdef USE_ZTEX
// This is here so cgminer -n shows them
// the ztex driver (as at 201303) doesn't use usbutils
{
.drv = DRV_ZTEX,
.name = "ZTX",
.idVendor = 0x221a,
.idProduct = 0x0100,
.kernel = 0,
.config = 1,
.interface = 1,
.timeout = 100,
.epcount = 0,
.eps = NULL },
#endif #endif
{ DRV_LAST, NULL, 0, 0, 0, 0, 0, 0, 0, NULL } { DRV_LAST, NULL, 0, 0, 0, 0, 0, 0, 0, NULL }
}; };
@ -277,6 +296,29 @@ static const char *BULK = "Bulk";
static const char *INTERRUPT = "Interrupt"; static const char *INTERRUPT = "Interrupt";
static const char *UNKNOWN = "Unknown"; static const char *UNKNOWN = "Unknown";
static const char *err_io_str = " IO Error";
static const char *err_access_str = " Access Denied-a";
static const char *err_timeout_str = " Reply Timeout";
static const char *err_pipe_str = " Access denied-p";
static const char *err_other_str = " Access denied-o";
static const char *usberrstr(int err)
{
switch (err) {
case LIBUSB_ERROR_IO:
return err_io_str;
case LIBUSB_ERROR_ACCESS:
return err_access_str;
case LIBUSB_ERROR_TIMEOUT:
return err_timeout_str;
case LIBUSB_ERROR_PIPE:
return err_pipe_str;
case LIBUSB_ERROR_OTHER:
return err_other_str;
}
return BLANK;
}
static const char *destype(uint8_t bDescriptorType) static const char *destype(uint8_t bDescriptorType)
{ {
switch (bDescriptorType) { switch (bDescriptorType) {
@ -481,11 +523,11 @@ static void usb_full(ssize_t *count, libusb_device *dev, char **buf, size_t *off
err = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, man, STRBUFLEN); err = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, man, STRBUFLEN);
if (err < 0) if (err < 0)
sprintf((char *)man, "** err(%d)", err); sprintf((char *)man, "** err(%d)%s", err, usberrstr(err));
err = libusb_get_string_descriptor_ascii(handle, desc.iProduct, prod, STRBUFLEN); err = libusb_get_string_descriptor_ascii(handle, desc.iProduct, prod, STRBUFLEN);
if (err < 0) if (err < 0)
sprintf((char *)prod, "** err(%d)", err); sprintf((char *)prod, "** err(%d)%s", err, usberrstr(err));
if (level == 0) { if (level == 0) {
libusb_close(handle); libusb_close(handle);
@ -561,7 +603,7 @@ static void usb_full(ssize_t *count, libusb_device *dev, char **buf, size_t *off
err = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, ser, STRBUFLEN); err = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, ser, STRBUFLEN);
if (err < 0) if (err < 0)
sprintf((char *)ser, "** err(%d)", err); sprintf((char *)ser, "** err(%d)%s", err, usberrstr(err));
sprintf(tmp, EOL " dev %d: More Info:" EOL "\tManufacturer: '%s'" EOL sprintf(tmp, EOL " dev %d: More Info:" EOL "\tManufacturer: '%s'" EOL
"\tProduct: '%s'" EOL "\tSerial '%s'", "\tProduct: '%s'" EOL "\tSerial '%s'",
@ -581,7 +623,7 @@ void usb_all(int level)
count = libusb_get_device_list(NULL, &list); count = libusb_get_device_list(NULL, &list);
if (count < 0) { if (count < 0) {
applog(LOG_ERR, "USB all: failed, err %d", (int)count); applog(LOG_ERR, "USB all: failed, err %d%s", (int)count, usberrstr((int)count));
return; return;
} }

Loading…
Cancel
Save