From 51578c6ac29b9fa768a081e955f5c41d64fd61ad Mon Sep 17 00:00:00 2001 From: levkovigor Date: Tue, 24 Aug 2021 10:48:24 +0300 Subject: [PATCH] Update PPPOSClient.cpp --- src/PPPOSClient.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 +}