AceRoutine
0.1
A low-memory, fast-switching, cooperative multitasking library using stackless coroutines on Arduino platforms.
|
Reads tokens (lines, words, integers, characters, etc) from the Stream device. More...
#include <StreamReader.h>
Public Member Functions | |
StreamReader (Stream &serial, char *buf, int bufSize) | |
Constructor. More... | |
bool | getChar (char *c) |
Get a character from serial port. More... | |
bool | getWordString (bool *isError, char **word) |
Get a string bounded by whitespace, i.e. More... | |
bool | getInteger (bool *isError, int *value) |
Get an integer. More... | |
bool | getComma (bool *isError) |
Parse a comma. More... | |
bool | skipWhiteSpace () |
Skip whitespace. More... | |
bool | getLine (bool *isError, char **line) |
Get a line. More... | |
Reads tokens (lines, words, integers, characters, etc) from the Stream device.
The Stream will normally be the global Serial object. These are non-blocking helper functions designed to be used inside COROUTINE() macros from the AceRoutine library.
Definition at line 39 of file StreamReader.h.
|
inline |
Constructor.
serial | The input stream, usually the global Serial object. |
buffer | The input character buffer. |
bufferSize | The size of the buffer, should be set large enough to hold the longest line without triggering buffer overflow. |
Definition at line 49 of file StreamReader.h.
bool ace_routine::cli::StreamReader::getChar | ( | char * | c | ) |
Get a character from serial port.
Return true if parsing is finished, otherwise false indicates that this method should be called again for further processing.
Definition at line 31 of file StreamReader.cpp.
bool ace_routine::cli::StreamReader::getComma | ( | bool * | isError | ) |
Parse a comma.
Return true if parsing is finished, otherwise false indicates that this method should be called again for further processing.
If isError is true, then a parsing error ocurred.
Definition at line 91 of file StreamReader.cpp.
bool ace_routine::cli::StreamReader::getInteger | ( | bool * | isError, |
int * | value | ||
) |
Get an integer.
Return true if parsing is finished, otherwise false indicates that this method should be called again for further processing.
If isError is true, then a parsing error occurred. If is false, then value contains the integer.
Definition at line 66 of file StreamReader.cpp.
bool ace_routine::cli::StreamReader::getLine | ( | bool * | isError, |
char ** | line | ||
) |
Get a line.
Returns true if parsing is finished required, otherwise false indicates that this method should be called again for further processing.
If a full line was read, then this returns true, isError=false, and line=line If the buffer overflowed, then this returns true, isError=true, and line is the partial buffer of the long line.
Definition at line 109 of file StreamReader.cpp.
bool ace_routine::cli::StreamReader::getWordString | ( | bool * | isError, |
char ** | word | ||
) |
Get a string bounded by whitespace, i.e.
a "word". Return true if parsing is finished, otherwise false indicates that this method should be called again for further processing.
If isError is true, then a parsing error occurred. If is false, then word contains the pointer to the word string
Definition at line 43 of file StreamReader.cpp.
bool ace_routine::cli::StreamReader::skipWhiteSpace | ( | ) |
Skip whitespace.
Return true if parsing is finished, otherwise false indicates that this method should be called again for further processing.
Definition at line 98 of file StreamReader.cpp.