smartcard.pcsc.PCSCCardConnection.PCSCCardConnection

# ``smartcard`.`pcsc`.`PCSCCardConnection`.`PCSCCardConnection``

class documentation

`class PCSCCardConnection(CardConnection):`

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...
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` | 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` (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):
overrides `smartcard.CardConnection.CardConnection.__del__`

Destructor. Clean PCSC connection resources.

def __init__(self, reader):
overrides `smartcard.CardConnection.CardConnection.__init__`

Construct a new PCSC card connection.

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

def connect(self, protocol=None, mode=None, disposition=None):
overrides `smartcard.CardConnection.CardConnection.connect`

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.

def disconnect(self):
overrides `smartcard.CardConnection.CardConnection.disconnect`

Disconnect from the card.

def doControl(self, controlCode, bytes=[]):
overrides `smartcard.CardConnection.CardConnection.doControl`

Transmit a control command to the reader and return response.

Parameters
controlCode | control command
bytes | command data to transmit (list of bytes)
Returns
response are the response bytes (if any)

def doGetAttrib(self, attribId):
overrides `smartcard.CardConnection.CardConnection.doGetAttrib`

get an attribute

Parameters
attribId | Identifier for the attribute to get
Returns
response are the attribute byte array

def doTransmit(self, bytes, protocol=None):
overrides `smartcard.CardConnection.CardConnection.doTransmit`

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

def getATR(self):
overrides `smartcard.CardConnection.CardConnection.getATR`

Return card ATR

def reconnect(self, protocol=None, mode=None, disposition=None):
overrides `smartcard.CardConnection.CardConnection.reconnect`

Reconnect to the card.

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

If mode is not specified, connect with SCARD_SHARE_SHARED.

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

disposition =

Undocumented

hcard =

Undocumented

hcontext =

Undocumented