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

Add timeout to wait_for_tag method #70

Merged
merged 2 commits into from
Oct 3, 2023
Merged

Conversation

jo-me
Copy link
Contributor

@jo-me jo-me commented Jun 17, 2020

Based on @tlongeri 's suggestion in #44
I addded the timeout functionality to the wait_for_tag method so that it will return after a given number of seconds.
The timeout param is optional with default value of 0 (=no timeout) so that existing users of the library will not have any change in functionality unless they provide the new param.

This functionality is useful for detecting that the reader could not find a RFID tag, e.g. the card was removed.

Based on @tlongeri 's suggestion in ondryaso#44
I addded the timeout functionality to the wait_for_tag method so that it will return after a given number of seconds. 
The timeout param is optional with default value of 0 (=no timeout) so that existing users of the library will not have any change in functionality unless they provide the new param.

This functionality is useful for detecting that the reader could not find a RFID tag, e.g. the card was removed.
Copy link

@kim-tom kim-tom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work when timeout==0 since the loop doesn't run at all.
You should break in while sentence when timeout > 0 and (time.time() - start_time) >= timeout

handle timeout == 0 case in waiting loop
@jo-me
Copy link
Contributor Author

jo-me commented May 4, 2021

You're right. I updated the code to handle that case.

@Jonathan-0101
Copy link

Hi how do I use this in my code?

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.

4 participants