Open PaulVerhoeckx opened 3 years ago
Using print statements I found the problem. [...]
Add print statement changes the timing, I am not sure if this is the root cause.
Resulting in the following stack trace:
[ERROR] [1622561327.496872067]: CAN not ready [ERROR] [1622561327.497535175]: Initializing failed: could not reset node '1'
It looks like your CAN bus stops working in between. (?)
As a workaround I made reset_com() wait on the state PreOperational
If I recall it correctly not all nodes send PreOperational (it depends on the heartbeat interval?) That's why the state get's set to PreOperational right after the BootUp message without further checks.
I think this might not happen with our devices, because the heartbeat interval is 0 per default and gets activated after the reset.
If someone knows a good solution, I am willing to make a PR.
I would add a special variable to track the BootUp message and check this instead of state_
in a wait_for_bootup
function.
On initialization the reset communication NMT command is send (node.cpp#L47) after which it will wait until the NMT state
BootUp
(=0
) is reached. Occasionally this state is missed, due to the fast succession of the statePreOperational
. Resulting in the following stack trace:Using print statements I found the problem. A switch to NMT state
0
was made here, causing wait_until() to return. However, before thewhile
condition was evaluated (here),state_
had already transitioned toPreOperational
. This prevents breaking thewhile
loop, again triggering wait_until(), which now times out.As a workaround I made
reset_com()
wait on the statePreOperational
, but this does not guarantee a reset of the node. If someone knows a good solution, I am willing to make a PR.