[Pcsclite-muscle] Patch for readers based on a Realtek chip on OSX

Martin Paljak martin
Fri Jan 3 10:32:15 PST 2014


Hello,

It seems to be a bug in libusb(x) that makes several readers based on
a Realtek chip (RTS5169) not function on OSX when re-plugged into the
system where pcscd is already running (a clean state of libusb works
though).

As I don't have what it takes to debug and fix libusb(x), I found a
workaround. Not an elegant solution, but makes the device work. The
patch marks it as an ugly hack and also localizes it pretty well, so
it would be nice to include it in the upstream source (because there
should be an installer based on published releases, as I'll write in
another post)


Have a fruitful 2014!

--
Martin
+372 515 6495
-------------- next part --------------
diff --git a/trunk/Drivers/ccid/src/ccid_usb.c b/trunk/Drivers/ccid/src/ccid_usb.c
index 9584016..c74ac5f 100644
--- a/trunk/Drivers/ccid/src/ccid_usb.c
+++ b/trunk/Drivers/ccid/src/ccid_usb.c
@@ -311,6 +311,16 @@ status_t OpenUSBByName(unsigned int reader_index, /*@null@*/ char *device)
 		}
 	}
 
+#ifdef __APPLE__
+	/* XXX: there seems to be a bug in libusb that makes this specific device not
+	   show up properly for libusb after it is (re)plugged. Giving it a bit more time
+	   makes it show up in libusb list. Not an elegant solution but makes the device
+	   work. */
+	if (!strcmp("Generic USB2.0-CRW", device)) {
+		DEBUG_CRITICAL("Giving Realtek chip some more time...");
+		usleep(900000);
+	}
+#endif
 	cnt = libusb_get_device_list(ctx, &devs);
 	if (cnt < 0)
 	{



More information about the pcsclite-muscle mailing list