Update PPPOSClient.cpp

This commit is contained in:
levkovigor 2021-08-24 10:48:24 +03:00 committed by GitHub
parent d9dc2ef35d
commit 51578c6ac2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -233,18 +233,21 @@ uint8_t PPPOSClient::connected() {
int PPPOSClient::read(uint8_t *buf, size_t size) { int PPPOSClient::read(uint8_t *buf, size_t size) {
if (!_connected) return -1; if (!_connected) return -1;
int res = -1; int res = -1;
if (available()){
int j = 0; int j = 0;
if (available()){
for (int i = _startPos; i < _endPos; i++) { for (int i = _startPos; i < _endPos; i++) {
if (j < size) { if (j < size) {
buf[j] = RxBuffer[i]; buf[j] = RxBuffer[i];
} else { } else {
res = j; break;
_startPos += j;
} }
j++; j++;
} }
} }
if (j > 0) {
_startPos += j;
res = j;
}
return res; return res;
} }