Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add M118 Gcode support #3946

Merged
merged 4 commits into from
Jul 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3936,6 +3936,7 @@ extern uint8_t st_backlash_y;
//!@n M114 - Output current position to serial port
//!@n M115 - Capabilities string
//!@n M117 - display message
//!@n M118 - Serial print
//!@n M119 - Output Endstop status to serial port
//!@n M123 - Tachometer value
//!@n M126 - Solenoid Air Valve Open (BariCUDA support by jmil)
Expand Down Expand Up @@ -6512,6 +6513,39 @@ SERIAL_PROTOCOLPGM("\n\n");
}
break;

/*!
### M118 - Serial print <a href="https://reprap.org/wiki/G-code#M118:_Echo_message_on_host">M118: Serial print</a>
#### Usage

M118 [ A1 | E1 ] [ String ]

#### Parameters
- `A1` - Prepend // to denote a comment or action command. Hosts like OctoPrint can interpret such commands to perform special actions. See your host’s documentation.
- `E1` - Prepend echo: to the message. Some hosts will display echo messages differently when preceded by echo:.
- `String` - Message string. If omitted, a blank line will be sent.
*/
gudnimg marked this conversation as resolved.
Show resolved Hide resolved
case 118: {
bool hasE = false, hasA = false;
char *p = strchr_pointer + 5;

for (uint8_t i = 2; i--;) {
// A1, E1, and Pn are always parsed out
if (!((p[0] == 'A' || p[0] == 'E') && p[1] == '1')) break;
RoboMagus marked this conversation as resolved.
Show resolved Hide resolved
switch (p[0]) {
case 'A': hasA = true; break;
case 'E': hasE = true; break;
}
p += 2;
while (*p == ' ') ++p;
}

if (hasE) SERIAL_ECHO_START;
if (hasA) SERIAL_ECHOPGM("//");

SERIAL_ECHOLN(p);
RoboMagus marked this conversation as resolved.
Show resolved Hide resolved
}
break;

#ifdef M120_M121_ENABLED
/*!
### M120 - Enable endstops <a href="https://reprap.org/wiki/G-code#M120:_Enable_endstop_detection">M120: Enable endstop detection</a>
Expand Down