The expected result would be to open a session to the card in reader with number readernum.
The older listReaders() works as expected:
reader = smartcard.System.listReaders()[readernum]
session = smartcard.Session(reader)
The same example with the newer readers():
reader = smartcard.System.readers()[readernum]
session = smartcard.Session(reader)
...throws the following error:
File "/usr/lib/pymodules/python2.6/smartcard/pcsc/PCSCCardConnection.py", line 111, in connect
raise CardConnectionException( 'Unable to connect with protocol: ' + dictProtocol[pcscprotocol] + '. ' + SCardGetErrorMessage(hresult) )
smartcard.Exceptions.CardConnectionException: 'Smartcard Exception: Unable to connect with protocol: T0 or T1. No smart card inserted.!'
test script:
import smartcard.System
import smartcard.Session
from smartcard.util import toHexString
readernum=0
reader=smartcard.System.readers()[readernum]
session = smartcard.Session(reader)
print toHexString( session.getATR() )
session.close()
reader=smartcard.System.listReaders()[readernum]
session = smartcard.Session(reader)
print toHexString( session.getATR() )
session.close()
Test script output:
3B 16 18 20 02 01 00 80 0D
3B 16 18 20 02 01 00 80 0D