Fix regression: SerialUSB.available() do not return correct values
Fix #172
This commit is contained in:
parent
dfe465f0eb
commit
b06501baee
1 changed files with 13 additions and 1 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue