1 """PCSCReader: concrete reader class for PCSC Readers
2
3 __author__ = "gemalto http://www.gemalto.com"
4
5 Copyright 2001-2011 gemalto
6 Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel@gemalto.com
7
8 This file is part of pyscard.
9
10 pyscard is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 pyscard is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with pyscard; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 """
24
25 from smartcard.CardConnectionDecorator import CardConnectionDecorator
26 from smartcard.reader.Reader import Reader
27 from smartcard.pcsc.PCSCContext import PCSCContext
28 from smartcard.pcsc.PCSCCardConnection import PCSCCardConnection
29 from smartcard.Exceptions import *
30 from smartcard.pcsc.PCSCExceptions import *
31 from smartcard.scard import *
32
33
51
52
54 """PCSC reader class."""
55
57 """Constructs a new PCSC reader."""
58 Reader.__init__(self, readername)
59
77
94
98
104
112 readers = staticmethod(readers)
113
114 if __name__ == '__main__':
115 from smartcard.util import *
116 SELECT = [0xA0, 0xA4, 0x00, 0x00, 0x02]
117 DF_TELECOM = [0x7F, 0x10]
118
119 creaders = PCSCReader.readers()
120 for reader in creaders:
121 try:
122 print reader.name
123 connection = reader.createConnection()
124 connection.connect()
125 print toHexString(connection.getATR())
126 data, sw1, sw2 = connection.transmit(SELECT + DF_TELECOM)
127 print "%X %X" % (sw1, sw2)
128 except NoCardException, x:
129 print 'no card in reader'
130