Skip to content

Commit af43a67

Browse files
committed
Add M118 Gcode support
1 parent 7b163cf commit af43a67

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Firmware/Marlin_main.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -3936,6 +3936,7 @@ extern uint8_t st_backlash_y;
39363936
//!@n M114 - Output current position to serial port
39373937
//!@n M115 - Capabilities string
39383938
//!@n M117 - display message
3939+
//!@n M118 - Serial print
39393940
//!@n M119 - Output Endstop status to serial port
39403941
//!@n M123 - Tachometer value
39413942
//!@n M126 - Solenoid Air Valve Open (BariCUDA support by jmil)
@@ -6512,6 +6513,31 @@ SERIAL_PROTOCOLPGM("\n\n");
65126513
}
65136514
break;
65146515

6516+
/*!
6517+
### M118 - Serial print <a href="https://reprap.org/wiki/G-code#M118:_Echo_message_on_host">M118: Serial print</a>
6518+
*/
6519+
case 118: {
6520+
bool hasE, hasA = false;
6521+
char *p = strchr_pointer;
6522+
6523+
for (uint8_t i = 2; i--;) {
6524+
// A1, E1, and Pn are always parsed out
6525+
if (!((p[0] == 'A' || p[0] == 'E') && p[1] == '1')) break;
6526+
switch (p[0]) {
6527+
case 'A': hasA = true; break;
6528+
case 'E': hasE = true; break;
6529+
}
6530+
p += 2;
6531+
while (*p == ' ') ++p;
6532+
}
6533+
6534+
if (hasE) SERIAL_ECHO_START;
6535+
if (hasA) SERIAL_ECHO("//");
6536+
6537+
SERIAL_ECHOLN(p);
6538+
}
6539+
break;
6540+
65156541
#ifdef M120_M121_ENABLED
65166542
/*!
65176543
### M120 - Enable endstops <a href="https://reprap.org/wiki/G-code#M120:_Enable_endstop_detection">M120: Enable endstop detection</a>

0 commit comments

Comments
 (0)