Fixed slowdown with repeated CDC bool operator test #3624
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.
The
delay(10)
in thebool
operator of the USB CDC/ACM Serial operator was being imposed on every single call to the operator when it is not needed. Instead thisdelay(10)
should only be called when the line state transitions from ==0 to >0 (i.e., as the line enters the active state from the inactive state), otherwise repeated calls to (eg)if (Serial)
cause the entire sketch to slow down to a crawl.By only imposing the delay when the line changes state it avoids that slowdown whilst at the same time giving the system a chance to complete the port opening operation before data is allowed to be sent.