2
我想知道是否有方法來輪詢ACR122U在Python中,如果是的話如何?下面我的腳本獲取一張卡的UID,但不斷運行。我知道它運行,因爲while1但它說明了什麼,我想才達到Python ACR122U投票
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()
那麼你的實際問題是什麼? –
現在它只是運行顯示找不到或uid一遍又一遍 – shaggs
是的,這正是你的代碼應該做的,這也非常符合你指定的要求(「*在Python *中輪詢ACR122U的方法* 「)。因此,再一次,你的實際問題是什麼? –