diff --git a/Marlin/G26_Mesh_Validation_Tool.cpp b/Marlin/G26_Mesh_Validation_Tool.cpp index 09dc6e324..9bddfc1f6 100644 --- a/Marlin/G26_Mesh_Validation_Tool.cpp +++ b/Marlin/G26_Mesh_Validation_Tool.cpp @@ -274,7 +274,7 @@ // action to give the user a more responsive 'Stop'. set_destination_from_current(); idle(); - MYSERIAL0.flush(); // Prevent host M105 buffer overrun. + SERIAL_FLUSH(); // Prevent host M105 buffer overrun. } wait_for_release(); @@ -501,7 +501,7 @@ SERIAL_EOL(); } idle(); - MYSERIAL0.flush(); // Prevent host M105 buffer overrun. + SERIAL_FLUSH(); // Prevent host M105 buffer overrun. } #if ENABLED(ULTRA_LCD) } @@ -525,7 +525,7 @@ } idle(); - MYSERIAL0.flush(); // Prevent host M105 buffer overrun. + SERIAL_FLUSH(); // Prevent host M105 buffer overrun. } #if ENABLED(ULTRA_LCD) lcd_reset_status(); @@ -811,12 +811,12 @@ #endif print_line_from_here_to_there(rx, ry, g26_layer_height, xe, ye, g26_layer_height); - MYSERIAL0.flush(); // Prevent host M105 buffer overrun. + SERIAL_FLUSH(); // Prevent host M105 buffer overrun. } if (look_for_lines_to_connect()) goto LEAVE; } - MYSERIAL0.flush(); // Prevent host M105 buffer overrun. + SERIAL_FLUSH(); // Prevent host M105 buffer overrun. } while (--g26_repeats && location.x_index >= 0 && location.y_index >= 0); LEAVE: diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 8b40524c9..34a82140a 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -11981,7 +11981,7 @@ void process_next_command() { */ void FlushSerialRequestResend() { //char command_queue[cmd_queue_index_r][100]="Resend:"; - MYSERIAL0.flush(); + SERIAL_FLUSH(); SERIAL_PROTOCOLPGM(MSG_RESEND); SERIAL_PROTOCOLLN(gcode_LastN + 1); ok_to_send(); diff --git a/Marlin/serial.h b/Marlin/serial.h index 5e9d9fbce..acad50266 100644 --- a/Marlin/serial.h +++ b/Marlin/serial.h @@ -48,6 +48,11 @@ extern const char errormagic[] PROGMEM; #define SERIAL_PRINTLN(x,b) MYSERIAL0.println(x,b) #define SERIAL_PRINTF(args...) MYSERIAL0.printf(args) +#define SERIAL_FLUSH() MYSERIAL0.flush() +#if TX_BUFFER_SIZE > 0 + #define SERIAL_FLUSHTX() MYSERIAL0.flushTX() +#endif + #define SERIAL_PROTOCOLCHAR(x) SERIAL_CHAR(x) #define SERIAL_PROTOCOL(x) MYSERIAL0.print(x) #define SERIAL_PROTOCOL_F(x,y) MYSERIAL0.print(x,y) diff --git a/Marlin/ubl.cpp b/Marlin/ubl.cpp index f6a9a6873..92eacacdf 100644 --- a/Marlin/ubl.cpp +++ b/Marlin/ubl.cpp @@ -199,7 +199,7 @@ if (map_type == 1 && i < GRID_MAX_POINTS_X - 1) SERIAL_CHAR(','); #if TX_BUFFER_SIZE > 0 - MYSERIAL0.flushTX(); + SERIAL_FLUSHTX(); #endif safe_delay(15); if (map_type == 0) { diff --git a/Marlin/ubl_G29.cpp b/Marlin/ubl_G29.cpp index 8b8ebc365..bd232cb27 100644 --- a/Marlin/ubl_G29.cpp +++ b/Marlin/ubl_G29.cpp @@ -763,7 +763,7 @@ const float measured_z = probe_pt(rawx, rawy, stow_probe, g29_verbose_level); // TODO: Needs error handling z_values[location.x_index][location.y_index] = measured_z; } - MYSERIAL0.flush(); // Prevent host M105 buffer overrun. + SERIAL_FLUSH(); // Prevent host M105 buffer overrun. } while (location.x_index >= 0 && --max_iterations); @@ -902,7 +902,7 @@ SERIAL_PROTOCOL_F(z_values[location.x_index][location.y_index], 6); SERIAL_EOL(); } - MYSERIAL0.flush(); // Prevent host M105 buffer overrun. + SERIAL_FLUSH(); // Prevent host M105 buffer overrun. } while (location.x_index >= 0 && location.y_index >= 0); if (do_ubl_mesh_map) display_map(g29_map_type); // show user where we're probing @@ -1414,7 +1414,7 @@ do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited #endif idle(); - MYSERIAL0.flush(); // Prevent host M105 buffer overrun. + SERIAL_FLUSH(); // Prevent host M105 buffer overrun. } while (!is_lcd_clicked()); if (!lcd_map_control) lcd_return_to_status();