@@ -1393,17 +1393,12 @@ void IridiumSBD::check9603data()
1393
1393
wireport->beginTransmission ((uint8_t )deviceaddress); // Talk to the I2C device
1394
1394
wireport->write (LEN_REG); // Point to the serial buffer length
1395
1395
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
1398
1397
{
1399
1398
uint8_t msb = wireport->read ();
1400
1399
uint8_t lsb = wireport->read ();
1401
1400
bytesAvailable = (((uint16_t )msb) << 8 ) | lsb;
1402
1401
}
1403
- while (wireport->available ())
1404
- {
1405
- wireport->read (); // Mop up any unexpected bytes
1406
- }
1407
1402
1408
1403
// Now read the serial bytes (if any)
1409
1404
if (bytesAvailable > 0 )
@@ -1441,15 +1436,10 @@ void IridiumSBD::check9603pins()
1441
1436
wireport->beginTransmission ((uint8_t )deviceaddress); // Talk to the I2C device
1442
1437
wireport->write (IO_REG); // Point to the 'IO register'
1443
1438
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
1446
1440
{
1447
1441
IO_REGISTER = wireport->read (); // Read the IO register
1448
1442
}
1449
- while (wireport->available ())
1450
- {
1451
- wireport->read (); // Mop up any unexpected bytes (hopefully redundant!?)
1452
- }
1453
1443
}
1454
1444
1455
1445
// Set the IO pins
@@ -1476,17 +1466,12 @@ int IridiumSBD::internalPassThruI2Cread(uint8_t *rxBuffer, size_t &rxBufferSize,
1476
1466
wireport->beginTransmission ((uint8_t )deviceaddress); // Talk to the I2C device
1477
1467
wireport->write (LEN_REG); // Point to the serial buffer length
1478
1468
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
1481
1470
{
1482
1471
uint8_t msb = wireport->read ();
1483
1472
uint8_t lsb = wireport->read ();
1484
1473
bytesAvailable = (((uint16_t )msb) << 8 ) | lsb;
1485
1474
}
1486
- while (wireport->available ())
1487
- {
1488
- wireport->read (); // Mop up any unexpected bytes
1489
- }
1490
1475
1491
1476
numBytes = (size_t )bytesAvailable; // Store bytesAvailable in numBytes
1492
1477
0 commit comments