<p>I am writing a python code for a 3D printer (Marlin). I'm trying to execute a movement that might be composed of multiple commands (<code>G0</code>). Unfortunately, sending all commands at once does not seem to work. To my understanding, this is caused because the printer command buffer for unexecuted commands is quite small and gets overloaded when sending so many commands at once.
Is there a way for me to know how much of the printer buffer is free, so I'll know when to send the next 1, 2, 5, etc. commands to the printer? I cannot send the next commands once the buffer is completely free as this would stop the movement and I need it to be fluid the whole way.</p>
<p>Two supplementary questions:</p>
<ol>
<li>Does any of you know how the printer handles the G-code file it receives on an SD card so it executes it whole fluidly without overloading?</li>
<li>Does the <code>'ok'</code> message received from the printer tell me that all the commands have been executed or that there is at least one free space in the command buffer?</li>
</ol>

CC BY-SA 4.0
2021-04-07T11:21:08.967Z
I think something similar has been asked before, see e.g. [this answer](/a/14680/). This could we'll be a duplicate question. I think this answers your questions. With respect to the SD reading part of the question, you could look that up in the Marlin sources.
0scar
CC BY-SA 4.0
2021-04-07T11:43:35.507Z
Thanks for the link. I completely missed that "Buffering" subsection on the RepRap page. I had a problem previously with sending multiple `M105` during movement and I might have falsely assumed that it was due to buffer overload. I did not realize that signals are treated differently and only some are buffered. I will check this behaviour with my printer tomorrow, maybe I was worrying over nothing :)
Alathen
CC BY-SA 4.0
2021-04-08T17:30:13.050Z
OK means there is space in the "buffer". Whenever you receive OK send a command. Also Marlin will never execute a "fluid" set of commands. There will always be a pause in between. The idea is that it will be smooth enough.
user77232
<marlin><g-code>
Sending multiple commands to printer without overloading its command buffer
Alathen
# Sending multiple commands to printer without overloading its command buffer

(Asked by: username_0 on 2021-04-07)

I am writing a python code for a 3D printer (Marlin). I'm trying to execute a movement that might be composed of multiple commands (`G0`). Unfortunately, sending all commands at once does not seem to work. To my understanding, this is caused because the printer command buffer for unexecuted commands is quite small and gets overloaded when sending so many commands at once.
Is there a way for me to know how much of the printer buffer is free, so I'll know when to send the next 1, 2, 5, etc. commands to the printer? I cannot send the next commands once the buffer is completely free as this would stop the movement and I need it to be fluid the whole way.

Two supplementary questions:

1. Does any of you know how the printer handles the G-code file it receives on an SD card so it executes it whole fluidly without overloading?
2. Does the `'ok'` message received from the printer tell me that all the commands have been executed or that there is at least one free space in the command buffer?

**Tags:** marlin, g-code
> **Comments:**
> **username_1**: I think something similar has been asked before, see e.g. [this answer](/a/14680/). This could we'll be a duplicate question. I think this answers your questions. With respect to the SD reading part of the question, you could look that up in the Marlin sources.  
> **username_0**: Thanks for the link. I completely missed that "Buffering" subsection on the RepRap page. I had a problem previously with sending multiple `M105` during movement and I might have falsely assumed that it was due to buffer overload. I did not realize that signals are treated differently and only some are buffered. I will check this behaviour with my printer tomorrow, maybe I was worrying over nothing :)  
> **username_2**: OK means there is space in the "buffer". Whenever you receive OK send a command. Also Marlin will never execute a "fluid" set of commands. There will always be a pause in between. The idea is that it will be smooth enough.  

---

## 0 answers

