- if ((dev->descriptor.idVendor == VID) && (dev->descriptor.idProduct == PID))
- {
- result->usb_handle = usb_open(dev);
-
- /*
- * Some j-link dongles experience intermittent communication issues at startup to varying degrees
- * depending on the host operating system. Troubleshooting this problem all the way back to libusb
- * revealed that without a usb reset, the hardware can start in an uncertain state causing a litany
- * of annoying problems. The next step was added to the original code to address this problem.
- */
-
- usb_reset(result->usb_handle);
-
- /* usb_set_configuration required under win32 */
- usb_set_configuration(result->usb_handle, dev->config[0].bConfigurationValue);
- usb_claim_interface(result->usb_handle, 0);
+ usleep(1000);
+ timeout--;
+ if (!timeout) {
+ break;
+ }
+ }
+
+ if (dev == NULL)
+ {
+ free(result);
+ return NULL;
+ }
+
+ result->usb_handle = usb_open(dev);
+#endif
+
+#endif
+
+ if (result->usb_handle)
+ {
+ /* usb_set_configuration required under win32 */
+ usb_set_configuration(result->usb_handle, dev->config[0].bConfigurationValue);
+ usb_claim_interface(result->usb_handle, 0);