Skip to content

Commit a04e9ed

Browse files
committed
timeout if we don't receive new data after too long
1 parent b369946 commit a04e9ed

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

adafruit_bme680.py

+3
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,13 @@ def _perform_reading(self) -> None:
385385
ctrl = (ctrl & 0xFC) | 0x01 # enable single shot!
386386
self._write(_BME680_REG_CTRL_MEAS, [ctrl])
387387
new_data = False
388+
start_time = time.monotonic()
388389
while not new_data:
389390
data = self._read(_BME680_REG_MEAS_STATUS, 17)
390391
new_data = data[0] & 0x80 != 0
391392
time.sleep(0.005)
393+
if start_time >= time.monotonic() - 3.0:
394+
raise RuntimeError("Timeout while reading sensor data")
392395
self._last_reading = time.monotonic()
393396

394397
self._adc_pres = _read24(data[2:5]) / 16

0 commit comments

Comments
 (0)