-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Workaround for when USB CDC is unplugged #7583
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
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
There are no files selected for viewing
This file contains 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.
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.
with this being 0, it means that is the ring buffer is full, the code will not give it time to empty some space and will just discard the input. Maybe wait if the is not enough space? Fixing it for when USB is disconnected, but breaking it for when connected is not all that nice :)
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.
Waiting when there is no space (timeout) is exacty the issue... when the board is turned on with the USB unplugged. That is what causes the delay from the point when the RingBuffer gets full and it never is flushed because there is no USB connection.
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.
There is no event that tells the user that USB is or not plugged. Even the ARDUINO_HW_CDC_CONNECTED_EVENT works only the first time, but if we unplug the board, it doesn't tell anything.
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.
@me-no-dev - Added code to test if USB is plugged and the application has never changed Tx Timeout. In that case, it will set Tx Timeout to default 100ms.
Otherwise (USB has never been plugged or the Application has explicitly changed Tx Timeout Value), it will keep it zero or the new value set by the application.