Skip to content

Commit d0160a5

Browse files
committed
Merge branch 'master' into feature-asyncio
1 parent 9dd782e commit d0160a5

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ __pycache__/
1111
# Distribution / packaging
1212
.Python
1313
env/
14-
venv/
14+
venv*/
1515
build/
1616
develop-eggs/
1717
dist/

canopen/pdo/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def save(self) -> None:
508508
self._fill_map(sdo.raw)
509509
else:
510510
# NOTE: Blocking call
511-
sdo.set_raw(value)
511+
sdo.raw = value
512512

513513
async def asave(self) -> None:
514514
"""Read PDO configuration for this map using SDO, async variant."""

canopen/sdo/client.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class SdoClient(SdoBase):
2828
#: Seconds to wait before sending a request, for rate limiting
2929
PAUSE_BEFORE_SEND = 0.0
3030

31-
#: Seconds to wait after sending a request
32-
PAUSE_AFTER_SEND = 0.1
31+
#: Seconds to wait before retrying a request after a send error
32+
RETRY_DELAY = 0.1
3333

3434
def __init__(self, rx_cobid, tx_cobid, od):
3535
"""
@@ -56,21 +56,19 @@ async def aon_response(self, can_id, data, timestamp):
5656
@ensure_not_async # NOTE: Safeguard for accidental async use
5757
def send_request(self, request):
5858
retries_left = self.MAX_RETRIES
59+
if self.PAUSE_BEFORE_SEND:
60+
time.sleep(self.PAUSE_BEFORE_SEND)
5961
while True:
6062
try:
61-
if self.PAUSE_BEFORE_SEND:
62-
# NOTE: Blocking call
63-
time.sleep(self.PAUSE_BEFORE_SEND)
6463
self.network.send_message(self.rx_cobid, request)
6564
except CanError as e:
6665
# Could be a buffer overflow. Wait some time before trying again
6766
retries_left -= 1
6867
if not retries_left:
6968
raise
7069
logger.info(str(e))
71-
if self.PAUSE_AFTER_SEND:
72-
# NOTE: Blocking call
73-
time.sleep(self.PAUSE_AFTER_SEND)
70+
if self.RETRY_DELAY:
71+
time.sleep(self.RETRY_DELAY)
7472
else:
7573
break
7674

0 commit comments

Comments
 (0)