adafruit / Adafruit_CircuitPython_PN532

CircuitPython driver for the PN532 NFC/RFID Breakout and PN532 NFC/RFID Shield
MIT License
91 stars 47 forks source link

get_passive_target is asking for more data from the UART than is provided, so we are blocking #44

Closed infrastructure-ninja closed 1 year ago

infrastructure-ninja commented 3 years ago

greetings everyone!

I am presenting a card and the following line in the __readdata 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 _adafruitpn532.py: response = self.process_response( _COMMAND_INLISTPASSIVETARGET, response_length=19, timeout=timeout )

So we hard-code to 19 bytes? I have adjusted the "_responselength" 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