kliment / Printrun

Pronterface, Pronsole, and Printcore - Pure Python 3d printing host software
GNU General Public License v3.0
2.38k stars 996 forks source link

Is it possible to check if a sent gcode command is done? #1248

Closed yihan0512 closed 2 years ago

yihan0512 commented 2 years ago

Hello, I'm controlling a Lulzbot TAZ 6 with printcore. I use p.send_now() to send individual gcode command (e.g. G01 X100 Y100) to the printer (to move the head). My question is: would it be possible to check (using the printcore API) if the printer has done moving the head?

rockstorm101 commented 2 years ago

Could you provide a use case for this? Couldn't you just queue in the next command? Which will be executed upon termination of the first

yihan0512 commented 2 years ago

@rockstorm101 it's for a research project. I'm recording some sensor data while the head is moving. Below is the workflow I'm doing:

for loop
    1. randomly position the head 
    2. start recording
    3. execute a gcode command
    4. stop recording
end

I need to know when step 1 is finished so I can start recording. A workaround I came up with is to wait long enough to let step 1 finish. But I figure it'd be great if I can get feedback from the printer.

volconst commented 2 years ago

Send this https://marlinfw.org/docs/gcode/M400.html and by the time you receive its 'ok' the move should be done, I guess.

kliment commented 2 years ago

For this kind of application I usually send_now two M400s in a row and check when the queue is empty (printrun.priqueue.empty()).