我尝试在MacOSXMojav10.14.6和libnfc上使用ACR122 USB,当我尝试使用LIBNFC_LOG_LEVEL=3 nfc-list命令时,我遇到了一个“无法写入USB (结果太大)”的错误。
info libnfc.config Unable to open file: /usr/local/etc/nfc/libnfc.conf
debug libnfc.config key: [device.allow_autoscan], value: [false]
info libnfc.config Unknown key in config line: device.allow_autoscan = false
debug libnfc.config key: [device.allow_intrusive_scan], value: [false]
info libnfc.config Unknown key in config line: device.allow_intrusive_scan = false
debug libnfc.config key: [device.log_level], value: [3]
info libnfc.config Unknown key in config line: device.log_level = 3
debug libnfc.general log_level is set to 3
debug libnfc.general allow_autoscan is set to true
debug libnfc.general allow_intrusive_scan is set to false
debug libnfc.general 0 device(s) defined by user
nfc-list uses libnfc 1.7.1
debug libnfc.driver.acr122_usb device found: Bus 020 Device 020 Name ACS ACR122
debug libnfc.general 1 device(s) found using acr122_usb driver
debug libnfc.driver.acr122_usb 3 element(s) have been decoded from "acr122_usb:020:020"
debug libnfc.driver.acr122_usb TX: 62 00 00 00 00 00 00 01 00 00
error libnfc.driver.acr122_usb Unable to write to USB (Result too large)
debug libnfc.general Unable to open "acr122_usb:020:020".
nfc-list: ERROR: Unable to open NFC device: acr122_usb:020:020当我开始故障排除时,我出现了一个“无法声明USB接口”的错误,其他人也有。因此,我从这堆栈溢出问题和这 github问题中找到了以下内容:
brew install libnfc安装libnfc ->获得“无法声明.”错误。/usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist ->没有帮助autoreconf -iv && ./configure --with-drivers=acr122_usb && make clean && make && make install编译sudo launchctl remove com.apple.ifdreadersudo launchctl stop com.apple.ifdreader
在故障排除之后,我被错误困住了,不知道如何解决这个问题。阅读器灯不再闪烁红色,但由于错误,设备显然连接到计算机和可用的。
作为一个侧节点:我通过USB集线器连接读取器,因为读取器没有USB电缆,但这不应该是个问题。有没有人有同样的问题或者我可以尝试的另一种方法?
发布于 2019-12-07 20:54:39
您的步骤4,编辑/usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist为我工作,这是我能找到的唯一干净的解决方案。
这里是一个简短的描述,您需要做什么:
在我的例子中的三行是条目编号370:
详细描述一步一步:
<cmd>+<R>键,进入恢复模式。csrutil disablenfc-scan-device<cmd>+<R>键,然后启动Mac进入恢复模式。csrutil enable@anderssonjohan给出了正确的答案在他的岗位,但他发布的plist文件不一致,因为他只删除了一行而不是三行。
发布于 2021-10-13 15:30:53
第一种解决方案是我所需要的,但是启用SIP、更改驱动程序和恢复SIP对于我来说是太多了,这对我们的读者来说只是禁用PC/SC而已。
如果您在某些符合PC/SC标准的macos应用程序中使用读取器,此解决方案将不适用于您。
我找到了没有启用/禁用SIP的解决方案。
在这种情况下,macos系统会忽略系统驱动程序,因为它已经安装了用户驱动程序并应用于它们的所有配置,即使设备在其中被忽略了。
测试并与最新版本的libnfc从主机和macos BigSur 11.6
注意:为了能够正确地使用gen3 fob,我建议从主程序编译和安装libnfc,已经做了一些新的更改,但还没有发布(
发布于 2019-12-08 13:12:21
最初的问题是,守护进程system/com.apple.ifdreader加载用户级驱动程序/usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle,即基于pcsc-lite,并声称拥有USB设备。要使libnfc可以访问读卡器,您可以
我对这个问题作了两个回答:
在这里,可以执行一些命令来显示服务的状态:
launchctl list com.apple.ifdreader
launchctl blame system/com.apple.ifdreader仅仅关闭守护进程或禁用它将无法工作,当系统检测到其Info.plist中列出其ID的USB设备时,它将自动(重新)启动,因此您需要从/usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist中删除USB ID。
不幸的是,该文件受到MacOS Mojave 10.14.6中的“系统完整性保护”的保护,因此您只能在启动到恢复模式并在那里修改它时才能修改它,或者在那里使用csrutil disable禁用“系统完整性保护”,以便能够在正常的用户环境中修改它。
以下是您需要执行的步骤:
<cmd>+<R>键,然后启动Mac进入恢复模式。/usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist替换为您准备的在进入恢复模式之前,您需要知道在哪些路径下可以找到文件,因为根文件系统是不同的,并且您的普通根文件系统将被挂载在/卷/下,所以在恢复模式之前在Finder中查找这个名称。
例如,我的系统驱动器名为Macintosh HD,路径如下:
/Volumes/Macintosh HD/Users/michael/Volumes/Macintosh HD/usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist在我的示例中,最好的方法是使chroot '/Volumes/Macintosh HD'能够使用大多数普通的CLI命令。
要创建新的Info.plist文件,您可以使用我的另一个答案中的小补丁。或者您可以使用附加的python脚本,这更灵活。只需调用脚本,它将在当前目录的sub SmartCardService_disable中创建已更改的SmartCardService_disable文件:
#!/usr/bin/env python3
import os, re, plistlib
from shutil import copyfile
plistFile = "/usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist"
plistFileBak = "Info.plist.orig"
plistFileOut = "Info.plist"
workDir = "SmartCardService_disable"
usbFriendlyNamePattern = ".*ACS.*ACR122.*"
def findDevicesByFriendlyName(pl, usbFriendlyNamePattern) :
reUsbFriendlyName = re.compile(usbFriendlyNamePattern, re.IGNORECASE)
indexes = []
for index, item in enumerate(pl["ifdFriendlyName"]):
if reUsbFriendlyName.fullmatch(item) :
indexes.append(index)
return indexes
def makePlistCopy() :
try:
os.mkdir(workDir)
except FileExistsError:
pass
except:
raise Exception("Unable to create work directory")
os.chdir(workDir)
try:
os.stat(plistFileBak)
except FileNotFoundError:
copyfile(plistFile, plistFileBak)
except:
raise Exception("Unable to copy plist file")
makePlistCopy()
pl = plistlib.readPlist(plistFileBak)
indexes = findDevicesByFriendlyName(pl, usbFriendlyNamePattern)
indexes.sort(reverse = True)
for index in indexes:
del pl["ifdFriendlyName"][index]
del pl["ifdVendorID"][index]
del pl["ifdProductID"][index]
plistlib.writePlist(pl, plistFileOut)该脚本可以很容易地修改以删除其他读卡器,只需将usbFriendlyNamePattern = ".*ACS.*ACR122.*"更改为任何其他模式即可。
https://stackoverflow.com/questions/57876097
复制相似问题