Repository: adafruit/Adafruit_CircuitPython_PN532 (language: python)

Issue:
get_passive_target is asking for more data from the UART than is provided, so we are blocking
greetings everyone!

I am presenting a card and the following line in the __read_data_ function (line #82 in uart.py): 
`frame = self._uart.read(count)`
is never returning as we've [presumably] told it to expect more data than is available (being returned from PN532).

After some digging, I found the following in line #419 of _adafruit_pn532.py_:
`        response = self.process_response(
            _COMMAND_INLISTPASSIVETARGET, response_length=19, timeout=timeout
        )`

So we hard-code to 19 bytes? I have adjusted the "_response_length_" parameter down to 10, and it appears to work properly, for the specific card I am using here.

Can someone explain how we derived this length, and more importantly - why is this not dynamic based on what the chip is sending back to us? I'm reading through the datasheet, which is how I got to where I am now - but it's honestly making my head hurt.

Hoping to get fresh eyes on this that are far more intimately familiar with the device and protocol already.

Thanks for talking this out with me!  - Joel
Cannot found mifare card using UART
I'm running the example code on Windows 10 (python 3.8, pyserial 3.5), my PN532 can be found, but it's stuck while waiting for a card, my PN532 and card work fine by using other mifare tools


Discussion / hints:

Fix patch:
diff --git a/examples/pn532_readwrite_mifare.py b/examples/pn532_readwrite_mifare.py
index 3b756cb..82333e7 100644
--- a/examples/pn532_readwrite_mifare.py
+++ b/examples/pn532_readwrite_mifare.py
@@ -44,7 +44,7 @@
 # pn532 = PN532_SPI(spi, cs_pin, debug=False)
 
 # UART connection
-# uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
+# uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1)
 # pn532 = PN532_UART(uart, debug=False)
 
 ic, ver, rev, support = pn532.firmware_version
diff --git a/examples/pn532_readwrite_ntag2xx.py b/examples/pn532_readwrite_ntag2xx.py
index 765e062..9755d87 100644
--- a/examples/pn532_readwrite_ntag2xx.py
+++ b/examples/pn532_readwrite_ntag2xx.py
@@ -40,7 +40,7 @@
 pn532 = PN532_SPI(spi, cs_pin, debug=False)
 
 # UART connection
-# uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
+# uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1)
 # pn532 = PN532_UART(uart, debug=False)
 
 ic, ver, rev, support = pn532.firmware_version
diff --git a/examples/pn532_simplelisten.py b/examples/pn532_simplelisten.py
index c9f7851..35eea95 100644
--- a/examples/pn532_simplelisten.py
+++ b/examples/pn532_simplelisten.py
@@ -46,7 +46,7 @@
 # pn532 = PN532_SPI(spi, cs_pin, debug=False)
 
 # UART connection
-# uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
+# uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1)
 # pn532 = PN532_UART(uart, debug=False)
 
 ic, ver, rev, support = pn532.firmware_version


Test patch:
diff --git a/examples/pn532_simpletest.py b/examples/pn532_simpletest.py
index 25de1e1..4308525 100644
--- a/examples/pn532_simpletest.py
+++ b/examples/pn532_simpletest.py
@@ -40,7 +40,7 @@
 # pn532 = PN532_SPI(spi, cs_pin, debug=False)
 
 # UART connection
-# uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
+# uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1)
 # pn532 = PN532_UART(uart, debug=False)
 
 ic, ver, rev, support = pn532.firmware_version