Skip to content

Commit

Permalink
Ability to disable M32
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Nov 10, 2020
1 parent 12ba2ad commit f17394d
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 45 deletions.
5 changes: 4 additions & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 28: M28(); break; // M28: Start SD write
case 29: M29(); break; // M29: Stop SD write
case 30: M30(); break; // M30 <filename> Delete File
case 32: M32(); break; // M32: Select file and start SD print

#if HAS_MEDIA_SUBCALLS
case 32: M32(); break; // M32: Select file and start SD print
#endif

#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
case 33: M33(); break; // M33: Get the long full path to a file or folder
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ class GcodeSuite {
static void M31();

#if ENABLED(SDSUPPORT)
static void M32();
TERN_(HAS_MEDIA_SUBCALLS, static void M32());
TERN_(LONG_FILENAME_HOST_SUPPORT, static void M33());
#if BOTH(SDCARD_SORT_ALPHA, SDSORT_GCODE)
static void M34();
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/sd/M32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "../../inc/MarlinConfig.h"

#if ENABLED(SDSUPPORT)
#if HAS_MEDIA_SUBCALLS

#include "../gcode.h"
#include "../../sd/cardreader.h"
Expand Down Expand Up @@ -56,4 +56,4 @@ void GcodeSuite::M32() {
}
}

#endif // SDSUPPORT
#endif // HAS_MEDIA_SUBCALLS
4 changes: 4 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@
#define HAS_PRINT_PROGRESS 1
#endif

#if ENABLED(SDSUPPORT) && SD_PROCEDURE_DEPTH
#define HAS_MEDIA_SUBCALLS 1
#endif

#if HAS_PRINT_PROGRESS && EITHER(PRINT_PROGRESS_SHOW_DECIMALS, SHOW_REMAINING_TIME)
#define HAS_PRINT_PROGRESS_PERMYRIAD 1
#endif
Expand Down
82 changes: 46 additions & 36 deletions Marlin/src/sd/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ Sd2Card CardReader::sd2card;
SdVolume CardReader::volume;
SdFile CardReader::file;

uint8_t CardReader::file_subcall_ctr;
uint32_t CardReader::filespos[SD_PROCEDURE_DEPTH];
char CardReader::proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
#if HAS_MEDIA_SUBCALLS
uint8_t CardReader::file_subcall_ctr;
uint32_t CardReader::filespos[SD_PROCEDURE_DEPTH];
char CardReader::proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
#endif

uint32_t CardReader::filesize, CardReader::sdpos;

Expand All @@ -135,7 +137,8 @@ CardReader::CardReader() {
#endif
flag.sdprinting = flag.mounted = flag.saving = flag.logging = false;
filesize = sdpos = 0;
file_subcall_ctr = 0;

TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);

workDirDepth = 0;
ZERO(workDirParents);
Expand Down Expand Up @@ -540,34 +543,39 @@ void CardReader::openFileRead(char * const path, const uint8_t subcall_type/*=0*
switch (subcall_type) {
case 0: // Starting a new print. "Now fresh file: ..."
announceOpen(2, path);
file_subcall_ctr = 0;
TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);
break;

case 1: // Starting a sub-procedure
#if HAS_MEDIA_SUBCALLS

// With no file is open it's a simple macro. "Now doing file: ..."
if (!isFileOpen()) { announceOpen(1, path); break; }
case 1: // Starting a sub-procedure

// Too deep? The firmware has to bail.
if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
SERIAL_ERROR_MSG("Exceeded max SUBROUTINE depth:" STRINGIFY(SD_PROCEDURE_DEPTH));
kill(GET_TEXT(MSG_KILL_SUBCALL_OVERFLOW));
return;
}
// With no file is open it's a simple macro. "Now doing file: ..."
if (!isFileOpen()) { announceOpen(1, path); break; }

// Store current filename (based on workDirParents) and position
getAbsFilename(proc_filenames[file_subcall_ctr]);
filespos[file_subcall_ctr] = sdpos;
// Too deep? The firmware has to bail.
if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
SERIAL_ERROR_MSG("Exceeded max SUBROUTINE depth:", int(SD_PROCEDURE_DEPTH));
kill(GET_TEXT(MSG_KILL_SUBCALL_OVERFLOW));
return;
}

// For sub-procedures say 'SUBROUTINE CALL target: "..." parent: "..." pos12345'
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("SUBROUTINE CALL target:\"", path, "\" parent:\"", proc_filenames[file_subcall_ctr], "\" pos", sdpos);
file_subcall_ctr++;
break;
// Store current filename (based on workDirParents) and position
getAbsFilename(proc_filenames[file_subcall_ctr]);

case 2: // Resuming previous file after sub-procedure
SERIAL_ECHO_MSG("END SUBROUTINE");
break;
TERN_(HAS_MEDIA_SUBCALLS, filespos[file_subcall_ctr] = sdpos);

// For sub-procedures say 'SUBROUTINE CALL target: "..." parent: "..." pos12345'
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("SUBROUTINE CALL target:\"", path, "\" parent:\"", proc_filenames[file_subcall_ctr], "\" pos", sdpos);
file_subcall_ctr++;
break;

case 2: // Resuming previous file after sub-procedure
SERIAL_ECHO_MSG("END SUBROUTINE");
break;

#endif
}

endFilePrint();
Expand Down Expand Up @@ -603,7 +611,7 @@ void CardReader::openFileWrite(char * const path) {
if (!isMounted()) return;

announceOpen(2, path);
file_subcall_ctr = 0;
TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);

endFilePrint();

Expand Down Expand Up @@ -1158,17 +1166,19 @@ uint16_t CardReader::get_num_Files() {
void CardReader::fileHasFinished() {
planner.synchronize();
file.close();
if (file_subcall_ctr > 0) { // Resume calling file after closing procedure
file_subcall_ctr--;
openFileRead(proc_filenames[file_subcall_ctr], 2); // 2 = Returning from sub-procedure
setIndex(filespos[file_subcall_ctr]);
startFileprint();
}
else {
endFilePrint(TERN_(SD_RESORT, true));

marlin_state = MF_SD_COMPLETE;
}
#if HAS_MEDIA_SUBCALLS
if (file_subcall_ctr > 0) { // Resume calling file after closing procedure
file_subcall_ctr--;
openFileRead(proc_filenames[file_subcall_ctr], 2); // 2 = Returning from sub-procedure
setIndex(filespos[file_subcall_ctr]);
startFileprint();
return;
}
#endif

endFilePrint(TERN_(SD_RESORT, true));
marlin_state = MF_SD_COMPLETE;
}

#if ENABLED(AUTO_REPORT_SD_STATUS)
Expand Down
9 changes: 4 additions & 5 deletions Marlin/src/sd/cardreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,11 @@ class CardReader {
//
// Procedure calls to other files
//
#ifndef SD_PROCEDURE_DEPTH
#define SD_PROCEDURE_DEPTH 1
#if HAS_MEDIA_SUBCALLS
static uint8_t file_subcall_ctr;
static uint32_t filespos[SD_PROCEDURE_DEPTH];
static char proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
#endif
static uint8_t file_subcall_ctr;
static uint32_t filespos[SD_PROCEDURE_DEPTH];
static char proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];

//
// SD Auto Reporting
Expand Down
1 change: 1 addition & 0 deletions buildroot/tests/LPC1769-tests
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ opt_enable VIKI2 SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \
PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \
Z_SAFE_HOMING ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE \
LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES SDCARD_SORT_ALPHA EMERGENCY_PARSER
opt_disable SD_PROCEDURE_DEPTH
opt_set GRID_MAX_POINTS_X 16
exec_test $1 $2 "Smoothieboard with many features"

Expand Down
2 changes: 2 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
-<src/gcode/probe/M951.cpp>
-<src/gcode/scara>
-<src/gcode/sd>
-<src/gcode/sd/M32.cpp>
-<src/gcode/temp/M104_M109.cpp>
-<src/gcode/temp/M155.cpp>
-<src/gcode/units/G20_G21.cpp>
Expand Down Expand Up @@ -370,6 +371,7 @@ Z_PROBE_SLED = src_filter=+<src/gcode/probe/G31_G32.cpp>
G38_PROBE_TARGET = src_filter=+<src/gcode/probe/G38.cpp>
MAGNETIC_PARKING_EXTRUDER = src_filter=+<src/gcode/probe/M951.cpp>
SDSUPPORT = src_filter=+<src/gcode/sd>
HAS_MEDIA_SUBCALLS = src_filter=+<src/gcode/sd/M32.cpp>
HAS_EXTRUDERS = src_filter=+<src/gcode/temp/M104_M109.cpp> +<src/gcode/config/M221.cpp>
AUTO_REPORT_TEMPERATURES = src_filter=+<src/gcode/temp/M155.cpp>
INCH_MODE_SUPPORT = src_filter=+<src/gcode/units/G20_G21.cpp>
Expand Down

0 comments on commit f17394d

Please sign in to comment.