Browse Source

Ensure that ALL variants of read respect timeout

v_master
Sara Damiano 5 years ago
parent
commit
7f7a7563cf
12 changed files with 27 additions and 17 deletions
  1. +2
    -1
      src/TinyGsmClientA6.h
  2. +2
    -1
      src/TinyGsmClientBG96.h
  3. +2
    -1
      src/TinyGsmClientESP8266.h
  4. +2
    -1
      src/TinyGsmClientM590.h
  5. +2
    -1
      src/TinyGsmClientM95.h
  6. +2
    -1
      src/TinyGsmClientMC60.h
  7. +4
    -3
      src/TinyGsmClientSIM7000.h
  8. +3
    -2
      src/TinyGsmClientSIM800.h
  9. +2
    -2
      src/TinyGsmClientSaraR4.h
  10. +2
    -1
      src/TinyGsmClientSequansMonarch.h
  11. +2
    -1
      src/TinyGsmClientUBLOX.h
  12. +2
    -2
      src/TinyGsmClientXBee.h

+ 2
- 1
src/TinyGsmClientA6.h View File

@ -599,7 +599,8 @@ TINY_GSP_MODEM_STREAM_UTILITIES()
DBG("### Got: ", len, "->", sockets[mux]->rx.free());
}
while (len--) {
while (!stream.available()) { TINY_GSM_YIELD(); }
startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
sockets[mux]->rx.put(stream.read());
}
if (len_orig > sockets[mux]->available()) { // TODO


+ 2
- 1
src/TinyGsmClientBG96.h View File

@ -517,7 +517,8 @@ protected:
sockets[mux]->sock_available = len;
for (size_t i=0; i<len; i++) {
while (!stream.available()) { TINY_GSM_YIELD(); }
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
sockets[mux]->rx.put(c);
}


+ 2
- 1
src/TinyGsmClientESP8266.h View File

@ -421,7 +421,8 @@ TINY_GSP_MODEM_STREAM_UTILITIES()
DBG("### Got: ", len, "->", sockets[mux]->rx.free());
}
while (len--) {
while (!stream.available()) { TINY_GSM_YIELD(); }
startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
sockets[mux]->rx.put(stream.read());
}
if (len_orig > sockets[mux]->available()) { // TODO


+ 2
- 1
src/TinyGsmClientM590.h View File

@ -520,7 +520,8 @@ TINY_GSP_MODEM_STREAM_UTILITIES()
DBG("### Got: ", len, "->", sockets[mux]->rx.free());
}
while (len--) {
while (!stream.available()) { TINY_GSM_YIELD(); }
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
sockets[mux]->rx.put(stream.read());
}
if (len_orig > sockets[mux]->available()) { // TODO


+ 2
- 1
src/TinyGsmClientM95.h View File

@ -571,7 +571,8 @@ protected:
sockets[mux]->sock_available = len;
for (size_t i=0; i<len; i++) {
while (!stream.available()) { TINY_GSM_YIELD(); }
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
sockets[mux]->rx.put(c);
}


+ 2
- 1
src/TinyGsmClientMC60.h View File

@ -591,7 +591,8 @@ protected:
sockets[mux]->sock_available = len;
for (size_t i=0; i<len; i++) {
while (!stream.available()) { TINY_GSM_YIELD(); }
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
sockets[mux]->rx.put(c);
}


+ 4
- 3
src/TinyGsmClientSIM7000.h View File

@ -9,7 +9,7 @@
#ifndef TinyGsmClientSIM7000_h
#define TinyGsmClientSIM7000_h
#define TINY_GSM_DEBUG Serial
// #define TINY_GSM_DEBUG Serial
//#define TINY_GSM_USE_HEX
#if !defined(TINY_GSM_RX_BUFFER)
@ -815,14 +815,15 @@ protected:
// 0 indicates that no data can be read.
for (size_t i=0; i<TinyGsmMin(len_confirmed, len_requested) ; i++) {
uint32_t startMillis = millis();
#ifdef TINY_GSM_USE_HEX
while (stream.available() < 2) { TINY_GSM_YIELD(); }
while (stream.available() < 2 && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char buf[4] = { 0, };
buf[0] = stream.read();
buf[1] = stream.read();
char c = strtol(buf, NULL, 16);
#else
while (!stream.available()) { TINY_GSM_YIELD(); }
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
#endif
sockets[mux]->rx.put(c);


+ 3
- 2
src/TinyGsmClientSIM800.h View File

@ -743,14 +743,15 @@ protected:
// 0 indicates that no data can be read.
for (size_t i=0; i<TinyGsmMin(len_confirmed, len_requested) ; i++) {
uint32_t startMillis = millis();
#ifdef TINY_GSM_USE_HEX
while (stream.available() < 2) { TINY_GSM_YIELD(); }
while (stream.available() < 2 && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char buf[4] = { 0, };
buf[0] = stream.read();
buf[1] = stream.read();
char c = strtol(buf, NULL, 16);
#else
while (!stream.available()) { TINY_GSM_YIELD(); }
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
#endif
sockets[mux]->rx.put(c);


+ 2
- 2
src/TinyGsmClientSaraR4.h View File

@ -566,7 +566,6 @@ protected:
sockets[mux]->sock_connected = false;
return true;
}
bool success;
// These modems allow a faster "asynchronous" close
sendAT(GF("+USOCL="), mux, GF(",1"));
return 1 == waitResponse(120000L); // but it still can take up to 120s to get a response
@ -602,7 +601,8 @@ protected:
streamSkipUntil('\"');
for (size_t i=0; i<len; i++) {
while (!stream.available()) { TINY_GSM_YIELD(); }
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
sockets[mux]->rx.put(c);
}


+ 2
- 1
src/TinyGsmClientSequansMonarch.h View File

@ -541,7 +541,8 @@ protected:
streamSkipUntil(','); // Skip mux
size_t len = stream.readStringUntil('\n').toInt();
for (size_t i=0; i<len; i++) {
while (!stream.available()) { TINY_GSM_YIELD(); }
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
sockets[mux]->rx.put(c);
}


+ 2
- 1
src/TinyGsmClientUBLOX.h View File

@ -587,7 +587,8 @@ protected:
streamSkipUntil('\"');
for (size_t i=0; i<len; i++) {
while (!stream.available()) { TINY_GSM_YIELD(); }
uint32_t startMillis = millis();
while (!stream.available() && (millis() - startMillis < sockets[mux]->_timeout)) { TINY_GSM_YIELD(); }
char c = stream.read();
sockets[mux]->rx.put(c);
}


+ 2
- 2
src/TinyGsmClientXBee.h View File

@ -103,7 +103,7 @@ public:
return sock_connected;
}
virtual int connect(const char *host, uint16_t port) {
return connect(host, port, 75000L);
return connect(host, port, 75);
}
virtual int connect(IPAddress ip, uint16_t port, int timeout_s) {
@ -113,7 +113,7 @@ public:
return sock_connected;
}
virtual int connect(IPAddress ip, uint16_t port) {
return connect(ip, port, 75000L);
return connect(ip, port, 75);
}
virtual void stop() {


Loading…
Cancel
Save