I used my socat hack today to record what happens during a problematic slew. The full log is attached but here is what's most relevant:

## this is probably in response to the second, spurious slew command
[14:10:10.650601] :f1.                  [14:10:10.651333] =101.
[14:10:10.651754] :G130.                [14:10:10.652651] =.
[14:10:10.652836] :f1.                  [14:10:10.653530] =501.
[14:10:10.653844] :I1BA0000.            [14:10:10.655067] =.
[14:10:10.655282] :J1.                  [14:10:10.656078] =.
[14:10:10.656259] :f1.                  [14:10:10.656958] =501.
[14:10:11.650969] :j1.                  [14:10:11.652099] =08387D.
[14:10:11.652672] :j2.                  [14:10:11.653672] =97BE7B.
[14:10:11.654226] :f1.                  [14:10:11.654882] =101.
[14:10:11.655379] :f2.                  [14:10:11.655995] =101.
[14:10:12.658263] :j1.                  [14:10:12.659286] =A54D7E.
[14:10:12.660084] :j2.                  [14:10:12.661261] =97BE7B.
[14:10:12.661986] :f1.                  [14:10:12.662842] =101.

## this is probably when I turned off the mount power
[14:10:12.663561] :f2.                  [14:10:12.664345] =101.............8...l.............
[14:10:13.666533] :j1.                  [14:10:13.667306] j.

First column is what sent to the mount, second column is what the mount responded. Timestamps are in square brackets. This is what happened after the mount had come to a complete stop, and started to handle the second spurious slew command. Notice that, after the J1 command is sent, the motor status as reported by the mount is "motor stopped" (:f1 -> =101.). But if you look at the axis position queries (j1 commands), you can see that the axis was indeed moving (from 0x08387D to 0xA54D7E before I shut the mount off).

Another thing I noticed is that the second K1 was never sent. This is probably because of the new
if(*motorrunning)
code you introduced last night. Since f1 never responded that the motor was running, *motorrunning was probably never true, hence the if block was never executed.

I got the sense that it is whatever action before the J1 command that was causing the mount control board to be in an undefined state... I'll keep playing with this and report back if I find anything.

Read More...