Skip to content

Commit 810803c

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 3e68702 + b495294 commit 810803c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

cores/arduino/Stream.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,27 @@ size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length)
244244
return index; // return number of characters, not including null terminator
245245
}
246246

247+
String Stream::readString()
248+
{
249+
String ret;
250+
int c = timedRead();
251+
while (c >= 0)
252+
{
253+
ret += (char)c;
254+
c = timedRead();
255+
}
256+
return ret;
257+
}
258+
259+
String Stream::readStringUntil(char terminator)
260+
{
261+
String ret;
262+
int c = timedRead();
263+
while (c >= 0 && c != terminator)
264+
{
265+
ret += (char)c;
266+
c = timedRead();
267+
}
268+
return ret;
269+
}
270+

cores/arduino/Stream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class Stream : public Print
8282
// returns the number of characters placed in the buffer (0 means no valid data found)
8383

8484
// Arduino String functions to be added here
85+
String readString();
86+
String readStringUntil(char terminator);
8587

8688
protected:
8789
long parseInt(char skipChar); // as above but the given skipChar is ignored

0 commit comments

Comments
 (0)