Skip to content
Snippets Groups Projects
Commit b06501ba authored by Cristian Maglie's avatar Cristian Maglie
Browse files

Fix regression: SerialUSB.available() do not return correct values

Fix #172
parent dfe465f0
Branches
Tags
No related merge requests found
......@@ -350,7 +350,19 @@ public:
// Returns how many bytes are stored in the buffers
virtual uint32_t available() const {
return (last0 - first0) + (last1 - first1);
if (current == 0) {
bool ready = false;
synchronized {
ready = ready0;
}
return ready ? (last0 - first0) : 0;
} else {
bool ready = false;
synchronized {
ready = ready1;
}
return ready ? (last1 - first1) : 0;
}
}
void release() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment