class documentation

class PCSCCardConnection(CardConnection):

Constructor: PCSCCardConnection(reader)

View In Hierarchy

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

Method __del__ Destructor. Clean PCSC connection resources.
Method __init__ Construct a new PCSC card connection.
Method connect Connect to the card.
Method disconnect Disconnect from the card.
Method doControl Transmit a control command to the reader and return response.
Method doGetAttrib get an attribute
Method doTransmit Transmit an apdu to the card and return response apdu.
Method getATR Return card ATR
Method reconnect Reconnect to the card.
Instance Variable disposition Undocumented
Instance Variable hcard Undocumented
Instance Variable hcontext Undocumented

Inherited from CardConnection:

Method __enter__ Enter the runtime context.
Method __exit__ Exit the runtime context trying to disconnect.
Method addObserver Add a CardConnection observer.
Method addSWExceptionToFilter Add a status word exception class to be filtered.
Method control Send a control command and buffer. Internally calls doControl() class method and notify observers upon command/response events. Subclasses must override the doControl() class method.
Method deleteObserver Remove a CardConnection observer.
Method getAttrib return the requested attribute
Method getProtocol Return bit mask for the protocol of connection, or None if no protocol set. The return value is a bit mask of CardConnection.T0_protocol, CardConnection.T1_protocol, CardConnection.RAW_protocol, CardConnection.T15_protocol...
Method getReader Return card connection reader
Method setErrorCheckingChain Add an error checking chain.
Method setProtocol Set protocol for card connection.
Method transmit Transmit an apdu. Internally calls doTransmit() class method and notify observers upon command/response APDU events. Subclasses must override the doTransmit() class method.
Class Variable RAW_protocol protocol RAW (direct access to the reader)
Class Variable T0_protocol protocol T=0
Class Variable T15_protocol protocol T=15
Class Variable T1_protocol protocol T=1
Instance Variable defaultprotocol see setProtocol and getProtocol
Instance Variable errorcheckingchain see setErrorCheckingChain
Instance Variable reader reader name

Inherited from Observable (via CardConnection):

Method clearChanged Undocumented
Method countObservers Undocumented
Method deleteObservers Undocumented
Method hasChanged Undocumented
Method notifyObservers If 'changed' indicates that this object has changed, notify all its observers, then call clearChanged(). Each observer has its update() called with two arguments: this observable object and the generic 'arg'.
Method setChanged Undocumented
Instance Variable changed Undocumented
Instance Variable obs Undocumented

Inherited from Synchronization (via CardConnection, Observable):

Instance Variable mutex Undocumented
def __del__(self):

Destructor. Clean PCSC connection resources.

def __init__(self, reader):

Construct a new PCSC card connection.

Parameters
readerthe reader in which the smartcard to connect to is located.
def connect(self, protocol=None, mode=None, disposition=None):

Connect to the card.

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

If mode is not specified, connect with smartcard.scard.SCARD_SHARE_SHARED.

def disconnect(self):

Disconnect from the card.

def doControl(self, controlCode, command=None):

Transmit a control command to the reader and return response.

Parameters
controlCodecontrol command
commandcommand data to transmit (list of bytes)
Returns
response are the response bytes (if any)
def doGetAttrib(self, attribId):

get an attribute

Parameters
attribIdIdentifier for the attribute to get
Returns
response are the attribute byte array
def doTransmit(self, command, protocol=None):

Transmit an apdu to the card and return response apdu.

Parameters
commandcommand apdu to transmit (list of bytes)
protocolthe transmission protocol, from CardConnection.T0_protocol, CardConnection.T1_protocol, or CardConnection.RAW_protocol
Returns

a tuple (response, sw1, sw2) where

  • response are the response bytes excluding status words
  • sw1 is status word 1, e.g. 0x90
  • sw2 is status word 2, e.g. 0x1A
def getATR(self):
def reconnect(self, protocol=None, mode=None, disposition=None):

Reconnect to the card.

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

If mode is not specified, connect with smartcard.scard.SCARD_SHARE_SHARED.

If disposition is not specified, do a warm reset (smartcard.scard.SCARD_RESET_CARD)

disposition =

Undocumented

hcard =

Undocumented

hcontext =

Undocumented