I was wondering if there is a way to poll an ACR122U in python and if so how? My script below gets the UID of a card but continuously runs. I know it runs because of while1 but it shows what i want to achive
from smartcard.scard import *
from smartcard.util import toHexString
def s():
while 1:
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
assert hresult==SCARD_S_SUCCESS
hresult, readers = SCardListReaders(hcontext, [])
assert len(readers)>0
reader = readers[0]
hresult, hcard, dwActiveProtocol = SCardConnect(
hcontext,
reader,
SCARD_SHARE_SHARED,
SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1)
try:
hresult, response = SCardTransmit(hcard,dwActiveProtocol,[0xFF,0xCA,0x00,0x00,0x04])
uid = toHexString(response, format=0)
print uid
except SystemError:
print "no card found"
s()