From e02b06672c273ce16d37f0d90da2106ef0fc80bd Mon Sep 17 00:00:00 2001
From: Timm <saeugetier@googlemail.com>
Date: Thu, 24 Oct 2019 19:28:41 +0200
Subject: [PATCH] Increase MMU2 serial buffer size with USB serial (#15646)

---
 Marlin/src/feature/prusa_MMU2/mmu2.cpp |  2 +-
 Marlin/src/feature/prusa_MMU2/mmu2.h   | 10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Marlin/src/feature/prusa_MMU2/mmu2.cpp b/Marlin/src/feature/prusa_MMU2/mmu2.cpp
index 66b3877f0c..d101cf7f93 100644
--- a/Marlin/src/feature/prusa_MMU2/mmu2.cpp
+++ b/Marlin/src/feature/prusa_MMU2/mmu2.cpp
@@ -97,7 +97,7 @@ volatile int8_t MMU2::finda = 1;
 volatile bool MMU2::finda_runout_valid;
 int16_t MMU2::version = -1, MMU2::buildnr = -1;
 millis_t MMU2::last_request, MMU2::next_P0_request;
-char MMU2::rx_buffer[16], MMU2::tx_buffer[16];
+char MMU2::rx_buffer[MMU_RX_SIZE], MMU2::tx_buffer[MMU_TX_SIZE];
 
 #if HAS_LCD_MENU && ENABLED(MMU2_MENUS)
 
diff --git a/Marlin/src/feature/prusa_MMU2/mmu2.h b/Marlin/src/feature/prusa_MMU2/mmu2.h
index e102481c19..9628c4be7f 100644
--- a/Marlin/src/feature/prusa_MMU2/mmu2.h
+++ b/Marlin/src/feature/prusa_MMU2/mmu2.h
@@ -27,6 +27,14 @@
   #include "../runout.h"
 #endif
 
+#if SERIAL_USB
+  #define MMU_RX_SIZE 256
+  #define MMU_TX_SIZE 256
+#else
+  #define MMU_RX_SIZE  16
+  #define MMU_TX_SIZE  16
+#endif
+
 struct E_Step;
 
 class MMU2 {
@@ -79,7 +87,7 @@ private:
   static volatile bool finda_runout_valid;
   static int16_t version, buildnr;
   static millis_t last_request, next_P0_request;
-  static char rx_buffer[16], tx_buffer[16];
+  static char rx_buffer[MMU_RX_SIZE], tx_buffer[MMU_TX_SIZE];
 
   static inline void set_runout_valid(const bool valid) {
     finda_runout_valid = valid;
-- 
GitLab