Skip to content

Commit e5355f4

Browse files
acolombaf-silva
andauthored
p402: Make HOMING_TIMEOUT_DEFAULT configurable per instance. (#258)
When the HOMING_TIMEOUT_DEFAULT class attribute is overridden as an object attribute, the argument default value definition in homing() still uses the old value from the class attribute. Check the argument and apply the default value at runtime to pick up the updated default timeout if the argument is omitted. Co-authored-by: André Filipe Silva <[email protected]>
1 parent c161ab3 commit e5355f4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

canopen/profiles/p402.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ def homing(self, timeout=TIMEOUT_HOMING_DEFAULT):
316316
:return: If the homing was complete with success.
317317
:rtype: bool
318318
"""
319+
if timeout is None:
320+
timeout = self.TIMEOUT_HOMING_DEFAULT
319321
previus_op_mode = self.op_mode
320322
self.op_mode = 'HOMING'
321323
# The homing process will initialize at operation enabled
@@ -335,7 +337,7 @@ def homing(self, timeout=TIMEOUT_HOMING_DEFAULT):
335337
'ERROR VELOCITY IS ZERO'):
336338
raise RuntimeError('Unable to home. Reason: {0}'.format(homingstatus))
337339
time.sleep(self.INTERVAL_CHECK_STATE)
338-
if time.monotonic() > t:
340+
if timeout and time.monotonic() > t:
339341
raise RuntimeError('Unable to home, timeout reached')
340342
logger.info('Homing mode carried out successfully.')
341343
return True

0 commit comments

Comments
 (0)