Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions canopen/emcy.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,19 @@ def wait(
while True:
with self.emcy_received:
prev_log_size = len(self.log)
self.emcy_received.wait(timeout)
remaining = end_time - time.time()
if remaining <= 0:
return None # Actual timeout reached
self.emcy_received.wait(remaining)
if len(self.log) == prev_log_size:
# Resumed due to timeout
return None
if time.time() >= end_time:
# Resumed due to timeout
return None
else:
continue
# Get last logged EMCY
emcy = self.log[-1]
logger.info("Got %s", emcy)
if time.time() > end_time:
# No valid EMCY received on time
return None
if emcy_code is None or emcy.code == emcy_code:
# This is the one we're interested in
return emcy
Expand Down
Loading