![]() |
Arduino Core for STM32
1.0
|
This class is for receiving and transmitting data. More...
#include <Stream.h>
Public Member Functions | |
virtual int | available ()=0 |
Checks how many bytes are available in receiving buffer. More... | |
virtual int | read ()=0 |
Reads one byte from receiving buffer and removes it from buffer. More... | |
virtual int | peek ()=0 |
Reads one byte from receiving buffer and without removing it from buffer. More... | |
Stream () | |
Constructor. More... | |
Stream & | operator>> (char &c) |
This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator. More... | |
Stream & | operator>> (char *buffer) |
This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator. More... | |
Stream & | operator>> (uint8_t *buffer) |
This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator. More... | |
__INTEGER_ONLY__ (T, Stream &) operator>>(T &val) | |
This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator. More... | |
__FLOATING_ONLY__ (T, Stream &) operator>>(T &val) | |
This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator. More... | |
void | setTimeout (unsigned long timeout) |
Sets the maximum milliseconds to wait for data transmitting or receiving. More... | |
virtual void | width (size_t width_) |
Sets receiving width, that is applied when using operators >> (same as cin.width() method). More... | |
bool | find (const char *target) |
Reads and removes data from the stream until the target string is found. More... | |
bool | find (uint8_t *target) |
Reads and removes data from the stream until the target string is found. More... | |
bool | find (const char *target, size_t length) |
Reads and removes data from the stream until the target string is found. More... | |
bool | find (const uint8_t *target, size_t length) |
Reads and removes data from the stream until the target string is found. More... | |
bool | find (char target) |
Reads and removes data from the stream until the target character is found. More... | |
bool | findUntil (const char *target, const char *terminator) |
Reads data from the stream until a target string or terminator string is found. More... | |
bool | findUntil (const uint8_t *target, const char *terminator) |
Reads data from the stream until a target string or terminator string is found. More... | |
bool | findUntil (const char *target, size_t targetLen, const char *terminate, size_t termLen) |
Reads data from the stream until a target string or terminator string is found. More... | |
bool | findUntil (const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen) |
Reads data from the stream until a target string or terminator string is found. More... | |
long | parseInt () |
Parses the first valid (long) integer number from the stream. More... | |
__INTEGER_ONLY__ (T, T) inline parseNum() | |
Parses the first valid integer number from the stream. More... | |
float | parseFloat () |
Parses the first valid floating point number from the stream. More... | |
__FLOATING_ONLY__ (T, T) inline parseNum() | |
Parses the first valid floating point number from the stream. More... | |
virtual size_t | readBytes (char *buffer, size_t length) |
Reads characters from the stream into a buffer. More... | |
virtual size_t | readBytes (uint8_t *buffer, size_t length) |
Reads characters from the stream into a buffer. More... | |
size_t | readBytesUntil (char terminator, char *buffer, size_t length) |
Reads characters from the stream into a buffer. More... | |
size_t | readBytesUntil (char terminator, uint8_t *buffer, size_t length) |
Reads characters from the stream into a buffer. More... | |
![]() | |
Print () | |
Constructor. More... | |
int | getWriteError () |
Gets write error. More... | |
void | clearWriteError () |
Clears write error. More... | |
virtual size_t | write (uint8_t byte)=0 |
Writes one unsigned byte (character). More... | |
size_t | write (const char *str) |
Writes character array (string). More... | |
virtual size_t | write (const uint8_t *buffer, size_t size) |
Writes byte array (string). More... | |
size_t | write (const char *buffer, size_t size) |
Writes character array (string). More... | |
__INTEGER_ONLY__ (T, size_t) inline write(T val) | |
Converts integer type variable to unsigned byte and writes it. More... | |
virtual int | availableForWrite () |
Gets how many bytes can be written, meaning "a single write may block". More... | |
size_t | printf (const char *format,...) __attribute__((format(printf |
Prints formatted data. More... | |
size_t size_t | print (const String &s) |
Prints string. More... | |
size_t | print (const char str[]) |
Prints character array (string). More... | |
size_t | print (char c) |
Prints one character. More... | |
__SIGNED_INTEGER_ONLY__ (T, size_t) print(T n | |
Converts integer number to character array and prints it. More... | |
size_t | println (const String &s) |
Prints string followed by carriage return and new line. More... | |
size_t | println (const char[]) |
Prints character array (string) followed by carriage return and new line. More... | |
size_t | println (char) |
Prints one character followed by carriage return and new line. More... | |
__INTEGER_ONLY__ (T, size_t) inline println(T n | |
Converts integer number to character array followed by carriage return and new line and prints it. More... | |
size_t | println (void) |
Prints carriage return and new line. More... | |
template<class T > | |
Print & | operator<< (T value) |
This operator (<<) applied to an output stream is known as insertion operator, it can be used same as cout<< operator. More... | |
Protected Member Functions | |
int | timedRead () |
Private method to read stream with timeout. More... | |
int | timedPeek () |
Private method to peek stream with timeout. More... | |
int | peekNextDigit () |
Gets the next numeric digit in the stream or -1 if timeout. More... | |
long | parseInt (char skipChar) |
Parses the first valid (long) integer number from the stream. More... | |
__INTEGER_ONLY__ (T, T) parseNum(char skipChar) | |
Parses the first valid integer number from the stream. More... | |
float | parseFloat (char skipChar) |
Parses the first valid floating point number from the stream. More... | |
__FLOATING_ONLY__ (T, T) parseNum(char skipChar) | |
Parses the first valid floating point number from the stream. More... | |
virtual size_t | widthCheck (size_t width_) |
Checks if the correct width in width() method was set. More... | |
![]() | |
void | setWriteError (int err=1) |
Sets write error. More... | |
Protected Attributes | |
unsigned long | _timeout = 1000 |
Number of milliseconds to wait for the next char before aborting timed read. More... | |
unsigned long | _startMillis |
Used for timeout measurement. More... | |
size_t | _width = INT32_MAX |
Maximum operator >> read width. More... | |
Additional Inherited Members | |
![]() | |
int | base |
|
inline |
Constructor.
|
protected |
Private method to read stream with timeout.
|
protected |
Private method to peek stream with timeout.
|
protected |
Gets the next numeric digit in the stream or -1 if timeout.
|
pure virtual |
Checks how many bytes are available in receiving buffer.
Implemented in HardwareSerial, and HardwareI2C.
|
pure virtual |
Reads one byte from receiving buffer and removes it from buffer.
Implemented in HardwareSerial, and HardwareI2C.
|
pure virtual |
Reads one byte from receiving buffer and without removing it from buffer.
Implemented in HardwareSerial, and HardwareI2C.
Stream & Stream::operator>> | ( | char & | c | ) |
This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator.
c | Reads one character to this variable. |
Stream & Stream::operator>> | ( | char * | buffer | ) |
This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator.
buffer | Reads characters from stream to this buffer. |
Stream & Stream::operator>> | ( | uint8_t * | buffer | ) |
This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator.
buffer | Reads characters from stream to this buffer. |
|
inline |
This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator.
val | Read value is written to this variable. |
|
inline |
This operator (>>) applied to an input stream is known as extraction operator, it can be used same as cin>> operator.
val | Read value is written to this variable. |
void Stream::setTimeout | ( | unsigned long | timeout | ) |
Sets the maximum milliseconds to wait for data transmitting or receiving.
It defaults to 1000 milliseconds.
timeout | Timeout in milliseconds. |
|
virtual |
Sets receiving width, that is applied when using operators >> (same as cin.width() method).
width_ | Data width, that can be received at one time with >> operator to char array. |
bool Stream::find | ( | const char * | target | ) |
Reads and removes data from the stream until the target string is found.
target | Target string. |
|
inline |
Reads and removes data from the stream until the target string is found.
target | Target string. |
bool Stream::find | ( | const char * | target, |
size_t | length | ||
) |
Reads and removes data from the stream until the target string is found.
target | Target string. |
length | Length of the target string. |
|
inline |
Reads and removes data from the stream until the target string is found.
target | Target string. |
length | Length of the target string. |
|
inline |
Reads and removes data from the stream until the target character is found.
target | Target character. |
bool Stream::findUntil | ( | const char * | target, |
const char * | terminator | ||
) |
Reads data from the stream until a target string or terminator string is found.
target | The string to search for. |
terminator | The terminal string in the search. |
|
inline |
Reads data from the stream until a target string or terminator string is found.
target | The string to search for. |
terminator | The terminal string in the search. |
bool Stream::findUntil | ( | const char * | target, |
size_t | targetLen, | ||
const char * | terminate, | ||
size_t | termLen | ||
) |
Reads data from the stream until a target string or terminator string is found.
target | The string to search for. |
targetLen | Length of the target string. |
terminator | The terminal string in the search. |
targetLen | Length of the terminator string. |
|
inline |
Reads data from the stream until a target string or terminator string is found.
target | The string to search for. |
targetLen | Length of the target string. |
terminator | The terminal string in the search. |
targetLen | Length of the terminator string. |
|
inline |
Parses the first valid (long) integer number from the stream.
Characters that are not integers (or the minus sign) are skipped. Parsing stops when no characters have been read for a configurable time-out value, or a non-digit is read. If no valid digits were read when the time-out occurs (see setTimeout()), 0 is returned.
|
inline |
Parses the first valid integer number from the stream.
Characters that are not integers (or the minus sign) are skipped. Parsing stops when no characters have been read for a configurable time-out value, or a non-digit is read. If no valid digits were read when the time-out occurs (see setTimeout()), 0 is returned.
|
inline |
Parses the first valid floating point number from the stream.
Characters that are not digits (or the minus sign or the decimal point) are skipped. Parsing stops when no characters have been read for a configurable time-out value, or a non-digit is read. If no valid digits were read when the time-out occurs (see setTimeout()), 0 is returned.
|
inline |
Parses the first valid floating point number from the stream.
Characters that are not digits (or the minus sign or the decimal point) are skipped. Parsing stops when no characters have been read for a configurable time-out value, or a non-digit is read. If no valid digits were read when the time-out occurs (see setTimeout()), 0 is returned.
|
virtual |
Reads characters from the stream into a buffer.
The function terminates if the determined length has been read, or it times out (see setTimeout()).
buffer | Buffer, where to read data. |
length | Length of the data, you want to read. |
Reimplemented in HardwareSerial.
|
inlinevirtual |
Reads characters from the stream into a buffer.
The function terminates if the determined length has been read, or it times out (see setTimeout()).
buffer | Buffer, where to read data. |
length | Length of the data, you want to read. |
Reimplemented in HardwareSerial.
size_t Stream::readBytesUntil | ( | char | terminator, |
char * | buffer, | ||
size_t | length | ||
) |
Reads characters from the stream into a buffer.
The function terminates (checks being done in this order) if the determined length has been read, if it times out (see setTimeout()), or if the terminator character is detected (in which case the function returns the characters up to the last character before the supplied terminator).
terminator | Terminator character. |
buffer | Buffer, where to read data. |
length | Length of the data, you want to read. |
|
inline |
Reads characters from the stream into a buffer.
The function terminates (checks being done in this order) if the determined length has been read, if it times out (see setTimeout()), or if the terminator character is detected (in which case the function returns the characters up to the last character before the supplied terminator).
terminator | Terminator character. |
buffer | Buffer, where to read data. |
length | Length of the data, you want to read. |
|
inlineprotected |
Parses the first valid (long) integer number from the stream.
Characters that are not integers (or the minus sign) are skipped. Parsing stops when no characters have been read for a configurable time-out value, or a non-digit is read. If no valid digits were read when the time-out occurs (see setTimeout()), 0 is returned.
skipChar | Character, that will be ignored. |
|
inlineprotected |
Parses the first valid integer number from the stream.
Characters that are not integers (or the minus sign) are skipped. Parsing stops when no characters have been read for a configurable time-out value, or a non-digit is read. If no valid digits were read when the time-out occurs (see setTimeout()), 0 is returned.
skipChar | Character, that will be ignored. |
|
inlineprotected |
Parses the first valid floating point number from the stream.
Characters that are not digits (or the minus sign or the decimal point) are skipped. Parsing stops when no characters have been read for a configurable time-out value, or a non-digit is read. If no valid digits were read when the time-out occurs (see setTimeout()), 0 is returned.
skipChar | Character, that will be ignored. |
|
inlineprotected |
Parses the first valid floating point number from the stream.
Characters that are not digits (or the minus sign or the decimal point) are skipped. Parsing stops when no characters have been read for a configurable time-out value, or a non-digit is read. If no valid digits were read when the time-out occurs (see setTimeout()), 0 is returned.
skipChar | Character, that will be ignored. |
|
protectedvirtual |
Checks if the correct width in width() method was set.
width_ | Width value to check. |
Reimplemented in HardwareSerial.
|
protected |
Number of milliseconds to wait for the next char before aborting timed read.
|
protected |
Used for timeout measurement.
|
protected |
Maximum operator >> read width.