@@ -98,11 +98,11 @@ boolean SARA_R5::bufferedPoll(void)
98
98
memset (saraResponseBacklog, 0 , RXBuffSize);
99
99
}
100
100
101
- if (hwAvailable () || backlogLen > 0 ) // If either new data is available, or backlog had data.
101
+ if (hwAvailable () > 0 || backlogLen > 0 ) // If either new data is available, or backlog had data.
102
102
{
103
103
while (micros () - timeIn < rxWindowUS && avail < RXBuffSize)
104
104
{
105
- if (hwAvailable ())
105
+ if (hwAvailable () > 0 ) // hwAvailable can return -1 if the serial port is NULL
106
106
{
107
107
c = readChar ();
108
108
saraRXBuffer[avail++] = c;
@@ -198,11 +198,11 @@ boolean SARA_R5::poll(void)
198
198
199
199
memset (saraRXBuffer, 0 , RXBuffSize);
200
200
201
- if (hwAvailable ())
201
+ if (hwAvailable () > 0 ) // hwAvailable can return -1 if the serial port is NULL
202
202
{
203
203
while (c != ' \n ' )
204
204
{
205
- if (hwAvailable ())
205
+ if (hwAvailable () > 0 ) // hwAvailable can return -1 if the serial port is NULL
206
206
{
207
207
c = readChar ();
208
208
saraRXBuffer[avail++] = c;
@@ -3226,7 +3226,7 @@ SARA_R5_error_t SARA_R5::waitForResponse(const char *expectedResponse, const cha
3226
3226
3227
3227
while ((!found) && ((timeIn + timeout) > millis ()))
3228
3228
{
3229
- if (hwAvailable ())
3229
+ if (hwAvailable () > 0 ) // hwAvailable can return -1 if the serial port is NULL
3230
3230
{
3231
3231
char c = readChar ();
3232
3232
if (_printDebug == true ) _debugPort->print ((String)c);
@@ -3292,7 +3292,7 @@ SARA_R5_error_t SARA_R5::sendCommandWithResponse(
3292
3292
3293
3293
while ((!found) && ((timeIn + commandTimeout) > millis ()))
3294
3294
{
3295
- if (hwAvailable ())
3295
+ if (hwAvailable () > 0 ) // hwAvailable can return -1 if the serial port is NULL
3296
3296
{
3297
3297
char c = readChar ();
3298
3298
if (_printDebug == true ) _debugPort->print ((String)c);
@@ -3346,11 +3346,11 @@ int SARA_R5::sendCommand(const char *command, boolean at)
3346
3346
int backlogIndex = strlen (saraResponseBacklog);
3347
3347
3348
3348
unsigned long timeIn = micros ();
3349
- if (hwAvailable ())
3349
+ if (hwAvailable () > 0 ) // hwAvailable can return -1 if the serial port is NULL
3350
3350
{
3351
3351
while (micros ()-timeIn < rxWindowUS && backlogIndex < RXBuffSize) // May need to escape on newline?
3352
3352
{
3353
- if (hwAvailable ())
3353
+ if (hwAvailable () > 0 ) // hwAvailable can return -1 if the serial port is NULL
3354
3354
{
3355
3355
char c = readChar ();
3356
3356
saraResponseBacklog[backlogIndex++] = c;
@@ -3529,7 +3529,7 @@ int SARA_R5::readAvailable(char *inString)
3529
3529
if (_printDebug == true ) _debugPort->println (inString);
3530
3530
}
3531
3531
#ifdef SARA_R5_SOFTWARE_SERIAL_ENABLED
3532
- if (_softSerial != NULL )
3532
+ else if (_softSerial != NULL )
3533
3533
{
3534
3534
while (_softSerial->available ())
3535
3535
{
0 commit comments