|
|
@ -118,9 +118,11 @@ Sd2Card CardReader::sd2card;
|
|
|
|
SdVolume CardReader::volume;
|
|
|
|
SdVolume CardReader::volume;
|
|
|
|
SdFile CardReader::file;
|
|
|
|
SdFile CardReader::file;
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t CardReader::file_subcall_ctr;
|
|
|
|
#if HAS_MEDIA_SUBCALLS
|
|
|
|
uint32_t CardReader::filespos[SD_PROCEDURE_DEPTH];
|
|
|
|
uint8_t CardReader::file_subcall_ctr;
|
|
|
|
char CardReader::proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
|
|
|
|
uint32_t CardReader::filespos[SD_PROCEDURE_DEPTH];
|
|
|
|
|
|
|
|
char CardReader::proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t CardReader::filesize, CardReader::sdpos;
|
|
|
|
uint32_t CardReader::filesize, CardReader::sdpos;
|
|
|
|
|
|
|
|
|
|
|
@ -135,7 +137,8 @@ CardReader::CardReader() {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
flag.sdprinting = flag.mounted = flag.saving = flag.logging = false;
|
|
|
|
flag.sdprinting = flag.mounted = flag.saving = flag.logging = false;
|
|
|
|
filesize = sdpos = 0;
|
|
|
|
filesize = sdpos = 0;
|
|
|
|
file_subcall_ctr = 0;
|
|
|
|
|
|
|
|
|
|
|
|
TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);
|
|
|
|
|
|
|
|
|
|
|
|
workDirDepth = 0;
|
|
|
|
workDirDepth = 0;
|
|
|
|
ZERO(workDirParents);
|
|
|
|
ZERO(workDirParents);
|
|
|
@ -540,34 +543,39 @@ void CardReader::openFileRead(char * const path, const uint8_t subcall_type/*=0*
|
|
|
|
switch (subcall_type) {
|
|
|
|
switch (subcall_type) {
|
|
|
|
case 0: // Starting a new print. "Now fresh file: ..."
|
|
|
|
case 0: // Starting a new print. "Now fresh file: ..."
|
|
|
|
announceOpen(2, path);
|
|
|
|
announceOpen(2, path);
|
|
|
|
file_subcall_ctr = 0;
|
|
|
|
TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 1: // Starting a sub-procedure
|
|
|
|
#if HAS_MEDIA_SUBCALLS
|
|
|
|
|
|
|
|
|
|
|
|
// With no file is open it's a simple macro. "Now doing file: ..."
|
|
|
|
case 1: // Starting a sub-procedure
|
|
|
|
if (!isFileOpen()) { announceOpen(1, path); break; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Too deep? The firmware has to bail.
|
|
|
|
// With no file is open it's a simple macro. "Now doing file: ..."
|
|
|
|
if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
|
|
|
|
if (!isFileOpen()) { announceOpen(1, path); break; }
|
|
|
|
SERIAL_ERROR_MSG("Exceeded max SUBROUTINE depth:" STRINGIFY(SD_PROCEDURE_DEPTH));
|
|
|
|
|
|
|
|
kill(GET_TEXT(MSG_KILL_SUBCALL_OVERFLOW));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Store current filename (based on workDirParents) and position
|
|
|
|
// Too deep? The firmware has to bail.
|
|
|
|
getAbsFilename(proc_filenames[file_subcall_ctr]);
|
|
|
|
if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
|
|
|
|
filespos[file_subcall_ctr] = sdpos;
|
|
|
|
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'
|
|
|
|
// Store current filename (based on workDirParents) and position
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
getAbsFilename(proc_filenames[file_subcall_ctr]);
|
|
|
|
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
|
|
|
|
TERN_(HAS_MEDIA_SUBCALLS, filespos[file_subcall_ctr] = sdpos);
|
|
|
|
SERIAL_ECHO_MSG("END SUBROUTINE");
|
|
|
|
|
|
|
|
break;
|
|
|
|
// 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();
|
|
|
|
endFilePrint();
|
|
|
@ -603,7 +611,7 @@ void CardReader::openFileWrite(char * const path) {
|
|
|
|
if (!isMounted()) return;
|
|
|
|
if (!isMounted()) return;
|
|
|
|
|
|
|
|
|
|
|
|
announceOpen(2, path);
|
|
|
|
announceOpen(2, path);
|
|
|
|
file_subcall_ctr = 0;
|
|
|
|
TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);
|
|
|
|
|
|
|
|
|
|
|
|
endFilePrint();
|
|
|
|
endFilePrint();
|
|
|
|
|
|
|
|
|
|
|
@ -1158,17 +1166,19 @@ uint16_t CardReader::get_num_Files() {
|
|
|
|
void CardReader::fileHasFinished() {
|
|
|
|
void CardReader::fileHasFinished() {
|
|
|
|
planner.synchronize();
|
|
|
|
planner.synchronize();
|
|
|
|
file.close();
|
|
|
|
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)
|
|
|
|
#if ENABLED(AUTO_REPORT_SD_STATUS)
|
|
|
|