@@ -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;
@@ -3239,7 +3239,7 @@ SARA_R5_error_t SARA_R5::waitForResponse(const char *expectedResponse, const cha
3239
3239
3240
3240
while ((!found) && ((timeIn + timeout) > millis ()))
3241
3241
{
3242
- if (hwAvailable ())
3242
+ if (hwAvailable () > 0 ) // hwAvailable can return -1 if the serial port is NULL
3243
3243
{
3244
3244
char c = readChar ();
3245
3245
if (_printDebug == true ) _debugPort->print ((String)c);
@@ -3305,7 +3305,7 @@ SARA_R5_error_t SARA_R5::sendCommandWithResponse(
3305
3305
3306
3306
while ((!found) && ((timeIn + commandTimeout) > millis ()))
3307
3307
{
3308
- if (hwAvailable ())
3308
+ if (hwAvailable () > 0 ) // hwAvailable can return -1 if the serial port is NULL
3309
3309
{
3310
3310
char c = readChar ();
3311
3311
if (_printDebug == true ) _debugPort->print ((String)c);
@@ -3352,11 +3352,11 @@ int SARA_R5::sendCommand(const char *command, boolean at)
3352
3352
int backlogIndex = strlen (saraResponseBacklog);
3353
3353
3354
3354
unsigned long timeIn = micros ();
3355
- if (hwAvailable ())
3355
+ if (hwAvailable () > 0 ) // hwAvailable can return -1 if the serial port is NULL
3356
3356
{
3357
3357
while (micros ()-timeIn < rxWindowUS && backlogIndex < RXBuffSize) // May need to escape on newline?
3358
3358
{
3359
- if (hwAvailable ())
3359
+ if (hwAvailable () > 0 ) // hwAvailable can return -1 if the serial port is NULL
3360
3360
{
3361
3361
char c = readChar ();
3362
3362
saraResponseBacklog[backlogIndex++] = c;
@@ -3535,7 +3535,7 @@ int SARA_R5::readAvailable(char *inString)
3535
3535
if (_printDebug == true ) _debugPort->println (inString);
3536
3536
}
3537
3537
#ifdef SARA_R5_SOFTWARE_SERIAL_ENABLED
3538
- if (_softSerial != NULL )
3538
+ else if (_softSerial != NULL )
3539
3539
{
3540
3540
while (_softSerial->available ())
3541
3541
{
0 commit comments