kliment / Printrun

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

Blocking versions of `send` and `send_now` do not exist #1449

Open tomasiser opened 1 month ago

tomasiser commented 1 month ago

Hello, in Printrun 2.1.0, there are send and send_now methods as part of printcore.py.

These methods are non-blocking, which means when you send a G0 ... command to move to a certain position, the method returns immediately without waiting for the printer to finish the movement.

Could blocking versions of these commands be implemented? Is it even possible given the communication protocol? Of course you can calculate a rough estimate of the time it needs to move by dividing the distance by the move rate (in mm/min), but that is not the same as a blocking version of these methods.

kliment commented 1 month ago

There are no blocking methods like this. However, there is a synchronization command M400. M400 will not complete until all moves are done, so sending two M400s in a row will let you check for completion by seeing if queue is empty.

For related work, see https://github.com/kliment/Printrun/issues/990 and https://github.com/kliment/Printrun/pull/1008 which implements a very similar thing but needs to be rebased because it's drifted away from the current state of the code.

tomasiser commented 1 month ago

Thank you, so what you recommend as a workaround is to send M400 twice and then wait until priqueue.empty()? :)

kliment commented 1 month ago

That's probably the easiest way to do it, yes.