Skip to content

Commit c1e3659

Browse files
committed
Minor comment and typing updates
1 parent 535f975 commit c1e3659

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

canopen/emcy.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class EmcyConsumer:
2020

2121
def __init__(self):
2222
#: Log of all received EMCYs for this node
23-
self.log: List["EmcyError"] = []
23+
self.log: List[EmcyError] = []
2424
#: Only active EMCYs. Will be cleared on Error Reset
25-
self.active: List["EmcyError"] = []
25+
self.active: List[EmcyError] = []
2626
self.callbacks = []
2727
self.emcy_received = threading.Condition()
2828
self.aemcy_received = asyncio.Condition()
@@ -66,9 +66,8 @@ async def aon_emcy(self, can_id, data, timestamp):
6666
if res is not None and asyncio.iscoroutine(res):
6767
await res
6868

69-
def add_callback(self, callback: Callable[["EmcyError"], None]):
70-
"""Get notified on EMCY messages from this node. The callback must
71-
be multi-threaded.
69+
def add_callback(self, callback: Callable[[EmcyError], None]):
70+
"""Get notified on EMCY messages from this node.
7271
7372
:param callback:
7473
Callable which must take one argument of an

canopen/network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,13 @@ def stop(self):
365365
"""Stop transmission"""
366366
self._task.stop()
367367

368+
# @callback # NOTE: Indirectly called from another thread via other callbacks
368369
def update(self, data: bytes) -> None:
369370
"""Update data of message
370371
371372
:param data:
372373
New data to transmit
373374
"""
374-
# NOTE: Callback. Called from another thread unless async
375375
new_data = bytearray(data)
376376
old_data = self.msg.data
377377
self.msg.data = new_data

canopen/nmt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def __init__(self, node_id: int, local_node):
266266
self._heartbeat_time_ms = 0
267267
self._local_node = local_node
268268

269-
# @callback # NOTE: called from another thread
269+
# @callback # NOTE: called from another thread
270270
def on_command(self, can_id, data, timestamp):
271271
super(NmtSlave, self).on_command(can_id, data, timestamp)
272272
self.update_heartbeat()
@@ -326,8 +326,8 @@ def stop_heartbeat(self):
326326
self._send_task.stop()
327327
self._send_task = None
328328

329+
# @callback # NOTE: Indirectly called from another thread via on_command
329330
def update_heartbeat(self):
330-
# NOTE: Called from callback. Called from another thread unless async
331331
if self._send_task is not None:
332332
# FIXME: Make this thread-safe
333333
self._send_task.update([self._state])

0 commit comments

Comments
 (0)