Skip to content

Commit

Permalink
Small change in NMT log message and FIXME comment for DS402. (#260)
Browse files Browse the repository at this point in the history
* nmt: Include node ID in state change message.

These log messages can get rather confusing with more nodes involved.

* p402: Add FIXME about the messed up logic in reset_from_fault().

That method does not work as intended.  Until a fix is ready, at least
explain what goes wrong in a code comment.
  • Loading branch information
acolomb authored Aug 16, 2021
1 parent 7c5e4ce commit b2ef201
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions canopen/nmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def send_command(self, code):
"""
if code in COMMAND_TO_STATE:
new_state = COMMAND_TO_STATE[code]
logger.info("Changing NMT state from %s to %s",
NMT_STATES[self._state], NMT_STATES[new_state])
logger.info("Changing NMT state on node %d from %s to %s",
self.id, NMT_STATES[self._state], NMT_STATES[new_state])
self._state = new_state

@property
Expand Down
2 changes: 2 additions & 0 deletions canopen/profiles/p402.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ def reset_from_fault(self):
if self.state == 'FAULT':
# Resets the Fault Reset bit (rising edge 0 -> 1)
self.controlword = State402.CW_DISABLE_VOLTAGE
# FIXME! The rising edge happens with the transitions toward OPERATION
# ENABLED below, but until then the loop will always reach the timeout!
timeout = time.monotonic() + self.TIMEOUT_RESET_FAULT
while self.is_faulted():
if time.monotonic() > timeout:
Expand Down

0 comments on commit b2ef201

Please sign in to comment.