python - 在 ACR1252U NFC 读卡器上强制 PC/SC 驱动程序并使用 python 进入卡仿真模式
问题描述
目的:让ACR1252U NFC读卡器在Mac上使用python进入卡模拟模式
我在使用 PC/SC 驱动程序的 macOS Catalina 10.15.3 上使用 ACS ACR1252U 读卡器时遇到问题。我从ACS 网站安装了驱动程序。
通过使用 pyscard ( http://pyscard.sourceforge.net/ ) 库,以下 python 代码工作并在windows计算机上返回正确的输入卡模拟模式响应: 输入卡模拟模式命令和响应格式
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 上给出了错误。我按照这个答案来更改 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,但我不确定如何根据答案的第二部分来编译它。
任何帮助将不胜感激。
解决方案
推荐阅读
- java - 如何正确显示用户的个人资料图片
- bash - 使用 getopt 解析负值的参数 - 有什么方法可以让 getopt 忽略它们?
- php - 我在循环内的查询处理时间过长
- java - 在 Spring boot 和 Angular App 的 Tomcat 上部署 WAR 文件
- c - C整数到二进制位顺序
- reactjs - 动态页面分页在反应表中不起作用
- r - R Shiny:If 中的错误 - 参数长度为 zerp
- c - C - 打印链表的头部
- apache-spark - 如何在 Pyspark 中确保多行代码的原子性?
- tableau-api - 在 Tableau Desktop 中创建表格