1
$\begingroup$

I'm writing a Python module that allows new tricks with printing - it already can produce G-code I can put into a file, send to the printer and print out. No problem with generating the correct codes to print.

What I want to add to it is interactive mode: connect to the printer over serial interface, then control the printer "as you go", you enter a command, the printer responds. You run a procedure, the printer executes the sequence of G-codes, then the software returns to awaiting further commands. The Marlin website provides a comprehensive reference of all G-codes for me to use. What it lacks though is an intro about the protocol as a whole, especially the busy/wait and error responses, the timing of me sending the next command in sequence.

Can someone either explain that part in sufficient detail to allow me to write the code that knows when (and if) to send the next G-code command, and/or refer me to a resource that does just that?

$\endgroup$
5
  • $\begingroup$ I think this has been answered before. Does this or more specifically, this answer your question? If not, how does the question differ? $\endgroup$
    – 0scar
    Commented Sep 11, 2023 at 6:23
  • $\begingroup$ @Oscar: The latter one is useless, it's how to do send a single fire-and-forget command, not a dialogue question. The earlier one has bare minimum about the buffer and 'ok' but the answer is so perfunctory it's nowhere near sufficient. I could post a bounty there for 'improve details' if I had the points, otherwise I'm stuck with way too little. In particular not a peep about all the possible answers that are not 'ok'. Also, came by M400 all by myself; I don't think any answer that doesn't mention it is comprehensive enough. $\endgroup$
    – SF.
    Commented Sep 11, 2023 at 15:29
  • $\begingroup$ What do you mean by interactive mode: connect to the printer over serial interface, then control the printer "as you go", that is not clear in your question. You mean to control the printer from the printer itself when connected over serial and from code, or just interface with the printer through code only? A programming interface only is exactly as described in the latter answer I linked, only your program will be bigger with more user interaction, upon quitting you should close the serial connection. I have done this multiple times that way. $\endgroup$
    – 0scar
    Commented Sep 11, 2023 at 18:17
  • $\begingroup$ @Oscar: A shell, but you give commands in the language I provide, not directly in g-code. One your command can be one g-code command, or can be a sequence of 500. So your input is frozen until the printer completes the 500 commands. The sequence can easily be longer than Marlin's buffer, or contain unbufferable commands. You control the printer from a PC connected over USB. $\endgroup$
    – SF.
    Commented Sep 11, 2023 at 18:41
  • $\begingroup$ Yes, I should close upon quitting the interactive shell, but not after executing one command - after a command I await further user input, with connection kept live. $\endgroup$
    – SF.
    Commented Sep 11, 2023 at 18:48

0

You must log in to answer this question.

Browse other questions tagged .