diff --git a/ATParser.cpp b/ATParser.cpp index f3e3d6d..42a2521 100644 --- a/ATParser.cpp +++ b/ATParser.cpp @@ -67,10 +67,10 @@ int ATParser::write(const char *data, int size) int i = 0; for ( ; i < size; i++) { if (putc(data[i]) < 0) { - return -1; + break; } } - return i; + return (i == 0) ? -1 : i; } int ATParser::read(char *data, int size) @@ -79,11 +79,12 @@ int ATParser::read(char *data, int size) for ( ; i < size; i++) { int c = getc(); if (c < 0) { - return -1; + break; + } else { + data[i] = c; } - data[i] = c; } - return i; + return (i == 0) ? -1 : i; } diff --git a/ATParser.h b/ATParser.h index 2780390..0afa288 100644 --- a/ATParser.h +++ b/ATParser.h @@ -93,7 +93,7 @@ class ATParser /** * Allows timeout to be changed between commands * - * @param timeout timeout of the connection + * @param timeout timeout of the connection in ms */ void setTimeout(int timeout) { _timeout = timeout;