class documentation

Card connection abstract class.

Method __del__ Connect to card.
Method __enter__ Enter the runtime context.
Method __exit__ Exit the runtime context trying to disconnect.
Method __init__ Construct a new card connection.
Method addObserver Add a CardConnection observer.
Method addSWExceptionToFilter Add a status word exception class to be filtered.
Method connect Connect to card.
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 disconnect Disconnect from card.
Method doControl Performs the command control.
Method doGetAttrib Performs the command get attrib.
Method doTransmit Performs the command APDU transmission.
Method getATR Return card ATR
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 reconnect Reconnect to card.
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:

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 Observable):

Instance Variable mutex Undocumented
def __del__(self):
def __enter__(self):

Enter the runtime context.

def __exit__(self, type, value, traceback):

Exit the runtime context trying to disconnect.

def __init__(self, reader):

Construct a new card connection.

Parameters
readername of the reader in which the smartcard to connect to is located.
def addSWExceptionToFilter(self, exClass):

Add a status word exception class to be filtered.

Parameters
exClass

the class to filter, e.g. smartcard.sw.SWExceptions.WarningProcessingException

Filtered exceptions will not be raised when encountered in the error checking chain.

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

Connect to card.

Parameters
protocola bit mask of the protocols to use, from CardConnection.T0_protocol, CardConnection.T1_protocol, CardConnection.RAW_protocol, CardConnection.T15_protocol
modesmartcard.scard.SCARD_SHARE_SHARED (default), smartcard.scard.SCARD_SHARE_EXCLUSIVE or smartcard.scard.SCARD_SHARE_DIRECT
dispositionsmartcard.scard.SCARD_LEAVE_CARD (default), smartcard.scard.SCARD_RESET_CARD, smartcard.scard.SCARD_UNPOWER_CARD or smartcard.scard.SCARD_EJECT_CARD
def control(self, controlCode, command=None):

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.

Parameters
controlCodecommand code
commandlist of bytes to transmit
def doControl(self, controlCode, command):

Performs the command control.

Subclasses must override this method for implementing control.

def doGetAttrib(self, attribId):

Performs the command get attrib.

Subclasses must override this method for implementing get attrib.

def doTransmit(self, command, protocol):

Performs the command APDU transmission.

Subclasses must override this method for implementing apdu transmission.

def getAttrib(self, attribId):

return the requested attribute

Parameters
attribIdattribute id like smartcard.scard.SCARD_ATTR_VENDOR_NAME
def getProtocol(self):

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

def getReader(self):

Return card connection reader

def reconnect(self, protocol=None, mode=None, disposition=None):

Reconnect to card.

Parameters
protocola bit mask of the protocols to use, from CardConnection.T0_protocol, CardConnection.T1_protocol, CardConnection.RAW_protocol, CardConnection.T15_protocol
modesmartcard.scard.SCARD_SHARE_SHARED (default), smartcard.scard.SCARD_SHARE_EXCLUSIVE or smartcard.scard.SCARD_SHARE_DIRECT
dispositionsmartcard.scard.SCARD_LEAVE_CARD, smartcard.scard.SCARD_RESET_CARD (default), smartcard.scard.SCARD_UNPOWER_CARD or smartcard.scard.SCARD_EJECT_CARD
def setErrorCheckingChain(self, errorcheckingchain):

Add an error checking chain.

Parameters
errorcheckingchaina smartcard.sw.ErrorCheckingChain object The error checking strategies in errorchecking chain will be tested with each received response APDU, and a smartcard.sw.SWExceptions.SWException will be raised upon error.
def setProtocol(self, protocol):

Set protocol for card connection.

Parameters
protocol

a bit mask of CardConnection.T0_protocol, CardConnection.T1_protocol, CardConnection.RAW_protocol, CardConnection.T15_protocol

>>> setProtocol(CardConnection.T1_protocol | CardConnection.T0_protocol)
def transmit(self, command, protocol=None):

Transmit an apdu. Internally calls doTransmit() class method and notify observers upon command/response APDU events. Subclasses must override the doTransmit() class method.

Parameters
commandlist of bytes to transmit
protocolthe transmission protocol, from CardConnection.T0_protocol, CardConnection.T1_protocol, or CardConnection.RAW_protocol
RAW_protocol: int =

protocol RAW (direct access to the reader)

T0_protocol: int =

protocol T=0

T15_protocol: int =

protocol T=15

T1_protocol: int =

protocol T=1

defaultprotocol =
errorcheckingchain =
reader =

reader name