Skip to content

PN532_SPI._wait_ready cannot recover if failing #28

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

Closed
basil-huber opened this issue Jan 5, 2020 · 0 comments · Fixed by #29
Closed

PN532_SPI._wait_ready cannot recover if failing #28

basil-huber opened this issue Jan 5, 2020 · 0 comments · Fixed by #29

Comments

@basil-huber
Copy link
Contributor

PN532_SPI._wait_ready polls the status until ready. However, the command to be sent is overwritten by the response received. Hence, if the device is not ready at the first request, we might send the wrong command for subsequent polling:

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

the command in status is overwritten.

basil-huber added a commit to basil-huber/Adafruit_CircuitPython_PN532 that referenced this issue Jan 5, 2020
Use separate buffer for sending and receiving form SPI
This fixes adafruit#28
@jepler jepler closed this as completed in #29 Jan 7, 2020
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 a pull request may close this issue.

1 participant