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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions adafruit_pn532/spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ def _wait_ready(self, timeout=1):
status = bytearray([reverse_bit(_SPI_STATREAD), 0])

timestamp = time.monotonic()
while (time.monotonic() - timestamp) < timeout:
with self._spi as spi:
with self._spi as spi:
while (time.monotonic() - timestamp) < timeout:
time.sleep(0.02) # required
spi.write_readinto(status, status) #pylint: disable=no-member
if reverse_bit(status[1]) == 0x01: # LSB data is read in MSB
return True # Not busy anymore!
else:
time.sleep(0.01) # pause a bit till we ask again
if reverse_bit(status[1]) == 0x01: # LSB data is read in MSB
return True # Not busy anymore!
else:
time.sleep(0.01) # pause a bit till we ask again
# We timed out!
return False

Expand Down