Skip to content

SPI read_passive_target timeout #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 3, 2019
Merged

SPI read_passive_target timeout #24

merged 3 commits into from
Jul 3, 2019

Conversation

tgikal
Copy link
Contributor

@tgikal tgikal commented Jul 1, 2019

To address the issue described in #19:
Modified the _wait_ready function, by avoiding re-declaring the with statement each iteration of the while loop.

tgikal added 2 commits June 28, 2019 15:12
Tested writing 437 bytes of data to an NTAG215.
Original script: 18.9 seconds write, 19.2 seconds read.
Modified script: 7.6 seconds write, 7.8 seconds read.
Moving the `with` statement seems to correct the timeout issue.
@ladyada
Copy link
Member

ladyada commented Jul 1, 2019

nice, did you try this on raspi only or also on some circuitpy hardware?

@tgikal
Copy link
Contributor Author

tgikal commented Jul 1, 2019

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.

@ladyada
Copy link
Member

ladyada commented Jul 1, 2019

@caternuson wanna review by checking on a samd?

@caternuson caternuson self-requested a review July 2, 2019 16:28
@caternuson
Copy link
Contributor

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~')
>>> 

@caternuson caternuson merged commit b949e87 into adafruit:master Jul 3, 2019
@tgikal
Copy link
Contributor Author

tgikal commented Jul 4, 2019

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.

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jul 4, 2019
@tgikal tgikal deleted the tgikal-SPI-read_passive_target-timeout branch July 9, 2019 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants