Hosted: Handle devices w/o serial number, e.g. GigaDevices GD-Link ARM/CMSIS-DAP
This commit is contained in:
parent
0f1fe9e438
commit
4c5ce0b16a
|
@ -98,12 +98,19 @@ int find_debuggers(BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
||||||
char serial[64];
|
char serial[64];
|
||||||
char manufacturer[128];
|
char manufacturer[128];
|
||||||
char product[128];
|
char product[128];
|
||||||
bmp_type_t type = BMP_TYPE_NONE;
|
bmp_type_t type;
|
||||||
bool access_problems = false;
|
bool access_problems = false;
|
||||||
char *active_cable = NULL;
|
char *active_cable = NULL;
|
||||||
bool ftdi_unknown = false;
|
bool ftdi_unknown = false;
|
||||||
rescan:
|
rescan:
|
||||||
|
type = BMP_TYPE_NONE;
|
||||||
found_debuggers = 0;
|
found_debuggers = 0;
|
||||||
|
serial[0] = 0;
|
||||||
|
manufacturer[0] = 0;
|
||||||
|
product[0] = 0;
|
||||||
|
access_problems = false;
|
||||||
|
active_cable = NULL;
|
||||||
|
ftdi_unknown = false;
|
||||||
for (int i = 0; devs[i]; i++) {
|
for (int i = 0; devs[i]; i++) {
|
||||||
libusb_device *dev = devs[i];
|
libusb_device *dev = devs[i];
|
||||||
int res = libusb_get_device_descriptor(dev, &desc);
|
int res = libusb_get_device_descriptor(dev, &desc);
|
||||||
|
@ -130,12 +137,8 @@ int find_debuggers(BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
||||||
res = libusb_get_string_descriptor_ascii(
|
res = libusb_get_string_descriptor_ascii(
|
||||||
handle, desc.iSerialNumber, (uint8_t*)serial,
|
handle, desc.iSerialNumber, (uint8_t*)serial,
|
||||||
sizeof(serial));
|
sizeof(serial));
|
||||||
if (res <= 0) {
|
if (cl_opts->opt_serial && ((res <= 0) ||
|
||||||
/* This can fail for many devices. Continue silent!*/
|
!strstr(serial, cl_opts->opt_serial))) {
|
||||||
libusb_close(handle);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (cl_opts->opt_serial && !strstr(serial, cl_opts->opt_serial)) {
|
|
||||||
libusb_close(handle);
|
libusb_close(handle);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -154,6 +157,9 @@ int find_debuggers(BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info)
|
||||||
libusb_close(handle);
|
libusb_close(handle);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
libusb_close(handle);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
libusb_close(handle);
|
libusb_close(handle);
|
||||||
if (cl_opts->opt_ident_string) {
|
if (cl_opts->opt_ident_string) {
|
||||||
|
|
|
@ -56,18 +56,18 @@ int dap_init(bmp_info_t *info)
|
||||||
if (hid_init())
|
if (hid_init())
|
||||||
return -1;
|
return -1;
|
||||||
int size = strlen(info->serial);
|
int size = strlen(info->serial);
|
||||||
wchar_t serial[size + 1], *wc = serial;
|
wchar_t serial[64] = {0}, *wc = serial;
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
*wc++ = info->serial[i];
|
*wc++ = info->serial[i];
|
||||||
*wc = 0;
|
*wc = 0;
|
||||||
/* Blacklist devices that do not wirk with 513 byte report length
|
/* Blacklist devices that do not work with 513 byte report length
|
||||||
* FIXME: Find a solution to decipher from the device.
|
* FIXME: Find a solution to decipher from the device.
|
||||||
*/
|
*/
|
||||||
if ((info->vid == 0x1fc9) && (info->pid == 0x0132)) {
|
if ((info->vid == 0x1fc9) && (info->pid == 0x0132)) {
|
||||||
DEBUG_WARN("Blacklist\n");
|
DEBUG_WARN("Blacklist\n");
|
||||||
report_size = 64 + 1;
|
report_size = 64 + 1;
|
||||||
}
|
}
|
||||||
handle = hid_open(info->vid, info->pid, serial);
|
handle = hid_open(info->vid, info->pid, (serial[0]) ? serial : NULL);
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return -1;
|
return -1;
|
||||||
dap_disconnect();
|
dap_disconnect();
|
||||||
|
|
Loading…
Reference in New Issue