Fwd: Patch for readers based on a Realtek chip on OSX

Martin Paljak <[email protected]>
Newsgroups gmane.comp.lib.muscle
Message-ID <CACsm3DXcRxMgdUM68J=Z6zd1BY4quQQbWuA4_eUxWkSRU0feZg@mail.gmail.com>
Hello,

somehow my mail client had the other address as default for MUSCLE.

---------- Forwarded message ----------
From: Martin Paljak <[email protected]>
Date: Fri, Jan 3, 2014 at 6:32 PM
Subject: Patch for readers based on a Realtek chip on OSX
To: Talks about MUSCLE <[email protected]>


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

_______________________________________________
Muscle mailing list
[email protected]
http://lists.musclecard.com/mailman/listinfo/muscle_lists.musclecard.com
ccid.diff (text/plain, 780 B)
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)
 	{
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.