Skip to content

USB: Only swap incoming buffers for non-ZLP's #231

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 1 commit into from
May 2, 2017

Conversation

sandeepmistry
Copy link
Contributor

I noticed Serial.available() was stuck returning 0 when I sent 1033 bytes from the Serial Monitor in the IDE from macOS. Sketch snipping:

  do {
    if (SerialUSB.available()) {
      char c = SerialUSB.read();

       SerialUSB.print(c);

       publicCert += (char)c;
    }
  } while (!publicCert.endsWith("-----END CERTIFICATE-----"));

It turns out a ZLP was being received, and the USB code was swapping incoming buffers, when it didn't need to and this confused the code in available() which never swaps back to the other buffer.

This change prevents the swap in the USB endpoint ISR handler when a ZLP is received. NOTE: the call to release(); is needed, this is why I didn't use the if (last0 == 0) { return; } style.

@ArduinoBot
Copy link

✅ Build completed.

⬇️ Build URL: http://downloads.arduino.cc/PR/samd/package_samd-b150_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 USB: Only swap incoming buffers for non-ZLP's #231
  5. Select one of the boards under SAMD Pull Request USB: Only swap incoming buffers for non-ZLP's #231 in Tools->Board menu
  6. Compile/Upload as usual

Copy link
Member

@cmaglie cmaglie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍

@sandeepmistry sandeepmistry merged commit 70b011b into arduino:master May 2, 2017
@sandeepmistry
Copy link
Contributor Author

@cmaglie could you please create a new 1.6.16 milestone for this?

@sandeepmistry sandeepmistry deleted the usb-zlp-rx-fix branch May 2, 2017 14:06
@cmaglie cmaglie modified the milestones: Release 1.6.12, Release 1.6.16 May 2, 2017
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.

4 participants