NFC 读卡器 ACR122U 和 libnfc.driver.acr122_usb 无法写入 USB(结果太大)

Me7*_*e0r 1 nfc lib-nfc acr122

我尝试在 Mac OSX Mojave 10.14.6 上使用带有 libnfc 的 ACR122 USB NFC 读卡器,当我尝试使用以下命令时,出现“无法写入 USB(结果太大)”错误LIBNFC_LOG_LEVEL=3 nfc-list

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
Run Code Online (Sandbox Code Playgroud)

当我开始排除故障时,我遇到了“无法声明 USB 接口”错误,其他人也遇到过这种情况。所以我从这个stackoverflow 问题和我发现的这个github 问题中尝试了以下操作:

  1. 安装 libnfc brew install libnfc--> 出现“无法声明...”错误。
  2. 使用 sudo -> 没有变化
  3. 禁用 PC/SC 守护程序 -> 未执行任何操作
  4. 编辑/usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist-> 没有帮助
  5. 卸载libnfc,自己编译项目并禁用ifreader。我尝试使用驱动程序 acr122_usb 和 acr122_pcsc 构建它 -> 现在出现“无法写入 USB(结果太大)”错误。
    • 编译:autoreconf -iv && ./configure --with-drivers=acr122_usb && make clean && make && make install
    • sudo launchctl remove com.apple.ifdreader
    • sudo launchctl stop com.apple.ifdreader

现在排除故障后,我陷入了错误,不知道如何解决问题。读卡器指示灯不再呈红色闪烁,但从错误中可以看出,设备已明显连接到计算机并且可用。

作为侧面节点:我通过 USB 集线器连接读卡器,因为读卡器没有 USB C 电缆,但这应该不是问题。有没有人遇到同样的问题或我可以尝试其他方法?

Mic*_*her 5

你的第 4 步,编辑/usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist对我有用,这是我能找到的唯一干净的解决方案。

这里是您需要做什么的简短描述:

  • 禁用“系统完整性保护”
  • 从 plist 的 3 个数组 ifdFriendlyName、ifdVendorID 和 ifdProductID 中删除 3 个匹配行(具有相同的数组索引! )/usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist
  • 启用“系统完整性保护”

我的例子中的三行是条目号 370:

  • ifdFriendlyName="ACS ACR122U PICC 接口"
  • ifdVendorID=0x072F
  • ifd产品ID=0x2200

详细的分步说明:

  1. 拔下 NFC 读卡器
  2. 关闭 OSX
  3. 启动 Mac 时<cmd>+<R>按住键盘上的按键以进入恢复模式
  4. 在恢复模式下使用“实用程序”菜单打开终端窗口
  5. 执行命令csrutil disable
  6. 正常重启你的Mac
  7. 打开终端窗口并执行以下命令:

    sudo -i
    cd /usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents
    cp Info.plist Info.plist.orig
    patch -l -p0 <<EOF
    --- Info.plist.orig 2019-12-07 20:26:36.000000000 +0100
    +++ Info.plist  2019-12-07 20:26:40.000000000 +0100
    @@ -471,7 +471,6 @@
            <string>0x1050</string>
            <string>0x1050</string>
            <string>0x1050</string>
    -       <string>0x072F</string>
            <string>0x09C3</string>
            <string>0x03EB</string>
            <string>0x0A5C</string>
    @@ -864,7 +863,6 @@
            <string>0x0405</string>
            <string>0x0406</string>
            <string>0x0407</string>
    -       <string>0x2200</string>
            <string>0x0008</string>
            <string>0x6016</string>
            <string>0x5800</string>
    @@ -1257,7 +1255,6 @@
            <string>Yubico Yubikey 4 OTP+CCID</string>
            <string>Yubico Yubikey 4 U2F+CCID</string>
            <string>Yubico Yubikey 4 OTP+U2F+CCID</string>
    -       <string>ACS ACR122U PICC Interface</string>
            <string>ActivCard ActivCard USB Reader V2</string>
            <string>ATMEL VaultIC460</string>
            <string>Broadcom Corp 5880</string>
    EOF
    
    Run Code Online (Sandbox Code Playgroud)
  8. 正常重启你的Mac

  9. 插入 NFC 读卡器
  10. 测试 nfc utils 现在是否正常工作,例如通过调用nfc-scan-device
  11. 关闭 OSX
  12. 按住<cmd>+<R>键盘上的按键,然后启动 Mac 进入恢复模式
  13. 使用“实用程序”菜单打开终端窗口
  14. 执行命令csrutil enable
  15. 正常重启你的Mac

@anderssonjohan在他的帖子中给出了正确的答案,但他发布的 plist 文件不一致,因为他只删除了一行而不是三行。