Force PC/SC driver on ACR122U NFC reader
Asked Answered
F

1

5

I have trouble with using my ACR122U RFID card reader form ACS. I need to connect it to my Mac using the PC/SC driver. I installed the driver from the ACS website and confirmed that it's running.

However, whenever I test using the nfc-list command, I get the following error:

nfc-list uses libnfc libnfc-1.7.1-189-g2869ae2
error   libnfc.driver.acr122_usb        Unable to claim USB interface (Permission denied)
nfc-list: ERROR: Unable to open NFC device: acr122_usb:020:002

As far as I've understood from googling is that it is the Mac taking over the USB that prevents PC/SC using the device, but how can I force the computer to use the PC/SC driver instead of the default Apple USB?

PS: I have installed libusb

Frodine answered 4/8, 2017 at 13:30 Comment(0)
K
11

You seem to be mixing two different options for connecting the ACR122U to libnfc:

  1. You can either use the direct USB driver for the ACR122U, libnfc.driver.acr122_usb (which is what you are currently using). In this case, you need to make sure that the PC/SC daemon does not take over control of the reader (since only one instance can access the USB interface of the reader at a time).

    • The quick-and-dirty fix is to disable the PC/SC daemon that takes control over the ACR122U. Though this is not straight forward on Mac OS X, a detailed explanation can be found in Ludovic's blog.
    • Alternatively, you could prevent the PC/SC daemon from taking control over that specific reader by editing /usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist. You would need search for the entry

      <key>ifdProductID</key>
      

      Below this entry, there is an array of entries of the form

      <string>0xXXXX</string>
      

      You will need to search for entries containing the values 0x2200, 0x90CC, and 0x2214. Remove those lines, but remember the relative line number (i.e. the offset in the <array>). Then, also remove the corresponding lines under

      <key>ifdVendorID</key>
      

      They should all contain the value 0x072F and thus have the form

      <string>0x072F</string>
      

      Moreover, you also need to remove the corresponding lines under

      <key>ifdFriendlyName</key>
      

      All of them will probably start with <string>ACS.

  2. Alternatively, you could use the PC/SC based libnfc driver for the ACR122U (libnfc.driver.acr122_pcsc). This driver uses the system PC/SC daemon to access the reader instead of taking control over the USB interface directly. For this option to work, you need to configure lib-nfc to use the PC/SC driver instead of the direct USB driver. When you compile libnfc yourself, you could do this by explicitly activating only the PC/SC based driver:

    ./configure --with-drivers=acr122_pcsc
    make
    

    However, note that this driver has been depreciated and libnfc authors strongly discourage its use.

Kerianne answered 11/8, 2017 at 10:19 Comment(5)
Thank you! This is the single most informative answer I have ever found on the Internet.Frodine
When I edit /usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist (using sudo) the contents just revert to the original contents … any clue?Cowen
You've noted that the acr122_pcsc driver is deprecated and no longer recommended for use. Is there a preferred way to use libnfc with a CCID-compliant PC/SC device? (ref: https://mcmap.net/q/2029516/-macos-10-15-4-external-nfc-reader-over-usb-ccid-amp-pc-sc-compliant-for-host-card-emulation)Yonita
@jared no, since there is no NFC support in PC/SC, any libnfc to PC/SC or CCID interface would need to be specific to any (proprietary) reader implementation.Kerianne
How do I edit the .plit file? Even after disabling system integrity I don't have enough permission to change anything.Anarchic

© 2022 - 2024 — McMap. All rights reserved.