aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
authorDavid A. Mellis <d.mellis@arduino.cc>2012-05-21 09:31:54 -0700
committerDavid A. Mellis <d.mellis@arduino.cc>2012-05-21 09:31:54 -0700
commit810803c6d3ab33a4496a89f41ef7e1dda15e8680 (patch)
tree345c144177d85336e151119a578e2c13d37cee73 /cores/arduino
parent3e68702149cbf938f11bc9410eb7f9a0c811fa28 (diff)
parentb495294aa32ca838180af57efdb1f04727487d55 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'cores/arduino')
-rw-r--r--cores/arduino/Stream.cpp24
-rw-r--r--cores/arduino/Stream.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/cores/arduino/Stream.cpp b/cores/arduino/Stream.cpp
index 3d5b905..aafb7fc 100644
--- a/cores/arduino/Stream.cpp
+++ b/cores/arduino/Stream.cpp
@@ -244,3 +244,27 @@ size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length)
return index; // return number of characters, not including null terminator
}
+String Stream::readString()
+{
+ String ret;
+ int c = timedRead();
+ while (c >= 0)
+ {
+ ret += (char)c;
+ c = timedRead();
+ }
+ return ret;
+}
+
+String Stream::readStringUntil(char terminator)
+{
+ String ret;
+ int c = timedRead();
+ while (c >= 0 && c != terminator)
+ {
+ ret += (char)c;
+ c = timedRead();
+ }
+ return ret;
+}
+
diff --git a/cores/arduino/Stream.h b/cores/arduino/Stream.h
index 13f11be..58bbf75 100644
--- a/cores/arduino/Stream.h
+++ b/cores/arduino/Stream.h
@@ -82,6 +82,8 @@ class Stream : public Print
// returns the number of characters placed in the buffer (0 means no valid data found)
// Arduino String functions to be added here
+ String readString();
+ String readStringUntil(char terminator);
protected:
long parseInt(char skipChar); // as above but the given skipChar is ignored