Skip to content
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

How can I make read_passive_target wait indefinitely until a tag becomes available? #43

Open
xetum opened this issue Oct 4, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@xetum
Copy link

xetum commented Oct 4, 2020

Other libraries have this possibility. I don't see how in this one. Thanks

@FoamyGuy
Copy link
Contributor

FoamyGuy commented Oct 4, 2020

You can put it inside of a loop such as in the simpletest example here: https://github.com/adafruit/Adafruit_CircuitPython_PN532/blob/master/examples/pn532_simpletest.py

If if it does not find a card it will just keep retrying until one is in range.

The relavent code in that example is at the bottom:

print("Waiting for RFID/NFC card...")
while True:
    # Check if a card is available to read
    uid = pn532.read_passive_target(timeout=0.5)
    print(".", end="")
    # Try again if no card is available.
    if uid is None:
        continue
    print("Found card with UID:", [hex(i) for i in uid])

@xetum
Copy link
Author

xetum commented Oct 4, 2020 via email

@FoamyGuy
Copy link
Contributor

FoamyGuy commented Oct 4, 2020

https://github.com/adafruit/Adafruit-PN532/blob/d988fb4a28e54efe4de638883ce00858064ddf5f/Adafruit_PN532.h#L173

In the arduino library there is a comment that mentions using a timeout of 0 will make it wait forever.

Did you try setting timeout=0 in the CircuitPython one? Maybe it will work the same.

@xetum
Copy link
Author

xetum commented Oct 4, 2020 via email

@xetum
Copy link
Author

xetum commented Oct 5, 2020 via email

@caternuson caternuson added the enhancement New feature or request label Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants