rtlabs-com / c-open

CANopen stack for embedded devices
http://www.rt-labs.com
Other
79 stars 40 forks source link

Split NMT Initialisation state into its three sub-states #47

Closed nattgris closed 3 years ago

nattgris commented 3 years ago

Treat each sub-state as a separate step in the FSM processing, to expose the sub-states to the application NMT callback, which may need to do different things depending on whether the application or only the communication is reset.

The previous STATE_INIT in an NMT callback now corresponds to STATE_INIT_COMM, so add an alias to keep the behaviour of existing callbacks.

Move the reset callback to the NMT command reception to avoid having to disable it during power-on initialisation.

hefloryd commented 3 years ago

Looks great, please rebase.

nattgris commented 3 years ago

I see that there are checks along the lines of net->state == STATE_INIT in some places. I think they do the right thing even though that condition now only matches the final sub-state, because that's the only sub-state which give these checks a chance to run as far as I can see. But probably worth to take a closer look and verify that, or if any of them need to expand the check to include the other two init states, or at least change the checks to STATE_INIT_COMM to make it clear.