[Pcsclite-cvs-commit] CVS Drivers/ccid/src
CVS User rousseau
ludovic.rousseau@free.fr
Tue, 26 Apr 2005 13:46:07 +0000
Update of /cvsroot/pcsclite/Drivers/ccid/src
In directory haydn:/tmp/cvs-serv10596
Modified Files:
ifdhandler.c
Log Message:
IFDHSetProtocolParameters(): only use a data rate supported by the
reader in the PPS negociation, otherwise we stay at the default speed.
--- /cvsroot/pcsclite/Drivers/ccid/src/ifdhandler.c 2005/04/26 12:29:45 1.66
+++ /cvsroot/pcsclite/Drivers/ccid/src/ifdhandler.c 2005/04/26 13:46:07 1.67
@@ -17,7 +17,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: ifdhandler.c,v 1.66 2005/04/26 12:29:45 rousseau Exp $ */
+/* $Id: ifdhandler.c,v 1.67 2005/04/26 13:46:07 rousseau Exp $ */
#include <stdio.h>
#include <string.h>
@@ -55,6 +55,7 @@
/* local functions */
static void init_driver(void);
static void extra_egt(ATR_t *atr, _ccid_descriptor *ccid_desc, DWORD Protocol);
+static char find_baud_rate(unsigned int baudrate, unsigned int *list);
RESPONSECODE IFDHCreateChannelByName(DWORD Lun, LPTSTR lpcDevice)
@@ -476,10 +477,17 @@
/* and the card does not try to lower the default speed */
&& (card_baudrate > default_baudrate ))
{
- pps[1] |= 0x10; /* PTS1 presence */
- pps[2] = atr.ib[0][ATR_INTERFACE_BYTE_TA].value;
+ if (find_baud_rate(card_baudrate,
+ ccid_desc->arrayOfSupportedDataRates))
+ {
+ pps[1] |= 0x10; /* PTS1 presence */
+ pps[2] = atr.ib[0][ATR_INTERFACE_BYTE_TA].value;
- DEBUG_COMM2("Set speed to %d bauds", card_baudrate);
+ DEBUG_COMM2("Set speed to %d bauds", card_baudrate);
+ }
+ else
+ DEBUG_COMM2("Reader does not support %d bauds",
+ card_baudrate);
}
}
}
@@ -1085,3 +1093,29 @@
}
} /* extra_egt */
+
+static char find_baud_rate(unsigned int baudrate, unsigned int *list)
+{
+ int i;
+
+ DEBUG_COMM2("Card baud rate: %d", baudrate);
+
+ /* Does the reader support the annonced smart card data speed? */
+ for (i=0;; i++)
+ {
+ /* end of array marker */
+ if (0 == list[i])
+ break;
+
+ DEBUG_COMM2("Reader can do: %d", list[i]);
+
+ /* We must take into account that the card_baudrate integral value
+ * is an approximative result, computed from the d/f float result.
+ */
+ if ((baudrate < list[i] + 2) && (baudrate > list[i] - 2))
+ return TRUE;
+ }
+
+ return FALSE;
+} /* find_baud_rate */
+