Skip to content

Commit 1ea906d

Browse files
authored
p402: Fix missing fallback behavior in check_statusword(). (#277)
The docstring for BaseNode402.check_statusword() promises it will fall back to SDO if the TPDO is not configured as periodic. However, that actually only happens when there is no TPDO for the Statusword at all. Fix that small detail, as the code using this function relies on getting an up-to-date value and on the implicit throttling caused by the SDO round-trip time.
1 parent 0f13cfb commit 1ea906d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

canopen/profiles/p402.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,9 @@ def statusword(self):
477477
return self.sdo[0x6041].raw
478478

479479
def check_statusword(self, timeout=None):
480-
"""Report an up-to-date reading of the statusword (0x6041) from the device.
480+
"""Report an up-to-date reading of the Statusword (0x6041) from the device.
481481
482-
If the TPDO with the statusword is configured as periodic, this method blocks
482+
If the TPDO with the Statusword is configured as periodic, this method blocks
483483
until one was received. Otherwise, it uses the SDO fallback of the ``statusword``
484484
property.
485485
@@ -494,6 +494,8 @@ def check_statusword(self, timeout=None):
494494
timestamp = pdo.wait_for_reception(timeout or self.TIMEOUT_CHECK_TPDO)
495495
if timestamp is None:
496496
raise RuntimeError('Timeout waiting for updated statusword')
497+
else:
498+
return self.sdo[0x6041].raw
497499
return self.statusword
498500

499501
@property

0 commit comments

Comments
 (0)