Browse Source

Ability to disable M32

Scott Lahteine 4 years ago
parent
commit
f17394d677

+ 4
- 1
Marlin/src/gcode/gcode.cpp View File

@@ -431,7 +431,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
431 431
         case 28: M28(); break;                                    // M28: Start SD write
432 432
         case 29: M29(); break;                                    // M29: Stop SD write
433 433
         case 30: M30(); break;                                    // M30 <filename> Delete File
434
-        case 32: M32(); break;                                    // M32: Select file and start SD print
434
+
435
+        #if HAS_MEDIA_SUBCALLS
436
+          case 32: M32(); break;                                  // M32: Select file and start SD print
437
+        #endif
435 438
 
436 439
         #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
437 440
           case 33: M33(); break;                                  // M33: Get the long full path to a file or folder

+ 1
- 1
Marlin/src/gcode/gcode.h View File

@@ -541,7 +541,7 @@ private:
541 541
   static void M31();
542 542
 
543 543
   #if ENABLED(SDSUPPORT)
544
-    static void M32();
544
+    TERN_(HAS_MEDIA_SUBCALLS, static void M32());
545 545
     TERN_(LONG_FILENAME_HOST_SUPPORT, static void M33());
546 546
     #if BOTH(SDCARD_SORT_ALPHA, SDSORT_GCODE)
547 547
       static void M34();

+ 2
- 2
Marlin/src/gcode/sd/M32.cpp View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 #include "../../inc/MarlinConfig.h"
24 24
 
25
-#if ENABLED(SDSUPPORT)
25
+#if HAS_MEDIA_SUBCALLS
26 26
 
27 27
 #include "../gcode.h"
28 28
 #include "../../sd/cardreader.h"
@@ -56,4 +56,4 @@ void GcodeSuite::M32() {
56 56
   }
57 57
 }
58 58
 
59
-#endif // SDSUPPORT
59
+#endif // HAS_MEDIA_SUBCALLS

+ 4
- 0
Marlin/src/inc/Conditionals_adv.h View File

@@ -146,6 +146,10 @@
146 146
   #define HAS_PRINT_PROGRESS 1
147 147
 #endif
148 148
 
149
+#if ENABLED(SDSUPPORT) && SD_PROCEDURE_DEPTH
150
+  #define HAS_MEDIA_SUBCALLS 1
151
+#endif
152
+
149 153
 #if HAS_PRINT_PROGRESS && EITHER(PRINT_PROGRESS_SHOW_DECIMALS, SHOW_REMAINING_TIME)
150 154
   #define HAS_PRINT_PROGRESS_PERMYRIAD 1
151 155
 #endif

+ 46
- 36
Marlin/src/sd/cardreader.cpp View File

@@ -118,9 +118,11 @@ Sd2Card CardReader::sd2card;
118 118
 SdVolume CardReader::volume;
119 119
 SdFile CardReader::file;
120 120
 
121
-uint8_t CardReader::file_subcall_ctr;
122
-uint32_t CardReader::filespos[SD_PROCEDURE_DEPTH];
123
-char CardReader::proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
121
+#if HAS_MEDIA_SUBCALLS
122
+  uint8_t CardReader::file_subcall_ctr;
123
+  uint32_t CardReader::filespos[SD_PROCEDURE_DEPTH];
124
+  char CardReader::proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
125
+#endif
124 126
 
125 127
 uint32_t CardReader::filesize, CardReader::sdpos;
126 128
 
@@ -135,7 +137,8 @@ CardReader::CardReader() {
135 137
   #endif
136 138
   flag.sdprinting = flag.mounted = flag.saving = flag.logging = false;
137 139
   filesize = sdpos = 0;
138
-  file_subcall_ctr = 0;
140
+
141
+  TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);
139 142
 
140 143
   workDirDepth = 0;
141 144
   ZERO(workDirParents);
@@ -540,34 +543,39 @@ void CardReader::openFileRead(char * const path, const uint8_t subcall_type/*=0*
540 543
   switch (subcall_type) {
541 544
     case 0:      // Starting a new print. "Now fresh file: ..."
542 545
       announceOpen(2, path);
543
-      file_subcall_ctr = 0;
546
+      TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);
544 547
       break;
545 548
 
546
-    case 1:      // Starting a sub-procedure
549
+    #if HAS_MEDIA_SUBCALLS
547 550
 
548
-      // With no file is open it's a simple macro. "Now doing file: ..."
549
-      if (!isFileOpen()) { announceOpen(1, path); break; }
551
+      case 1:      // Starting a sub-procedure
550 552
 
551
-      // Too deep? The firmware has to bail.
552
-      if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
553
-        SERIAL_ERROR_MSG("Exceeded max SUBROUTINE depth:" STRINGIFY(SD_PROCEDURE_DEPTH));
554
-        kill(GET_TEXT(MSG_KILL_SUBCALL_OVERFLOW));
555
-        return;
556
-      }
553
+        // With no file is open it's a simple macro. "Now doing file: ..."
554
+        if (!isFileOpen()) { announceOpen(1, path); break; }
557 555
 
558
-      // Store current filename (based on workDirParents) and position
559
-      getAbsFilename(proc_filenames[file_subcall_ctr]);
560
-      filespos[file_subcall_ctr] = sdpos;
556
+        // Too deep? The firmware has to bail.
557
+        if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
558
+          SERIAL_ERROR_MSG("Exceeded max SUBROUTINE depth:", int(SD_PROCEDURE_DEPTH));
559
+          kill(GET_TEXT(MSG_KILL_SUBCALL_OVERFLOW));
560
+          return;
561
+        }
561 562
 
562
-      // For sub-procedures say 'SUBROUTINE CALL target: "..." parent: "..." pos12345'
563
-      SERIAL_ECHO_START();
564
-      SERIAL_ECHOLNPAIR("SUBROUTINE CALL target:\"", path, "\" parent:\"", proc_filenames[file_subcall_ctr], "\" pos", sdpos);
565
-      file_subcall_ctr++;
566
-      break;
563
+        // Store current filename (based on workDirParents) and position
564
+        getAbsFilename(proc_filenames[file_subcall_ctr]);
567 565
 
568
-    case 2:      // Resuming previous file after sub-procedure
569
-      SERIAL_ECHO_MSG("END SUBROUTINE");
570
-      break;
566
+        TERN_(HAS_MEDIA_SUBCALLS, filespos[file_subcall_ctr] = sdpos);
567
+
568
+        // For sub-procedures say 'SUBROUTINE CALL target: "..." parent: "..." pos12345'
569
+        SERIAL_ECHO_START();
570
+        SERIAL_ECHOLNPAIR("SUBROUTINE CALL target:\"", path, "\" parent:\"", proc_filenames[file_subcall_ctr], "\" pos", sdpos);
571
+        file_subcall_ctr++;
572
+        break;
573
+
574
+      case 2:      // Resuming previous file after sub-procedure
575
+        SERIAL_ECHO_MSG("END SUBROUTINE");
576
+        break;
577
+
578
+    #endif
571 579
   }
572 580
 
573 581
   endFilePrint();
@@ -603,7 +611,7 @@ void CardReader::openFileWrite(char * const path) {
603 611
   if (!isMounted()) return;
604 612
 
605 613
   announceOpen(2, path);
606
-  file_subcall_ctr = 0;
614
+  TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);
607 615
 
608 616
   endFilePrint();
609 617
 
@@ -1158,17 +1166,19 @@ uint16_t CardReader::get_num_Files() {
1158 1166
 void CardReader::fileHasFinished() {
1159 1167
   planner.synchronize();
1160 1168
   file.close();
1161
-  if (file_subcall_ctr > 0) { // Resume calling file after closing procedure
1162
-    file_subcall_ctr--;
1163
-    openFileRead(proc_filenames[file_subcall_ctr], 2); // 2 = Returning from sub-procedure
1164
-    setIndex(filespos[file_subcall_ctr]);
1165
-    startFileprint();
1166
-  }
1167
-  else {
1168
-    endFilePrint(TERN_(SD_RESORT, true));
1169 1169
 
1170
-    marlin_state = MF_SD_COMPLETE;
1171
-  }
1170
+  #if HAS_MEDIA_SUBCALLS
1171
+    if (file_subcall_ctr > 0) { // Resume calling file after closing procedure
1172
+      file_subcall_ctr--;
1173
+      openFileRead(proc_filenames[file_subcall_ctr], 2); // 2 = Returning from sub-procedure
1174
+      setIndex(filespos[file_subcall_ctr]);
1175
+      startFileprint();
1176
+      return;
1177
+    }
1178
+  #endif
1179
+
1180
+  endFilePrint(TERN_(SD_RESORT, true));
1181
+  marlin_state = MF_SD_COMPLETE;
1172 1182
 }
1173 1183
 
1174 1184
 #if ENABLED(AUTO_REPORT_SD_STATUS)

+ 4
- 5
Marlin/src/sd/cardreader.h View File

@@ -249,12 +249,11 @@ private:
249 249
   //
250 250
   // Procedure calls to other files
251 251
   //
252
-  #ifndef SD_PROCEDURE_DEPTH
253
-    #define SD_PROCEDURE_DEPTH 1
252
+  #if HAS_MEDIA_SUBCALLS
253
+    static uint8_t file_subcall_ctr;
254
+    static uint32_t filespos[SD_PROCEDURE_DEPTH];
255
+    static char proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
254 256
   #endif
255
-  static uint8_t file_subcall_ctr;
256
-  static uint32_t filespos[SD_PROCEDURE_DEPTH];
257
-  static char proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
258 257
 
259 258
   //
260 259
   // SD Auto Reporting

+ 1
- 0
buildroot/tests/LPC1769-tests View File

@@ -23,6 +23,7 @@ opt_enable VIKI2 SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \
23 23
            PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \
24 24
            Z_SAFE_HOMING ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE \
25 25
            LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES SDCARD_SORT_ALPHA EMERGENCY_PARSER
26
+opt_disable SD_PROCEDURE_DEPTH
26 27
 opt_set GRID_MAX_POINTS_X 16
27 28
 exec_test $1 $2 "Smoothieboard with many features"
28 29
 

+ 2
- 0
platformio.ini View File

@@ -180,6 +180,7 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
180 180
   -<src/gcode/probe/M951.cpp>
181 181
   -<src/gcode/scara>
182 182
   -<src/gcode/sd>
183
+  -<src/gcode/sd/M32.cpp>
183 184
   -<src/gcode/temp/M104_M109.cpp>
184 185
   -<src/gcode/temp/M155.cpp>
185 186
   -<src/gcode/units/G20_G21.cpp>
@@ -370,6 +371,7 @@ Z_PROBE_SLED            = src_filter=+<src/gcode/probe/G31_G32.cpp>
370 371
 G38_PROBE_TARGET        = src_filter=+<src/gcode/probe/G38.cpp>
371 372
 MAGNETIC_PARKING_EXTRUDER = src_filter=+<src/gcode/probe/M951.cpp>
372 373
 SDSUPPORT               = src_filter=+<src/gcode/sd>
374
+HAS_MEDIA_SUBCALLS      = src_filter=+<src/gcode/sd/M32.cpp>
373 375
 HAS_EXTRUDERS           = src_filter=+<src/gcode/temp/M104_M109.cpp> +<src/gcode/config/M221.cpp>
374 376
 AUTO_REPORT_TEMPERATURES = src_filter=+<src/gcode/temp/M155.cpp>
375 377
 INCH_MODE_SUPPORT       = src_filter=+<src/gcode/units/G20_G21.cpp>

Loading…
Cancel
Save