Skip to content
Closed
Show file tree
Hide file tree
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
13 changes: 7 additions & 6 deletions canopen/nmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import struct
import threading
import time
from typing import Callable, Optional, TYPE_CHECKING
from typing import Callable, Dict, Final, List, Optional, TYPE_CHECKING

import canopen.network

Expand All @@ -12,7 +12,7 @@

logger = logging.getLogger(__name__)

NMT_STATES = {
NMT_STATES: Final[Dict[int, str]] = {
0: 'INITIALISING',
4: 'STOPPED',
5: 'OPERATIONAL',
Expand All @@ -21,7 +21,7 @@
127: 'PRE-OPERATIONAL'
}

NMT_COMMANDS = {
NMT_COMMANDS: Final[Dict[str, int]] = {
'OPERATIONAL': 1,
'STOPPED': 2,
'SLEEP': 80,
Expand All @@ -32,7 +32,7 @@
'RESET COMMUNICATION': 130
}

COMMAND_TO_STATE = {
COMMAND_TO_STATE: Final[Dict[int, int]] = {
1: 5,
2: 4,
80: 80,
Expand Down Expand Up @@ -117,7 +117,7 @@
#: Timestamp of last heartbeat message
self.timestamp: Optional[float] = None
self.state_update = threading.Condition()
self._callbacks = []
self._callbacks: List[Callable[[int], None]] = []

def on_heartbeat(self, can_id, data, timestamp):
with self.state_update:
Expand Down Expand Up @@ -186,7 +186,8 @@
:param period:
Period (in seconds) at which the node guarding should be advertised to the slave node.
"""
if self._node_guarding_producer : self.stop_node_guarding()
if self._node_guarding_producer:
self.stop_node_guarding()

Check warning on line 190 in canopen/nmt.py

View check run for this annotation

Codecov / codecov/patch

canopen/nmt.py#L190

Added line #L190 was not covered by tests
self._node_guarding_producer = self.network.send_periodic(0x700 + self.id, None, period, True)

def stop_node_guarding(self):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ exclude = [
"^test*",
"^setup.py*",
]
disable_error_code = "annotation-unchecked"
Loading