Skip to content

Commit 66b3f6b

Browse files
committed
use monotonic clock on parameter actions
1 parent 5d9edb3 commit 66b3f6b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

dronekit/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ def listener(self, name, msg):
12321232
self._params_loaded = False
12331233
self._params_start = False
12341234
self._params_map = {}
1235-
self._params_last = time.time() # Last new param.
1235+
self._params_last = monotonic.monotonic() # Last new param.
12361236
self._params_duration = start_duration
12371237
self._parameters = Parameters(self)
12381238

@@ -1246,7 +1246,7 @@ def listener(_):
12461246
self._params_loaded = True
12471247
self.notify_attribute_listeners('parameters', self.parameters)
12481248

1249-
if not self._params_loaded and time.time() - self._params_last > self._params_duration:
1249+
if not self._params_loaded and monotonic.monotonic() - self._params_last > self._params_duration:
12501250
c = 0
12511251
for i, v in enumerate(self._params_set):
12521252
if v == None:
@@ -1255,7 +1255,7 @@ def listener(_):
12551255
if c > 50:
12561256
break
12571257
self._params_duration = repeat_duration
1258-
self._params_last = time.time()
1258+
self._params_last = monotonic.monotonic()
12591259

12601260
@self.on_message(['PARAM_VALUE'])
12611261
def listener(self, name, msg):
@@ -1273,7 +1273,7 @@ def listener(self, name, msg):
12731273
try:
12741274
if msg.param_index < msg.param_count and msg:
12751275
if self._params_set[msg.param_index] == None:
1276-
self._params_last = time.time()
1276+
self._params_last = monotonic.monotonic()
12771277
self._params_duration = start_duration
12781278
self._params_set[msg.param_index] = msg
12791279
self._params_map[msg.param_id] = msg.param_value
@@ -2386,11 +2386,11 @@ def set(self, name, value, retries=3, wait_ready=False):
23862386
remaining = retries
23872387
while True:
23882388
self._vehicle._master.param_set_send(name, value)
2389-
tstart = time.time()
2389+
tstart = monotonic.monotonic()
23902390
if remaining == 0:
23912391
break
23922392
remaining -= 1
2393-
while time.time() - tstart < 1:
2393+
while monotonic.monotonic() - tstart < 1:
23942394
if name in self._vehicle._params_map and self._vehicle._params_map[name] == value:
23952395
return True
23962396
time.sleep(0.1)

0 commit comments

Comments
 (0)