Package smartcard :: Package pcsc :: Module PCSCCardConnection :: Class PCSCCardConnection
[hide private]
[frames] | no frames]

Class PCSCCardConnection

source code


PCSCCard connection class. Handles connection with a card thru a PCSC reader.

Instance Methods [hide private]
 
__init__(self, reader)
Construct a new PCSC card connection.
source code
 
__del__(self)
Destructor.
source code
 
connect(self, protocol=None, mode=None, disposition=None)
Connect to the card.
source code
 
disconnect(self)
Disconnect from the card.
source code
 
getATR(self)
Return card ATR
source code
 
doTransmit(self, bytes, protocol=None)
Transmit an apdu to the card and return response apdu.
source code
 
doControl(self, controlCode, bytes=[])
Transmit a control command to the reader and return response.
source code
 
doGetAttrib(self, attribId)
get an attribute
source code

Inherited from CardConnection.CardConnection: __enter__, __exit__, addObserver, addSWExceptionToFilter, control, deleteObserver, getAttrib, getProtocol, getReader, setErrorCheckingChain, setProtocol, transmit

Inherited from Observer.Observable: clearChanged, countObservers, deleteObservers, hasChanged, notifyObservers, setChanged

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from CardConnection.CardConnection: RAW_protocol, T0_protocol, T15_protocol, T1_protocol

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, reader)
(Constructor)

source code 

Construct a new PCSC card connection.

reader: the reader in which the smartcard to connect to is located.

Parameters:
  • reader - name of the reader in which the smartcard to connect to is located.
Overrides: object.__init__

__del__(self)
(Destructor)

source code 

Destructor. Clean PCSC connection resources.

Overrides: CardConnection.CardConnection.__del__

connect(self, protocol=None, mode=None, disposition=None)

source code 

Connect to the card.

If protocol is not specified, connect with the default connection protocol.

If mode is not specified, connect with SCARD_SHARE_SHARED.

Parameters:
Overrides: CardConnection.CardConnection.connect

disconnect(self)

source code 

Disconnect from the card.

Overrides: CardConnection.CardConnection.disconnect

getATR(self)

source code 

Return card ATR

Overrides: CardConnection.CardConnection.getATR

doTransmit(self, bytes, protocol=None)

source code 

Transmit an apdu to the card and return response apdu.

Parameters:
  • bytes - command apdu to transmit (list of bytes)
  • protocol - the transmission protocol, from CardConnection.T0_protocol, CardConnection.T1_protocol, or CardConnection.RAW_protocol
Returns:
a tuple (response, sw1, sw2) where sw1 is status word 1, e.g. 0x90 sw2 is status word 2, e.g. 0x1A response are the response bytes excluding status words
Overrides: CardConnection.CardConnection.doTransmit

doControl(self, controlCode, bytes=[])

source code 

Transmit a control command to the reader and return response.

controlCode: control command

bytes: command data to transmit (list of bytes)

return: response are the response bytes (if any)

Overrides: CardConnection.CardConnection.doControl

doGetAttrib(self, attribId)

source code 

get an attribute

attribId: Identifier for the attribute to get

return: response are the attribute byte array

Overrides: CardConnection.CardConnection.doGetAttrib