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) {
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];
}
}