40#ifndef SERIAL_INPUT_EOL
41#define SERIAL_INPUT_EOL '\n'
118 { mTimeOut = milliseconds; }
128 bool find(
const char *target )
141 bool find(
const char *target,
size_t length )
142 {
return findUntil( target, length, NULL, 0 ); }
157 bool findUntil(
const char *target,
const char *terminator );
174 bool findUntil(
const char *target,
size_t targetLen,
const char *terminate,
size_t termLen );
217 bool readLong(
long* result,
char skipChar );
234 bool readFloat(
float* result,
char skipChar );
247 size_t readBytes(
char *buffer,
size_t length );
262 size_t readBytesUntil(
char terminator,
char* buffer,
size_t length );
276 {
return readBytes(
reinterpret_cast<char*
>(buffer), length ); }
293 {
return readBytesUntil(
static_cast<char>(terminator),
reinterpret_cast<char*
>(buffer), length ); }
307 size_t readLine(
char *buffer,
size_t length );
320 unsigned long mTimeOut;
This is an abstract class defining a generic interface to read numbers and strings from a sequential ...
Definition Reader.h:66
bool findUntil(const char *target, const char *terminator)
Read data from the stream until the target string is found, or the terminator string is found,...
Definition Reader.cpp:156
size_t readBytes(char *buffer, size_t length)
Read characters from the input stream into a buffer, terminating if length characters have been read ...
Definition Reader.cpp:371
bool readLong(long *result)
Return the first valid long integer value from the stream.
Definition Reader.cpp:212
size_t readBytes(uint8_t *buffer, size_t length)
Read bytes (uint8_t) from the input stream into a buffer, terminating if length bytes have been read ...
Definition Reader.h:275
size_t readBytesUntil(char terminator, char *buffer, size_t length)
Read characters from the input stream into a buffer, terminating when the terminator charactor is enc...
Definition Reader.cpp:398
void consumeWhiteSpace()
Consumes whitespace characters until the first non-whitespace character is encountered or the functio...
Definition Reader.cpp:449
bool find(const char *target, size_t length)
Read data from the stream until the target string of given length is found.
Definition Reader.h:141
size_t readBytesUntil(uint8_t terminator, uint8_t *buffer, size_t length)
Read bytes (uint8_t) from the input stream into a buffer, terminating when the terminator byte is enc...
Definition Reader.h:292
size_t readLine(char *buffer, size_t length)
Read characters from the input stream into a buffer, until it reaches EOL, or if length characters ha...
Definition Reader.cpp:424
bool find(const char *target)
Read data from the input stream until the target string is found.
Definition Reader.h:128
virtual int peek()=0
Pure virtual function that examines the next byte from the input stream, without removing it.
virtual int read()=0
Pure virtual function that reads and removes the next byte from the input stream.
void setTimeout(unsigned long milliseconds)
Sets maximum milliseconds to wait for stream data, default is 1 second.
Definition Reader.h:117
virtual bool available()=0
Pure virtual function that determines if data is available in the input stream.
Reader()
Constructor. It sets the default timeout to 1 second.
Definition Reader.cpp:70
bool readFloat(float *result)
Return the first valid float value from the stream.
Definition Reader.cpp:280