[Pcsclite-cvs-commit] r6650 - in /trunk/Drivers/ccid/src: ccid.c ccid.h ccid_serial.c ccid_usb.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Mon Jun 10 08:43:25 UTC 2013


Author: rousseau
Date: Mon Jun 10 08:43:24 2013
New Revision: 6650

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6650
Log:
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 when connected on a USB3 bus. Only the readers with
firmware 2.00 have the problem.

The solution is to use a short read before every USB write.

Modified:
    trunk/Drivers/ccid/src/ccid.c
    trunk/Drivers/ccid/src/ccid.h
    trunk/Drivers/ccid/src/ccid_serial.c
    trunk/Drivers/ccid/src/ccid_usb.c

Modified: trunk/Drivers/ccid/src/ccid.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/ccid.c?rev=6650&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/ccid.c (original)
+++ trunk/Drivers/ccid/src/ccid.c Mon Jun 10 08:43:24 2013
@@ -33,6 +33,7 @@
 #include "defs.h"
 #include "ccid_ifdhandler.h"
 #include "commands.h"
+#include "utils.h"
 
 #ifdef __APPLE__
 #include <CoreFoundation/CoreFoundation.h>
@@ -63,6 +64,19 @@
 			/* the firmware needs some time to initialize */
 			(void)sleep(1);
 			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_INFO("ZLP fixup");
+			}
 			break;
 	}
 

Modified: trunk/Drivers/ccid/src/ccid.h
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/ccid.h?rev=6650&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/ccid.h (original)
+++ trunk/Drivers/ccid/src/ccid.h Mon Jun 10 08:43:24 2013
@@ -141,6 +141,11 @@
 	 * Gemalto extra features, if any
 	 */
 	struct GEMALTO_FIRMWARE_FEATURES *gemalto_firmware_features;
+
+	/*
+	 * Zero Length Packet fixup (boolean)
+	 */
+	char zlp;
 } _ccid_descriptor;
 
 /* Features from dwFeatures */

Modified: trunk/Drivers/ccid/src/ccid_serial.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/ccid_serial.c?rev=6650&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/ccid_serial.c (original)
+++ trunk/Drivers/ccid/src/ccid_serial.c Mon Jun 10 08:43:24 2013
@@ -601,6 +601,7 @@
 	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 */

Modified: trunk/Drivers/ccid/src/ccid_usb.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/ccid_usb.c?rev=6650&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/ccid_usb.c (original)
+++ trunk/Drivers/ccid/src/ccid_usb.c Mon Jun 10 08:43:24 2013
@@ -576,6 +576,7 @@
 				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];
@@ -649,6 +650,16 @@
 	(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 1 ms */
+		(void)libusb_bulk_transfer(usbDevice[reader_index].dev_handle,
+			usbDevice[reader_index].bulk_in, NULL, 0, &dummy_length, 1);
+	}
+
 	DEBUG_XXD(debug_header, buffer, length);
 
 	rv = libusb_bulk_transfer(usbDevice[reader_index].dev_handle,
@@ -704,15 +715,6 @@
 			return STATUS_NO_SUCH_DEVICE;
 
 		return STATUS_UNSUCCESSFUL;
-	}
-
-	if (0 == actual_length)
-	{
-		/* Zero Length Packet */
-		/* The Gemalto IDBridge CT30 and IDBridge K30 readers may send
-		 * a ZLP after some commands when connected on a USB3 bus */
-		DEBUG_INFO("ZLP detected. read again!");
-		goto read_again;
 	}
 
 	*length = actual_length;




More information about the Pcsclite-cvs-commit mailing list