[Pcsclite-muscle] [PATCH v2 ccid]: Improve the recent fix for getting the number of supported data rates

Guido Trentalancia guido at trentalancia.com
Thu Apr 8 22:15:26 BST 2021

Improve the following two recent fixes to get the number of supported data rates:
commit b00292f718e9f13626147af63bfb9164ec74d2cb
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Sat Mar 27 18:46:15 2021 +0100

    ccid_usb: ask for bNumDataRatesSupported data rates

    Some devices set bNumDataRatesSupported to a value different from 0 but
    libusb_control_transfer() fails if another value (like 256) is used.

    The Alcor Micro 9540 is such a reader.

commit 19b9e9256781b55513e22e8ecd9c85ad409e9069 (HEAD -> master, origin/master, origin/HEAD)
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Sun Apr 4 19:04:10 2021 +0200

    get_data_rates(): fix bug if bNumDataRatesSupported > 0

    The bug was introduced in b00292f718e9f13626147af63bfb9164ec74d2cb (not
    released in a stable version)

    Thanks to Godfrey Chung got the bug report


These fixes seem also needed on the following reader: Bit4Id miniLector AIR NFC v3 (25DD:3403).

Signed-off-by: Guido Trentalancia <guido at trentalancia.com>

diff -pru ccid-git-08042021-0700/src/parse.c ccid-1.4.34-to-git-08042021-0700/src/parse.c
--- ccid-git-08042021-0700/src/parse.c	2021-04-08 06:55:26.700371266 +0200
+++ ccid-1.4.34-to-git-08042021-0700/src/parse.c	2021-04-08 21:51:23.354942352 +0200
@@ -496,15 +501,15 @@ static int ccid_parse_interface_descript
 				int i;
 				/* we do not get the expected number of data rates */
-				if ((n != device_descriptor[27]*4) && device_descriptor[27])
+				if ((n != bNumDataRatesSupported*4) && bNumDataRatesSupported)
 					(void)printf("   Got %d data rates but was expecting %d\n", n/4,
-						device_descriptor[27]);
+						bNumDataRatesSupported);
 					/* we got more data than expected */
-					if (n > device_descriptor[27]*4)
-						n = device_descriptor[27]*4;
+					if (n > bNumDataRatesSupported*4)
+						n = bNumDataRatesSupported*4;

More information about the pcsclite-muscle mailing list