[Pcsclite-cvs-commit] CVS Drivers/ccid/src

CVS User rousseau ludovic.rousseau@free.fr
Tue, 26 Apr 2005 14:34:53 +0000


Update of /cvsroot/pcsclite/Drivers/ccid/src
In directory haydn:/tmp/cvs-serv15072

Modified Files:
	ccid_usb.c ccid_serial.c 
Log Message:
use the calculated read timeout instead of a fixed value


--- /cvsroot/pcsclite/Drivers/ccid/src/ccid_usb.c	2005/04/26 13:43:13	1.48
+++ /cvsroot/pcsclite/Drivers/ccid/src/ccid_usb.c	2005/04/26 14:34:52	1.49
@@ -18,7 +18,7 @@
 */
 
 /*
- * $Id: ccid_usb.c,v 1.48 2005/04/26 13:43:13 rousseau Exp $
+ * $Id: ccid_usb.c,v 1.49 2005/04/26 14:34:52 rousseau Exp $
  */
 
 #define __CCID_USB__
@@ -40,12 +40,6 @@
 #include "ccid_ifdhandler.h"
 
 
-/* read timeout
- * we must wait enough so that the card can finish its calculation
- * the card, and then the reader should send TIME REQUEST bytes
- * so this timeout should never occur */
-#define USB_READ_TIMEOUT (60 * 1000)	/* 1 minute timeout */
-
 /* write timeout
  * we don't have to wait a long time since the card was doing nothing */
 #define USB_WRITE_TIMEOUT (5 * 1000)  /* 5 seconds timeout */
@@ -404,6 +398,7 @@
 					usbDevice[reader_index].ccid.dwMaxDataRate = dw2i(usb_interface->altsetting->extra, 23);
 					usbDevice[reader_index].ccid.bMaxSlotIndex = usb_interface->altsetting->extra[4];
 					usbDevice[reader_index].ccid.bCurrentSlotIndex = 0;
+					usbDevice[reader_index].ccid.readTimeout = DEFAULT_COM_READ_TIMEOUT;
 					usbDevice[reader_index].ccid.arrayOfSupportedDataRates = get_data_rates(reader_index);
 					goto end;
 				}
@@ -474,7 +469,7 @@
 
 	rv = usb_bulk_read(usbDevice[reader_index].handle,
 		usbDevice[reader_index].bulk_in, (char *)buffer, *length,
-		USB_READ_TIMEOUT);
+		usbDevice[reader_index].ccid.readTimeout * 1000);
 
 	if (rv < 0)
 	{
@@ -710,7 +705,7 @@
 		0x00, /* interface */
 		buffer,
 		sizeof(buffer),
-		USB_READ_TIMEOUT);
+		usbDevice[reader_index].ccid.readTimeout * 1000);
 
 	/* we got an error? */
 	if (n <= 0)
--- /cvsroot/pcsclite/Drivers/ccid/src/ccid_serial.c	2005/04/26 13:44:08	1.35
+++ /cvsroot/pcsclite/Drivers/ccid/src/ccid_serial.c	2005/04/26 14:34:52	1.36
@@ -20,7 +20,7 @@
  */
 
 /*
- * $Id: ccid_serial.c,v 1.35 2005/04/26 13:44:08 rousseau Exp $
+ * $Id: ccid_serial.c,v 1.36 2005/04/26 14:34:52 rousseau Exp $
  */
 
 #include <stdio.h>
@@ -42,10 +42,6 @@
 #include "utils.h"
 #include "commands.h"
 
-/* communication timeout in seconds
- * the value is set at the end of OpenSerialByName() */
-int SerialTimeout;
-
 #define SYNC 0x03
 #define CTRL_ACK 0x06
 #define CTRL_NAK 0x15
@@ -447,7 +443,7 @@
 		/* use select() to, eventually, timeout */
 		FD_ZERO(&fdset);
 		FD_SET(fd, &fdset);
-		t.tv_sec = SerialTimeout;
+		t.tv_sec = serialDevice[reader_index].ccid.readTimeout;
 		t.tv_usec = 0;
 
 		i = select(fd+1, &fdset, NULL, NULL, &t);
@@ -459,7 +455,7 @@
 		else
 			if (i == 0)
 			{
-				DEBUG_COMM2("Timeout! (%d sec)", SerialTimeout);
+				DEBUG_COMM2("Timeout! (%d sec)", serialDevice[reader_index].ccid.readTimeout);
 				return -1;
 			}
 
@@ -620,7 +616,7 @@
 		unsigned int rx_length = sizeof(rx_buffer);
 
 		/* 2 seconds timeout to not wait too long if no reader is connected */
-		SerialTimeout = 2;
+		serialDevice[reader].ccid.readTimeout = 2;
 
 		if (IFD_SUCCESS != CmdEscape(reader_index, tx_buffer, sizeof(tx_buffer),
 			rx_buffer, &rx_length))
@@ -629,8 +625,8 @@
 			return STATUS_UNSUCCESSFUL;
 		}
 
-		/* normal timeout: 1 minute to allow long time APDU */
-		SerialTimeout = 60;
+		/* normal timeout: 2 seconds */
+		serialDevice[reader].ccid.readTimeout = DEFAULT_COM_READ_TIMEOUT ;
 
 		rx_buffer[rx_length] = '\0';
 		DEBUG_INFO2("Firmware: %s", rx_buffer);