Skip to content

Commit 8737fd8

Browse files
committed
Merge branch 'fix-usbserial-available'
2 parents 7836764 + b06501b commit 8737fd8

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

CHANGELOG

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SAMD CORE 1.6.8
22

33
* Fixed regression on analogWrite. Thanks @bose-mdellisanti!
4+
* Fixed regression on SerialUSB.available()
45

56
SAMD CORE 1.6.7 2016.09.28
67

cores/arduino/USB/SAMD21_USBDevice.h

+13-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,19 @@ class DoubleBufferedEPOutHandler : public EPHandler {
350350

351351
// Returns how many bytes are stored in the buffers
352352
virtual uint32_t available() const {
353-
return (last0 - first0) + (last1 - first1);
353+
if (current == 0) {
354+
bool ready = false;
355+
synchronized {
356+
ready = ready0;
357+
}
358+
return ready ? (last0 - first0) : 0;
359+
} else {
360+
bool ready = false;
361+
synchronized {
362+
ready = ready1;
363+
}
364+
return ready ? (last1 - first1) : 0;
365+
}
354366
}
355367

356368
void release() {

0 commit comments

Comments
 (0)