-
-
Notifications
You must be signed in to change notification settings - Fork 726
Improved SerialUSB.read() reliability #159
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
Conversation
this is the proper type to encapsulate a byte when data is available or -1 when there is no data.
The reference to the upper USBDevice class is passed on the EPHandler constructor.
Now the release() function only performs the action that is called for, i.e. release the endpoint and let it receive data. All the buffers handling has been inlined in the callers, this also slightly improves performance because it allows to remove some redundant checks.
It makes no sense to have ::recv calling repeatedly ::read in this case.
This change improves read performance when massive data is sent via USB by exploiting the hardware capability to handle multi-packet transfers autonomously.
This bypass the generic (but inefficient) implementation of Stream::readBytes and uses an optimized version of readBytes than can do efficient multi-byte reads.
✅ Build completed. ⬇️ Build URL: ℹ️ To test this build:
|
@@ -128,6 +127,8 @@ class Serial_ : public Stream | |||
using Print::write; // pull in write(str) from Print | |||
operator bool(); | |||
|
|||
size_t readBytes(char *buffer, size_t length); |
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.
Was this new API just for testing?
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.
it's not a new a API is an overloaded method of Stream!
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.
Since it is not virtual
it won't necessarily be called if SerialUSB
is passed in to code that accepts a Stream
object. Just something to keep in mind.
Tested this with OS X 10.11.6 + MKR1000 + WiFi101 Firmware updater tool. No more issues upgrading firmware. Nice work @cmaglie! |
tested here with OSX 10.10.5 + MKR1000 and Zero + WifiShield101 and it's dramatical speed improvement! |
Has anyone tested with Windows or Linux? |
I can run some test under windows 7 |
Tested with Windows 10 ( 10.0.10586) + MKR1000 and Zero + WifiShield101 |
Works great in OS X El Capitan! Thanks! |
/cc @sandeepmistry @akash73