目标:让ACR1252U NFC读卡器在Mac上使用python进入卡仿真模式
使用PC/SC驱动程序在macOS Catalina 10.15.3上使用ACS ACR1252U读卡器时遇到问题。我从ACS website安装了驱动程序
通过使用pyscard(http://pyscard.sourceforge.net/)库,以下python代码在windows计算机上运行并返回正确的enter card仿真模式响应:Enter Card Emulation Mode Command & Response Format
import smartcard
hresult, hcontext = smartcard.scard.SCardEstablishContext( smartcard.scard.SCARD_SCOPE_USER )
hresult, readers = smartcard.scard.SCardListReaders( hcontext, [] )
print(readers)
hresult, hcard, dwActiveProtocol = smartcard.scard.SCardConnect(hcontext, readers[0], smartcard.scard.SCARD_SHARE_DIRECT, 0)
CTL_CODE = smartcard.scard.SCARD_CTL_CODE(3500)
apdu = [0xE0, 0x00, 0x00, 0x40, 0x03, 0x01, 0x00, 0x00]
hresult, response = smartcard.scard.SCardControl( hcard, CTL_CODE, apdu )
但它在Mac上给出了一个错误。我按照this的答案更改plist文件,但仍然得到相同的错误:
python3 nfc.py
['ACS ACR1252 1S CL Reader(1)', 'ACS ACR1252 1S CL Reader(2)']
Traceback (most recent call last):
File "nfc.py", line 17, in <module>
hresult, response = smartcard.scard.SCardControl( hcard, CTL_CODE, apdu )
File "/usr/local/lib/python3.7/site-packages/smartcard/scard/scard.py", line 408, in SCardControl
return _scard.SCardControl(hcard, dwControlCode, inbuffer)
SystemError: <built-in function SCardControl> returned NULL without setting an error
我使用自制软件安装了libnfc,但根据答案的第二部分,我不确定如何编译它
任何帮助都将不胜感激
目前没有回答
相关问题 更多 >
编程相关推荐