title: Can't read card with NFC/RFID reader through Python
body: <p>I've bought a NFC card reader (ACS / ACR122U) that I plug in my raspberry 3 thru an USB port;  I've installed swig, pcsc-tools, pcscd ,libpcsclite...
  The pcscd service is launched by systemctl and is bind to pcscd.socket.
  I can see the reader when I start <code>nfc-scan-device</code> and can also read the card provided with the reader when I start <code>nfc-list</code>
  Then I try to read the tag-Id using python3 and pyscard and it doesn't work.
  I can see the reader and launch a connection without any error message but can't read the tagID. </p>
  
  <p><em>sudo nfc-list</em> returns:</p>
  
  <pre><code>&gt;nfc-list uses libnfc 1.7.1
  &gt;NFC device: ACS / ACR122U PICC Interface opened
  &gt;1 ISO14443A passive target(s) found:
  &gt;ISO/IEC 14443A (106 kbps) target:
  &gt;ATQA (SENS_RES): 00  04  
  &gt;UID (NFCID1): d6  71  c5  f0  
  &gt;SAK (SEL_RES): 08`  
  </code></pre>
  
  <p>the NFC card reader is thus reachable and I can even get the tag id of cards</p>
  
  <p>Then I try to use it on python
  I've found some info there:
  <a href="https://pyscard.sourceforge.io/user-guide.html" rel="nofollow noreferrer">https://pyscard.sourceforge.io/user-guide.html</a>
  <a href="https://pyscard.sourceforge.io/epydoc/smartcard-module.html" rel="nofollow noreferrer">https://pyscard.sourceforge.io/epydoc/smartcard-module.html</a></p>
  
  <p>I first try it within a pipenv environment but it didn't worked. 
  I then removed pipenv to be sure it was not on the critical path...  </p>
  
  <h1>first test</h1>
  
  <p>I try a basic script that can be found on pyscard doc and an most tutorials... let's call it <strong>nfcReader-1.py</strong></p>
  
  <pre><code>from smartcard.System import readers
  import sys
  
  getuid=[0xFF, 0xCA, 0x00, 0x00, 0x00]
  r = readers()
  if len(r) &lt; 1:
    print("error: No readers available!")
    sys.exit()
  
  print("Available readers: ", r)
  reader = r[0]
  print("Using: ", reader)
  conn = reader.createConnection()
  conn.connect()
  data, sw1, sw2 = conn.transmit(getuid)
  if (sw1, sw2) == (0x90, 0x0):
    print("Status: The operation completed successfully.")
  elif (sw1, sw2) == (0x63, 0x0):
    print("Status: The operation failed.")
  
  print("uid={}".format(data))
  conn=disconnect()
  r=None  #to prevent error messages when calling sys.exit() below
  sys.exit()
  
  &gt;Available readers:  ['ACS ACR122U PICC Interface 00 00']
  &gt;Using:  ACS ACR122U PICC Interface 00 00
  &gt;Status: The operation failed.
  &gt;uid=[]
  </code></pre>
  
  <p>the reader is found but I can't read the card. The transmit() method returns [0x63,x0x00] ([99,00]) which mean something weird happened
  It does not work neither when I type each command in python command line</p>
  
  <h1>SECOND TEST</h1>
  
  <p>I also try another way. I found this second method in the pyscard doc but the result is exacltly the same:</p>
  
  <pre><code>from smartcard.CardType import AnyCardType
  from smartcard.CardRequest import CardRequest
  from smartcard.CardConnection import CardConnection
  from smartcard.util import toHexString
  
  import sys
  getuid=[0xFF, 0xCA, 0x00, 0x00, 0x00]
  act = AnyCardType()
  cr = CardRequest( timeout=10, cardType=act )
  cs = cr.waitforcard()
  cs.connection.connect()
  
  print(toHexString( cs.connection.getATR() ))
  print(cs.connection.getReader())
  data, sw1, sw2 = cs.connection.transmit( cmdmap['getuid'] )
  if (sw1, sw2) == (0x90, 0x0):
    print("Status: The operation completed successfully.")
  elif (sw1, sw2) == (0x63, 0x0):
    print("Status: The operation failed.")
  
  print("uid={}".format(data))
  cs=None  #to prevent error message when calling sys.exit() below
  sys.exit()
  </code></pre>
  
  <p>the response was not different:</p>
  
  <pre><code>&gt;3B 00
  &gt;ACS ACR122U PICC Interface 00 00
  &gt;Status: The operation failed.
  &gt;uid=[]
  </code></pre>
  
  <p>The command I used was [0xFF,0xCA,0x00,0x00,0x00] which seems to be the one to get the tagid.
  The ACS reader doc (<a href="https://www.acs.com.hk/en/download-manual/419/API-ACR122U-2.04.pdf" rel="nofollow noreferrer">https://www.acs.com.hk/en/download-manual/419/API-ACR122U-2.04.pdf</a>) confirms this is the correct sequence.
   <a href="https://i.stack.imgur.com/hxEi7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hxEi7.png" alt="ACS tagid sequence description"></a></p>
  
  <p>At least, I try to launch my python script using <em>sudo</em> in case it could help. and I change the permissions on the socket's folder (/var/run/pcscd/pcscd.comm) to 777... just in case</p>
  
  <p>Do someone any idea of the way I can solve this weird problem ? 
  thanks for your help.</p>