<p>Do you have the option to edit the source code or is recompilation not an option for you? I'd just edit the <code>M118</code> function to print your variable when a specific text is given. You could have it print different variables per text that is supplied.</p>
<p>A more fancy way would be to copy and alter the <code>M118</code> to an unused function (above 1000 seems unused) to match your needs.</p>

CC BY-SA 4.0
2023-01-13T08:14:11.470Z
2023-01-16T10:55:11.453Z
2023-01-16T10:55:11.453Z
Hacky
<p>I am looking for the equivalent of <code>System.out.println()</code> or <code>Console.WriteLine()</code>, but using <code>M118</code>.</p>
<p>For example, every time a particular variable changes its value I want to send a message to the terminal in OctoPrint as if it were sent by <code>M118</code>.</p>
<p>These commands would be hardcoded into the firmware files before compiling/flashing.</p>
<p>Since <code>M118.cpp</code> is only designed to parse a string given by the user I am not quite clear how to co-opt it for this use.</p>
<p>Any help would be appreciated!</p>

CC BY-SA 4.0
2023-01-14T07:57:52.400Z
Please find the answer [here](https://reprap.org/forum/read.php?415,822581). If it works make your own answer, else I might do it later.
0scar
<marlin>
Marlin: How to print to terminal to debug?
benram14159
# Marlin: How to print to terminal to debug?

(Asked by: username_0 on 2022-06-29)

I am looking for the equivalent of `System.out.println()` or `Console.WriteLine()`, but using `M118`.

For example, every time a particular variable changes its value I want to send a message to the terminal in OctoPrint as if it were sent by `M118`.

These commands would be hardcoded into the firmware files before compiling/flashing.

Since `M118.cpp` is only designed to parse a string given by the user I am not quite clear how to co-opt it for this use.

Any help would be appreciated!

**Tags:** marlin

> **Comments:**
> **username_1**: Please find the answer [here](https://reprap.org/forum/read.php?415,822581). If it works make your own answer, else I might do it later.  

---

## 1 answers

### Answer by username_2 on 2023-01-13. Score: 1

Do you have the option to edit the source code or is recompilation not an option for you? I'd just edit the `M118` function to print your variable when a specific text is given. You could have it print different variables per text that is supplied.

A more fancy way would be to copy and alter the `M118` to an unused function (above 1000 seems unused) to match your needs.


---

