g2
g2 copied to clipboard
G4P0 does not wait until queue is empty to return
In OpenPnP when we send a movement to the controller we need to block until that movement is complete. In most Gcode processors we do this by performing a G4P0 dwell command which causes the controller to wait until the queue is empty, then do a 0 second dwell, then return "ok". I believe this worked in TinyG, but I can't verify it at the moment. In G2 the G4P0 returns immediately, even if a movement is still in progress.
I spoke with @aldenhart and he said I should log an issue. Here is our conversation:
Jason von Nieda: Well, OpenPnP expects movement commands to block before returning. I normally do that by issuing a G4P0 but that doesn't seem to be working in G2. It returns "ok" immediately, even if there is still a move happening.
Jason von Nieda: So, short version of that question is "How do I wait for a movement to complete, preferably just with Gcode and not JSON?"
Alden Hart: You monitor the status reports for stat STOPPED. There is no way in Gcode to determine that, as it wasn't designed for it. This is probably best put on the G2 Issues list.
So, I am reporting this in hopes that either G4P0 can be modified to work this way, or perhaps that something else can be added to perform this "Wait until movement stops" function. In the mean time I will be modifying OpenPnP to monitor status reports for G2.