Need to read negative bytes

This commit is contained in:
Sara Damiano
2019-05-24 16:49:05 -04:00
parent 3fee997934
commit 9e3e67473a

View File

@@ -768,8 +768,6 @@ protected:
// ^^ Confirmed number of data bytes to be read, which may be less than requested. // ^^ Confirmed number of data bytes to be read, which may be less than requested.
// 0 indicates that no data can be read. // 0 indicates that no data can be read.
// This is actually be the number of bytes that will be remaining after the read // This is actually be the number of bytes that will be remaining after the read
size_t len_read = 0;
// Attempt to read the full amount we requested, even if that quantity was not confirmed
for (size_t i=0; i<len_requested; i++) { for (size_t i=0; i<len_requested; i++) {
uint32_t startMillis = millis(); uint32_t startMillis = millis();
#ifdef TINY_GSM_USE_HEX #ifdef TINY_GSM_USE_HEX
@@ -782,16 +780,13 @@ protected:
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); } while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read(); char c = stream.read();
#endif #endif
if (c > 0) { sockets[mux]->rx.put(c);
sockets[mux]->rx.put(c);
len_read++;
}
} }
DBG("### READ:", len_read, "from", mux); DBG("### READ:", len_requested, "from", mux);
// sockets[mux]->sock_available = modemGetAvailable(mux); // sockets[mux]->sock_available = modemGetAvailable(mux);
sockets[mux]->sock_available = len_confirmed; sockets[mux]->sock_available = len_confirmed;
waitResponse(); waitResponse();
return len_read; return len_requested;
} }
size_t modemGetAvailable(uint8_t mux) { size_t modemGetAvailable(uint8_t mux) {