1

Objective: let ACR1252U NFC reader enter card emulation mode using python on Mac

I have trouble with using the ACS ACR1252U card reader on macOS Catalina 10.15.3 using the PC/SC driver. I installed the driver from the ACS website.

By using the pyscard (http://pyscard.sourceforge.net/) library, the following python code works and returns the correct enter card emulation mode response on windows computer: 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 )

But it gives an error on Mac. I followed this answer to change plist files but I still get the same error:

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

I installed libnfc using homebrew but I am not sure how to compile it according to the 2nd part of the answer.

Any help will be greatly appreciated.

Azurespace
  • 11
  • 2

0 Answers0