File tree Expand file tree Collapse file tree 2 files changed +3
-10
lines changed Expand file tree Collapse file tree 2 files changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,6 @@ bool SHTSensorDriver::readSample()
5353
5454const uint8_t SHTI2cSensor::CMD_SIZE = 2 ;
5555const uint8_t SHTI2cSensor::EXPECTED_DATA_SIZE = 6 ;
56- const uint8_t SHTI2cSensor::MAX_I2C_READ_TRIES = 5 ;
5756
5857bool SHTI2cSensor::readFromI2c (uint8_t i2cAddress,
5958 const uint8_t *i2cCommand,
@@ -73,14 +72,9 @@ bool SHTI2cSensor::readFromI2c(uint8_t i2cAddress,
7372
7473 Wire.requestFrom (i2cAddress, dataLength);
7574
76- // there should be no reason for this to not be ready, since we're using clock
77- // stretching mode, but just in case we'll try a few times
78- uint8_t tries = 1 ;
79- while (Wire.available () < dataLength) {
80- delay (1 );
81- if (tries++ >= MAX_I2C_READ_TRIES) {
82- return false ;
83- }
75+ // check if the same number of bytes are received that are requested.
76+ if (Wire.available () != dataLength) {
77+ return false ;
8478 }
8579
8680 for (int i = 0 ; i < dataLength; ++i) {
Original file line number Diff line number Diff line change @@ -226,7 +226,6 @@ class SHTI2cSensor : public SHTSensorDriver {
226226 float mY ;
227227
228228private:
229- static const uint8_t MAX_I2C_READ_TRIES;
230229 static uint8_t crc8 (const uint8_t *data, uint8_t len);
231230 static bool readFromI2c (uint8_t i2cAddress,
232231 const uint8_t *i2cCommand,
You can’t perform that action at this time.
0 commit comments