1 """Sample CardConnectionDecorator that provides exclusive transmit()
2
3 __author__ = "http://www.gemalto.com"
4
5 Copyright 2001-2012 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 from __future__ import print_function
25 from smartcard.CardConnectionDecorator import CardConnectionDecorator
26 from smartcard.Exceptions import CardConnectionException
27 from smartcard.scard import SCardBeginTransaction, SCardEndTransaction
28 from smartcard.scard import SCARD_LEAVE_CARD
29 from smartcard.scard import SCardGetErrorMessage
30 import smartcard.pcsc
31
32
34 '''This decorator uses SCardBeginTransaction/SCardEndTransaction to
35 preserve other processes of threads to access the card during
36 transmit().'''
37
40
62
84
85 - def transmit(self, bytes, protocol=None):
86 '''Gain exclusive access to card during APDU transmission for if this
87 decorator decorates a PCSCCardConnection.'''
88 data, sw1, sw2 = CardConnectionDecorator.transmit(
89 self, bytes, protocol)
90 return data, sw1, sw2
91