Skip to content

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

Merged
merged 17 commits into from
Aug 29, 2016
Merged

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Aug 23, 2016

sandeepmistry and others added 17 commits August 24, 2016 01:04
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.
@ArduinoBot
Copy link

✅ Build completed.

⬇️ Build URL: http://downloads.arduino.cc/PR/samd/package_samd-b90_index.json

ℹ️ To test this build:

  1. Open the Preferences of the Arduino IDE.
  2. Add the Build URL above in the Additional Boards Manager URLs field, and click OK.
  3. Open the Boards Manager (menu Tools->Board->Board Manager...)
  4. Install Arduino SAMD core - Pull Request Improved SerialUSB.read() reliability #159
  5. Select one of the boards under SAMD Pull Request Improved SerialUSB.read() reliability #159 in Tools->Board menu
  6. Compile/Upload as usual

@@ -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);
Copy link
Contributor

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?

Copy link
Member Author

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!

Copy link
Contributor

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.

@sandeepmistry
Copy link
Contributor

Tested this with OS X 10.11.6 + MKR1000 + WiFi101 Firmware updater tool. No more issues upgrading firmware.

Nice work @cmaglie!

@akash73
Copy link
Member

akash73 commented Aug 24, 2016

tested here with OSX 10.10.5 + MKR1000 and Zero + WifiShield101 and it's dramatical speed improvement!
firmware updater + certificate upload worked fine.
great!

@sandeepmistry
Copy link
Contributor

Has anyone tested with Windows or Linux?

@akash73
Copy link
Member

akash73 commented Aug 24, 2016

I can run some test under windows 7
@agdl can you try under linux / win ?

@akash73
Copy link
Member

akash73 commented Aug 25, 2016

Tested with Windows 10 ( 10.0.10586) + MKR1000 and Zero + WifiShield101
Firmware update + certificate upload worked fine.

@cmaglie cmaglie merged commit 4691ef4 into arduino:master Aug 29, 2016
@cmaglie cmaglie added this to the Release 1.6.7 milestone Aug 29, 2016
@alvarolb
Copy link

alvarolb commented Sep 5, 2016

Works great in OS X El Capitan! Thanks!

@cmaglie cmaglie deleted the usb-buffering branch September 22, 2016 10:05
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.

5 participants