G-code command to determine if DexArm is in motion?


Is there any G-code command to identify if DexArm is currently in motion from executing a move command, for example, a G0 or G1 command? Or determine if DexArm has finished processing a move command, i.e. has reached target coordinates.

The current workaround I have is to send the G-code command: β€œM894” in a loop with a small delay, to return encoder positions. If successive returned values are equal, then I assume the arm has stopped moving. This time based polling approach works in a pinch, but it isn’t always reliable, especially if the axis feedrate is low.

Maybe you find something in here: https://reprap.org/wiki/G-code ? It’s very huge collection of different G-code flavours, as the DexArm works on Marlin you will need to look at the corresponding columns.

Thanks @ahorn42, I managed to work out a solution by using command β€œM400”, which only returns a response β€œok” after all buffered commands have executed.

I spin up a new thread to poll the serial output for the β€œok” response, and continue my other logic on the original thread, continuing only when the new thread returns the β€œok” response.