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?