Skip to content

Commit ad2b51e

Browse files
mhightower83d-a-v
authored andcommitted
Do not call yield() from timedRead() or timedPeek() when _timeout is set to 0. (#6242)
1 parent 4bfa2ae commit ad2b51e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: cores/esp8266/Stream.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ int Stream::timedRead() {
3333
c = read();
3434
if(c >= 0)
3535
return c;
36+
if(_timeout == 0)
37+
return -1;
3638
yield();
3739
} while(millis() - _startMillis < _timeout);
3840
return -1; // -1 indicates timeout
@@ -46,6 +48,8 @@ int Stream::timedPeek() {
4648
c = peek();
4749
if(c >= 0)
4850
return c;
51+
if(_timeout == 0)
52+
return -1;
4953
yield();
5054
} while(millis() - _startMillis < _timeout);
5155
return -1; // -1 indicates timeout
@@ -254,4 +258,3 @@ String Stream::readStringUntil(char terminator) {
254258
}
255259
return ret;
256260
}
257-

0 commit comments

Comments
 (0)