From 3c9a838651861968109ea06b731d2a92905eb115 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <sourcetree@thinkyhead.com>
Date: Tue, 8 Nov 2016 18:05:59 -0600
Subject: [PATCH] Extended capabilities report in M115

---
 Marlin/Conditionals_post.h                    |  6 --
 Marlin/Configuration_adv.h                    |  5 ++
 Marlin/Marlin_main.cpp                        | 68 ++++++++++++++++++-
 .../Cartesio/Configuration_adv.h              |  5 ++
 .../Felix/Configuration_adv.h                 |  5 ++
 .../Hephestos/Configuration_adv.h             |  5 ++
 .../Hephestos_2/Configuration_adv.h           |  5 ++
 .../K8200/Configuration_adv.h                 |  5 ++
 .../K8400/Configuration_adv.h                 |  5 ++
 .../RigidBot/Configuration_adv.h              |  5 ++
 .../SCARA/Configuration_adv.h                 |  5 ++
 .../TAZ4/Configuration_adv.h                  |  5 ++
 .../WITBOX/Configuration_adv.h                |  5 ++
 .../delta/biv2.5/Configuration_adv.h          |  5 ++
 .../delta/generic/Configuration_adv.h         |  5 ++
 .../delta/kossel_mini/Configuration_adv.h     |  5 ++
 .../delta/kossel_pro/Configuration_adv.h      |  5 ++
 .../delta/kossel_xl/Configuration_adv.h       |  5 ++
 .../makibox/Configuration_adv.h               |  5 ++
 .../tvrrug/Round2/Configuration_adv.h         |  5 ++
 Marlin/language.h                             |  2 +-
 21 files changed, 157 insertions(+), 9 deletions(-)

diff --git a/Marlin/Conditionals_post.h b/Marlin/Conditionals_post.h
index 5dc5abc482..ff997ce109 100644
--- a/Marlin/Conditionals_post.h
+++ b/Marlin/Conditionals_post.h
@@ -28,12 +28,6 @@
 #ifndef CONDITIONALS_POST_H
 #define CONDITIONALS_POST_H
 
-  #if ENABLED(EMERGENCY_PARSER)
-    #define EMERGENCY_PARSER_CAPABILITIES " EMERGENCY_CODES:M108,M112,M410"
-  #else
-    #define EMERGENCY_PARSER_CAPABILITIES ""
-  #endif
-
   /**
    * Axis lengths and center
    */
diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index 2be4fb46a3..6faa05ae46 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -842,4 +842,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp
index 33cc43cbd1..eef793eee8 100755
--- a/Marlin/Marlin_main.cpp
+++ b/Marlin/Marlin_main.cpp
@@ -175,7 +175,7 @@
  * M112 - Emergency stop.
  * M113 - Get or set the timeout interval for Host Keepalive "busy" messages. (Requires HOST_KEEPALIVE_FEATURE)
  * M114 - Report current position.
- * M115 - Report capabilities.
+ * M115 - Report capabilities. (Extended capabilities requires EXTENDED_CAPABILITIES_REPORT)
  * M117 - Display a message on the controller screen. (Requires an LCD)
  * M119 - Report endstops status.
  * M120 - Enable endstops detection.
@@ -5771,7 +5771,71 @@ inline void gcode_M114() { report_current_position(); }
  * M115: Capabilities string
  */
 inline void gcode_M115() {
-  SERIAL_PROTOCOLPGM(MSG_M115_REPORT);
+  SERIAL_PROTOCOLLNPGM(MSG_M115_REPORT);
+
+  #if ENABLED(EXTENDED_CAPABILITIES_REPORT)
+
+    // EEPROM (M500, M501)
+    SERIAL_PROTOCOLPGM("Cap:");
+    #if ENABLED(EEPROM_SETTINGS)
+      SERIAL_PROTOCOLLNPGM("EEPROM:1");
+    #else
+      SERIAL_PROTOCOLLNPGM("EEPROM:0");
+    #endif
+
+    // AUTOREPORT_TEMP (M155)
+    SERIAL_PROTOCOLPGM("Cap:");
+    #if ENABLED(AUTO_REPORT_TEMPERATURES)
+      SERIAL_PROTOCOLLNPGM("AUTOREPORT_TEMP:1");
+    #else
+      SERIAL_PROTOCOLLNPGM("AUTOREPORT_TEMP:0");
+    #endif
+
+    // PROGRESS (M530 S L, M531 <file>, M532 X L)
+    SERIAL_PROTOCOLPGM("Cap:");
+    SERIAL_PROTOCOLPGM("PROGRESS:0");
+
+    // AUTOLEVEL (G29)
+    SERIAL_PROTOCOLPGM("Cap:");
+    #if HAS_ABL
+      SERIAL_PROTOCOLLNPGM("AUTOLEVEL:1");
+    #else
+      SERIAL_PROTOCOLLNPGM("AUTOLEVEL:0");
+    #endif
+
+    // Z_PROBE (G30)
+    SERIAL_PROTOCOLPGM("Cap:");
+    #if HAS_BED_PROBE
+      SERIAL_PROTOCOLLNPGM("Z_PROBE:1");
+    #else
+      SERIAL_PROTOCOLLNPGM("Z_PROBE:0");
+    #endif
+
+    // SOFTWARE_POWER (G30)
+    SERIAL_PROTOCOLPGM("Cap:");
+    #if HAS_POWER_SWITCH
+      SERIAL_PROTOCOLLNPGM("SOFTWARE_POWER:1");
+    #else
+      SERIAL_PROTOCOLLNPGM("SOFTWARE_POWER:0");
+    #endif
+
+    // TOGGLE_LIGHTS (M355)
+    SERIAL_PROTOCOLPGM("Cap:");
+    #if HAS_CASE_LIGHT
+      SERIAL_PROTOCOLLNPGM("TOGGLE_LIGHTS:1");
+    #else
+      SERIAL_PROTOCOLLNPGM("TOGGLE_LIGHTS:0");
+    #endif
+
+    // EMERGENCY_PARSER (M108, M112, M410)
+    SERIAL_PROTOCOLPGM("Cap:");
+    #if ENABLED(EMERGENCY_PARSER)
+      SERIAL_PROTOCOLLNPGM("EMERGENCY_PARSER:1");
+    #else
+      SERIAL_PROTOCOLLNPGM("EMERGENCY_PARSER:0");
+    #endif
+
+  #endif // EXTENDED_CAPABILITIES_REPORT
 }
 
 /**
diff --git a/Marlin/example_configurations/Cartesio/Configuration_adv.h b/Marlin/example_configurations/Cartesio/Configuration_adv.h
index f7e905a529..9457e2cf08 100644
--- a/Marlin/example_configurations/Cartesio/Configuration_adv.h
+++ b/Marlin/example_configurations/Cartesio/Configuration_adv.h
@@ -842,4 +842,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h
index 23f9ddfaa8..4b6863eac6 100644
--- a/Marlin/example_configurations/Felix/Configuration_adv.h
+++ b/Marlin/example_configurations/Felix/Configuration_adv.h
@@ -842,4 +842,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h
index 5b800b49e7..4a1f18a7da 100644
--- a/Marlin/example_configurations/Hephestos/Configuration_adv.h
+++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h
@@ -842,4 +842,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h
index fb2eab1352..d56a4aba3e 100644
--- a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h
+++ b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h
@@ -842,4 +842,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h
index 01ddd10827..1388269065 100644
--- a/Marlin/example_configurations/K8200/Configuration_adv.h
+++ b/Marlin/example_configurations/K8200/Configuration_adv.h
@@ -848,4 +848,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/K8400/Configuration_adv.h b/Marlin/example_configurations/K8400/Configuration_adv.h
index 16b87d259a..d601e039aa 100644
--- a/Marlin/example_configurations/K8400/Configuration_adv.h
+++ b/Marlin/example_configurations/K8400/Configuration_adv.h
@@ -842,4 +842,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h
index 2a6a15c3e0..49e85037f8 100644
--- a/Marlin/example_configurations/RigidBot/Configuration_adv.h
+++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h
@@ -842,4 +842,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h
index 30e90f70b0..8147a0246a 100644
--- a/Marlin/example_configurations/SCARA/Configuration_adv.h
+++ b/Marlin/example_configurations/SCARA/Configuration_adv.h
@@ -842,4 +842,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/TAZ4/Configuration_adv.h b/Marlin/example_configurations/TAZ4/Configuration_adv.h
index 68d67ce568..e9417311ec 100644
--- a/Marlin/example_configurations/TAZ4/Configuration_adv.h
+++ b/Marlin/example_configurations/TAZ4/Configuration_adv.h
@@ -850,4 +850,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h
index 5b800b49e7..4a1f18a7da 100644
--- a/Marlin/example_configurations/WITBOX/Configuration_adv.h
+++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h
@@ -842,4 +842,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h
index 172f6bda70..a478e01977 100644
--- a/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h
+++ b/Marlin/example_configurations/delta/biv2.5/Configuration_adv.h
@@ -844,4 +844,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h
index d320474937..08f36f5f73 100644
--- a/Marlin/example_configurations/delta/generic/Configuration_adv.h
+++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h
@@ -844,4 +844,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h
index d320474937..08f36f5f73 100644
--- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h
+++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h
@@ -844,4 +844,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h
index 550269bfb5..894ce85edd 100644
--- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h
+++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h
@@ -849,4 +849,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h
index 7c61bfdc57..77c899597a 100644
--- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h
+++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h
@@ -844,4 +844,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h
index 986c09cff0..ca451cc3bf 100644
--- a/Marlin/example_configurations/makibox/Configuration_adv.h
+++ b/Marlin/example_configurations/makibox/Configuration_adv.h
@@ -842,4 +842,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h
index 07a097fcb3..22c0a04e7f 100644
--- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h
+++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h
@@ -842,4 +842,9 @@
  */
 //#define AUTO_REPORT_TEMPERATURES
 
+/**
+ * Include capabilities in M115 output
+ */
+//#define EXTENDED_CAPABILITIES_REPORT
+
 #endif // CONFIGURATION_ADV_H
diff --git a/Marlin/language.h b/Marlin/language.h
index 87a0d08c31..4254f44938 100644
--- a/Marlin/language.h
+++ b/Marlin/language.h
@@ -129,7 +129,7 @@
 #define MSG_INVALID_EXTRUDER                "Invalid extruder"
 #define MSG_INVALID_SOLENOID                "Invalid solenoid"
 #define MSG_ERR_NO_THERMISTORS              "No thermistors - no temperature"
-#define MSG_M115_REPORT                     "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID EMERGENCY_PARSER_CAPABILITIES "\n"
+#define MSG_M115_REPORT                     "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID
 #define MSG_COUNT_X                         " Count X: "
 #define MSG_COUNT_A                         " Count A: "
 #define MSG_ERR_KILLED                      "Printer halted. kill() called!"
-- 
GitLab