我有一個RFID項目,並希望系統檢測讀卡器上的卡,因爲它處於讀取範圍並捕獲UID並繼續該過程。到目前爲止,我已經放置了一個名爲ScanCard的按鈕,其中放置了卡片讀取功能,它將返回卡片的UID。我只使用兩種類型的ATR。想要擺脫掃描卡按鈕並想要自動執行掃描功能。我在Windows 7上使用Python 2.7和HID Omnikey讀卡器如何通過使用Python2.7在讀卡器上刷卡來捕獲RFID卡的UID?
atr = "3B 8F 80 01 80 4F 0C A0 00 00 03 06 0A 00 18 00 00 00 00 7A"
cardtype = ATRCardType(toBytes("%s" %(atr)))
cardrequest = CardRequest(timeout=1, cardType=cardtype)
cardservice = cardrequest.waitforcard()
cardservice.connection.connect()
SELECT = [0xFF, 0xCA, 0x00, 0x00, 0x00]
apdu = SELECT
print 'sending ' + toHexString(apdu)
response, sw1, sw2 = cardservice.connection.transmit(apdu)
print 'response: ', response, ' status words: ', "%x %x" % (sw1, sw2)
tagid = toHexString(response).replace(' ','')
print "tagid ",tagid
id = tagid
print" UID is",id
上面的代碼是我現在遵循的。我需要保持等待卡無限,什麼可能是一個最佳的方式來做到這一點?
你試過了什麼?我發佈了一個答案,但這實際上只是一個快速的Google搜索。 –