REST API arbitrary command ready status

Hi,

when using OctoPrint API for sending arbitrary commands list (/api/printer/command) is it possible to somehow get information when they have been executed?

If not, what could be a way to implement that as custom plugin, could it be based on command queue on OctoPrint or command buffer lenght in printer etc? I don't know how OctoPrint monitors the job status but it must be able to get information already for print jobs from printer.

Br, JL

No. See the big note right at the top of the printer API documentation:

Let's go back a step here and start at the beginning. What do you want to achieve with your plugin?

Hi,

thanks for quick reply. So basically it would then need to implement custom rest endpoint for returning if printer has executed all commands sent to it previously using that arbitrary commands api endpoint.

So if I send 'G01 X100 Y100' using arbitrary commands api, then I could poll somehow using rest api if printer is done with movement. The actual api http request doesn't need to be synchronous. Printer firmware would be Marlin.

Detecting when movement is finished is hard. There is no feedback from the firmware about that. What you could do from your plugin is send an M400 and a queue marker right after that then calls back your plugin once it gets sent, indicating that the blocking M400 has finished processing on the printer and movements are done.

But that is quite advanced stuff and not easy to pull off due to how the communication protocol available on printers is designed.

Hence again my question: what is your end goal? What is your plugin supposed to do? You are currently asking precise questions related to a specific possible solution for a part of a problem you are trying to solve via a plugin, what I'm unclear about is what exactly you are trying to implement in the first place. There might be better ways than sending commands and waiting for movement to finish, and there certainly are better ways directly on the plugin interface than on the REST API. But unless you tell us what exactly you are trying to accomplish (on a level of "I want to write a plugin that does X when Y happens", not "I need to query the REST API when movement finishes"), it's hard to give you advice on how best to accomplish that.

Ok, thanks. I'll try that M400 use approach.

Regarding end goal I have custom setup where I use OctoPrint to send gcodes to Marlin that it controls X Y plane where camera is attached. I want to for example send gcode G01 X100 Y100 and wait for movement to finish and then take camera photo from that location. Everything works already but I need to clean up uploaded print job files periodically because those pile up quickly to sd card due to creation of new job for each movement where camera image is needed. Arbitrary commands wouldn't fill sd card with job files, but with that I don't know when print (movement) is done. That is why I was wondering if it would be possible to use some same functionality that OctoPrint is using to detect is print job is ready without creating print jobs..

That sounds very alike to what Octolapse by @FormerLurker already does, so you really want to take a look at how it does it.