Koduino
|
Stream library inherited by Wire, Serial, etc. More...
#include <Stream.h>
Stream library inherited by Wire, Serial, etc.
This file is part of koduino https://github.com/avikde/koduino
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, see http://www.gnu.org/licenses/.
Stream is a collection of functions for ASCII or binary streams used by Serial, Wire, etc. These methods are identical to the Arduino equivalents.
The Arduino String library is included as well.
The excellent Streaming library is also available.
Public Member Functions | |
virtual int | available ()=0 |
Return the number of bytes in the receive buffer. More... | |
virtual int | read ()=0 |
Reads a single byte from the receive buffer. More... | |
virtual int | peek ()=0 |
Reads a single byte from the receive buffer. More... | |
virtual void | flush ()=0 |
Waits till the previous write operation is finished. | |
void | setTimeout (uint32_t timeout) |
Sets maximum milliseconds to wait for stream data. More... | |
bool | find (char *target) |
Reads data from the stream until the target string is found. More... | |
bool | find (char *target, size_t length) |
Reads data from the stream until the target string of given length is found. More... | |
bool | findUntil (char *target, char *terminator) |
Same as find() but search ends if the terminator string is found. More... | |
int | parseInt () |
Returns the first valid (long) integer value from the current position. More... | |
float | parseFloat () |
Float version of parseInt() More... | |
size_t | readBytes (char *buffer, size_t length) |
Read chars from stream into buffer. More... | |
size_t | readBytesUntil (char terminator, char *buffer, size_t length) |
Same as readBytes() with terminator character. More... | |
Inherits Print.
Inherited by TwoWire, and USARTClass.
|
pure virtual |
bool Stream::find | ( | char * | target | ) |
Reads data from the stream until the target string is found.
target |
bool Stream::find | ( | char * | target, |
size_t | length | ||
) |
Reads data from the stream until the target string of given length is found.
target | |
length |
bool Stream::findUntil | ( | char * | target, |
char * | terminator | ||
) |
Same as find() but search ends if the terminator string is found.
target | |
terminator |
float Stream::parseFloat | ( | ) |
Float version of parseInt()
int Stream::parseInt | ( | ) |
Returns the first valid (long) integer value from the current position.
Initial characters that are not digits (or the minus sign) are skipped. Integer is terminated by the first character that is not a digit.
|
pure virtual |
Reads a single byte from the receive buffer.
Does not increment the buffer pointer
Implemented in TwoWire, and USARTClass.
|
pure virtual |
Reads a single byte from the receive buffer.
Increments the buffer pointer
Implemented in TwoWire, and USARTClass.
size_t Stream::readBytes | ( | char * | buffer, |
size_t | length | ||
) |
Read chars from stream into buffer.
Terminates if length characters have been read or timeout (see setTimeout())
buffer | |
length |
size_t Stream::readBytesUntil | ( | char | terminator, |
char * | buffer, | ||
size_t | length | ||
) |
Same as readBytes() with terminator character.
Terminates if length characters have been read, timeout, or if the terminator character detected
terminator | |
buffer | |
length |
void Stream::setTimeout | ( | uint32_t | timeout | ) |
Sets maximum milliseconds to wait for stream data.
timeout | Default is 1 second |