cmdctrl can change target when processing pc command, however timer thread is used to re-apply saved speed. Following sequence of operations needs to be impossible (but is not)
periodic reapply (timer thread) reads the current target
cmdctrl thread handles a speed set message and changes current target and/or mode
cmdctrl thread sets new speed
periodic reapply (timer thread) sets the target it previously read (now wrong target)
Sequence of accessing current mode & saved target speeds then setting speeds needs to be protected by mutex.
cmdctrl can change target when processing pc command, however timer thread is used to re-apply saved speed. Following sequence of operations needs to be impossible (but is not)
Sequence of accessing current mode & saved target speeds then setting speeds needs to be protected by mutex.