[Pcsclite-cvs-commit] r1797 - trunk/Drivers/ccid/src
Ludovic Rousseau
rousseau at costa.debian.org
Wed Jan 11 15:32:38 UTC 2006
Author: rousseau
Date: 2006-01-11 15:32:37 +0000 (Wed, 11 Jan 2006)
New Revision: 1797
Modified:
trunk/Drivers/ccid/src/ifdhandler.c
Log:
IFDHSetProtocolParameters(): if the card is faster than the reader
(TA1=97 for example) we try to use a no so bad speed (corresponding to
TA1=96, 95 or 94) instead of the default speed of TA1=11
Modified: trunk/Drivers/ccid/src/ifdhandler.c
===================================================================
--- trunk/Drivers/ccid/src/ifdhandler.c 2006-01-11 14:56:24 UTC (rev 1796)
+++ trunk/Drivers/ccid/src/ifdhandler.c 2006-01-11 15:32:37 UTC (rev 1797)
@@ -499,9 +499,56 @@
DEBUG_COMM2("Set speed to %d bauds", card_baudrate);
}
else
+ {
DEBUG_COMM2("Reader does not support %d bauds",
card_baudrate);
+
+ /* TA2 present -> specific mode: the card is supporting
+ * only the baud rate specified in TA1 but reader does not
+ * support this value. Reject the card. */
+ if (atr.ib[1][ATR_INTERFACE_BYTE_TA].present)
+ return IFD_PROTOCOL_NOT_SUPPORTED;
+ }
}
+ else
+ {
+ /* the card is too fast for the reader */
+ if ((card_baudrate >= ccid_desc->dwMaxDataRate)
+ /* but TA1 <= 97 */
+ && (atr.ib[0][ATR_INTERFACE_BYTE_TA].value <= 0x97)
+ /* and the reader has a baud rate table */
+ && ccid_desc->arrayOfSupportedDataRates)
+ {
+ unsigned char old_TA1;
+
+ old_TA1 = atr.ib[0][ATR_INTERFACE_BYTE_TA].value;
+ while (atr.ib[0][ATR_INTERFACE_BYTE_TA].value > 0x94)
+ {
+ /* use a lower TA1 */
+ atr.ib[0][ATR_INTERFACE_BYTE_TA].value--;
+
+ ATR_GetParameter(&atr, ATR_PARAMETER_D, &d);
+ ATR_GetParameter(&atr, ATR_PARAMETER_F, &f);
+
+ /* Baudrate = f x D/F */
+ card_baudrate = (unsigned int) (1000 *
+ ccid_desc->dwDefaultClock * d / f);
+
+ 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 adapted speed to %d bauds",
+ card_baudrate);
+ }
+ }
+
+ /* restore original TA1 value */
+ atr.ib[0][ATR_INTERFACE_BYTE_TA].value = old_TA1;
+ }
+ }
}
}
More information about the Pcsclite-cvs-commit
mailing list