[Pcsclite-cvs-commit] r6617 - /trunk/Drivers/ccid/src/commands.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Sat May 4 15:50:40 UTC 2013


Author: rousseau
Date: Sat May  4 15:50:40 2013
New Revision: 6617

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6617
Log:
CCID_Receive(): better management of time extension requests

The driver now uses the value returned in the time extension frame to
multiply the timeout value. The timeout value may be bigger than
needed but the goal is to timeout _after_ the reader.

Thanks to Henryk Plötz for the bug report

Modified:
    trunk/Drivers/ccid/src/commands.c

Modified: trunk/Drivers/ccid/src/commands.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/Drivers/ccid/src/commands.c?rev=6617&op=diff
==============================================================================
--- trunk/Drivers/ccid/src/commands.c (original)
+++ trunk/Drivers/ccid/src/commands.c Sat May  4 15:50:40 2013
@@ -1264,10 +1264,10 @@
 	unsigned int length;
 	RESPONSECODE return_value = IFD_SUCCESS;
 	status_t ret;
+	_ccid_descriptor *ccid_descriptor = get_ccid_descriptor(reader_index);
+	unsigned int old_timeout;
 
 #ifndef TWIN_SERIAL
-	_ccid_descriptor *ccid_descriptor = get_ccid_descriptor(reader_index);
-
 	if (PROTOCOL_ICCD_A == ccid_descriptor->bInterfaceProtocol)
 	{
 		unsigned char pcbuffer[SIZE_GET_SLOT_STATUS];
@@ -1385,9 +1385,15 @@
 	}
 #endif
 
+	/* store the original value of read timeout*/
+	old_timeout = ccid_descriptor -> readTimeout;
+
 time_request:
 	length = sizeof(cmd);
 	ret = ReadPort(reader_index, &length, cmd);
+
+	/* restore the original value of read timeout */
+	ccid_descriptor -> readTimeout = old_timeout;
 	CHECK_STATUS(ret)
 
 	if (length < STATUS_OFFSET+1)
@@ -1428,6 +1434,12 @@
 	if (cmd[STATUS_OFFSET] & CCID_TIME_EXTENSION)
 	{
 		DEBUG_COMM2("Time extension requested: 0x%02X", cmd[ERROR_OFFSET]);
+
+		/* compute the new value of read timeout */
+		if (cmd[ERROR_OFFSET] > 0)
+			ccid_descriptor -> readTimeout *= cmd[ERROR_OFFSET];
+
+		DEBUG_COMM2("New timeout: %d ms", ccid_descriptor -> readTimeout);
 		goto time_request;
 	}
 




More information about the Pcsclite-cvs-commit mailing list