diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index c4d2413779dc..e729ddc50255 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 3 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/default/Configuration_adv.h b/Marlin/src/config/default/Configuration_adv.h index c4d2413779dc..ab9bde7a539f 100644 --- a/Marlin/src/config/default/Configuration_adv.h +++ b/Marlin/src/config/default/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration_adv.h b/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration_adv.h index 8dcf63c54501..4fea96b99cc7 100644 --- a/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration_adv.h +++ b/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Anet/A6/Configuration_adv.h b/Marlin/src/config/examples/Anet/A6/Configuration_adv.h index 25464f9f3f84..24ee85f45e53 100644 --- a/Marlin/src/config/examples/Anet/A6/Configuration_adv.h +++ b/Marlin/src/config/examples/Anet/A6/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Anet/A8/Configuration_adv.h b/Marlin/src/config/examples/Anet/A8/Configuration_adv.h index dff8527806b1..78daf17fb17e 100644 --- a/Marlin/src/config/examples/Anet/A8/Configuration_adv.h +++ b/Marlin/src/config/examples/Anet/A8/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Azteeg/X5GT/Configuration_adv.h b/Marlin/src/config/examples/Azteeg/X5GT/Configuration_adv.h index d9c942ee160c..7794abd45502 100644 --- a/Marlin/src/config/examples/Azteeg/X5GT/Configuration_adv.h +++ b/Marlin/src/config/examples/Azteeg/X5GT/Configuration_adv.h @@ -1440,6 +1440,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/BIBO/TouchX/Configuration_adv.h b/Marlin/src/config/examples/BIBO/TouchX/Configuration_adv.h index cb8ff049bc5b..8ffa4d90320d 100644 --- a/Marlin/src/config/examples/BIBO/TouchX/Configuration_adv.h +++ b/Marlin/src/config/examples/BIBO/TouchX/Configuration_adv.h @@ -1444,6 +1444,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/BQ/Hephestos/Configuration_adv.h b/Marlin/src/config/examples/BQ/Hephestos/Configuration_adv.h index f27da5eab1e7..81d89e1dd04b 100644 --- a/Marlin/src/config/examples/BQ/Hephestos/Configuration_adv.h +++ b/Marlin/src/config/examples/BQ/Hephestos/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/BQ/Hephestos_2/Configuration_adv.h b/Marlin/src/config/examples/BQ/Hephestos_2/Configuration_adv.h index 71ff69617493..17192e503040 100644 --- a/Marlin/src/config/examples/BQ/Hephestos_2/Configuration_adv.h +++ b/Marlin/src/config/examples/BQ/Hephestos_2/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/BQ/WITBOX/Configuration_adv.h b/Marlin/src/config/examples/BQ/WITBOX/Configuration_adv.h index f27da5eab1e7..81d89e1dd04b 100644 --- a/Marlin/src/config/examples/BQ/WITBOX/Configuration_adv.h +++ b/Marlin/src/config/examples/BQ/WITBOX/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Cartesio/Configuration_adv.h b/Marlin/src/config/examples/Cartesio/Configuration_adv.h index ac49be545bfc..55e9f2977c6a 100644 --- a/Marlin/src/config/examples/Cartesio/Configuration_adv.h +++ b/Marlin/src/config/examples/Cartesio/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Creality/CR-10/Configuration_adv.h b/Marlin/src/config/examples/Creality/CR-10/Configuration_adv.h index 29c5cbcb4aca..3d4d7328f51d 100755 --- a/Marlin/src/config/examples/Creality/CR-10/Configuration_adv.h +++ b/Marlin/src/config/examples/Creality/CR-10/Configuration_adv.h @@ -1442,6 +1442,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Creality/CR-10S/Configuration_adv.h b/Marlin/src/config/examples/Creality/CR-10S/Configuration_adv.h index a20bcd0bf17b..8d589b63bcf2 100644 --- a/Marlin/src/config/examples/Creality/CR-10S/Configuration_adv.h +++ b/Marlin/src/config/examples/Creality/CR-10S/Configuration_adv.h @@ -1433,6 +1433,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Creality/Ender/Configuration_adv.h b/Marlin/src/config/examples/Creality/Ender/Configuration_adv.h index 403fac4c5b03..8e023ae438eb 100644 --- a/Marlin/src/config/examples/Creality/Ender/Configuration_adv.h +++ b/Marlin/src/config/examples/Creality/Ender/Configuration_adv.h @@ -1433,6 +1433,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Felix/Configuration_adv.h b/Marlin/src/config/examples/Felix/Configuration_adv.h index 73fd6076519d..bc0ae5e768c8 100644 --- a/Marlin/src/config/examples/Felix/Configuration_adv.h +++ b/Marlin/src/config/examples/Felix/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration_adv.h b/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration_adv.h index 0a509456578f..79d220ca62ce 100644 --- a/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration_adv.h +++ b/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Infitary/i3-M508/Configuration_adv.h b/Marlin/src/config/examples/Infitary/i3-M508/Configuration_adv.h index 6ccefaa5d27a..ad1e0fd50cdd 100644 --- a/Marlin/src/config/examples/Infitary/i3-M508/Configuration_adv.h +++ b/Marlin/src/config/examples/Infitary/i3-M508/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/JGAurora/A5/Configuration_adv.h b/Marlin/src/config/examples/JGAurora/A5/Configuration_adv.h index faaf7d38dc88..475182115000 100644 --- a/Marlin/src/config/examples/JGAurora/A5/Configuration_adv.h +++ b/Marlin/src/config/examples/JGAurora/A5/Configuration_adv.h @@ -1433,6 +1433,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/MakerParts/Configuration_adv.h b/Marlin/src/config/examples/MakerParts/Configuration_adv.h index 572ae83aeb48..e513611efa00 100644 --- a/Marlin/src/config/examples/MakerParts/Configuration_adv.h +++ b/Marlin/src/config/examples/MakerParts/Configuration_adv.h @@ -1440,6 +1440,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Malyan/M150/Configuration_adv.h b/Marlin/src/config/examples/Malyan/M150/Configuration_adv.h index 5235c7640557..5f98fd6b3353 100644 --- a/Marlin/src/config/examples/Malyan/M150/Configuration_adv.h +++ b/Marlin/src/config/examples/Malyan/M150/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Malyan/M200/Configuration_adv.h b/Marlin/src/config/examples/Malyan/M200/Configuration_adv.h index 5c4bf303d05c..4ce865da526a 100644 --- a/Marlin/src/config/examples/Malyan/M200/Configuration_adv.h +++ b/Marlin/src/config/examples/Malyan/M200/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration_adv.h b/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration_adv.h index 16988fea5a8c..b220d8035c30 100644 --- a/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration_adv.h +++ b/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Mks/Sbase/Configuration_adv.h b/Marlin/src/config/examples/Mks/Sbase/Configuration_adv.h index 107a4787d60b..c64a6c707e91 100644 --- a/Marlin/src/config/examples/Mks/Sbase/Configuration_adv.h +++ b/Marlin/src/config/examples/Mks/Sbase/Configuration_adv.h @@ -1447,6 +1447,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/RigidBot/Configuration_adv.h b/Marlin/src/config/examples/RigidBot/Configuration_adv.h index 10195bd61e12..576c0042066f 100644 --- a/Marlin/src/config/examples/RigidBot/Configuration_adv.h +++ b/Marlin/src/config/examples/RigidBot/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/SCARA/Configuration_adv.h b/Marlin/src/config/examples/SCARA/Configuration_adv.h index 1c4ea0d3b29c..6f30f0238a77 100644 --- a/Marlin/src/config/examples/SCARA/Configuration_adv.h +++ b/Marlin/src/config/examples/SCARA/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Sanguinololu/Configuration_adv.h b/Marlin/src/config/examples/Sanguinololu/Configuration_adv.h index ffb2d4db82bd..8ab961ea3379 100644 --- a/Marlin/src/config/examples/Sanguinololu/Configuration_adv.h +++ b/Marlin/src/config/examples/Sanguinololu/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/TheBorg/Configuration_adv.h b/Marlin/src/config/examples/TheBorg/Configuration_adv.h index 2ad30161b32a..7340212358a8 100644 --- a/Marlin/src/config/examples/TheBorg/Configuration_adv.h +++ b/Marlin/src/config/examples/TheBorg/Configuration_adv.h @@ -1430,6 +1430,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/TinyBoy2/Configuration_adv.h b/Marlin/src/config/examples/TinyBoy2/Configuration_adv.h index 8c6e4c5dba6c..24a697b4db5d 100644 --- a/Marlin/src/config/examples/TinyBoy2/Configuration_adv.h +++ b/Marlin/src/config/examples/TinyBoy2/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/UltiMachine/Archim2/Configuration_adv.h b/Marlin/src/config/examples/UltiMachine/Archim2/Configuration_adv.h index b55c4479319b..aefecb13781d 100644 --- a/Marlin/src/config/examples/UltiMachine/Archim2/Configuration_adv.h +++ b/Marlin/src/config/examples/UltiMachine/Archim2/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Velleman/K8200/Configuration_adv.h b/Marlin/src/config/examples/Velleman/K8200/Configuration_adv.h index 51c3ab11d855..5ae5f976dbbd 100644 --- a/Marlin/src/config/examples/Velleman/K8200/Configuration_adv.h +++ b/Marlin/src/config/examples/Velleman/K8200/Configuration_adv.h @@ -1452,6 +1452,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Velleman/K8400/Configuration_adv.h b/Marlin/src/config/examples/Velleman/K8400/Configuration_adv.h index 685b37676bc4..718c7e1c6361 100644 --- a/Marlin/src/config/examples/Velleman/K8400/Configuration_adv.h +++ b/Marlin/src/config/examples/Velleman/K8400/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration_adv.h b/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration_adv.h index e73fb18dc246..b33d13c8652e 100644 --- a/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration_adv.h +++ b/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration_adv.h @@ -1441,6 +1441,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration_adv.h b/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration_adv.h index 506d55ff90b7..502c0798f6fb 100644 --- a/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration_adv.h @@ -1441,6 +1441,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/delta/FLSUN/kossel/Configuration_adv.h b/Marlin/src/config/examples/delta/FLSUN/kossel/Configuration_adv.h index 3243c7d1ba42..d02f9a895cc8 100644 --- a/Marlin/src/config/examples/delta/FLSUN/kossel/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/FLSUN/kossel/Configuration_adv.h @@ -1435,6 +1435,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration_adv.h b/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration_adv.h index 5ab045749a18..305d38dd4601 100644 --- a/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration_adv.h @@ -1441,6 +1441,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/delta/generic/Configuration_adv.h b/Marlin/src/config/examples/delta/generic/Configuration_adv.h index 5ab045749a18..305d38dd4601 100644 --- a/Marlin/src/config/examples/delta/generic/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/generic/Configuration_adv.h @@ -1441,6 +1441,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/delta/kossel_mini/Configuration_adv.h b/Marlin/src/config/examples/delta/kossel_mini/Configuration_adv.h index 5ab045749a18..305d38dd4601 100644 --- a/Marlin/src/config/examples/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/kossel_mini/Configuration_adv.h @@ -1441,6 +1441,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/delta/kossel_pro/Configuration_adv.h b/Marlin/src/config/examples/delta/kossel_pro/Configuration_adv.h index 1454beb94979..3907b2f7a8b1 100644 --- a/Marlin/src/config/examples/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/kossel_pro/Configuration_adv.h @@ -1446,6 +1446,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/delta/kossel_xl/Configuration_adv.h b/Marlin/src/config/examples/delta/kossel_xl/Configuration_adv.h index 6140077c741d..2bdb5fdbb1db 100644 --- a/Marlin/src/config/examples/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/kossel_xl/Configuration_adv.h @@ -1441,6 +1441,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration_adv.h b/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration_adv.h index 32a40a8a0fb0..cef75035f027 100644 --- a/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration_adv.h +++ b/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/makibox/Configuration_adv.h b/Marlin/src/config/examples/makibox/Configuration_adv.h index 1af6c0a1cdd3..1127efa2c6d0 100644 --- a/Marlin/src/config/examples/makibox/Configuration_adv.h +++ b/Marlin/src/config/examples/makibox/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/tvrrug/Round2/Configuration_adv.h b/Marlin/src/config/examples/tvrrug/Round2/Configuration_adv.h index 4c3a61b0cd9d..203300bd66c8 100644 --- a/Marlin/src/config/examples/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/src/config/examples/tvrrug/Round2/Configuration_adv.h @@ -1439,6 +1439,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/config/examples/wt150/Configuration_adv.h b/Marlin/src/config/examples/wt150/Configuration_adv.h index cf007a40c898..e34d4f0fdb77 100644 --- a/Marlin/src/config/examples/wt150/Configuration_adv.h +++ b/Marlin/src/config/examples/wt150/Configuration_adv.h @@ -1440,6 +1440,21 @@ */ #define FASTER_GCODE_PARSER +/** + * Enhanced command injection. + * + * Allow to inject commands from PROGMEM and SRAM. The required stack size depends on + * the complexity and encapsulation of the injected commands. For every injected command + * which triggers another command injection an additional stack slot is required. + * The default value of 3 should work for most use cases. + */ +//#define ENHANCED_COMMAND_INJECTION +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #ifndef ENHANCED_COMMAND_INJECTION_STACK + #define ENHANCED_COMMAND_INJECTION_STACK 2 + #endif +#endif + /** * User-defined menu items that execute custom GCode */ diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index f613ab1362e1..e89787a61b92 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -81,6 +81,54 @@ bool send_ok[BUFSIZE]; */ static const char *injected_commands_P = NULL; +#if ENABLED(ENHANCED_COMMAND_INJECTION) + /** + * Stack of injected commands. + * Used by Marlin internally to ensure that commands initiated from within + * are enqueued ahead of any pending serial or sd card commands. + */ + static struct command_injection_stack_t { + const char *commands; + bool progmem; + } command_injection_stack [ENHANCED_COMMAND_INJECTION_STACK]; + + static int8_t command_injection_stack_top = -1; + + + bool push_injected_commands(const char *cmd, bool progmem) { + uint8_t next = command_injection_stack_top + 1; + + if (next >= ENHANCED_COMMAND_INJECTION_STACK) { + // stack is full + return false; + } + + command_injection_stack[next].commands = cmd; + command_injection_stack[next].progmem = progmem; + command_injection_stack_top = next; + + return true; + } + + + command_injection_stack_t * pop_injected_commands() { + if (command_injection_stack_top == -1) { + // stack is empty + return NULL; + } + + if (command_injection_stack[command_injection_stack_top].commands == NULL) { + command_injection_stack_top--; + if (command_injection_stack_top == -1) { + return NULL; + } + } + + return &(command_injection_stack[command_injection_stack_top]); + + } +#endif + void queue_setup() { // Send "ok" after commands by default for (uint8_t i = 0; i < COUNT(send_ok); i++) send_ok[i] = true; @@ -143,6 +191,71 @@ bool enqueue_and_echo_command(const char* cmd, bool say_ok/*=false*/) { return false; } + +#if ENABLED(ENHANCED_COMMAND_INJECTION) + + static bool drain_injected_commands_P(); + static bool drain_injected_commands_SRAM(command_injection_stack_t * stack_entry); + /** + * Inject the next "immediate" command, when possible, onto the front of the queue. + * Return true if any immediate PROGMEM or SRAM commands remain to inject. + */ + + static bool drain_injected_commands() { + command_injection_stack_t * stack_entry = pop_injected_commands(); + + if (stack_entry == NULL) { + return false; + } + + if (stack_entry->progmem) { + injected_commands_P = stack_entry->commands; + drain_injected_commands_P(); + stack_entry->commands = injected_commands_P; + } else { + drain_injected_commands_SRAM(stack_entry); + } + + return pop_injected_commands() != NULL; + } + + /** + * Inject the next "immediate" command from SRAM, when possible, onto the front of the queue. + * Return true if any immediate commands remain to inject. + */ + static bool drain_injected_commands_SRAM(command_injection_stack_t * stack_entry) { + if (stack_entry->commands != NULL) { + size_t len = strlen(stack_entry->commands); + + if (len == 0) { + stack_entry->commands = NULL; + } else { + if (enqueue_and_echo_command(stack_entry->commands)) { // success? + stack_entry->commands = stack_entry->commands + len + 1; // next command + } + } + } + return (stack_entry->commands != NULL); // return whether any more remain + } + + + /** + * Record one or many commands to run from memory. Commands have to be separated by \0 + * Aborts the current queue, if any. + * Note: drain_injected_commands_SRAM() must be called repeatedly to drain the commands afterwards + */ + void enqueue_and_echo_commands_SRAM(const char * const gcode) { + if (!push_injected_commands(gcode, false)) { + // what should we do in this case? + kill(PSTR(MSG_ERR_STOPPED)); + return; + } + drain_injected_commands(); + } + +#endif + + /** * Inject the next "immediate" command, when possible, onto the front of the queue. * Return true if any immediate commands remain to inject. @@ -168,9 +281,23 @@ static bool drain_injected_commands_P() { */ void enqueue_and_echo_commands_P(const char * const pgcode) { injected_commands_P = pgcode; - (void)drain_injected_commands_P(); // first command executed asap (when possible) + + #if ENABLED(ENHANCED_COMMAND_INJECTION) + if (!push_injected_commands(pgcode, true)) { + // what should we do in this case? + kill(PSTR(MSG_ERR_STOPPED)); + return; + } + drain_injected_commands(); + #else + (void)drain_injected_commands_P(); // first command executed asap (when possible) + #endif } + + + + #if HAS_QUEUE_NOW /** * Enqueue and return only when commands are actually enqueued @@ -488,8 +615,12 @@ inline void get_serial_commands() { */ void get_available_commands() { - // if any immediate commands remain, don't get other commands yet - if (drain_injected_commands_P()) return; + // if any immediate commands remain, don't get other commands yet + #if ENABLED(ENHANCED_COMMAND_INJECTION) + if (drain_injected_commands()) return; + #else + if (drain_injected_commands_P()) return; + #endif get_serial_commands(); diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 68e9de65aa1d..8c860bd5320f 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -92,6 +92,15 @@ void ok_to_send(); */ void enqueue_and_echo_commands_P(const char * const pgcode); +#if ENABLED(ENHANCED_COMMAND_INJECTION) + /** + * Record one or many commands to run from memory. + * Aborts the current queue, if any. + * Note: drain_injected_commands_SRAM() must be called repeatedly to drain the commands afterwards + */ + void enqueue_and_echo_commands_SRAM(const char * const gcode); +#endif + /** * Enqueue with Serial Echo */ diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 4901a3664f1a..6931302ddb2a 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1549,6 +1549,22 @@ static_assert(1 >= 0 #endif #endif + +/** + * Enhanced command injection requirements + */ +#if ENABLED(ENHANCED_COMMAND_INJECTION) + #if !defined(ENHANCED_COMMAND_INJECTION_STACK) + #error "ENHANCED_COMMAND_INJECTION requires ENHANCED_COMMAND_INJECTION_STACK." + #endif + #if defined(ENHANCED_COMMAND_INJECTION_STACK) && (ENHANCED_COMMAND_INJECTION_STACK < 2) + #error "ENHANCED_COMMAND_INJECTION requires ENHANCED_COMMAND_INJECTION_STACK >= 2." + #endif +#endif + + + + /** * Require 4 or more elements in per-axis initializers */ @@ -1592,4 +1608,5 @@ static_assert(COUNT(sanity_arr_3) <= XYZE_N, "DEFAULT_MAX_ACCELERATION has too m #endif #endif + #endif // _SANITYCHECK_H_