Browse Source

Need to read negative bytes

v_master
Sara Damiano 5 years ago
parent
commit
9e3e67473a
1 changed files with 3 additions and 8 deletions
  1. +3
    -8
      src/TinyGsmClientSIM800.h

+ 3
- 8
src/TinyGsmClientSIM800.h 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);
len_read++;
}
sockets[mux]->rx.put(c);
} }
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) {


Loading…
Cancel
Save