From 05d7d3787260a3f019b93f512b09edd356fb5869 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <github@thinkyhead.com>
Date: Thu, 18 Mar 2021 22:49:04 -0500
Subject: [PATCH] Suppress redundant serial errors

---
 Marlin/src/HAL/STM32F1/HAL.h                  | 36 ++++++++++++-------
 .../lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp |  4 +--
 .../extui/lib/dgus/mks/DGUSScreenHandler.h    |  3 +-
 buildroot/tests/BIGTREE_SKR_PRO               |  2 +-
 4 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h
index 46565835909..4f430ab4d9c 100644
--- a/Marlin/src/HAL/STM32F1/HAL.h
+++ b/Marlin/src/HAL/STM32F1/HAL.h
@@ -84,10 +84,13 @@
   #define MYSERIAL1 UsbSerial
 #elif WITHIN(SERIAL_PORT, 1, NUM_UARTS)
   #define MYSERIAL1 MSERIAL(SERIAL_PORT)
-#elif NUM_UARTS == 5
-  #error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
 #else
-  #error "SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
+  #define MYSERIAL1 MSERIAL(1) // dummy port
+  #if NUM_UARTS == 5
+    #error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
+  #else
+    #error "SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
+  #endif
 #endif
 
 #ifdef SERIAL_PORT_2
@@ -95,10 +98,13 @@
     #define MYSERIAL2 UsbSerial
   #elif WITHIN(SERIAL_PORT_2, 1, NUM_UARTS)
     #define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
-  #elif NUM_UARTS == 5
-    #error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration."
   #else
-    #error "SERIAL_PORT_2 must be -1 or from 1 to 3. Please update your configuration."
+    #define MYSERIAL2 MSERIAL(1) // dummy port
+    #if NUM_UARTS == 5
+      #error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration."
+    #else
+      #error "SERIAL_PORT_2 must be -1 or from 1 to 3. Please update your configuration."
+    #endif
   #endif
 #endif
 
@@ -107,10 +113,13 @@
     #define MMU2_SERIAL UsbSerial
   #elif WITHIN(MMU2_SERIAL_PORT, 1, NUM_UARTS)
     #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
-  #elif NUM_UARTS == 5
-    #error "MMU2_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
   #else
-    #error "MMU2_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
+    #define MMU2_SERIAL MSERIAL(1) // dummy port
+    #if NUM_UARTS == 5
+      #error "MMU2_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
+    #else
+      #error "MMU2_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
+    #endif
   #endif
 #endif
 
@@ -119,10 +128,13 @@
     #define LCD_SERIAL UsbSerial
   #elif WITHIN(LCD_SERIAL_PORT, 1, NUM_UARTS)
     #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
-  #elif NUM_UARTS == 5
-    #error "LCD_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
   #else
-    #error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
+    #define LCD_SERIAL MSERIAL(1) // dummy port
+    #if NUM_UARTS == 5
+      #error "LCD_SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration."
+    #else
+      #error "LCD_SERIAL_PORT must be -1 or from 1 to 3. Please update your configuration."
+    #endif
   #endif
   #if HAS_DGUS_LCD
     #define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp
index 786d1821a60..355565ae5aa 100644
--- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp
+++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp
@@ -733,7 +733,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
 
 
   // SDCard File listing
-  
+
   #if ENABLED(SDSUPPORT)
     VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr),
     VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr),
@@ -760,7 +760,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
       VPHELPER(VP_OFFSET_Y, &probe.offset.y, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
       VPHELPER(VP_OFFSET_Z, &probe.offset.z, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
     #endif
-  #else 
+  #else
     VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.PrintReturn, nullptr),
   #endif
 
diff --git a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h
index 07c123d928b..382197c7d6c 100644
--- a/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h
+++ b/Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h
@@ -158,7 +158,6 @@ public:
     static void GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr);
   #endif
 
-  
   #if ENABLED(SDSUPPORT)
     // Callback for VP "Display wants to change screen when there is a SD card"
     static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr);
@@ -184,7 +183,7 @@ public:
     static void SDCardError();
     // Marlin informed us about SD print completion.
     static void SDPrintingFinished();
-  #else 
+  #else
     static void PrintReturn(DGUS_VP_Variable &var, void *val_ptr);
   #endif
 
diff --git a/buildroot/tests/BIGTREE_SKR_PRO b/buildroot/tests/BIGTREE_SKR_PRO
index 025d8cbce8f..2503b28544a 100755
--- a/buildroot/tests/BIGTREE_SKR_PRO
+++ b/buildroot/tests/BIGTREE_SKR_PRO
@@ -26,7 +26,7 @@ opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1 SERIAL_PORT -1 \
         CUTTER_POWER_UNIT PERCENT \
         SPINDLE_LASER_PWM_PIN HEATER_1_PIN SPINDLE_LASER_ENA_PIN HEATER_2_PIN \
         TEMP_SENSOR_COOLER 1000 TEMP_COOLER_PIN PD13
-opt_enable LASER_FEATURE REPRAP_DISCOUNT_SMART_CONTROLLER 
+opt_enable LASER_FEATURE REPRAP_DISCOUNT_SMART_CONTROLLER
 exec_test $1 $2 "BigTreeTech SKR Pro | Laser (Percent) | Cooling | LCD" "$3"
 
 # clean up