diff --git a/src/PPPOSClient.cpp b/src/PPPOSClient.cpp index 65608fb..c88caf9 100644 --- a/src/PPPOSClient.cpp +++ b/src/PPPOSClient.cpp @@ -233,18 +233,21 @@ uint8_t PPPOSClient::connected() { int PPPOSClient::read(uint8_t *buf, size_t size) { if (!_connected) return -1; int res = -1; + int j = 0; if (available()){ - int j = 0; for (int i = _startPos; i < _endPos; i++) { if (j < size) { buf[j] = RxBuffer[i]; } else { - res = j; - _startPos += j; + break; } j++; } } + if (j > 0) { + _startPos += j; + res = j; + } return res; } @@ -263,4 +266,4 @@ int PPPOSClient::peek() { } } return RxBuffer[_startPos]; -} \ No newline at end of file +}