[Pcsclite-git-commit] [CCID] 01/02: Add Zero Length Packet (ZLP) support for Gemalto IDBridge CT30 and K30

Ludovic Rousseau rousseau at moszumanska.debian.org
Wed Mar 22 17:37:31 UTC 2017


This is an automated email from the git hooks/post-receive script.

rousseau pushed a commit to branch master
in repository CCID.

commit 0b557087017e27e13356a6455cad1e94b9620a00
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Thu Jan 26 13:29:38 2017 +0100

    Add Zero Length Packet (ZLP) support for Gemalto IDBridge CT30 and K30
    
    The Gemalto IDBridge CT30 and IDBridge K30 readers may send a ZLP after
    some commands. Only the readers with firmware 2.00 have the problem.
    
    The solution is to use a short read before every USB write.
    This patch uses a timeout of 10 ms instead of 1 ms in the original patch.
---
 src/ccid.c        | 13 +++++++++++++
 src/ccid.h        |  5 +++++
 src/ccid_serial.c |  1 +
 src/ccid_usb.c    | 11 +++++++++++
 4 files changed, 30 insertions(+)

diff --git a/src/ccid.c b/src/ccid.c
index a1c3b21..2fdbc71 100644
--- a/src/ccid.c
+++ b/src/ccid.c
@@ -67,6 +67,19 @@ int ccid_open_hack_pre(unsigned int reader_index)
 			ccid_descriptor->readTimeout = 60*1000; /* 60 seconds */
 			break;
 
+		case GEMPCTWIN:
+		case GEMPCKEY:
+		case DELLSCRK:
+			/* Only the chipset with firmware version 2.00 is "bogus"
+			 * The reader may send packets of 0 bytes when the reader is
+			 * connected to a USB 3 port */
+			if (0x0200 == ccid_descriptor->IFD_bcdDevice)
+			{
+				ccid_descriptor->zlp = TRUE;
+				DEBUG_INFO1("ZLP fixup");
+			}
+			break;
+
 		case OZ776:
 		case OZ776_7772:
 			ccid_descriptor->dwMaxDataRate = 9600;
diff --git a/src/ccid.h b/src/ccid.h
index fc3a484..b09fe5f 100644
--- a/src/ccid.h
+++ b/src/ccid.h
@@ -137,6 +137,11 @@ typedef struct
 	 * Gemalto extra features, if any
 	 */
 	struct GEMALTO_FIRMWARE_FEATURES *gemalto_firmware_features;
+
+	/*
+	 * Zero Length Packet fixup (boolean)
+	 */
+	char zlp;
 } _ccid_descriptor;
 
 /* Features from dwFeatures */
diff --git a/src/ccid_serial.c b/src/ccid_serial.c
index 32f4027..deffd07 100644
--- a/src/ccid_serial.c
+++ b/src/ccid_serial.c
@@ -614,6 +614,7 @@ static status_t set_ccid_descriptor(unsigned int reader_index,
 	serialDevice[reader_index].ccid.dwSlotStatus = IFD_ICC_PRESENT;
 	serialDevice[reader_index].ccid.bVoltageSupport = 0x07;	/* 1.8V, 3V and 5V */
 	serialDevice[reader_index].ccid.gemalto_firmware_features = NULL;
+	serialDevice[reader_index].ccid.zlp = FALSE;
 	serialDevice[reader_index].echo = TRUE;
 
 	/* change some values depending on the reader */
diff --git a/src/ccid_usb.c b/src/ccid_usb.c
index 0cea7f6..8c2ef77 100644
--- a/src/ccid_usb.c
+++ b/src/ccid_usb.c
@@ -722,6 +722,7 @@ again:
 				usbDevice[reader_index].ccid.bVoltageSupport = device_descriptor[5];
 				usbDevice[reader_index].ccid.sIFD_serial_number = NULL;
 				usbDevice[reader_index].ccid.gemalto_firmware_features = NULL;
+				usbDevice[reader_index].ccid.zlp = FALSE;
 				if (desc.iSerialNumber)
 				{
 					unsigned char serial[128];
@@ -821,6 +822,16 @@ status_t WriteUSB(unsigned int reader_index, unsigned int length,
 	(void)snprintf(debug_header, sizeof(debug_header), "-> %06X ",
 		(int)reader_index);
 
+	if (usbDevice[reader_index].ccid.zlp)
+	{ /* Zero Length Packet */
+		int dummy_length;
+
+		/* try to read a ZLP so transfer length = 0
+		 * timeout of 10 ms */
+		(void)libusb_bulk_transfer(usbDevice[reader_index].dev_handle,
+			usbDevice[reader_index].bulk_in, NULL, 0, &dummy_length, 10);
+	}
+
 	DEBUG_XXD(debug_header, buffer, length);
 
 	rv = libusb_bulk_transfer(usbDevice[reader_index].dev_handle,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pcsclite/CCID.git



More information about the Pcsclite-cvs-commit mailing list