smartcard.CardConnection.CardConnection

# ``smartcard`.`CardConnection`.`CardConnection``

class documentation

`class CardConnection(Observable):`

Known subclasses: `smartcard.CardConnectionDecorator.CardConnectionDecorator`, `smartcard.pcsc.PCSCCardConnection.PCSCCardConnection`

View In Hierarchy

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...
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` | Undocumented
Class Variable | `T0_protocol` | Undocumented
Class Variable | `T15_protocol` | Undocumented
Class Variable | `T1_protocol` | Undocumented
Instance Variable | `defaultprotocol` | Undocumented
Instance Variable | `errorcheckingchain` | Undocumented
Instance Variable | `reader` | Undocumented

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):
overridden in `smartcard.pcsc.PCSCCardConnection.PCSCCardConnection`

Connect to card.

def __enter__(self):

Enter the runtime context.

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

Exit the runtime context trying to disconnect.

def __init__(self, reader):
overrides `smartcard.Observer.Observable.__init__`
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`, `smartcard.pcsc.PCSCCardConnection.PCSCCardConnection`

Construct a new card connection.

Parameters
reader | name of the reader in which the smartcard to connect to is located.

def addObserver(self, observer):
overrides `smartcard.Observer.Observable.addObserver`
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`

Add a `CardConnection` observer.

def addSWExceptionToFilter(self, exClass):
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`

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):
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`, `smartcard.pcsc.PCSCCardConnection.PCSCCardConnection`

Connect to card.

Parameters
protocol | a bit mask of the protocols to use, from `CardConnection.T0_protocol`, `CardConnection.T1_protocol`, `CardConnection.RAW_protocol`, `CardConnection.T15_protocol`
mode | SCARD_SHARE_SHARED (default), SCARD_SHARE_EXCLUSIVE or SCARD_SHARE_DIRECT
disposition | SCARD_LEAVE_CARD (default), SCARD_RESET_CARD, SCARD_UNPOWER_CARD or SCARD_EJECT_CARD

def control(self, controlCode, bytes=[]):
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`

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
controlCode | command code
bytes | list of bytes to transmit

def deleteObserver(self, observer):
overrides `smartcard.Observer.Observable.deleteObserver`
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`

Remove a `CardConnection` observer.

def disconnect(self):
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`, `smartcard.pcsc.PCSCCardConnection.PCSCCardConnection`

Disconnect from card.

def doControl(self, controlCode, bytes):
overridden in `smartcard.pcsc.PCSCCardConnection.PCSCCardConnection`

Performs the command control.

Subclasses must override this method for implementing control.

def doGetAttrib(self, attribId):
overridden in `smartcard.pcsc.PCSCCardConnection.PCSCCardConnection`

Performs the command get attrib.

Subclasses must override this method for implementing get attrib.

def doTransmit(self, bytes, protocol):
overridden in `smartcard.pcsc.PCSCCardConnection.PCSCCardConnection`

Performs the command APDU transmission.

Subclasses must override this method for implementing apdu transmission.

def getATR(self):
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`, `smartcard.pcsc.PCSCCardConnection.PCSCCardConnection`

Return card ATR

def getAttrib(self, attribId):
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`

return the requested attribute

Parameters
attribId | attribute id like SCARD_ATTR_VENDOR_NAME

def getProtocol(self):
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`

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):
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`

Return card connection reader

def reconnect(self, protocol=None, mode=None, disposition=None):
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`, `smartcard.pcsc.PCSCCardConnection.PCSCCardConnection`

Reconnect to card.

Parameters
protocol | a bit mask of the protocols to use, from `CardConnection.T0_protocol`, `CardConnection.T1_protocol`, `CardConnection.RAW_protocol`, `CardConnection.T15_protocol`
mode | SCARD_SHARE_SHARED (default), SCARD_SHARE_EXCLUSIVE or SCARD_SHARE_DIRECT
disposition | SCARD_LEAVE_CARD, SCARD_RESET_CARD (default), SCARD_UNPOWER_CARD or SCARD_EJECT_CARD

def setErrorCheckingChain(self, errorcheckingchain):
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`

Add an error checking chain.

Parameters
errorcheckingchain | a smartcard.sw.ErrorCheckingChain object The error checking strategies in errorchecking chain will be tested with each received response APDU, and a smartcard.sw.SWException.SWException will be raised upon error.

def setProtocol(self, protocol):
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`

Set protocol for card connection.

Parameters
protocol | a bit mask of CardConnection.T0_protocol, CardConnection.T1_protocol, CardConnection.RAW_protocol, CardConnection.T15_protocol e.g. setProtocol(CardConnection.T1_protocol | CardConnection.T0_protocol)

def transmit(self, bytes, protocol=None):
overridden in `smartcard.CardConnectionDecorator.CardConnectionDecorator`

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

Parameters
bytes | list of bytes to transmit
protocol | the transmission protocol, from CardConnection.T0_protocol, CardConnection.T1_protocol, or CardConnection.RAW_protocol

RAW_protocol: `int` =

Undocumented

T0_protocol: `int` =

Undocumented

T15_protocol: `int` =

Undocumented

T1_protocol: `int` =

Undocumented

defaultprotocol =

Undocumented

errorcheckingchain =

Undocumented

reader =

Undocumented