@@ -392,8 +392,8 @@ def _write_register(self, register, data): # pylint: disable=arguments-differ
392
392
if not isinstance (data , bytes ):
393
393
data = bytes ([data ])
394
394
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 :
397
397
pass
398
398
resp = self ._uart .read (self ._uart .in_waiting )
399
399
if len (resp ) < 2 :
@@ -403,15 +403,15 @@ def _write_register(self, register, data): # pylint: disable=arguments-differ
403
403
404
404
def _read_register (self , register , length = 1 ): # pylint: disable=arguments-differ
405
405
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 :
408
408
pass
409
409
resp = self ._uart .read (self ._uart .in_waiting )
410
410
411
411
if resp [0 ] != 0xBB : # Recursion
412
412
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 :
415
415
pass
416
416
resp = self ._uart .read (self ._uart .in_waiting )
417
417
if len (resp ) < 2 :
0 commit comments