Skip to content

Commit 46f9b4a

Browse files
committed
Workaround for NMT Slave to avoid blocking IO
1 parent dba463a commit 46f9b4a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

canopen/network.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ def connect(self, *args, **kwargs) -> Network:
107107
for full list of supported interfaces.
108108
:param int bitrate:
109109
Bitrate in bit/s.
110-
:param loop:
111-
Optional, pass the loop parameter if running under asyncio
112110
113111
:raises can.CanError:
114112
When connection fails.

canopen/nmt.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,11 @@ def send_command(self, code: int) -> None:
286286
# The heartbeat service should start on the transition
287287
# between INITIALIZING and PRE-OPERATIONAL state
288288
if old_state == 0 and self._state == 127:
289-
# NOTE: Blocking - OK. Protected in SdoClient
290-
heartbeat_time_ms = self._local_node.sdo[0x1017].raw
289+
if self._heartbeat_time_ms == 0:
290+
# NOTE: Blocking - OK. Protected in SdoClient
291+
heartbeat_time_ms = self._local_node.sdo[0x1017].raw
292+
else:
293+
heartbeat_time_ms = self._heartbeat_time_ms
291294
self.start_heartbeat(heartbeat_time_ms)
292295
else:
293296
self.update_heartbeat()

0 commit comments

Comments
 (0)