Skip to content
Merged
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
12 changes: 6 additions & 6 deletions canopen/sdo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class SdoClient(SdoBase):
#: Seconds to wait before sending a request, for rate limiting
PAUSE_BEFORE_SEND = 0.0

#: Seconds to wait after sending a request
PAUSE_AFTER_SEND = 0.1
#: Seconds to wait before retrying a request after a send error
RETRY_DELAY = 0.1

def __init__(self, rx_cobid, tx_cobid, od):
"""
Expand All @@ -45,19 +45,19 @@ def on_response(self, can_id, data, timestamp):

def send_request(self, request):
retries_left = self.MAX_RETRIES
if self.PAUSE_BEFORE_SEND:
time.sleep(self.PAUSE_BEFORE_SEND)
while True:
try:
if self.PAUSE_BEFORE_SEND:
time.sleep(self.PAUSE_BEFORE_SEND)
self.network.send_message(self.rx_cobid, request)
except CanError as e:
# Could be a buffer overflow. Wait some time before trying again
retries_left -= 1
if not retries_left:
raise
logger.info(str(e))
if self.PAUSE_AFTER_SEND:
time.sleep(self.PAUSE_AFTER_SEND)
if self.RETRY_DELAY:
time.sleep(self.RETRY_DELAY)
else:
break

Expand Down