Closed tgikal closed 5 years ago
nice, did you try this on raspi only or also on some circuitpy hardware?
Unfortunately the only things I have that will run circuitpython are Raspberry Pis.
I'm still pretty new to submitting PRs, so sorry if it looks weird.
@caternuson wanna review by checking on a samd?
Thanks. Looks good. I recreated what I think is the original issue by doing this:
>>> pn532.read_passive_target(timeout=5)
bytearray(b'&)3~')
>>> pn532.read_passive_target(timeout=5)
>>>
where for the first read, the card was sitting on the reader, so could be read right away. For the second read, I put the card on the read after ~2 secs, and got nothing. With the updated code, both seem to work:
>>> pn532.read_passive_target(timeout=5)
bytearray(b'&)3~')
>>> pn532.read_passive_target(timeout=5)
bytearray(b'&)3~')
>>>
Yes, that's basically how I encountered the error as well, setting the timeout to a long value and trying to scan a tag somewhere after the initial call.
Without looking harder into the adafruit_bus_device.spi_device module and possibly one of it's imports, I assume something is being reset in the __exit__
call with
makes.
To address the issue described in https://github.com/adafruit/Adafruit_CircuitPython_PN532/issues/19: Modified the
_wait_ready
function, by avoiding re-declaring thewith
statement each iteration of thewhile
loop.