vvvv
Revision 14:69c3e57ef0f5, committed 2013-11-19
- Comitter:
- mazgch
- Date:
- Tue Nov 19 09:02:35 2013 +0000
- Parent:
- 13:e2446fcdc246
- Child:
- 15:5eda64e5b9d1
- Commit message:
- have a static getline function
Changed in this revision
SerialPipe.cpp | Show annotated file Show diff for this revision Revisions of this file |
SerialPipe.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/SerialPipe.cpp Tue Nov 19 08:34:51 2013 +0000 +++ b/SerialPipe.cpp Tue Nov 19 09:02:35 2013 +0000 @@ -104,16 +104,21 @@ int SerialPipeEx::getLine(char* buffer, int length) { + return getLine(buffer, length, &_pipeRx); +} + +int SerialPipeEx::getLine(char* buffer, int length, Pipe<char>* pipe) +{ int o = 0; int i = 0; - int l = _pipeRx.start(); + int l = pipe->start(); while ((i < l) && (o < length)) { - int t = _pipeRx.next(); + int t = pipe->next(); i ++; if (t == '\r') // terminate commands with carriage return { - _pipeRx.done(); + pipe->done(); if (length > o) buffer[o] = '\0'; return o; // if enter send the zero char
--- a/SerialPipe.h Tue Nov 19 08:34:51 2013 +0000 +++ b/SerialPipe.h Tue Nov 19 09:02:35 2013 +0000 @@ -35,4 +35,5 @@ public: SerialPipeEx(PinName tx, PinName rx, int rxSize = 128, int txSize = 128, const char* name = NULL); int getLine(char* buffer, int length); + static int getLine(char* buffer, int length, Pipe<char>* pipe); };