-
Notifications
You must be signed in to change notification settings - Fork 220
Closed
Milestone
Description
Hi, great library, thanks for the effort.
When reading NMT messages under the heartbeat protocol, occasionally the highest bit is set for state. I believe this is resulting in a crash because bit 8 is set for the state (PRE-OPERATIONAL state is 0xFF instead of 0x7F for example):
File "/home/user/miniconda2/envs/abc/lib/python2.7/site-packages/canopen/nmt.py", line 103, in state
self.send_command(code)
File "/home/user/miniconda2/envs/abc/lib/python2.7/site-packages/canopen/nmt.py", line 138, in send_command
super(NmtMaster, self).send_command(code)
File "/home/user/miniconda2/envs/abc/lib/python2.7/site-packages/canopen/nmt.py", line 72, in send_command
NMT_STATES[self._state], NMT_STATES[new_state])
KeyError: 255
nmt.py defines the codes for states as below 128
NMT_STATES = {
0: 'INITIALISING',
4: 'STOPPED',
5: 'OPERATIONAL',
80: 'SLEEP',
96: 'STANDBY',
127: 'PRE-OPERATIONAL'
}
The CANopen docs in section 7.2.8.3.2.2 Protocol heartbeat say that bit 8 of slave state is a toggle bit which is toggled with two consecutive NMT messages, so seeing a slave send 0xFF for PRE-OPERATIONAL state could be expected.
If I understand the issue correctly, can we have the above error mask out the toggle bit?
Metadata
Metadata
Assignees
Labels
No labels