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

When UART timeout of zero is given, make read() return data already a… #1159

Merged
merged 1 commit into from Sep 4, 2018

Conversation

PaulKierstead
Copy link

…vailable

Currently if you give a timeout of zero to UART, typically you'll get nothing as the comparison is < timeout and no time has passed. This makes that <= and makes sure only one pass of the read loop is performed. Now, when a timeout of 0 is given, it will return the data already available without waiting for any additional data.

@ladyada
Copy link
Member

ladyada commented Sep 1, 2018

@PaulKierstead thanks for the PR! one thing to check if you can - we want to make circuitpython a subset of CPython so code from circuitpython works on any os - for UART we want to mimic pyserial so can you see if this behavior is also specified there?

@PaulKierstead
Copy link
Author

For read timeouts, pyserial behaviour for timeout == 0:
timeout = 0: non-blocking mode, return immediately in any case, returning zero or more, up to the requested number of bytes

So this would get us closer to pyserial (though of course many differences remain, but the others generally require CP to change its API in backwards compatibility broken ways).

@ladyada
Copy link
Member

ladyada commented Sep 1, 2018

cool - thank you! that's good to hear, i'll wait for @tannewt or @dhalbert to review for possible mergin' - its a long weekend so may be a few days :)

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Great! Thank you!

@dhalbert dhalbert merged commit ba6e1b6 into adafruit:master Sep 4, 2018
@PaulKierstead
Copy link
Author

My pleasure, @ladyada and @dhalbert, I'm glad to contribute even this tiny change to a project that has provided many hours of fun and fulfillment.

@ladyada
Copy link
Member

ladyada commented Sep 4, 2018

yay! nice work :)

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.

None yet

3 participants