From 96bcf08477baa8b5bea5d6334839bb4ea1d4a0fb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 9 Feb 2018 04:06:44 -0600 Subject: [PATCH] Tweak escape handling in serial input --- Marlin/Marlin_main.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 93be9e1f9..af3b19573 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1135,12 +1135,9 @@ inline void get_serial_commands() { // Keep fetching, but ignore normal characters beyond the max length // The command will be injected when EOL is reached } - else if (serial_char == '\\') { // Handle escapes - if ((c = MYSERIAL.read()) >= 0) { - // if we have one more character, copy it over - serial_char = c; - if (!serial_comment_mode) serial_line_buffer[serial_count++] = serial_char; - } + else if (serial_char == '\\') { // Handle escapes + if ((c = MYSERIAL.read()) >= 0 && !serial_comment_mode) // if we have one more character, copy it over + serial_line_buffer[serial_count++] = (char)c; // otherwise do nothing } else { // it's not a newline, carriage return or escape char