@@ -1393,17 +1393,12 @@ void IridiumSBD::check9603data()
13931393 wireport->beginTransmission ((uint8_t )deviceaddress); // Talk to the I2C device
13941394 wireport->write (LEN_REG); // Point to the serial buffer length
13951395 wireport->endTransmission (); // Send data and release the bus (the 841 (WireS) doesn't like it if the Master holds the bus!)
1396- wireport->requestFrom ((uint8_t )deviceaddress, 2 ); // Request two bytes
1397- if (wireport->available () >= 2 )
1396+ if (wireport->requestFrom ((uint8_t )deviceaddress, 2 ) == 2 ) // Request two bytes
13981397 {
13991398 uint8_t msb = wireport->read ();
14001399 uint8_t lsb = wireport->read ();
14011400 bytesAvailable = (((uint16_t )msb) << 8 ) | lsb;
14021401 }
1403- while (wireport->available ())
1404- {
1405- wireport->read (); // Mop up any unexpected bytes
1406- }
14071402
14081403 // Now read the serial bytes (if any)
14091404 if (bytesAvailable > 0 )
@@ -1441,15 +1436,10 @@ void IridiumSBD::check9603pins()
14411436 wireport->beginTransmission ((uint8_t )deviceaddress); // Talk to the I2C device
14421437 wireport->write (IO_REG); // Point to the 'IO register'
14431438 wireport->endTransmission (); // Send data and release the bus (the 841 (WireS) doesn't like it if the Master holds the bus!)
1444- wireport->requestFrom ((uint8_t )deviceaddress, 1 ); // Request one byte from the IO register
1445- if (wireport->available ())
1439+ if (wireport->requestFrom ((uint8_t )deviceaddress, 1 ) == 1 ) // Request one byte from the IO register
14461440 {
14471441 IO_REGISTER = wireport->read (); // Read the IO register
14481442 }
1449- while (wireport->available ())
1450- {
1451- wireport->read (); // Mop up any unexpected bytes (hopefully redundant!?)
1452- }
14531443}
14541444
14551445// Set the IO pins
@@ -1476,17 +1466,12 @@ int IridiumSBD::internalPassThruI2Cread(uint8_t *rxBuffer, size_t &rxBufferSize,
14761466 wireport->beginTransmission ((uint8_t )deviceaddress); // Talk to the I2C device
14771467 wireport->write (LEN_REG); // Point to the serial buffer length
14781468 wireport->endTransmission (); // Send data and release the bus (the 841 (WireS) doesn't like it if the Master holds the bus!)
1479- wireport->requestFrom ((uint8_t )deviceaddress, 2 ); // Request two bytes
1480- if (wireport->available () >= 2 )
1469+ if (wireport->requestFrom ((uint8_t )deviceaddress, 2 ) == 2 ) // Request two bytes
14811470 {
14821471 uint8_t msb = wireport->read ();
14831472 uint8_t lsb = wireport->read ();
14841473 bytesAvailable = (((uint16_t )msb) << 8 ) | lsb;
14851474 }
1486- while (wireport->available ())
1487- {
1488- wireport->read (); // Mop up any unexpected bytes
1489- }
14901475
14911476 numBytes = (size_t )bytesAvailable; // Store bytesAvailable in numBytes
14921477
0 commit comments