Skip to content

Commit 09015f7

Browse files
Add uint8_t* versions of methods in Stream
The new functions just call their char* equivalents, but this allows reading bytes into a buffer of uint8_t as well as chars.
1 parent c2c503d commit 09015f7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cores/arduino/Stream.h

+6
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,18 @@ class Stream : public Print
5757
void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second
5858

5959
bool find(char *target); // reads data from the stream until the target string is found
60+
bool find(uint8_t *target) { return find ((char *)target); }
6061
// returns true if target string is found, false if timed out (see setTimeout)
6162

6263
bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found
64+
bool find(uint8_t *target, size_t length) { return find ((char *)target, length); }
6365
// returns true if target string is found, false if timed out
6466

6567
bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found
68+
bool findUntil(uint8_t *target, char *terminator) { return findUntil((char *)target, terminator); }
6669

6770
bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found
71+
bool findUntil(uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((char *)target, targetLen, terminate, termLen); }
6872

6973

7074
long parseInt(); // returns the first valid (long) integer value from the current position.
@@ -74,10 +78,12 @@ class Stream : public Print
7478
float parseFloat(); // float version of parseInt
7579

7680
size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer
81+
size_t readBytes( uint8_t *buffer, size_t length) { return readBytes((char *)buffer, length); }
7782
// terminates if length characters have been read or timeout (see setTimeout)
7883
// returns the number of characters placed in the buffer (0 means no valid data found)
7984

8085
size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character
86+
size_t readBytesUntil( char terminator, uint8_t *buffer, size_t length) { return readBytesUntil(terminator, (char *)buffer, length); }
8187
// terminates if length characters have been read, timeout, or if the terminator character detected
8288
// returns the number of characters placed in the buffer (0 means no valid data found)
8389

0 commit comments

Comments
 (0)