Skip to content

Commit 0879db5

Browse files
committed
Changed time.time to time.monotonic
1 parent 7147de8 commit 0879db5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

adafruit_bno055.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,8 @@ def _write_register(self, register, data): # pylint: disable=arguments-differ
392392
if not isinstance(data, bytes):
393393
data = bytes([data])
394394
self._uart.write(bytes([0xAA, 0x00, register, len(data)]) + data)
395-
now = time.time()
396-
while self._uart.in_waiting < 2 and time.time() - now < 0.25:
395+
now = time.monotonic()
396+
while self._uart.in_waiting < 2 and time.monotonic() - now < 0.25:
397397
pass
398398
resp = self._uart.read(self._uart.in_waiting)
399399
if len(resp) < 2:
@@ -403,15 +403,15 @@ def _write_register(self, register, data): # pylint: disable=arguments-differ
403403

404404
def _read_register(self, register, length=1): # pylint: disable=arguments-differ
405405
self._uart.write(bytes([0xAA, 0x01, register, length]))
406-
now = time.time()
407-
while self._uart.in_waiting < length + 2 and time.time() - now < 0.25:
406+
now = time.monotonic()
407+
while self._uart.in_waiting < length + 2 and time.monotonic() - now < 0.25:
408408
pass
409409
resp = self._uart.read(self._uart.in_waiting)
410410

411411
if resp[0] != 0xBB: # Recursion
412412
self._uart.write(bytes([0xAA, 0x01, register, length]))
413-
now = time.time()
414-
while self._uart.in_waiting < length + 2 and time.time() - now < 0.25:
413+
now = time.monotonic()
414+
while self._uart.in_waiting < length + 2 and time.monotonic() - now < 0.25:
415415
pass
416416
resp = self._uart.read(self._uart.in_waiting)
417417
if len(resp) < 2:

0 commit comments

Comments
 (0)