class documentation

The Session object enables programmers to transmit APDU to smartcards.

This is an example of use of the Session object:

>>> import smartcard
>>> reader=smartcard.listReaders()
>>> s = smartcard.Session(reader[0])
>>> SELECT = [0xA0, 0xA4, 0x00, 0x00, 0x02]
>>> DF_TELECOM = [0x7F, 0x10]
>>> data, sw1, sw2 = s.sendCommandAPDU(SELECT+DF_TELECOM)
>>> print(data, sw1, sw2)
>>> s.close()
>>> print(`s`)
Method __init__ Session constructor. Initializes a smart card session and connect to the card.
Method __repr__ Returns a string representation of the session.
Method close Close the smartcard session.
Method getATR Returns the ATR of the connected card.
Method sendCommandAPDU Send an APDU command to the connected smartcard.
Instance Variable cs Undocumented
Instance Variable reader Undocumented
Instance Variable readerName Undocumented
def __init__(self, readerName=None, cardServiceClass=None):

Session constructor. Initializes a smart card session and connect to the card.

Parameters
readerNamereader to connect to; default is first PCSC reader
cardServiceClasscard service to bind the session to; default is None
def __repr__(self):

Returns a string representation of the session.

def close(self):

Close the smartcard session.

Closing a session will disconnect from the card.

def getATR(self):

Returns the ATR of the connected card.

def sendCommandAPDU(self, command):

Send an APDU command to the connected smartcard.

Parameters
commandlist of APDU bytes, e.g. [0xA0, 0xA4, 0x00, 0x00, 0x02]
Returns
a tuple (response, sw1, sw2) where response is the APDU response sw1, sw2 are the two status words
cs =

Undocumented

reader =

Undocumented

readerName =

Undocumented