-
Notifications
You must be signed in to change notification settings - Fork 643
Improve slcan.py #1490
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
Improve slcan.py #1490
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2c9e1e6
Improve slcan.py
mikisama f95ca7d
Merge branch 'hardbyte:develop' into develop
mikisama 7fa9f5c
use `read_all` to read out serial port data.
mikisama c581cc9
fix when the `timeout` parameter is 0, it cannot enter the while loop.
mikisama 8722a11
For performance reason, revert to using `read` to read serial data.
mikisama fa62a63
add `size=1` and renamed `new_data` to `new_byte`
mikisama 73ce3dd
fix the issue of returning `None` before receiving
mikisama 3eb80b9
Due to the simplification of the control flow,
mikisama 2bbee49
Revert "Due to the simplification of the control flow,"
mikisama 1635381
Simplify the control flow for finding the end of a SLCAN message.
mikisama 42db106
improve the `timeout` handling of slcan.py
mikisama 6f994cc
Merge branch 'hardbyte:develop' into develop
mikisama 3c8a9e3
Change the plain format calls to f-strings.
mikisama ce3b9a4
using `bytearray.fromhex` to parse the frame's data.
mikisama 2c22b4e
change `del self._buffer[:]` to `self._buffer.clear` since it's more …
mikisama 09e1248
Simplify the timeout handling
mikisama e3a388b
fix the issue when the returned string is `None`.
mikisama 370a2ff
using `pyserial.reset_input_buffer` to discard
mikisama 68c9c71
fix failing PyPy test
mikisama cec01d7
fix failing PyPy test
mikisama 6c3b13a
improve the comments
mikisama File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix when the
timeout
parameter is 0, it cannot enter the while loop.
- Loading branch information
commit c581cc977a41ffab3b041e7a06a352b891e9eb0f
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need
_timeout
to handle timeout?The timeout can be determined when
pyserial.read
returnsb''
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timeout of
pyserial.read
is reset on everyread
call, so it might add up. The timeout argument of the user should be respected,_timeout
takes care of that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the
timeout's add up
should be ignored.For python on windows, the timer's resolution is about 16ms, obviously it is not very accurate.
And I think the
timeout add up
is not as big as the impact of timer jitter.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That depends on the
timeout
value, It might be seconds, or minutes, or hours, i don't know what users might be doing.