uTerminal is a simple AT-command style terminal processor, simplifying the work to send and parse COMMAND=value pairs to a microcontroller.
Revision 3:39fb12e8a2a3, committed 2019-02-21
- Comitter:
- fbcosentino
- Date:
- Thu Feb 21 14:51:43 2019 +0000
- Parent:
- 2:8029cce18e1a
- Commit message:
- bug fixes
Changed in this revision
uTerminal.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/uTerminal.cpp Mon Feb 18 19:42:41 2019 +0000 +++ b/uTerminal.cpp Thu Feb 21 14:51:43 2019 +0000 @@ -70,16 +70,15 @@ if (cursor > 0) { // Ok, we indeed have a command. has_command = 1; // 1-> Successful command (return). 2->Buffer full - buffer_len = cursor; // Does not count return itself. - _buffer[cursor] = 0x00; // make a null-terminated safe string + _buffer[cursor++] = 0x00; // make a null-terminated safe string + buffer_len = cursor; // Includes terminating null cursor = 0; transfer_buffers(); // prepare the Command and Value buffers } } else { has_command = 0; // If had unread command in buffer, cancel it. Sorry, you lost it. - _buffer[cursor] = val; - cursor++; + _buffer[cursor++] = val; if (cursor >= UTERMINAL_BUF_SIZE) { // Even if it's not a return, we must not continue since buffer is full // Consider input done, but with result=2 instead of 1, to tell it's buffer size @@ -111,8 +110,7 @@ Command[j++] = c; } } - if (i >= buffer_len) Command[j] = 0; // null-terminated safe, - // since buffer_len does not include \n + if (i >= buffer_len) Command[j] = 0; // null-terminated safe // transfer param buffer if (c == '=') { // if we have parameters @@ -124,7 +122,7 @@ if (c == ',') NumParams++; if (c == 0) break; } - params_len = j; // This length includes terminating null! + params_len = j; // length includes terminating null } else { Value[0] = 0; // empty string